hello! The problem I am having trouble with is this:
Calculate g(x) = sin(x) using the Taylor series expansion for a given value of x. Solve for g(pi/3) using 5, 10, 20 and 100 terms in the Taylor series (use a loop)
So I tried the following in the script editor:
clear clc n = input('Enter number of iiterations (n): ' ); x = pi/3; y = zeros(1,n); for i = 1:n y(i) = (-1)^i*x^(2*i+1)/factorial(2*i+1); end SINx = sum(y);
however when i run the script, the value of SINx that I get isn't what sin(pi/3) is supposed to be and I just can't figure out why.
Best Answer