Current location - Training Enrollment Network - Mathematics courses - Matlab mathematical experiment analysis
Matlab mathematical experiment analysis
Using matlab, how to use Taylor formula to approximately calculate SIN 7 and analyze the expansion point X and expansion order?

The first step is to create a function f=sin(x) according to sin 7.

Step 2, expand f=sin(x) with taylor () function relative to x=a(a=7), namely taylor(f, X,' Order', n).

When n=5, p = Taylor (f, x,' sequence', 5),% p =% p =-x 3/6+x.

When n=7, p = Taylor (f, x,' sequence', 10),% x 9/362880-x 7/5040+x 5/120-x 3/6+x.

Step 3, calculate the y value when x=7/ 180*pi. that is

When n=5, y=eval(p)% calculation result.

When n= 10, y=eval(p)% calculation result.

Fourthly, by analyzing the calculation results, we can see that with the increase of' order', the value of y is closer to the real value.

When n=5, the error is 2.267e-07.

When n= 10, the error is 0.