JuliaIntervals / IntervalRootFinding.jl

Library for finding the roots of a function using interval arithmetic
https://juliaintervals.github.io/IntervalRootFinding.jl/
Other
125 stars 26 forks source link

ERROR: SingularException(4)....what happen? #198

Closed LH1389 closed 2 months ago

LH1389 commented 3 months ago

using LinearAlgebra f(x) = (x[1]+10x[2])^2 + 5(x[3]-x[4])^2 + (x[2]-2x[3])^4 + 10(x[1]-x[4])^4 f1(x) = 2(x[1]+10x[2]) + 40(x[1]-x[4])^3 f2(x) = 20(x[1]+10x[2]) + 4(x[2]-2x[3])^3 f3(x) = 10(x[3]-x[4]) - 8(x[2]-2x[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]-2x[3])^2 f23(x) = -24(x[2]-2x[3])^2 f24(x) = 0 f25(x) = [f21(x);f22(x);f23(x);f24(x)] f31(x) = 0 f32(x) = -24(x[2]-2x[3])^2 f33(x) = 10 + 48(x[2]-2x[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)

Kolaru commented 2 months ago

Dup of #199