Skip to content

TrustRegion cannot solve the Readme example from NLsolve.jl #170

@junyuan-chen

Description

@junyuan-chen

If I didn't misunderstand how the solver is supposed to be used, there must be issues with TrustRegion. Also, what seems strange to me is that there is no warning message or something like that when the residuals are far from zeros. Somehow the solver just terminates quietly.

function f!(F, x, p)
    F[1] = (x[1]+3)*(x[2]^3-7)+18
    F[2] = sin(x[2]*exp(x[1])-1)
end

function j!(J, x, p)
    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

x0 = [0.1, 1.2]
F = NonlinearFunction(f!, jac=j!)
prob = NonlinearProblem(F, x0)
solver = solve(prob, TrustRegion(), reltol=1e-8)

Running above gives:

julia> solver = solve(prob, TrustRegion(), reltol=1e-8)
u: 2-element Vector{Float64}:
 0.22839632925361786
 1.1261248602773282

julia> solver.resid
2-element Vector{Float64}:
 0.011709310458734024
 0.40325365258870505

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions