ERROR: SingularException(4)
Closed this issue · 3 comments
LH1389 commented
using LinearAlgebra
f(x) = (x[1]+10*x[2])^2 + 5*(x[3]-x[4])^2 + (x[2]-2*x[3])^4 + 10*(x[1]-x[4])^4
f1(x) = 2(x[1]+10*x[2]) + 40(x[1]-x[4])^3
f2(x) = 20(x[1]+10*x[2]) + 4(x[2]-2*x[3])^3
f3(x) = 10(x[3]-x[4]) - 8(x[2]-2*x[3])^3
f4(x) = -10(x[3]-x[4]) - 40(x[1]-x[4])^3
X(x) = [f1(x);f2(x);f3(x);f4(x)]
;
f11(x) = 2+120(x[1]-x[4])^2
f12(x) = 20
f13(x) = 0
f14(x) = -120(x[1]-x[4])^2
f15(x) = [f11(x);f12(x);f13(x);f14(x)]
f21(x) = 20
f22(x) = 200+12(x[2]-2*x[3])^2
f23(x) = -24(x[2]-2*x[3])^2
f24(x) = 0
f25(x) = [f21(x);f22(x);f23(x);f24(x)]
f31(x) = 0
f32(x) = -24(x[2]-2*x[3])^2
f33(x) = 10 + 48(x[2]-2*x[3])^2
f34(x) = -10
f35(x) = [f31(x);f32(x);f33(x);f34(x)]
f41(x) = -120(x[1]-x[4])^2
f42(x) = 0
f43(x) = -10
f44(x) = 10 + 120(x[1]-x[4])^2
f45(x) = [f41(x);f42(x);f43(x);f44(x)]
F(x) = [f15(x) f25(x) f35(x) f45(x)]
x = [3,-1,0,1]
t1 = inv(F(x))
F([3,-1,0,1])
dis=1
function newton(x)
while dis > 0.01
g = X(x)
t1 = inv(F(x))
x1 = x - t1 * g
dis = sqrt((x1[1]-x[1])^2+(x1[2]-x[2])^2+(x1[3]-x[3])^2+(x1[4]-x[4])^2)
x = x1
println(x,f(x))
end
end
x = [3,-1,0,1]
newton(x)
LH1389 commented
ERROR: SingularException(4)
Stacktrace:
checknonsingular at [factorization.jl](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
checknonsingular at [factorization.jl](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
#lu!#170 at [lu.jl](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
lu! at [lu.jl](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
#lu#176 at [lu.jl](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
lu at [lu.jl](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html) (repeats 2 times)
inv(A::Matrix{Float64}) at [dense.jl](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
newton(x::Vector{Int64}) at [Untitled-3](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
top-level scope at [Untitled-3](vscode-file://vscode-app/d:/Microsoft%20VS%20Code/resources/app/out/vs/code/electron-sandbox/workbench/workbench.html)
LH1389 commented
Why it cannot stop?
Kolaru commented
The error comes from the fact that sometimes F(x)
is not invertible (resulting in a SinguarException
).
However this seems to be unrelated to IntervalRootFinding.jl, so I am closing the issue.