Here is my code and my output is a function and not a numerical value as I expected. Can anyone debug this code?
syms f y x dff=@(y) exp(y)-(sin(pi*y/3));df=@(y) exp(y)-((pi*cos(pi*y/3))/3);x(1)=-3.0;error=0.00001;for i=1:10 x(i+1)=x(i)-((f(x(i)))/df(x(i))); err(i)=abs((x(i+1)-x(i))/x(i)); if err(i)<error break endendroot=x(i);output: - (sin((pi*(exp(-3)/(pi/3 + exp(-3)) + 3))/3) + exp(- exp(-3)/(pi/3 + exp(-3)) - 3))/(exp(- exp(-3)/(pi/3 + exp(-3)) - 3) - (pi*cos((pi*(exp(-3)/(pi/3 + exp(-3)) + 3))/3))/3) - exp(-3)/(pi/3 + exp(-3)) - 3
Best Answer