Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No support for non-square problems? #270

Open
JurajLieskovsky opened this issue Mar 14, 2021 · 2 comments
Open

No support for non-square problems? #270

JurajLieskovsky opened this issue Mar 14, 2021 · 2 comments

Comments

@JurajLieskovsky
Copy link

JurajLieskovsky commented Mar 14, 2021

Hi, does NLsolve not support non-square problems? I ran into an error when trying to solve a problem with more equations than than unknown variables which I replicated on a small testing script.

using NLsolve
using Rotations

j = [0,1,0]

function f(ϕ,u)
	RotX(ϕ[1])*RotY(ϕ[2])*RotY(ϕ[3])*j - u
end

function g(ϕ,u)
	RotX(ϕ[1])*RotY(ϕ[2])*j - u
end

v = [0,cos(pi/3),sin(pi/3)]

f([pi/3;0;0],v)
nlsolve((x)->f(x,v),[pi/4;0;0])

g([pi/3;0],v)
nlsolve((x)->g(x,v),[pi/4;0])

with console output

julia> nlsolve((x)->g(x,v),[pi/4;0])                                                                 
ERROR: BoundsError: attempt to access 2-element Array{Float64,1} at index [1, 2, 3]

I am sure that the newton method is applicable to such problems so I do not see a reason why NLsolve would not handle it.

@JurajLieskovsky JurajLieskovsky changed the title No support for non-square problem? No support for non-square problems? Mar 14, 2021
@skleinbo
Copy link

Similarly, the solver might not report convergence on problems with input dimension larger than output dimension.

F(x) = sin(x[1])*sin(x[2])/sqrt(1+x[1]^2+x[2]^2)
res = nlsolve(F, rand(2), autodiff=:forward, store_trace=true, extended_trace=true)

Results of Nonlinear Solver Algorithm
 * Algorithm: Trust-region with dogleg and autoscaling
 * Starting Point: [0.08081342223001275, 0.42525217505251844]
 * Zero: [4.175125734506499e-9, 0.4132526768794085]
 * Inf-norm of residuals: 0.425252
 * Iterations: 1000
 * Convergence: false
   * |x - x'| < 0.0e+00: false
   * |f(x)| < 1.0e-08: false
 * Function Calls (f): 4
 * Jacobian Calls (df/dx): 3

res.trace.states[end]
  1000     4.252522e-01     0.000000e+00
 * f(x): [0.0, 0.42525217505251844]
 * g(x): [0.3711470323262712 2.9868402029688e-9; 0.0 0.0]
 * x: [4.175125734506499e-9, 0.4132526768794085]
 * delta: 0.000877443722023774
 * rho: NaN

@kungfugo
Copy link

kungfugo commented Jul 7, 2022

Hi, facing the same issue here. Is the package really restricted to square problems, or is there a workaround known?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants