Newton Raphson - Multiple functions

Newton-Raphson iterative method to find roots of a function (or multiple functions). Adjustable residue tolerance, max number of iterations
25 Descargas
Actualizado 2 sep 2023

Ver licencia

% Newton-Raphson iterative method to find roots of a function.
% Ex.: roots = NewtonRaphson(f, x, [tol], [MaxIt], [Delta])
%
% There are 2 mandatory inputs (f and x) and 3 optional arguments (tol,
% MaxIt, and Delta).
%
% The function returns 1 output (x).
%
% INPUTS:
% 1. f - function handle to which the roots should be found. It should
% be noted that if f is a multivariable function handle (for example, f =
% @(x, y) [x^2 + y^2 - 3^2; x - y = 3]), then the function handle
% should be rewritten as a one vector variable function handle (for
% example, f = @(x) [x(1)^2 + x(2)^2 - 3^2; x(1) - x(2) = 3]).
% Additionally, the output size of the function handle should always
% match the variable x size.
% 2. x - initial guess for the roots of the vector variable.
% 3. [Optional] tol - convergence tolerance.
% Type: Double. Default: 1e-3.
% 4. [Optional] MaxIt - Maximum number of iterations.
% Type: Double. Default: 1e3.
% 5. [Optional] Delta - Step for numerical derivative.
% Type: Double. Default: 1e-6.
%
% OUTPUTS:
% 1. roots - roots of the function. If the algorithm does not converge, then x
% is NaN. x is the same size and type as the input x.
%
% Examples:
% roots = NewtonRaphson(@(x) [x(1) - x(2) - 2; x(2) - 5], [0; 0])
% roots = NewtonRaphson(@(x) [x(1) - x(2) - 2; x(2) - 5], [0; 0]), 1e-6, 50, 1e-12)
%
% © Universidade de Brasilia, 2023
% Power Quality Laboratory (LQEE)
% Author: Victor do Prado Brasil
% Version History:
% 2023/07/13 - Creation of the function.

Citar como

Victor Brasil (2025). Newton Raphson - Multiple functions (https://es.mathworks.com/matlabcentral/fileexchange/134666-newton-raphson-multiple-functions), MATLAB Central File Exchange. Recuperado .

Compatibilidad con la versión de MATLAB
Se creó con R2023a
Compatible con cualquier versión
Compatibilidad con las plataformas
Windows macOS Linux
Etiquetas Añadir etiquetas

Community Treasure Hunt

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

Start Hunting!
Versión Publicado Notas de la versión
1.0.0