Message Boards Message Boards


Expand double derivative when substituted?

Posted 9 days ago
3 Replies
4 Total Likes

I am trying to evaluate:

Expand[D[x[t], {t, 2}] + (x[t])^3 /. x[t] -> A sin[[Omega]t]]

in Mathematica. However, I get the following output:

A^3 sin[[Omega]t]^3 + (x^[Prime][Prime])[t]

whereas I am expecting and output where x''[t] is also differentiated
Could somebody help me figure out what steps to follow to solve this issue?

3 Replies


 ClearAll["Global`*"]; Remove["Global`*"];
 (x''[t] + (x[t])^3) /. x[t] -> A Sin[Ω[t]] /. x''[t] -> D[A Sin[Ω[t]], {t, 2}]
 (*A^3 Sin[Ω[t]]^3 + A (-Sin[Ω[t]] Derivative[1][Ω][t]^2 + Cos[Ω[t]] (Ω^′′)[t])*)


ClearAll["Global`*"]; Remove["Global`*"];    
x[t_] := A Sin[Ω[t]];
D[x[t], {t, 2}] + (x[t])^3
(*A^3 Sin[Ω[t]]^3 + A (-Sin[Ω[t]] Derivative[1][Ω][t]^2 + Cos[Ω[t]] (Ω^′′)[t])*)

You could also try the anonymous function (i.e., #&) approach where you replace x[t] with # like so

(D[#, t, t] + #^3) &[A Sin[Omega t]]
(* -(A*Omega^2*Sin[Omega*t]) + A^3*Sin[Omega*t]^3 *)

You have to replace the symbol x with a function:

x''[t] + x[t]^3 /. x -> Function[t, A*Sin[\[Omega]*t]]

The pattern x[t_] does not match anything in x''[t].

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract