Solving two non-linear equations with two variables. Any suggestion?

I’m trying to solve a system of two non-linear equations with two variables.

I understand I can use the NLsolve package, but I was wondering if there is any dimension I can improve to get faster speed.

Suppose I have two non-linear equations, F(x,y) and G(x,y), which are functions of the variables x and y.

The first equation is given by the expression 0 = -k + F(x,y)[mid], where F(x,y)[mid] corresponds to the value of the middle grid of the iterated value function. For the second equation, I know only that it is very complicated and not necessarily smooth.

When I use the nlsolve function, the trust region method is three times slower than the Anderson method. Even the Anderson method seems quite slow, so I thought I could exploit more of the first equation.

What I have in mind is to collect solutions of the first equation and then plug them one by one into the second equation and verify if it’s true or not.

  1. Would there be any way to do the first step to collect every combination that satisfies the first equation?

  2. Other than what I’ve proposed, is there any better way to handle this problem?

Any suggestion would be greatly helpful.

It sounds like the reason why solving the equations is slow is that evaluating the F and G takes a lot of time. Then, should the focus be speeding up the F and G?

1 Like

Are you computing the analytical Jacobian so that it can take exact Newton steps? ForwardDiff.jl can help you do this automatically.

Most of the methods internally assume differentiability, so you should formulate your problem in a smooth way if you possibly can.