1
$\begingroup$

For example, if I input something like

b'[t_] = a[t];
a'[t_] = -Sin[b[t]];

a''[t]

it outputs just a''[t].

Is there a way to get Mathematica to always simplify any derivatives of a and b to expressions only involving a and b (with no derivatives), so that whenever I type in something like a''[t] it outputs -Cos[b[t]]a[t]?

$\endgroup$
9
  • 1
    $\begingroup$ use := instead of =? $\endgroup$ – AccidentalFourierTransform Feb 8 at 0:42
  • $\begingroup$ That doesn't work for me $\endgroup$ – keagan_callis Feb 8 at 0:44
  • 1
    $\begingroup$ Did you Clear your variables? $\endgroup$ – AccidentalFourierTransform Feb 8 at 0:44
  • 1
    $\begingroup$ a[t_] := -Sin[f[t]];a''[t] $\endgroup$ – cvgmt Feb 8 at 0:59
  • 1
    $\begingroup$ To evaluate a''[t] requires a[t] to be defined. Since only a'[t] is defined, you would need to enter a''[t]as D[a'[t], t] $\endgroup$ – Bob Hanlon Feb 8 at 2:23
2
$\begingroup$

You could try the following:

b' = a;
Derivative[n_?Positive][a] := Derivative[n-1][Function[-Sin[b[#]]]]

Then:

a''[t]

-a[t] Cos[b[t]]

$\endgroup$
3
  • $\begingroup$ Yes thank you this does work if I do Derivative[n_?Positive][b] := Derivative[n - 1][Function[a[#]]]; Derivative[n_?Positive][a] := Derivative[n - 1][Function[-Sin[b[#]]]]; $\endgroup$ – keagan_callis Feb 8 at 14:57
  • $\begingroup$ Would you mind explaining what the ?Positive part and the # is for? I don't know much about mathematica. $\endgroup$ – keagan_callis Feb 8 at 15:04
  • $\begingroup$ @keagan_callis [#](mathematica.stackexchange.com/a/25616/4999) is short for Slot[1], which represents the first argument to Function. Derivative operates only on functions, not expressions (one usually uses D, as in D[expr, t], to operate on expressions). $\endgroup$ – Michael E2 Feb 9 at 16:08

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