Newton raphson tranfsorm from 1d to 2d
1 view (last 30 days)
Show older comments
i have the solution for a 1d problem. How to solve it in 2d ?
1D:
function [x] = my_NR(fun, dfun, x_0,E_tol)
q = 1;
E = inf;
x(q) = x_0;
while E > E_tol
x(q+1) = x(q) - (fun(x(q)))/(dfun(x(q)));
E = abs(x(q+1)-x(q));
q = q+1;
end
end
How to do it in 2D ?
e.g
Input : f = @(x)[0.5*cos(x(1))-0.5*sin(x(2))-x(1);0.5*sin(x(1))+0.5*cos(x(2)-x(2))];
J = @(x)[-0.5*sin(x(1))-1,-0.5*cos(x(2));0.5*cos(x(1)),-0.5*sin(x(2))-1];
x_0 =[0 0]';
E_tol = 10E-04;
Output: x = [0.0 0.0 ;0.2 0.6;0.2287 0.5423;0.2291 0.5391]
1 Comment
David Wilson
on 2 Dec 2019
Edited: David Wilson
on 2 Dec 2019
The Newton-Rhapson is generally specific to 1D. If you want the more general nD case, you need to use the (multivariable) Newton scheme. See e.g. http://fourier.eng.hmc.edu/e176/lectures/NM/node21.html
or of course look up Wikipedia
If you want to just solve your particular problem then try fsolve.
By the way, do you really mean (in the 2nd equation of f(x))
cos(x(2)-x(2))
And is J above the Jacobian? (It's not what I compute!)
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!