Mathematica Asked by Aschoolar on February 10, 2021
I am trying to make a repeated differentiation of the differential equation and replacing the result with the previous answer. But I do not know how to substitute answer into another. I tried Merge, Join, Union, Replace and it does not work. Below is the example code,
ClearAll;
x[0]=1;
x'[0]=2;
equation = x''[t]==x'[t]-x[t];
answer = D[equation,t]
newanswer = Join[answer, equation]
The answer is $x”'[t]==x”[t]-x'[t]$. I want to substitute equation in the answer or replace $x”[t]$ in the answer with $x'[t]-x[t] $ as defined in the equation so that I should get a newanswer $ x”'[t]==x'[t]-x[t]-x'[t]$. Furthermore, I should later on substitute with $ x[0]=1$ and $x'[0]=2$. What are the functions that will allow me to do operations like that? Am I defining equation and differentiating it incorrectly?
You could define:
x[0] = 1;
x'[0] = 2;
Derivative[n_?(GreaterEqualThan[2])][x] = Derivative[n-1][x][#] - Derivative[n-2][x][#]&;
Then:
x'''[t]
x'''[0]
x''''''[0]
-x[t]
-1
1
Answered by Carl Woll on February 10, 2021
Perhaps this:
newanswer = Eliminate[{answer, equation}, x''[t]]
(* -x'''[t]] == x[t] *)
Or this:
newanswer = Reduce[{answer, equation}, x'''[t], {x''[t]}]
(* x'''[t]] == -x[t] *)
As for what to do "later on," perhaps this:
Reduce[{answer, equation, x[0] == 1, x'[0] == 2} /. t -> 0]
(* x'''[0] == -1 && x''[0] == 1 && x'[0] == 2 && x[0] == 1 *)
Or this:
Solve[{answer, equation, x[0] == 1, x'[0] == 2} /. t -> 0]
(* {{x[0] -> 1, x'[0] -> 2, x''[0] -> 1, x'''[0] -> -1}} *)
Answered by Michael E2 on February 10, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP