How to use Newton-Raphson for numerical solution of two variables?
古いコメントを表示
Hello community,
I have a non-linear function f(x,y), which I would like to find the roots of with the Newton-Raphson method. However, I haven't yet found a simple code on the internet in case of two variables, which just lets me enter my function and get the result. If I find one, the solutions on the internet always need two equations, but I only have one?
2 件のコメント
Newton-Raphson only applies to N equations in N unknowns. If you have fewer equations than unknowns, there will normally be an infinite continuum of roots. For example,
f(x,y)=x+y
has roots at all x=-y.
Jonas
2013 年 9 月 8 日
回答 (2 件)
Matt J
2013 年 9 月 8 日
Can i divide it into a real and an imaginary equation
You could just rewrite your function to return a 2x1 vector containing the real and imaginary part respectively.
If f() is your existing function, you could also do
f_new=[real(f(x,y)); imag(f(x,y))]
7 件のコメント
Jonas
2013 年 9 月 8 日
Jonas
2013 年 9 月 8 日
Matt J
2013 年 9 月 8 日
I'm having no difficulty with it.
>> f=@(x,y) [real(fname(x,y)) ; imag(fname(x,y)) ]
>> fname(.1,.2)
ans =
-2.0418e+23 + 2.1406e+23i
>> f(.1,.2)
ans =
1.0e+23 *
-2.0418
2.1406
Jonas
2013 年 9 月 8 日
Matt J
2013 年 9 月 8 日
Now that you have a system of 2 equations in 2 unknowns, the Newton-Raphson code that you've been using should work fine. There is also FZERO, if you have it.
Jonas
2013 年 9 月 8 日
カテゴリ
ヘルプ センター および File Exchange で Systems of Nonlinear Equations についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!