1
$\begingroup$

I need to convert derivatives of g[x,v] wrt v into derivatives wrt x using this relation:

$$\frac{dg[x,v]}{dv}=\frac{1}{2}\frac{d^{2}g}{dx^{2}}+\frac{1}{2}\left(\frac{dg}{dx}\right)^{2}$$

This code converts the 0-4th derivatives perfectly:

ord = 5;
Derivative[q_, 1][g][x, v] = D[(D[g[x, v], {x, 2}] + D[g[x, v], x]^2), {x, q}]/2;
dgdv = Table[D[g[x, v], {v, i}], {i, 0, ord - 1}];

Notice that I only defined the 1st deriv of g wrt v, but MMa was smart enough to just apply the relation repeated. However, Series[] doesn't figure that out, for example it just leaves the 2nd derivative wrt v in that form:

Series[g[x, v], {v, 0, 2}]

$g(x,0)+v g^{(0,1)}(x,0)+\frac{1}{2} v^2 g^{(0,2)}(x,0)+O\left(v^3\right)$

I attempted to fix my definition to cover higher derivatives wrt v explicitly, but then I ran into recursion problems, which I tried and failed to fix as follows:

Derivative[q_, Except[0, n_]][g][x, v] = D[(D[g[x, v], {x, 2}] + D[g[x, v], x]^2), {x, q}, {v, n - 1}]/2;

This also failed:

Derivative[q_, 0][g][x_, v_] := D[g[x, v], {x, q}];
Derivative[q_, r_][g][x_, v_] :=
  If[r > 1,
   D[D[g[x, v], {x, q}, {v, r - 1}], v],
   D[(D[g[x, v], {x, 2}] + D[g[x, v], x]^2), {x, q}]/2];

I know that's an ugly solution, but I don't know why it didn't work. Help?

$\endgroup$

1 Answer 1

2
$\begingroup$

Try this:

Derivative[m_, Except[0, n_]][g][x_, v_] := 
   1/2 Derivative[2 + m, n - 1][g][x, v] + 
   1/2 Sum[Binomial[n - 1, k] Binomial[m, j] *
      Derivative[m - j + 1, n - 1 - k][g][x, v] *
      Derivative[j + 1, k][g][x, v], {k, 0, n - 1}, {j, 0, m}]

Series[g[x, v], {v, 0, 2}] now gives the expected output.

$\endgroup$
4
  • $\begingroup$ Yes, that totally worked. I see what you did there, manually coding out the Binomial expansion for the derivs of $g'^2$. But that seems like something MMa should have been able to do itself. Why didn't my version work? $\endgroup$ Oct 12, 2015 at 22:04
  • $\begingroup$ @JerryGuern I don't quite know; if I better understood the relationship between D and Derivative, I think I would know why your version didn't work. $\endgroup$
    – QuantumDot
    Oct 12, 2015 at 22:14
  • $\begingroup$ I've Accepted this Answer because it did work, but I think I'm going to post another question about why 'D' couldn't do the recursion. Thanks for your help! $\endgroup$ Oct 12, 2015 at 22:26
  • $\begingroup$ I posted a follow up: mathematica.stackexchange.com/questions/96853/… $\endgroup$ Oct 12, 2015 at 23:21

Your Answer

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

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