MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi
Learn moreOpportunities for recent engineering grads.
Apply TodayMATLAB Central > MATLAB Newsreader > Newton Raphson Help 

So I'm writing this code to find the root of a function. It works fine with some functions. However, whenever I try to solve cos(x) it returns a value where cos(x)=1 instead of 0. Can somebody help me figure out what the problem is? thank you! 
> if f(i1)<tol 
"Roger Stafford" wrote in message <jc2p1k$jdm$1@newscl01ah.mathworks.com>... 
Thank you, Ill look into that. And if you try a function such as f(x)=x5 my code will return ans=5. I don't know why it worked out after reading your explanation haha. Maybe it's jsut a coincidence 
also i'm just trying to find one root. and whatever the funtion returns isnt even one of the roots. 
"Chm" wrote in message <jc2ue3$58n$1@newscl01ah.mathworks.com>... 
On 11 Des, 14:34, "Chm " <lrh...@gmail.com> wrote: 

No tags are associated with this thread.
A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.
Anyone can tag a thread. Tags are public and visible to everyone.