0

Imagine you are trying to get an equation of motion (in my case, the Lagrangian of a coupled drives CE108 system).

In such a case, you need to symbolically define certain derivatives as themselves, not as their value (i.e. D[x] = x' instead of D[x] = 1).

Is there any way within Mathematica to derive completely symbolically?

Complicated Example:

f = x' + mx + 7y
SymbolicDerivative[f,x] = x'' + mx'

Edit regarding duplication: This question tries to find a way to partially derive a function symbolically continuously - meaning, derive x to x' and then x'' and then x''' and so forth rather than trying to derive a function and plug values in

m_goldberg
  • 107,779
  • 16
  • 103
  • 257

1 Answers1

0

This can be done by using total derivatives (Dt) and defining additional constraints:

f=Dt[x]+m x+7 y
Dt[f] /. {Dt[m] -> 0, Dt[y] -> 0}
(* output -> m Dt[x] + Dt[Dt[x]] *)

In short, take the total derivative of f, and then hold every variable but x constant.

An automatic function for doing this process is provided below:

symD[f_, x_] := Module[{y, r},
r = Dt[f];
y = #[[1 ;; -2]] & /@ Position[r, Dt];
y = Part[r, Sequence @@ #] & /@ y;
y = DeleteDuplicates[Pick[y, Length[#] == 1 & /@ Dimensions /@ y]];
y = Select[y, Not[#[[1]] === x] &];
y = # -> 0 & /@ y;
r /. y]

It takes the total derivative and then assumes that all variables aside from the one entered as x have a total derivative equal to 0.

Note however that in most situations it's far more practical to define x as a function of another variable and take the derivative with respect to that.

eyorble
  • 9,383
  • 1
  • 23
  • 37