Here is my program for finding sin(x) at given x value.(adsbygoogle = window.adsbygoogle || []).push({});

x=input('x=\n')

tol=input('Tolerence=\n')

n=1

t(n)=1

s(n)=1

while(1)

n=n+1

t(n)=- ((x.^2)*(t(n-1))) / ((2*(n)-1)*(2*(n)-2))

s(n)=s(n-1)+t(n)

if(abs(t(n))>tol)

break;

end

end

fprintf('sinx for x=%d is %f',x,s(n))

%END

And here is a output

x=

5

Tolerence=

0.01

n =

1

t =

1.0000 -4.1667

s =

1.0000 -3.1667

n =

2

t =

1.0000 -4.1667

s =

1.0000 -3.1667

sinx for x=5 is -3.166667

But according to calculator sin(5)=0.08715

And I am confident that my recursion formula is correct.

Please help me.

Thanks

**Physics Forums - The Fusion of Science and Community**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Help in MATLAB please

Loading...

Similar Threads for Help MATLAB please |
---|

Help with Excel graph please |

MATLAB MATLAB: forces acting on an object |

MATLAB MATLab: Not enough inputs for nlinfit |

MATLAB Help needed to fix a matlab code |

LaTeX Help with page dimensions in latex |

**Physics Forums - The Fusion of Science and Community**