# Solving complex derivatives with Mathematica

**URL:** <https://community.wolfram.com/t/solving-complex-derivatives-with-mathematica/7378>\
**Category:** Questions\
**Tags:** equation-solving\
**Created:** [December 4, 2015, 4:09am UTC](https://community.wolfram.com/t/solving-complex-derivatives-with-mathematica/7378 "2015-12-04T04:09:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikeraguirrezabal](https://avatars.discourse-cdn.com/v4/letter/i/13edae/32.png) [@ikeraguirrezabal](https://community.wolfram.com/u/ikeraguirrezabal)\
**Post date:** [December 4, 2015, 4:09am UTC](https://community.wolfram.com/t/solving-complex-derivatives-with-mathematica/7378/1 "2015-12-04T04:09:40Z")

</div>

Hello community

I need to solve a complex set of equations using Mathematica and would like to know if you could help with the writing in the program. These are the equations that need to be written:

dx/dt=-ax-bxy-dxz

dy/dt=ax-by+cz-dxy

dz/dt=by-cz-cxz

d?/dt=dxy+exz

where x,y,z,? are variables and a, b, c, d, e are constants.

How can I obtain an expression for each variable that depends on the constants? Which are the functions to introduce in Mathematica?

Thanks

---

<div class="post-metadata">

**Author:** ![dreiss](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/dreiss/32/29094_2.png) [@dreiss](https://community.wolfram.com/u/dreiss)\
**Post date:** [December 4, 2015, 4:48am UTC](https://community.wolfram.com/t/solving-complex-derivatives-with-mathematica/7378/2 "2015-12-04T04:48:11Z")

</div>

Your first step is to learn about Mathematica. Take a look at some of the references listed in the following link and start to learn the system, then take a try at your problem. The particular function that you will be interested in is DSolve.

> [@For Beginners: A book (or two) to learn the Wolfram Language](https://wolfram.discourse.group/t/7218/1):
>
> Since there are many folks on this forum that are new to using Mathematica/WolframLanguage I'd suggest that each order a copy of Stephen Wolfram's soon-to-be-released (December 7 2015) "An Elementary Introduction to the Wolfram Language": [http://www.amazon.com/Elementary-Introduction-Wolfram-Language/dp/1944183000/](http://www.amazon.com/Elementary-Introduction-Wolfram-Language/dp/1944183000/) though I haven't read it yet, there is a clear need for a tutorial that helps beginning users "start right" and avoid the many issues that arise by simply diving in without a hel…

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [December 4, 2015, 6:11am UTC](https://community.wolfram.com/t/solving-complex-derivatives-with-mathematica/7378/3 "2015-12-04T06:11:43Z")

</div>

`DSolve` did not give solution:

```
ClearAll[x, y, z, gamma, t, a, b, c, d, e];
eq1 = x'[t] == -a x[t] - b x[t] y[t] - d x[t] z[t];
eq2 = y'[t] == a x[t] - b y[t] + c z[t] - d x[t] y[t];
eq3 = z'[t] == b y[t] - c z[t] - c x[t] z[t];
eq4 = gamma'[t] == d x[t] y[t] + e x[t] z[t];
DSolve[{eq1, eq2, eq3, eq4}, {x[t], y[t], z[t], gamma[t]}, t]

```

But `NDsolve` can solve them. You need to supply numerical values for all the parameters and initial conditions also.

```
ClearAll[x, y, z, gamma, t, a, b, c, d, e];
a = 1; b = 2; c = 3; d = 4; e = 5;
eq1 = x'[t] == -a x[t] - b x[t] y[t] - d x[t] z[t];
eq2 = y'[t] == a x[t] - b y[t] + c z[t] - d x[t] y[t];
eq3 = z'[t] == b y[t] - c z[t] - c x[t] z[t];
eq4 = gamma'[t] == d x[t] y[t] + e x[t] z[t];
NDSolve[{eq1, eq2, eq3, eq4, x[0] == 1, y[0] == 0, z[0] == 0, 
  gamma[0] == 0}, {x[t], y[t], z[t], gamma[t]}, {t, 0, 10}]

```

---

<div class="post-metadata">

**Author:** ![ikeraguirrezabal](https://avatars.discourse-cdn.com/v4/letter/i/13edae/32.png) [@ikeraguirrezabal](https://community.wolfram.com/u/ikeraguirrezabal)\
**Post date:** [December 5, 2015, 7:46pm UTC](https://community.wolfram.com/t/solving-complex-derivatives-with-mathematica/7378/4 "2015-12-05T19:46:10Z")

</div>

Thank you Nasser. Is there any way to obtain a formula corresponding to this interpolated functions or plots?

---

<div class="post-metadata">

**Author:** ![nma](https://avatars.discourse-cdn.com/v4/letter/n/b5e925/32.png) [@nma](https://community.wolfram.com/u/nma)\
**Post date:** [December 5, 2015, 8:21pm UTC](https://community.wolfram.com/t/solving-complex-derivatives-with-mathematica/7378/5 "2015-12-05T20:21:15Z")

</div>

> Is there any way to obtain a formula corresponding to this  
> interpolated functions or plots?

I am no expert in this area, but the way I’ve seen it done is by getting the `x,y` values from the `InterpolatingFunction` object, then use `InterpolatingPolynomial`.

`InterpolatingFunction` itself uses piecewise `InterpolatingPolynomial` under the cover. But to obtain just one `InterpolatingPolynomial` over all the grid points, will result in a very large polynomial of course (order one less that number of grid points), and is not recommended as it will be highly oscillatory. You could pick smaller grid regions at a time, and find the `InterpolatingPolynomial` over those. But here is what you can try:

```
ClearAll[x, y, z, gamma, t, a, b, c, d, e];
a = 1; b = 2; c = 3; d = 4; e = 5;
eq1 = x'[t] == -a x[t] - b x[t] y[t] - d x[t] z[t];
eq2 = y'[t] == a x[t] - b y[t] + c z[t] - d x[t] y[t];
eq3 = z'[t] == b y[t] - c z[t] - c x[t] z[t];
eq4 = gamma'[t] == d x[t] y[t] + e x[t] z[t];
sol = First@NDSolve[{eq1, eq2, eq3, eq4, x[0] == 1, y[0] == 0, z[0] == 0, gamma[0] == 0}, 
     {x, y, z, gamma}, {t, 0, 10}];

xSol = x /. sol; (* get formula for the x(t) solution *)
xpoints = Flatten@xSol["Coordinates"];
ypoints = Flatten@xSol["ValuesOnGrid"];
data = Transpose[{xpoints, ypoints}];
p = InterpolatingPolynomial[data, t];
Expand[p]

```

Here is your formula for the x(t) solution found by `NDSolve`

 ![6449Untitled.png](https://global.discourse-cdn.com/wolfram/original/3X/0/4/0489aa89bd01759c3a50035a418793601b7a6045.png)
