Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3. Write a python program that will calculate the function sin(x). Make sure your program meets the following requirements: 1. The value of x can

image text in transcribed
image text in transcribed
image text in transcribed
3. Write a python program that will calculate the function sin(x). Make sure your program meets the following requirements: 1. The value of x can be specified and changed in the code (or as user input). 2. The value of xo can be specified and changed in the code (or as user input). 3. The definition of fractional error is: If ref 99X Tour This can be expressed as percent error by multiplying the above equation by 100%. Note frue is the true/known value off and fapprx is the approximate value from the Taylor series expansion with N terms. Your program should continue to calculate the Talyor series until 10- 4. Demonstrate your program works correctly by running it for the following case: Xo = 1/12, x = x/2. 4. Write a python program that will calculate the function e'. Make sure your program meets the following requirements: 1. The value of x can be specified and changed in the code (or as user input). 2. The value of X, can be specified and changed in the code (or as user input). 3. Your program should continue to calculate the Talyor series until (510 4. Demonstrate your program works correctly by running it for the following case: Xo = 0.0, x = 4.0. 5. Use your program from #4 to use base points, Xo = 0.0, 0.5, 1.5, 2.0, 2.5, 3.0, 3.5 and X = 4.0 to determine the number of terms, N. required to get an answer that has ES 10-0 1. Make a graph of N. versus h (Note h = X-Xo). 11 x,+x2+x,+...+ x) = x Equation 1 1 11 il Equation 2 il Equation 3 1=0 Equation 4 The fractional relative error is fi Equation 5 Note in Eq. 5. fis the value being calculated with a computational technique. Also, this error cannot be calculated for the first iteration of the technique. Taylor Series Taylor Series Expansions (assume equally spaced points) 21 f(x)=f(x)+F(xwhol (xol buf (xo), ( x ) 3! Taylor series can be used to estimate the value of f(x) when you only actually know f(x). The value Xo is like a "base" point and you are going to project from Xo to x to estimate the value of Here is a video that might help visualize Taylor Series. Note they use a different notation. In the video c = Xo https://youtu.be/AFMXIXBVP-O It convenient to use the difference between x and Xo. h=x-xo The value of his just the distance you are projecting from xe. The smaller h is, in general, the better your estimate is. There is a value between X and X. $ such that this is from mean value theorem in calculus): f(x)=f(x)=f(x,) h0), 21 Sometimes that last part is called the remainder, R. fix)=f(x)+1(x)h+R Note that n is the number of terms. In the above example n = 2. Example: Find f(x)= cos(x) at x = 7/12 using a base point of Xo = o use n = 2 and n = 4 F'(x)=sin(x)=sin(0)=0 x)=-cos(x)=-cos(0)=-1 (x)=sin(x)=sin(0)=0 So for n = 2 (a/12) (0) (0) 1/12)-1+0x{#/12-0)=1 Real answer is 0.965025826289068 For n 4

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

Students also viewed these Databases questions