# Solve system of differential equations numerically?

**URL:** <https://community.wolfram.com/t/solve-system-of-differential-equations-numerically/17277>\
**Category:** Questions\
**Tags:** calculus, equation-solving, numerical-computation\
**Created:** [December 24, 2020, 4:05am UTC](https://community.wolfram.com/t/solve-system-of-differential-equations-numerically/17277 "2020-12-24T04:05:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alongcamp](https://avatars.discourse-cdn.com/v4/letter/a/7993a0/32.png) [@alongcamp](https://community.wolfram.com/u/alongcamp)\
**Post date:** [December 24, 2020, 4:05am UTC](https://community.wolfram.com/t/solve-system-of-differential-equations-numerically/17277/1 "2020-12-24T04:05:05Z")

</div>

Hello all,

I am currently trying to numerically analyze the system of differential equations below. I am struggling to solve g’(t), as it involves the partial differential equation w’(g(t)). My goal is to generate a simple plot that shows how the system changes over time. Attached is my code. Any suggestions would be greatly appreciated!

```
h'(t) = y(t)*(1-h(t))*g(t) - a*h(t)

y'(t) = y(t)*b*(1-c)*w(h(t)) - y(t)*d*(x(t)+y(t)), where w(h(t)) = h(t) - (1 - h(t))*g(t)

g'(t) = V*w'(g(t))

```

Alex

[Test.nb](https://community.wolfram.com/uploads/short-url/e2zNqQedyarQe2ksILAInB4Wpcr.nb) (4.09 KB)

---

<div class="post-metadata">

**Author:** ![danl](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/danl/32/41267_2.png) [@danl](https://community.wolfram.com/u/danl)\
**Post date:** [December 24, 2020, 1:48pm UTC](https://community.wolfram.com/t/solve-system-of-differential-equations-numerically/17277/2 "2020-12-24T13:48:57Z")

</div>

Substituting for `w[h[t]]` is straightforward, but it is not clear to me how the solver will be able to numerically compute `w'[g[t]]`.

---

<div class="post-metadata">

**Author:** ![celestinwafosoh](https://avatars.discourse-cdn.com/v4/letter/c/a5b964/32.png) [@celestinwafosoh](https://community.wolfram.com/u/celestinwafosoh)\
**Post date:** [December 24, 2020, 4:44pm UTC](https://community.wolfram.com/t/solve-system-of-differential-equations-numerically/17277/3 "2020-12-24T16:44:23Z")

</div>

Let’s start with

W(g(t)) = g^2(t).

Differentiate both side of the above equation using the chain rule on the left-hand side:

g'(t) W'(g(t)) = 2 g'(t) g(t).

If we assume that the derive of g does not vanish, the last equation implies that  
W'(g(t)) = 2g(t). Now the last equation in your system becomes

g'(t) = 2Vg(t).

By separating the variables, the last equation yields

g(t) = Ae^{2Vt},

where A is an arbitrary constant.

---

<div class="post-metadata">

**Author:** ![hdolhaine](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/hdolhaine/32/35924_2.png) [@hdolhaine](https://community.wolfram.com/u/hdolhaine)\
**Post date:** [December 25, 2020, 2:04pm UTC](https://community.wolfram.com/t/solve-system-of-differential-equations-numerically/17277/4 "2020-12-25T14:04:03Z")

</div>

It seems that your system has not enough equations:

```
 w[h_[t]] := h[t] - (1 - h[t])*g[t]

dgl = {
  h'[t] == y[t]*(1 - h[t])*g[t] - a*h[t],
  y'[t] == y[t]*b*(1 - c)*w[h[t]] - y[t]*d*(x[t] + y[t]),
  g'[t] == V*D[w[g[t]], t]}

NDSolve[dgl /. {a -> .1, b -> .6, c -> .03, d -> .7, V -> 2.3},
 {x, y, g, h},
 {t, 0, 5}]

```

You need another one for x. So with some (arbitrary, you should give them according to your problem) modifications the system runs and you get an answer

```
dgl = {
  h'[t] == y[t]*(1 - h[t])*g[t] - a*h[t],
  y'[t] == y[t]*b*(1 - c)*w[h[t]] - y[t]*d*(x[t] + y[t]),
  g'[t] == V*D[w[g[t]], t],
  x'[t] == g[t],
  x[0] == 0,
  y[0] == 0,
  g[0] == 0,
  h[0] == 0
  }

NDSolve[dgl /. {a -> .1, b -> .6, c -> .03, d -> .7, V -> 2.3},
 {x, y, g, h},
 {t, 0, 5}]

```
