Mathematica How to find the value for phi at a specific time in Mathematica?

  • Thread starter Thread starter bruce999
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion revolves around solving a simple differential equation using NDSolve in Mathematica. The user is attempting to find the value of phi at a specific time, t=0.224511, but encounters issues with the output, which returns "phi[0.224511]" instead of the expected numerical value. Despite trying different approaches, including using Evaluate, the user is unable to achieve the desired result. A suggestion is made to define a function based on the solution, allowing for easier evaluation. Ultimately, the user expresses gratitude for the assistance received, indicating they resolved their issue with help from another participant.
bruce999
Messages
11
Reaction score
1
Hello again.

I have a solution for a simple differenttial eqn. "Simpletreb=First@NDSolve[{phi''[t] == -d
Sin[phi[t]], phi[0] == (3π/4), phi'[0] == 0}, phi[t], {t, 0, 1}]"

After some plots and other calculations i need to find the value for phi at t=0.224511 so i input "phi[0.224511]/.simpletreb" but this just outputs "phi[0.224511]". I've also tried "Evaluate[phi[0.224511]/.simpletreb" with no joy.

My .nb file is here: (you have to cut and paste the link I'm afraid) "http://bruce1711.150m.com/simple trebuchet (first) final.nb"

Any ideas anyone?
 
Last edited:
Physics news on Phys.org
bruce999 said:
Hello again.

I have a solution for a simple differenttial eqn. "Simpletreb=First@NDSolve[{phi''[t] == -d
Sin[phi[t]], phi[0] == (3π/4), phi'[0] == 0}, phi[t], {t, 0, 1}]"

After some plots and other calculations i need to find the value for phi at t=0.224511 so i input "phi[0.224511]/.simpletreb" but this just outputs "phi[0.224511]". I've also tried "Evaluate[phi[0.224511]/.simpletreb" with no joy.

My .nb file is here: (you have to cut and paste the link I'm afraid) "http://bruce1711.150m.com/simple trebuchet (first) final.nb"

Any ideas anyone?

In general:

solution=NDSolve[{y''[x]=such and such},y,{x,0,end}];

f[x_]:=Evaulate[y[x]/.solution];

Now, can use f[x] like any other function.
 
Ok i tried that and i still get:
"Evaulate[phi[0.22]]" as the answer instead of a value. :confused:
 
Got it now thanks Saltydog. :smile:
 

Similar threads

Back
Top