Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I am given a system first order differential equations: $x'=y$ and $y'=6x^2-a/2$, where $a$ is a constant and $'$ denotes $t$-derivatives.

I then make the substitution $(x,y)=(x_1y_1,y_1)$.

This implies that $x_1=\frac{x}{y}$ and $y_1=y$.

The $t$-derivatives are $$x_{1}'=\left(\frac{x}{y}\right)'=\frac{yx'-xy'}{y^2}=1-x_{1}y_{1}^{-1}(6x_{1}^2y_{1}^2-a/2)$$ and $$y_{1}'=6x_{1}^2y_{1}^2-a/2.$$

I need to continue in this fashion, that is, in the next step, for example, we let $(x_{1},y_{1})=(x_{2}y_{2},y_{2})$ and then find $x_{2}'$, $y_{2}'$, etc.

Is there a way I can compute the derivatives in Mathematica? For instance, how would I find $x_{1}'$ in Mathematica.

Thanks, Radz.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

I assume that while the replacement rule is to be selectable; the same rule is used in each iteration.

Format[x[n_Integer]] := Subscript[x, n];
Format[y[n_Integer]] := Subscript[y, n];

eqn[1][0] = eqn[2][0] =
   {x[0]'[t] == y[0][t], y[0]'[t] == 6 x[0][t]^2 - a/2};

Rule set for {x, y} -> {x1*y1, y1}

sub[1][n_Integer?Positive] := sub[1][n] =
   NestList[D[#, t] &,
     {x[n - 1][t] :> y[n][t]*x[n][t], y[n - 1][t] :> y[n][t]},
     1] // Flatten;

Rule set for {x, y} -> {x1, x1*y1}

sub[2][n_Integer?Positive] := sub[2][n] =
   NestList[D[#, t] &,
     {y[n - 1][t] :> x[n][t]*y[n][t], x[n - 1][t] :> x[n][t]},
     1] // Flatten;

eqn[ruleSet_Integer?(# == 1 || # == 2 &)][n_Integer?Positive] :=
  eqn[m][n] =
   Equal @@@ Solve[eqn[ruleSet][n - 1] //. sub[ruleSet][n],
      {x[n]'[t], y[n]'[t]}][[1]];

 Grid[#, Frame -> All] & /@
  Table[eqn[ruleSet][n], {ruleSet, 2}, {n, 0, 3}]]

enter image description here

share|improve this answer
Dear @Bob Hanlon. Thanks your help. How can I modify this if for each iteration I want to use two different coordinates? For example, for the 1st iteration, either $(x,y)=(x_1y_1,y_1)$ or $(x,y)=(x_1,x_1y_1)$. – Radz Jun 27 '14 at 16:30
@Radz - modified answer to handle selectable replacement rules. – Bob Hanlon Jun 27 '14 at 17:39
Dear @Bob Hanlon, Thank you. – Radz Aug 12 '14 at 12:35

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.