newt

This function quickly preforms Newton's method on a vector function of multiple variables.
872 Downloads
Updated 15 Jul 2010

View License

Newt executes a generalized Newton's method that is applicable functions of multiple variables. There must be the same number of subfunctions, variables, and initial guesses (one for each variable). There are only 46 lines of executable code.

The first input of newt must be the tolerance you desire. This must be a non-negative real number. The next inputs must be guesses, variables, and equations. They should be entered in that order and the guesses and variables should agree in order. For example, if you enter your variables in the order y,z,x, your guesses must be entered as y guess, z guess, and x guess. Variables and equations must be entered as strings. Equations should be written explicitly i.e. instead of 2x^2, you write 2*x^2.
---
Generalized Newton's Method:
Newton's method typically appears in the form
f(xo)+(x-xo)f'(xo)=0, where xo is the initial guess and x is what is being solved for. When generalized to a vector function F, this becomes
F(xo)+h[D(F(xo))]=0, where xo is a vector of n number of initial guesses, F is a vector function with n subfunctions, h is a vector that represents the change from the initial guess to the estimation, and DF is the jacobian matrix of F. Now one must simply solve the equation [DF(xo)].h=-F(xo) for h and add this to their old guess, xo.

The screen shot illustrates newt working on one and two variables, and shows the value of pi/2 for comparison with the first example (they are the same to 16 digits). Also note the polynomial example.

Thank you Dr. Paul Bamberg for teaching me the generalized method.

Developed on MATLAB 2010, tested to work on at least as far back as 2008.

Cite As

Gabriel Frangakis (2024). newt (https://www.mathworks.com/matlabcentral/fileexchange/28162-newt), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Version Published Release Notes
1.2.0.0

added support for polynomials, changed screenshot to include polynomial example

1.1.0.0

Added two tags, included the fact that there are only 46 lines of executable code

1.0.0.0