Plotting the solution of an ODE

  • Mathematica
  • Thread starter Robin04
  • Start date
  • Tags
    Ode Plotting
In summary, the conversation discusses the use of Manipulate function to plot the solution to an ODE with given initial values. The person is trying to use sliders to evaluate constants in the equation, but is unsure of the correct syntax. They mention finding a solution using NDsolve and a helpful reference, but have not been able to find a way around the problem with Manipulate. The conversation also mentions the success of putting all necessary definitions and functions inside the Manipulate function.
  • #1
Robin04
260
16
I'm trying to plot the solution to an ODE (with given initial values) but there are some constants in it that I want to evaluate with sliders and I'm not sure what is the right syntax for this.

Code:
Manipulate[Plot[solution1[t], {t, 0, 10}, PlotRange -> {-Pi, Pi}],
{{a, 1, "Driving amplitude"}, 0, 10, Appearance -> "Labeled"},
{{g, 9.81, "Gravitational acceleration"}, 0, 10,
  Appearance -> "Labeled"},
{{l, 1, "Length"}, 0, 10, Appearance -> "Labeled"},
{{\[Gamma], 1, "Driving frequency"}, 0, 10, Appearance -> "Labeled"}]

K-pkiv-g-s.png


K-pkiv-g-s.png


If I copy solution1 explicitly into plot it works, but if I refer to it by the variable name it doesn't. What's the correct syntax for this?
 

Attachments

  • K-pkiv-g-s.png
    K-pkiv-g-s.png
    34.3 KB · Views: 408
  • K-pkiv-g-s.png
    K-pkiv-g-s.png
    12.9 KB · Views: 352
Physics news on Phys.org
  • #3
I have found the same problem with Manipulate. I have not found a way around it.
 
  • #4
I have had consistent success with putting all the needed definitions and functions inside the Manipulate

Manipulate[
sol=p[t]/.DSolve[{a p''[t]==p[t],p[0]==0,p'[0]==a},p[t],t][[1]];
Plot[sol,{t,0,4}],
{{a,1},0,4}
]
 

1. What is an ODE?

An ODE, or Ordinary Differential Equation, is a mathematical equation that describes the relationship between a function and its derivatives. It is used to model a wide range of physical phenomena in science and engineering.

2. Why is it important to plot the solution of an ODE?

Plotting the solution of an ODE helps us to visualize and understand the behavior of the system described by the equation. It can also provide valuable insights and predictions for future behavior.

3. How do you plot the solution of an ODE?

To plot the solution of an ODE, you can use a computer program or graphing calculator. These tools will allow you to input the ODE, specify initial conditions, and generate a graph of the solution.

4. What are the key components of a plot of an ODE solution?

The key components of a plot of an ODE solution are the independent variable (usually time) on the x-axis, the dependent variable (the solution to the ODE) on the y-axis, and the shape of the curve, which represents the behavior of the system over time.

5. Can you determine the solution to an ODE solely from its plot?

No, the plot of an ODE solution provides a visual representation of the behavior of the system, but it does not provide the exact solution. To determine the solution, you will need to solve the ODE using mathematical methods, such as separation of variables or numerical techniques.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
261
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
719
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
898
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
Back
Top