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

  • Context: Mathematica 
  • Thread starter Thread starter bruce999
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around finding the value of a function, phi, at a specific time using Mathematica after solving a differential equation. Participants share their attempts and methods for extracting the value from the solution obtained through NDSolve.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant shares their approach to solving a differential equation using NDSolve and expresses difficulty in retrieving the value of phi at a specific time.
  • Another participant suggests a general method for defining a function based on the solution from NDSolve, indicating how to use it to evaluate phi.
  • A later reply indicates that the suggested method did not work as expected, leading to confusion about the output.
  • Finally, one participant confirms they resolved their issue with assistance from another user.

Areas of Agreement / Disagreement

The discussion includes multiple attempts to solve the same problem, with some methods not yielding the expected results. There is no clear consensus on the best approach until one participant successfully resolves their issue.

Contextual Notes

Some limitations are present, such as potential misunderstandings of function evaluation in Mathematica and the specifics of the differential equation being solved. The discussion does not clarify all assumptions or definitions used in the approaches.

Who May Find This Useful

Users working with Mathematica for solving differential equations, particularly those looking for guidance on function evaluation from NDSolve outputs.

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

  • · Replies 4 ·
Replies
4
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 6 ·
Replies
6
Views
5K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
6K
  • · Replies 3 ·
Replies
3
Views
7K
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
6K