# How to solve a nonlinear system with redundancy with NonlinearSolve.jl

Hi,

I have problem using NonlinearSolve.jl to solve the following nonlinear system. The reason of the problem is because of the redundancy among the last 3 equations. I wonder if it is possible for NonlinearSolve.jl to somehow automatically remove this redundancy and succesfully solve the system.
I need NonlinearSolve.jl to do that automatically since it will work on many nonlinear systems generated by other codes. Thanks for your help!

``````using ModelingToolkit, NonlinearSolve
@variables ir1 ir2 ir3 yA yF SP
eqs = [0 ~ ir2 - min(ir1, yA*SP),
0 ~ ir2 - yF,
0 ~ ir3 - max(ir1, yF),
0 ~ ir3 - yA*SP,
0 ~ yA - 1.0,
0 ~ yF - 2.0,
0 ~ SP*yA - yF]

@named sys = NonlinearSystem(eqs, [ir1, ir2, ir3, yA, yF, SP], [])
sys = structural_simplify(sys)
u0 = [ir1 .=> 3.0, ir2 .=> 3.0, ir3 .=> 3.0, yA => 1.0, yF => 2.0, SP .=> 2.0]
prob = NonlinearProblem(sys, u0)
sol = solve(prob, NewtonRaphson())
``````

You don’t have a fully-determined system, so is this what you’re looking for?

``````julia> sys = structural_simplify(sys; fully_determined=false)
Model sys with 3 equations
Unknowns (2):
ir1
SP
Parameters (0):

julia> equations(sys)
3-element Vector{Equation}:
0 ~ ir2 - min(ir1, SP*yA)
0 ~ ir3 - max(ir1, yF)
0 ~ -yF + SP*yA

julia> observed(sys)
4-element Vector{Equation}:
yA ~ 1.0
yF ~ 2.0
ir3 ~ SP*yA
ir2 ~ yF
``````