2
$\begingroup$

How would I solve this systems of non-linear equations symbolically:

$$ \mu N -\frac{\beta S I}{N} - \nu S = 0 \qquad (1)$$

$$\frac{\beta S I}{N} -\gamma I - \nu I = 0 \qquad (2)$$

$$\gamma I - \nu R = 0 \qquad (3) $$

where $S+I+R=N$ and $\mu, \beta, \nu,\gamma >0$

EDIT:

Solve[u*n - (b/n)*p*s - v*s = 
  0 && (b/n)*p*s - g*p - v*p = 0 && g*p - v*r = 0 {s, p, r}, 
 n = s + p + r]

EDIT II:

How would I find the solution to this system:

$$ -\frac{\beta S I}{N} =0 \qquad (1)$$

$$\frac{\beta S I}{N} -\gamma I=0 \qquad (2)$$

$$\gamma I=0 \qquad (3) $$

where $S+I+R=N$ and $\beta,\gamma >0$.

I have these as the solutions;

$$(S^*,I^*,R^*) = (K, 0, N-K),$$ for any $0\leq K \leq N$.

$\endgroup$
9
  • 2
    $\begingroup$ Please provide Mathematica code. Which are the unknowns? It's not recommended to use N and I as variable names $\endgroup$ Mar 8, 2021 at 14:30
  • 1
    $\begingroup$ Look into Solve and NSolve, with FindRoot as a numerical backup plan in case those don't work. $\endgroup$
    – Chris K
    Mar 8, 2021 at 14:39
  • 3
    $\begingroup$ You don't have a code,but you tried Solve ? $\endgroup$ Mar 8, 2021 at 14:52
  • 2
    $\begingroup$ Solve[{n == s + p + r, u*n - (b/n)*p*s - v*s == 0, (b/n)*p*s - g*p - v*p == 0, g*p - v*r == 0}, {s, p, r}, MaxExtraConditions -> All] works fine for me. $\endgroup$ Mar 8, 2021 at 14:58
  • 3
    $\begingroup$ Syntax issue. Equal in infix is ==, not =. That latter is infix for Set (as in "set lhs to value on rhs"). $\endgroup$ Mar 8, 2021 at 15:05

2 Answers 2

5
$\begingroup$

An improved solution based on @MariuszIwaniuk straightforward comment follows with MaxExtraConditions -> Automatic

sol = Solve[{n == s + p + r,u*n - (b/n)*p*s - v*s == 0, (b/n)*p*s - g*p - v*p == 0,g*p - v*r == 0}
, {s, p, r } ,MaxExtraConditions ->   Automatic ]
(*{
{s -> ConditionalExpression[n, u == v],
p -> ConditionalExpression[0, u == v], 
r -> ConditionalExpression[0, u == v]}
,
{s ->ConditionalExpression[(n (g + v))/b, u == v],
p -> ConditionalExpression[(v (n - (n (g + v))/b))/(g + v), u == v],
r -> ConditionalExpression[n - (n (g + v))/b - (v (n - (n (g + v))/b))/(g + v), u == v]}
}*)
$\endgroup$
15
  • $\begingroup$ Why do I get the following when I use your input in Mathematica? "Solve[{True, -((b p s)/(p + r + s)) + (p + r + s) u - s v == 0, -g p + (b p s)/(p + r + s) - p v == 0, g p - r v == 0}, {s, p, r}, MaxExtraConditions -> {Automatic}]" $\endgroup$
    – Math
    Mar 9, 2021 at 12:40
  • $\begingroup$ Try to restart your kernel! I modified my answer and removed curly brackets in MaxExtraConditions -> Automatic $\endgroup$ Mar 9, 2021 at 12:46
  • $\begingroup$ aha! now it doesn't show solutions for "s"... $\endgroup$
    – Math
    Mar 9, 2021 at 12:48
  • $\begingroup$ Code runs as shown in my answer(with fresh kernel). My Mathematicaversion is 12.2 Windows 64 $\endgroup$ Mar 9, 2021 at 12:55
  • $\begingroup$ I'm using 11.1 Mathematica windows 10 but I don't know what's wrong... $\endgroup$
    – Math
    Mar 9, 2021 at 13:04
1
$\begingroup$
eq1 = mu *NN - beta*(SS*II)/NN - v *SS == 0;
eq2 = beta*(SS*II)/NN - gama*II - v*II == 0;
eq3 = gama*II - v*RR == 0;
eq4 = SS + II + RR == NN;
sol = Solve[{eq1, eq2, eq3}, {SS, II, RR}]

enter image description here

Note that the solutions should satisfy eq4 with given parameters.

$\endgroup$
16
  • $\begingroup$ Shouldn't SS be equal to N? $\endgroup$
    – Math
    Mar 8, 2021 at 14:57
  • $\begingroup$ @Math: Birth rate mu is assumed to be equal to the death rate v. Since these are two given parameters, they do not have to be equal in fact. But your formulation of the problem gives SS=(mu/v)*NN if II=0 and RR=0 (first solution). $\endgroup$ Mar 8, 2021 at 15:05
  • $\begingroup$ This is understood. we have assumed $\mu = \nu$. but your solution omits the "$N$" in the first solution part which is why I was wondering. maybe a typo! $\endgroup$
    – Math
    Mar 8, 2021 at 15:30
  • 1
    $\begingroup$ @Math as Tugrul indicates, this solution is normalized such that NN=1, this is why it is “missing” from the first solution part as you observed. If mu/v is unitless as it should be, and it is scaled to NN=1, then to have the appropriate units as SS, it must be that (mu/v)*NN==SS and this is true because NN=1. $\endgroup$ Mar 8, 2021 at 16:53
  • $\begingroup$ @Math: The formal symbolic solution includes NN but I dropped it because NN=1 is assumed. @CA Trevillian's explanation is right. $\endgroup$ Mar 8, 2021 at 17:45

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