1
$\begingroup$

I have a system of $n$ ODEs $\frac{dx_i}{dt} = f_i(x_1.\ldots,x_n)$, which I would like to solve at steady state.

However, $\sum_{i} x_i = 1$, and so it's actually only an $n-1$-dimensional system. As a result, the jacobian for my system is singular everywhere (which FindRoot tells me when I try to use it). Is there anyway I can get Find Root to work with this, without rewriting the equations in terms of the $n-1$ variables?

For example, what I would like to do is the following:

eqn1 = y-2x*y;
eqn2 = 2x*y-y;
FindRoot[{eqn1==0,eqn2==0,x+y==1},{{x,0.2},{y,0.2}}].

I know I can use NSolve instead in this scenario, but for the system I'm actually working with, NSolve doesn't compute it in a reasonable time.

This system doesn't actually throw the Jacobian error, but it is a similar system, so I imagine if I can do it for this system, my system of interest will work with the same method.

$\endgroup$
9
  • 4
    $\begingroup$ Please provide code (InputForm) for a concrete example that demonstrates the issue. $\endgroup$
    – Bob Hanlon
    Commented May 26, 2021 at 14:04
  • 1
    $\begingroup$ Have a look at the Affine Covariant Newton solver and it's options. $\endgroup$
    – user21
    Commented May 26, 2021 at 14:28
  • 1
    $\begingroup$ {min, arg} = Minimize[{eqn1^2 + eqn2^2, x + y == 1}, {x, y}] $\endgroup$
    – Bob Hanlon
    Commented May 26, 2021 at 15:38
  • 1
    $\begingroup$ "Minimize finds the global minimum of f subject to the constraints given" and "NMinimize always attempts to find a global minimum of f subject to the constraints given"; whereas, FindMinimum "searches for a local minimum". I would only use FindMinimum if neither Minimize nor NMinimize were successful. $\endgroup$
    – Bob Hanlon
    Commented May 26, 2021 at 15:56
  • 1
    $\begingroup$ Maybe obvious, but have you tried Solve[{eqn1 == 0, eqn2 == 0, x + y == 1}, {x, y}]? $\endgroup$
    – Roman
    Commented May 26, 2021 at 16:37

1 Answer 1

2
$\begingroup$

Introduce an additional variable (here a) that you use nowhere in the equations. (It's just to provide three variables for three equations.)

eqn1 = y - 2 x*y;
eqn2 = 2 x*y - y;
FindRoot[{eqn1 == 0, eqn2 == 0, (x + y - 1) == 0}, 
    {{x, 0.2}, {y, 2}, {a, 2}}]

(*   {x -> 0.5, y -> 0.5, a -> 2.}   *)

eqn1 = y - 2 x*y;
eqn2 = 2 x*y - y;
FindRoot[{eqn1 == 0, eqn2 == 0, (x + y - 1) == 0}, 
   {{x, 1.2}, {y, 2}, {a, 1}}]

(*   {x -> 1., y -> -7.38374*10^-28, a -> 1.}   *)
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.