{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw3 - Topic Recursive and difference functions Due Thurs...

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

Physics 503: Computational Physics Homework #3 Topic: Recursive and difference functions Due: Thurs. Feb. 18 by the beginning of class (please email your code to [email protected] ) Assignment 1. Write a recursive function to compute and return the value of the factorial of a number n : n ! =n(n-1)(n-2)(n-4)… and 0!! = 1. 2. Write a function to compute the Taylor series expansion of the sin(x) function to an arbitrary order N. The expansion is sin( x ) x x 3 3! + x 5 5! x 7 7! + ... x N N ! . Pick a value for x and compute the difference between sin( x ) and the expansion for a range of N values (say 3, 7, 11, 21). Make a plot of the error (difference) vs value of N. Make a second plot of the sin( x ) and each of the expansion over the domain x = [- π , π ]. Physics 503: Computational Physics Homework #3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Topic: Recursive and difference functions Due: Thurs. Feb. 18 by the beginning of class (please email your code to [email protected] ) Assignment 1. Write a recursive function to compute and return the value of the factorial of a number n : n ! =n(n-1)(n-2)(n-4)… and 0!! = 1. 2. Write a function to compute the Taylor series expansion of the sin(x) function to an arbitrary order N. The expansion is sin( x ) ≅ x − x 3 3! + x 5 5! − x 7 7! + ... x N N ! . Pick a value for x and compute the difference between sin( x ) and the expansion for a range of N values (say 3, 7, 11, 21). Make a plot of the error (difference) vs value of N. Make a second plot of the sin( x ) and each of the expansion over the domain x = [-π , π ]....
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online