Multidimensional Newton-Raphson method: Difference between revisions

julia example
(julia example)
Line 351:
Approximate solutions are x = 0.8936282, y = 0.8945270, z = -0.0400893
</pre>
 
 
=={{header|Julia}}==
NLsolve is a Julia package for nonlinear systems of equations, with the Newton-Raphson method one of the choices for solvers.
<lang julia># from the NLSolve documentation: to solve
# (x, y) -> ((x+3)*(y^3-7)+18, sin(y*exp(x)-1))
using NLsolve
 
function f!(F, x)
F[1] = (x[1]+3)*(x[2]^3-7)+18
F[2] = sin(x[2]*exp(x[1])-1)
end
 
function j!(J, x)
J[1, 1] = x[2]^3-7
J[1, 2] = 3*x[2]^2*(x[1]+3)
u = exp(x[1])*cos(x[2]*exp(x[1])-1)
J[2, 1] = x[2]*u
J[2, 2] = u
end
 
println(nlsolve(f!, j!, [ 0.1; 1.2], method = :newton))
</lang>{{out}}
<pre>
Results of Nonlinear Solver Algorithm
* Algorithm: Newton with line-search
* Starting Point: [0.1, 1.2]
* Zero: [-3.7818e-16, 1.0]
* Inf-norm of residuals: 0.000000
* Iterations: 4
* Convergence: true
* |x - x'| < 0.0e+00: false
* |f(x)| < 1.0e-08: true
* Function Calls (f): 5
* Jacobian Calls (df/dx): 4
</pre>
 
 
 
=={{header|Kotlin}}==
4,102

edits