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.

How could I replace for example:

Derivative[2][f][x]

by

Derivative[1][g][x]

where

g[x]=Derivative[1][f][x]

?

But doing this in a manner that work for all cases (all combinations of mixed derivates and multiple variables)?

share|improve this question

2 Answers 2

This seems to be very simple:

With[{f = Derivative[-1][g]},
 Derivative[2][f][x]]

(* ==> Derivative[1][g][x] *)
share|improve this answer

The objective of this was to use replacement rules with lower derivatives results inside higher ones.

Transform[differentialEquationArg_]:=Module[{differentialEquation,previousDerivative},
    differentialEquation=differentialEquationArg//.Derivative[a__][b_][c__]/;(previousDerivative=GetPreviousDerivative[{a},Length[{a}]];Total[{a}]>1&&True):>Derivative[previousDerivative/.List->Sequence][Derivative[{a}-previousDerivative/.List->Sequence][b][c]][c];
    differentialEquation
]

GetPreviousDerivative[derivativeTupleArg_,workingPositionArg_]:=Module[{derivativeTuple,workingPosition},
    derivativeTuple=derivativeTupleArg;
    workingPosition=workingPositionArg;
    If[derivativeTuple[[workingPosition]]>0,derivativeTuple[[workingPosition]]-=1,workingPosition-=1;derivativeTuple=GetPreviousDerivative[derivativeTuple,workingPosition]];
    derivativeTuple
]

Example:

D[y[t],t,t]+y[t]+D[y[t],t]==0

Out: y''(t)+y'(t)+y(t)=0

Transform[%]

Out: y'(t)'(t)+y'(t)+y(t)=0

%//FullForm

Equal[Plus[y[t],Derivative[1][y][t],Derivative[1][Derivative[1][y][t]][t]],0]

Not completely tested, can have some bugs.

share|improve this answer

Your Answer

 
discard

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.