{"id":4896,"date":"2013-11-08T09:08:00","date_gmt":"2013-11-08T14:08:00","guid":{"rendered":"https:\/\/blogs.mathworks.com\/pick\/?p=4896"},"modified":"2013-11-08T13:26:21","modified_gmt":"2013-11-08T18:26:21","slug":"rootfinding-demo","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/pick\/2013\/11\/08\/rootfinding-demo\/","title":{"rendered":"RootFinding Demo"},"content":{"rendered":"<a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/76890\">Will<\/a>'s pick this week is <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/41736-rootfinding-demo\">RootFinding Demo<\/a> by <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/authors\/66822\">Teja Muppirala<\/a>.\r\n<br><br>\r\nTeja is making a comeback after his 2011 <a href=\"https:\/\/blogs.mathworks.com\/pick\/2011\/07\/01\/video-sudoku\/\">Sudoku Pick of the Week<\/a>. 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 <i>x<\/i> that satisfies equation <i>f(x) = 0<\/i>. But if you're new to the concept, Wikipedia has a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Newton%27s_method\">great article<\/a> on the subject. \r\n<br><br>\r\nIn essence, this algorithm starts with an initial guess for the value of <i>x<\/i>. If <i>f(x)<\/i> 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 <i>x<\/i>. You repeat this process with your new value of <i>x<\/i>, and after a few iterations, you hopefully converge on <i>f(x) = 0<\/i>. In the image below, you see how we approach the zero-crossing of the blue line (our <i>f(x)<\/i>) with several Newton-Raphson iterations (the red lines). \r\n<br><br><center>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/will_campbell\/potw_root\/root_1.png\" alt=\"Solution to sin(x) + 0.1*x^0.5 = 1 with initial guess of 0.4\" \/>\r\n<\/center><br><br>\r\nIt 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.\r\n<br><br><center>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/will_campbell\/potw_root\/root_2.gif\" alt=\"'Solutions' to 0.2*sin(20*x) + 0.05*x^3 = 1\" \/>\r\n<img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/will_campbell\/potw_root\/root_3.png\" alt=\"Convergence for cos(x) + x^0.5*cos(x) despite kink at x = 0\" \/><\/center>\r\n<br><br>\r\n<strong>Comments<\/strong><br>\r\nLet us know what you think <a href=\"https:\/\/blogs.mathworks.com\/pick\/?p=4896#respond\">here<\/a> or leave a <a href=\"https:\/\/www.mathworks.com\/matlabcentral\/fileexchange\/41736-rootfinding-demo#comments\">comment<\/a> for Teja.\r\n<br>","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img decoding=\"async\"  class=\"img-responsive\" src=\"https:\/\/blogs.mathworks.com\/images\/pick\/will_campbell\/potw_root\/root_1.png\" onError=\"this.style.display ='none';\" \/><\/div><p>Will's pick this week is RootFinding Demo by Teja Muppirala.\r\n\r\nTeja is making a comeback after his 2011 Sudoku Pick of the Week. This time, he has created a wonderful little Newton-Raphson app. For... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/pick\/2013\/11\/08\/rootfinding-demo\/\">read more >><\/a><\/p>","protected":false},"author":45,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4896"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/users\/45"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/comments?post=4896"}],"version-history":[{"count":12,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4896\/revisions"}],"predecessor-version":[{"id":4911,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/posts\/4896\/revisions\/4911"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/media?parent=4896"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/categories?post=4896"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/pick\/wp-json\/wp\/v2\/tags?post=4896"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}