How do I find a solution to (x.^2)/2-10*atan(x) using the Newton-Raphson method?
Afficher commentaires plus anciens
How do I find a solution to (x.^2)/2-10*atan(x) using the Newton-Raphson method? Is there a general 'body' to this method?
Réponse acceptée
Plus de réponses (1)
Roger Stafford
le 13 Fév 2014
Modifié(e) : Roger Stafford
le 13 Fév 2014
See the Wikipedia article at
http://en.wikipedia.org/wiki/Newton's_method
If you plot a graph of your function f(x) = x^2/2-10*atan(x), you will see that it has two solutions, one exactly at x = 0 and one somewhere in the vicinity of x = 5. For Newton's method to work, you need an initial estimate to start the iteration going. In this case since you are undoubtedly seeking the root near x = 5, you should start x at that crossing place you see in the plot. You will also need the derivative of the above function which you can easily figure out from your classes in calculus. Then use a while-loop to do your iteration as explained in the Wikipedia article and stop when you see that the correction being made is sufficiently small in absolute value to give you an accurate answer.
2 commentaires
Roger Stafford
le 13 Fév 2014
I would recommend that first you express your function directly in the code to see if the code is good. (It looks valid to me on a quick glance.)
Xi = Xest - (Xest^2/2-10*atan(Xest))/(Xest-10/(1+Xest^2));
When you get that working, try to use names for your functions that are more likely to be unique, rather than 'f' and 'fd'. It is too easy for you to have accidentally used these for some other purpose. See if that doesn't work.
Catégories
En savoir plus sur Matrix Computations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!