Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need some help with Mathematica. How can I do the following?

Starting with f = y[0]^2 (y[0] is basically y with 0 subscript) and f' = 2*y[0]*y'[0] (Derivative of f), I want to replace y'[0] with y[1] (again 1 is a subscript), so it becomes f' = 2*y[0]*y[1]. Then I want to find f'', f''', and so on.

share|improve this question

closed as not a real question by Dr. belisarius, Oleksandr R., m_goldberg, Mr.Wizard Feb 19 '13 at 13:46

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Please try to write Mathematica code – Dr. belisarius Feb 18 '13 at 16:46
The problem isn't the lack of code; it's that the procedure you're prescribing is unclear. What do the subscripts represent and what precisely are the steps you wish to follow (iteratively)? – whuber Feb 18 '13 at 18:04
please provide minimal failing code and ask a concrete question. not providing code is a problem in that it forces people to actually solve your problem (rather than helping you with mathematica code). – acl Feb 18 '13 at 18:08

I offer this reply in an effort to help clarify the question and will gladly delete it if it turns out my interpretation is not the intended one.

The desired procedure seems to be to symbolically differentiate a function involving various $y_i$, where $y_i$ symbolically represents the derivative of $y_{i-1}$ when $i \ge 1$. As described in the question, this can be carried out in two successive steps:

  1. Differentiate the function. This is done with D.

  2. Replace any instances of $y'_i$ by $y_{i+1}$:

    augment[x_] := x /. {Derivative[1][Subscript[y, i_] ] :> Subscript[y, i + 1]}

The "and so on" seems to refer to repeatedly applying this procedure, presumably for a fixed number of times. Nest does exactly that; here is an example of its use in repeating the procedure $3$ times starting with $y_0(x)^2$:

Nest[augment[D[#, x] ] &, Subscript[y, 0][x]^2, 3]

$6 y_1(x) y_2(x)+2 y_0(x) y_3(x)$

Compare this to the third derivative itself:

D[y[x]^2, {x, 3}]

$6 y'(x) y''(x) + 2 y(x) y^{(3)}(x)$

Evidently, if we wished, we could avoid using Nest altogether and just apply a suitable replacement rule to this result to convert $i$th derivatives into subscripts $i$.

share|improve this answer
Your answer is a model of clarity. I hope it's on topic because I would hate to see it deleted. What a pity the question's not half so clearly stated. – m_goldberg Feb 19 '13 at 3:27

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