Below I have a function for a A Taylor Polynomial calculator in Matlab
function j= taylor(f,a,b,n)
syms p d x;
p=0;
d=f;
for i=[0:n];
p=p+subs(d,a)*((x-a)^i)/(factorial(i));
d=diff(d);
end
j=subs(p,b);
When I test it with this: taylor(@(x) exp(x),0,2,5), it returns errors. but it does not return errors when I test it like this taylor(x,exp(x),0,2,5)
How can I fix it so there are no errors when I use a anonymous function in this format: @(x) as input?