hand2ex1 - i = N X i =1 (-1) i +1 i ( x-1) i write a code...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Extra Exercises Handout Two October 5, 2011 Question One Write a fortran code to compute the sum of the squares of the first n integers.Use a single ‘ DO ’ loop to do this along with a ‘ REAL ’ data type to hold the summation. Note that you can read in a value from the keyboard, during the execution of a fortran program, with the ‘ READ ’ command as follows. Given you have declared ‘ num1 ’ to be and ‘ INTEGER ’ type in the specification part of your code. You can read an integer value into ‘ num1 ’ using READ*,num1 Question Two The Taylor Polynomial P N ( x ) for f ( x ) = ln( x ) expanded about x 0 = 1 is, P N ( x ) =
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: i = N X i =1 (-1) i +1 i ( x-1) i write a code that prints out the value of P N ( x ) for N { 2 , 4 , 6 , 8 , 10 , 12 , 14 , 16 , 18 , 20 } . Use a pair of nested DO loops for this purpose. In your code also print out the error in the approximation. Note to do this you can use the Fortran function ALOG(num) which returns the natural log of the value num . For example if you stored the result of the approximation P N ( num ) in the REAL variable tot then PRINT*,ALOG(num)-tot would give you a measure of the error. 1...
View Full Document

This note was uploaded on 02/13/2012 for the course MATH 5806 taught by Professor Brooks during the Fall '10 term at Minnesota.

Ask a homework question - tutors are online