Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I currently have a large system of 150 autonomous differential equations. I've indexed a more managable dummy system of identical form, using Part to reference each individual equation, so:

eqns = {z1' == -kf*z1 + kr*z2, z2 == kf*z1 - kr*z2 - kf*z2, z3' == kp*z2}

with each LHS denoted zn' where n ranges from 0 to 3 (or the # of equations). Inputting eqns[[1]] yields:

z1' == -a kf + b kr

Whereas inputting FullSimplify @ eqns[[1]]yields kf z1 + z1' == kr z2.

Does anyone know a way to specify that the format ought be maintained, ie.

Some Input which would isolate z1' in the FullSimplify term, or yield z1' == kr z2 - kf z1

This sounds petty and is in this dummy example, but isn't in the full-blown system of 150 equations.

Thank you in advance.


I've spent awhile digging around online and in the help to no avail other than possibly changing my notation format, which would render my future use of NDSolve, where I hope to use the shorthand of eqns, problematic given Mathematica's understanding of prime notation for derivatives. (Also, another complication in changing the LHS notation of z1', ..., zn' is in that each is an implicit (rather than explicit) function of (t) (see my attached link in line 1), and so in NDSolve each zn' and zn must be appended with a [t] on the end at some point in the NDSolve function.

share|improve this question
Does Map[yourFunc, eqns, {2}] fulfill your need? To preserve the format, you may apply your simplify function on LHS and RHS separately. –  Silvia May 25 '13 at 23:22
In this case, would the term yourFunc be zn, so, for z2 say, Map[z2, eqns, {2}]? –  Ghersic May 26 '13 at 1:55
Just try the command and see what's output:) If I understand correctly, yourFunc can be FullSimplify. It will apply on both RHS and LHS, but won't make actually difference on LHS. –  Silvia May 26 '13 at 9:50
That does seem to accomplish what I'm going after in my dummy model. Here's hoping I can successfully pull it off in my actual scenario. Thanks, @Silvia. –  Ghersic May 26 '13 at 15:59
add comment

1 Answer

up vote 3 down vote accepted

As discussed in chat earlier here the two main issues:

First, to apply FullSimplify only on the RHS of each equation, many ways are possible. One very verbose way is to use replacement rules. The following example shows how to apply a function FS (you can replace this with FullSimplify) only on the RHS of equations having a Derivative as LHS:

eqns = {a'[t] == -k1f a[t] + k1r b[t], 
   b'[t] == k1f a[t] - k1r b[t] - k2f b[t], c'[t] == k2f b[t], 
   a[0] == a0, b[0] == 0, c[0] == 0};

eqns /. ((lhs : Derivative[1][_][t]) == rhs_) :> (lhs == FS[rhs])

Second, although the time $t$ does not appear explicitly in your pde (because it is autonomous), you still have to use it on symbols, which are dependent on the time. The example in the wiki-page you linked was $y'=(2-y)y$, but to use it with NDSolve you have to make the dependency explicit:

NDSolve[{y'[t] == (2 - y[t])*y[t], y[0] == 2}, y, {t, 0, 10}]
share|improve this answer
Thanks, @halirutan. That seems to work quite well. I think it was mostly syntax and my trying to match FullSimplify's output to what I had achieved previously that was throwing me off there for awhile, but I have achieved. Yes... –  Ghersic May 26 '13 at 17:42
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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