Optimizing DE Solutions with Mathematica: Plotting x[t] vs. t"

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

Discussion Overview

The discussion revolves around solving a differential equation using Mathematica, specifically focusing on the challenges of obtaining a numerical solution and plotting the results. Participants explore both symbolic and numerical methods for solving the equation and address issues related to boundary conditions and variable types.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Homework-related

Main Points Raised

  • One participant encounters errors when attempting to use DSolve for a differential equation, indicating issues with boundary conditions and the nature of the equations.
  • Another suggests using NDSolve for a numerical solution, emphasizing the need to specify an interval for the solution.
  • A participant reports an error related to non-numerical values when trying to solve the equation numerically, highlighting the symbolic nature of the parameter \[Alpha].
  • It is noted that substituting a numerical value for \[Alpha] resolves the issue, allowing for a successful numerical solution.
  • One participant shares the output of NDSolve, which includes an InterpolatingFunction, but expresses difficulty in obtaining a numerical solution for plotting.
  • A later reply provides a complete example of using NDSolve with a specific value for \[Alpha] and demonstrates how to plot the resulting function.

Areas of Agreement / Disagreement

Participants generally agree on the necessity of using a numerical approach with NDSolve when dealing with symbolic parameters. However, there is no consensus on the best method to achieve the desired plot, as participants present different approaches and encounter various issues.

Contextual Notes

Limitations include the dependency on the specific value of \[Alpha] for successful numerical solutions and the unresolved nature of the boundary conditions that led to initial errors in using DSolve.

Nusc
Messages
752
Reaction score
2
DSolve[{x'[t] == (\[Alpha] - (x[t] - 1)^2) x[t], x[0] == 0.004}, x[t],
t]


I get the following message:
Solve::tdep: The equations appear to involve the variables to be solved for in an essentially non-algebraic way. >>

DSolve::bvnul: For some branches of the general solution, the given boundary conditions lead to an empty solution. >>


What do I do?

I need to plot the solution.
 
Physics news on Phys.org
If you just need the plot, you can try solving it numerically.

NDSolve[{x'[t] == (\[Alpha] - (x[t] - 1)^2) x[t], x[0] == 0.004}, x[t], {t, 0, 10}]

(note how you need to specify an interval)
 
I get the following:

NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. >>
 
Ah right, my mistake.
You can only solve it numerically if the entire expression is numerical. It chokes on \[Alpha] being symbolic, if you plug in a value for \[Alpha] it does work, e.g.

Code:
Block[ { \[Alpha] = 1 },
  NDSolve[{x'[t] == (\[Alpha] - (x[t] - 1)^2) x[t], x[0] == 0.004}, x[t], {t, 0, 10}]
]

Will that do for you, or do you need an exact solution?
 
I receive the following:

{{x[t] -> \!\(\*
TagBox[
RowBox[{"InterpolatingFunction", "[",
RowBox[{
RowBox[{"{",
RowBox[{"{",
RowBox[{"0.`", ",", "10.`"}], "}"}], "}"}], ",", "\<\"<>\"\>"}], "]"}],
False,
Editable->False]\)[t]}}

I can set the value for alpha but I don't obtain a numerical solution. Then I have to plot the solution.
 
Code:
s = NDSolve[{x'[t] == (4 - (x[t] - 1)^2) x[t], x[0] == 0.004}, 
  x[t], {t, 0, 10}]
Plot[Evaluate[x[t] /. s], {t, 0, 10}, PlotRange -> All]


notice you have to put in something for alpha, like previously stated. i did 4.
 

Similar threads

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