Multidimensional Newton-Raphson method: Difference between revisions
Content added Content deleted
(Added Kotlin) |
(→{{header|zkl}}: Added Kotlin example) |
||
Line 320: | Line 320: | ||
<pre> |
<pre> |
||
1.00,1.00 |
1.00,1.00 |
||
</pre> |
|||
Another example: |
|||
<lang zkl>v:=GSL.VectorFromData(1.0, 1.0, 0.0); // initial guess |
|||
fxyzs:=T( |
|||
fcn(x,y,z){ x*x*9 + y*y*36 + z*z*4 - 36 }, // 9x^2 + 36y^2 + 4z^2 - 36 = 0 |
|||
fcn(x,y,z){ x*x - y*y*2 - z*20 }, // x^2 - 2y^2 - 20z = 0 |
|||
fcn(x,y,z){ x*x - y*y + z*z }); // x^2 - y^2 + z^2 = 0 |
|||
(v=GSL.multiroot_fsolver(fxyzs,v)).format(12,8).println(); |
|||
xyz:=v.toList(); |
|||
fxyzs.apply('wrap(f){ f(xyz.xplode()) }).println(); // deltas from zero</lang> |
|||
{{out}} |
|||
<pre> |
|||
0.89362824, 0.89452701, -0.04008929 |
|||
L(6.00672e-08,1.0472e-08,9.84017e-09) |
|||
</pre> |
</pre> |