Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Python 3.6 Coding Exercise 7.18. Make a class for summation of series Our task in this exercise is to calculate a sum S(x)-M fk(z),

Using Python 3.6 Coding image text in transcribed

Exercise 7.18. Make a class for summation of series Our task in this exercise is to calculate a sum S(x)-M fk(z), where f(x) is a term in a sequence which is assumed to decrease in absolute value. In class Sum, for computing S(x), the constructor r quires the following three arguments: fk(x) 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(x). The next term in the series, fN+1(x), should be computed and stored as an attribute first_neglected_term. Here is an example where we compute S(2) = 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 your implementation of class Sum Apply class Sum to compute the Taylor polynomial approximation for sinx at x .30 and N-5. 10. 20. 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 r- 2,5,10 and N - 5,10, 20). Formulas for the Taylor polynomials can be looked up in Exercise 5.27. Name of program file: Sum.py. Compute the error and com- Exercise 7.18. Make a class for summation of series Our task in this exercise is to calculate a sum S(x)-M fk(z), where f(x) is a term in a sequence which is assumed to decrease in absolute value. In class Sum, for computing S(x), the constructor r quires the following three arguments: fk(x) 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(x). The next term in the series, fN+1(x), should be computed and stored as an attribute first_neglected_term. Here is an example where we compute S(2) = 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 your implementation of class Sum Apply class Sum to compute the Taylor polynomial approximation for sinx at x .30 and N-5. 10. 20. 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 r- 2,5,10 and N - 5,10, 20). Formulas for the Taylor polynomials can be looked up in Exercise 5.27. Name of program file: Sum.py. Compute the error and com

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing Fundamentals Design And Implementation

Authors: David M. Kroenke

5th Edition

B000CSIH5A, 978-0023668814

More Books

Students also viewed these Databases questions