Here is the code I'm working with currently:
function [ output_args ] = MaclaurinSeries( f,a,tol )syms x k;y = subs(f,a)disp(f)i=1error = 1;while error > tol f1 = symsum(diff(f,x,k) * (x^k)/(factorial(k)),k,0,i) error = y - subs(f1,a) q = subs(f1,a) i=i+1end
Every time I run it, no matter how many times I tweak it, I manage to get f1 = 0 every time (which just isn't true). It calculates the derivative properly and everything, but I just don't know why it's returning zero. Any help?
Best Answer