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

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

View Full Document Right Arrow Icon
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 jgladden@olemiss.edu ) 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
Background image of page 1
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 jgladden@olemiss.edu ) 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

This note was uploaded on 10/05/2010 for the course PHYS phy503 taught by Professor Gladden during the Spring '09 term at Ole Miss.

Ask a homework question - tutors are online