1
$\begingroup$

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

eqns = {c1' == -kf*c1 + kr*c2, c2 == kf*z1 - kr*z2 - kf*c2, c3' == kp*c2}

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

c1' == -a kf + b kr

Whereas inputting FullSimplify @ eqns[[1]]yields kf c1 + c1' == kr c2.

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

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

This sounds petty and is in this dummy example, but isn't for larger systems.

Thank you in advance.

Edit:

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 c1', ..., cn' 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 cn' and cn must be appended with a [t] on the end at some point in the NDSolve function.

$\endgroup$
3
  • 1
    $\begingroup$ Does Map[yourFunc, eqns, {2}] fulfill your need? To preserve the format, you may apply your simplify function on LHS and RHS separately. $\endgroup$
    – Silvia
    May 25, 2013 at 23:22
  • $\begingroup$ 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. $\endgroup$
    – Silvia
    May 26, 2013 at 9:50
  • $\begingroup$ 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. $\endgroup$
    – Ghersic
    May 26, 2013 at 15:59

1 Answer 1

3
$\begingroup$

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}]
$\endgroup$
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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