File Exchange Pick of the Week

Our best user submissions

RootFinding Demo

Will's pick this week is RootFinding Demo by Teja Muppirala.

Teja is making a comeback after his 2011 Sudoku Pick of the Week. This time, he has created a wonderful little Newton-Raphson app. For anyone who's taken a numerical methods class, you are probably familiar with this technique for finding a value for x that satisfies equation f(x) = 0. But if you're new to the concept, Wikipedia has a great article on the subject.

In essence, this algorithm starts with an initial guess for the value of x. If f(x) equals zero, then lucky you, you're done. If not, you calculate the derivative of the function and use that to aim yourself towards a better guess for the value of x. You repeat this process with your new value of x, and after a few iterations, you hopefully converge on f(x) = 0. In the image below, you see how we approach the zero-crossing of the blue line (our f(x)) with several Newton-Raphson iterations (the red lines).

Solution to sin(x) + 0.1*x^0.5 = 1 with initial guess of 0.4


It turns out that this is a screenshot from Teja's root finding app. The user interface enables you to symbolically express your equation. You specify your initial guess and number of iterations; the app will then present you the solution. What's really fun about this is that you can click on the figure and instantaneously get results for a new initial guess. This interaction is quite instructive in the effectiveness yet limitations of this root finding method. I enjoyed experimenting with functions that weren't continuously differentiable. Oftentimes, my results would be unstable, but every once in a while, I could still achieve convergence.

'Solutions' to 0.2*sin(20*x) + 0.05*x^3 = 1 Convergence for cos(x) + x^0.5*cos(x) despite kink at x = 0


Comments
Let us know what you think here or leave a comment for Teja.
|
  • print

コメント

コメントを残すには、ここ をクリックして MathWorks アカウントにサインインするか新しい MathWorks アカウントを作成します。