Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Exercise 7.18. Make a class for summation of series. M fe(x), Our task in this exercise is to calculate a sum S(z) = where fk()
Exercise 7.18. Make a class for summation of series. M fe(x), Our task in this exercise is to calculate a sum S(z) = where fk() is a term in a sequence which is assumed to decrease in absolute value. In class Sum, for computing S(x), the constructor re- quires the following three arguments: fk(r) as a function f(k, x). M as an int object M, and N as an int object N. A __call_. method com- putes and returns S(). The next term in the series, fN+1(x), shoulod be computed and stored as an attribute first_neglected_term. Here is an example where we compute S(r) = 0(-x)": def term(k, x):return (-x)*k S = Sum(term , M#0, N= 100) x 0.5 print S(x) # Print the value of the first neglected term from last S(x) comp print S.first_neglected_term Calculate by hand what the output of this test becomes, and use it to verify vour implementation of class Sum Apply class Sum to compute the Taylor polynomial approximation for sinx at x = .30 and N = 5. 10.20. Compute the error and com- pare with the first neglected term fN+1(x). Present the result in nicely formatted tables. Repeat such calculations for the Taylor polynomial for e-r at x = 1.3, 5 and N-5. 10. 20. Also demonstrate how class Sum can be used to calculate the sum (3.1) on page 98 (choose 2,5,10 and N = 510.20). Formulas for the Taylor polynomials can be looked up in Exercise 5.27. Name of program file: Sum.py Exercise 7.18. Make a class for summation of series. M fe(x), Our task in this exercise is to calculate a sum S(z) = where fk() is a term in a sequence which is assumed to decrease in absolute value. In class Sum, for computing S(x), the constructor re- quires the following three arguments: fk(r) as a function f(k, x). M as an int object M, and N as an int object N. A __call_. method com- putes and returns S(). The next term in the series, fN+1(x), shoulod be computed and stored as an attribute first_neglected_term. Here is an example where we compute S(r) = 0(-x)": def term(k, x):return (-x)*k S = Sum(term , M#0, N= 100) x 0.5 print S(x) # Print the value of the first neglected term from last S(x) comp print S.first_neglected_term Calculate by hand what the output of this test becomes, and use it to verify vour implementation of class Sum Apply class Sum to compute the Taylor polynomial approximation for sinx at x = .30 and N = 5. 10.20. Compute the error and com- pare with the first neglected term fN+1(x). Present the result in nicely formatted tables. Repeat such calculations for the Taylor polynomial for e-r at x = 1.3, 5 and N-5. 10. 20. Also demonstrate how class Sum can be used to calculate the sum (3.1) on page 98 (choose 2,5,10 and N = 510.20). Formulas for the Taylor polynomials can be looked up in Exercise 5.27. Name of program file: Sum.py
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started