# Understanding the symbolic solutions of a system of differential equations

I'm trying to solve a simple system of differential equations but get outputs i just cant grasp, they seem way overkill. Someone said it might be because mathematica interprits the constants as non-real and therefore gives an over kill solution. I tried adding this assumption but it doesn't seem to help. I'm new to mathmatica and have no idea what I'm doing, any help would be appreciated. The code can be found below

DSolve[{kbz*z1 + cbz*z11 == kbz*z2[t] + kvr*(z2[t] - z3[t]) + cbz*z2'[t] + cvr*(z2'[t] - z3'[t]),
ksoil*zr == kvr*(z3[t] - z2[t]) + ksoil*z3[t] + cvr*(z3'[t] - z2'[t]),
z2[0] == 0, z3[0] == 0}, {z2[t], z3[t]}, t,
Assumptions -> {kbz, kvr, ksoil, cbz, cvr, z1, z11, zr} \[Element] Reals]


Does anyone have any ideas of how to fix it?

Edited for proper initial conditions.

• Indeed, the output is huge. What happens when you try FullSimplify[]? Commented Feb 25, 2016 at 15:54
• NDSolve is made for this.
– user36273
Commented Feb 25, 2016 at 16:51
• FullSimplify simplified it quite a bit but the output is still very large. When trying to use the NDSolve I get the error: "Encountered non-numerical value for a derivative at t == 0.. " NDSolve[{kbzz1 == kbzz2[t] + kvr*(z2[t] - z3[t]) + cbzz2'[t] + cvr*(z2'[t] - z3'[t]), ksoilzr == kvr*(z3[t] - z2[t]) + ksoil*z3[t] + cvr*(z3'[t] - z2'[t]), z2[0] == 0, z3[0] == 0}, {z2[t], z3[t]}, {t, 0, 30}] Commented Feb 26, 2016 at 7:44

(The original question did not have initial conditions in the system of equations.)

Look at the simplified forms obtained after replacing the integration constants with appropriate values.

For example, if we assign the solution to a variable:

sol = DSolve[{kbz*z1 ==
kbz*z2[t] + kvr*(z2[t] - z3[t]) + cbz*z2'[t] + cvr*(z2'[t] - z3'[t]),
ksoil*zr ==
kvr*(z3[t] - z2[t]) + ksoil*z3[t] + cvr*(z3'[t] - z2'[t])}, {z2[t], z3[t]}, t,
Assumptions -> {z1, kbz, kvr, ksoil, cbz, cvr, zr} \[Element] Reals]


using the replacement rules {C[1] -> 0, C[2] -> 0} we get this simpler expression for z2[t]:

In[76]:= Simplify[(z2[t] /. sol[[1]]) /. {C[1] -> 0, C[2] -> 0}]

Out[76]= (kbz (ksoil + kvr) z1 + ksoil kvr zr)/(ksoil kvr + kbz (ksoil + kvr))


and for z3[t]:

In[77]:= Simplify[(z3[t] /. sol[[1]]) /. {C[1] -> 0, C[2] -> 0}]

Out[77]= (kbz kvr z1 + kbz ksoil zr + ksoil kvr zr)/(ksoil kvr + kbz (ksoil + kvr))


Second answer (initial conditions and NDSolve)

(This update is about dealing with the new system with added initial conditions.)

In order to solve this system with NDSolve, numerical values of the different constants in it have to be specified. Since the original question started with the sentence:

I'm trying to solve a simple system of differential equations but get outputs i just cant grasp, they seem way overkill.

I think it is best to use a combination of simplified DSolve results and plotted NDSolve results within a dynamic interface with Manipulate. Here is an example:

The code below does that. (Note that the preliminary simplification of the DSolve results has to be done otherwise the simplification within Manipulate might take too long.)

sol = DSolve[{kbz*z1 ==
kbz*z2[t] + kvr*(z2[t] - z3[t]) + cbz*z2'[t] +
cvr*(z2'[t] - z3'[t]),
ksoil*zr ==
kvr*(z3[t] - z2[t]) + ksoil*z3[t] + cvr*(z3'[t] - z2'[t]),
z2[0] == 0, z3[0] == 0}, {z2[t], z3[t]}, t,
Assumptions -> {z1, kbz, kvr, ksoil, cbz, cvr, zr} \[Element]
Reals];

dsol = {z2[t] -> Simplify[(z2[t] /. sol[[1]])],
z3[t] -> Simplify[(z3[t] /. sol[[1]])]};

varRangeWidth = 10;
Manipulate[
ndsol = NDSolve[{mkbz*mz1 ==
mkbz*z2[t] + mkvr*(z2[t] - z3[t]) + mcbz*z2'[t] +
mcvr*(z2'[t] - z3'[t]),
mksoil*mzr ==
mkvr*(z3[t] - z2[t]) + mksoil*z3[t] + mcvr*(z3'[t] - z2'[t]),
z2[0] == 0, z3[0] == 0}, {z2[t], z3[t]}, {t, 0, 10}];
rules = {z1 -> mz1, kbz -> mkbz, kvr -> mkvr, ksoil -> mksoil,
cbz -> mcbz, cvr -> mcvr, zr -> mzr};
rfunc = If[rationalizeQ, Rationalize, Identity];
Column[{
Grid[{
{z2[t], rfunc@Simplify[(z2[t] /. dsol) /. rules]}, {z3[t],
rfunc@Simplify[(z3[t] /. dsol) /. rules]}
}, Dividers -> All],
Plot[Evaluate[{z2[t], z3[t]} /. ndsol[[1]]], {t, 0, tend},
PlotTheme -> "Scientific", GridLines -> Automatic,
PlotLegends -> {"z2[t]", "z3[t]"}, ImageSize -> 500]
}],
{{mz1, 1, "z1"}, -varRangeWidth,
varRangeWidth}, {{mkbz, 1, "kbz"}, -varRangeWidth,
varRangeWidth}, {{mkvr, 1, "kvr"}, -varRangeWidth,
varRangeWidth}, {{mksoil, 1, "ksoil"}, -varRangeWidth,
varRangeWidth}, {{mcbz, 1, "cbz"}, -varRangeWidth,
varRangeWidth}, {{mcvr, 1, "cvr"}, -varRangeWidth,
varRangeWidth}, {{mzr, 1, "zr"}, -varRangeWidth,
varRangeWidth}, {{tend, 10}, 0, 100}, {rationalizeQ, {True, False}}]
`

Here is another snapshot of the code output:

• Yes this solves it quite nicely. Unfortunately our initial conditions are z2[0]=0 and z3[0]=0. Sorry that I forgot to specify the initial conditions. Commented Feb 26, 2016 at 7:46
• @tomatpinne Please change your question accordingly. Commented Feb 26, 2016 at 15:07