1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Maclaurin Series cos x (MATLAB) can somebody find my error

  1. Apr 30, 2010 #1
    Maclaurin Series cos x (MATLAB)... can somebody plz find my error

    a. Consider the MacLauren series for cos x.
    Find TN(x) for N = 2, 4, 6, 8. For each of these, graph cos(x) and TN(x) on the same plot for x (-pi/4,pi/4)




    y=cos(x);
    T2=zeros(1,length(x));
    for i=1:length(x)
    T2(i)=sum(bn(i,1:3));
    end
    plot(x,y,x,T2)
    title('T2 vs cos x')
    >> x=(-pi/4):(pi/400):(pi/4);
    bn=zeros(length(x),10);
    for i=1:10
    for j=1:length(x)
    n=i-1;
    bn(j,i)=((-1)^n*x(j)^(2*n))/(factorial(2*n));
    end
    end

    y=cos(x);
    T2=zeros(1,length(x));
    for i=1:length(x)
    T2(i)=sum(bn(j,1:3));
    end
    plot(x,y,x,T2)
    title('T2 vs cos x')
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?