Jump to content

Multidimensional Newton-Raphson method: Difference between revisions

m
→‎{{header|Phix}}: simplified exit condition
m (→‎{{header|Phix}}: simplified exit condition)
Line 674:
atom tol := 1e-8
while true do
gu1 := gu2
g := matrix_transpose({gu1})
t := repeat(0, size)
for i=1 to size do
t[i] := call_func(fs[i],{gu1})
end for
f := matrix_transpose({t})
for i=1 to size do
for j=1 to size do
jac[i][j] := call_func(jacob[i][j],{gu1})
end for
end for
g1 := sq_sub(g,matrix_mul(inverse(jac),f))
gu2 := vslice(g1,1)
iter += 1
bool any := falsefind(true,sq_gt(sq_sub(sq_abs(gu2),gu1),tol))!=0
for i=1 to length(gu2) do
if abs(gu2[i])-gu1[i] > tol then
any = true
exit
end if
end for
if not any or iter >= maxIter then exit end if
end while
7,806

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.