# Solve a system of ODE's with DSolve\[ \]?

**URL:** <https://community.wolfram.com/t/solve-a-system-of-odes-with-dsolve/17116>\
**Category:** Questions\
**Tags:** biological-sciences, medical-sciences, calculus, equation-solving, modeling, symbolic-computations\
**Created:** [November 30, 2020, 11:02pm UTC](https://community.wolfram.com/t/solve-a-system-of-odes-with-dsolve/17116 "2020-11-30T23:02:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jgourle2](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/jgourle2/32/4175_2.png) [@jgourle2](https://community.wolfram.com/u/jgourle2)\
**Post date:** [November 30, 2020, 11:02pm UTC](https://community.wolfram.com/t/solve-a-system-of-odes-with-dsolve/17116/1 "2020-11-30T23:02:37Z")

</div>

I’m new to Mathematica and would appreciate anyone with an experienced eye who would look at the following failed attempt to solve a system of ordinary differential equations and tell me what I’m doing wrong. The function is pasted below and a .nb file is attached.

I’m looking for general symbolic solution to a standard S,I,R (susceptible, infected, recovered) model. Then I’d like to learn how to play with parameters and plotting features. But first, I need a solution. This attached formulation has been running for a few hours without returning a result. What’s wrong with its arguments? Is there a way to limit parameter intervals and independent variable interval?

Thanks.

```
eqns = {s'[t] == m (s0 + i0 + r0) - \[Beta] s[t] i[t] - m s[t], i'[t] == \[Beta] s[t] i[t] - m i[t] - g i[t], r'[t] == g i[t] - m r[t]}
sol = DSolve[eqns, {s, i, r}, t]

```

[SIR Model DSolve.nb](https://community.wolfram.com/uploads/short-url/n9elHfQkNdEpRKQbJk2JC1z9a1n.nb) (4.34 KB)

---

<div class="post-metadata">

**Author:** ![rnachbar](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/rnachbar/32/10766_2.png) [@rnachbar](https://community.wolfram.com/u/rnachbar)\
**Post date:** [November 30, 2020, 11:20pm UTC](https://community.wolfram.com/t/solve-a-system-of-odes-with-dsolve/17116/2 "2020-11-30T23:20:54Z")

</div>

This system of equations contains two nonlinear equations, and therefore cannot be solved in closed form.

They can be solved numerically with ParametricNDSolve that will allow you to play with the parameters.

```
{ss, ii, rr} = {s, i, r} /. 
  ParametricNDSolve[{eqns, {s[0] == s0, i[0] == i0, r[0] == r0}}, {s, 
    i, r}, {t, 0, 100}, {s0, i0, r0, \[Beta], g, m}]

```

The following Plot can be put inside of Manipulate

```
Plot[{ss[1000, 1, 0, 0.002, 0.2, 0.003][t], 
  ii[1000, 1, 0, 0.002, 0.2, 0.003][t], 
  rr[1000, 1, 0, 0.002, 0.2, 0.003][t]}, {t, 0, 30}]

```

 ![sir.png](https://global.discourse-cdn.com/wolfram/original/3X/3/6/36e38d85b4bfc1c35717984710605022bb3afe70.png)

---

<div class="post-metadata">

**Author:** ![jgourle2](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/jgourle2/32/4175_2.png) [@jgourle2](https://community.wolfram.com/u/jgourle2)\
**Post date:** [December 1, 2020, 6:04pm UTC](https://community.wolfram.com/t/solve-a-system-of-odes-with-dsolve/17116/3 "2020-12-01T18:04:59Z")

</div>

Thanks, Robert Nachbar for the explanation. And also thanks for including the plot. Is it possible to animate the plot with sliders for the parameters? Also, I’m new to applied math. Is a system of closed form solutions not possible, even in a case like this where S’+I’+R’=0 for all t?

Is there web tutorial on Mathematica syntax? I understand functions I write with my limited vocabulary. But understanding yours involves guesswork. Your functions work perfectly, but I cannot explain why.

---

<div class="post-metadata">

**Author:** ![rnachbar](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/rnachbar/32/10766_2.png) [@rnachbar](https://community.wolfram.com/u/rnachbar)\
**Post date:** [December 2, 2020, 6:13pm UTC](https://community.wolfram.com/t/solve-a-system-of-odes-with-dsolve/17116/4 "2020-12-02T18:13:03Z")

</div>

The Manipulate function will allow you to easily attach sliders to parameters and dynamically update the plot as the sliders are moved.

All the Wolfram Language documentation is available on-line. the landing page is [here](https://reference.wolfram.com/language/). Documentation for Manipulate is [here](https://reference.wolfram.com/language/ref/Manipulate.html). Depending on your prior coding experience, these two “tutorials” may be good starting points: [An Elementary Introduction to the Wolfram Language](https://www.wolfram.com/language/elementary-introduction/2nd-ed/) (aka EIWL) and [Wolfram Language: Fast Introduction for Programmers](https://www.wolfram.com/language/fast-introduction-for-programmers/en/).

---

<div class="post-metadata">

**Author:** ![jgourle2](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/jgourle2/32/4175_2.png) [@jgourle2](https://community.wolfram.com/u/jgourle2)\
**Post date:** [December 2, 2020, 9:49pm UTC](https://community.wolfram.com/t/solve-a-system-of-odes-with-dsolve/17116/5 "2020-12-02T21:49:14Z")

</div>

Thanks, again Robert Nachbar.
