Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Solving DE Mathematica

  1. Jan 21, 2010 #1
    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.
     
  2. jcsd
  3. Jan 22, 2010 #2

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    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)
     
  4. Jan 22, 2010 #3
    I get the following:

    NDSolve::ndnum: Encountered non-numerical value for a derivative at t == 0.`. >>
     
  5. Jan 22, 2010 #4

    CompuChip

    User Avatar
    Science Advisor
    Homework Helper

    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 (Text):

    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?
     
  6. Jan 22, 2010 #5
    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.
     
  7. Jan 24, 2010 #6

    Hepth

    User Avatar
    Gold Member

    Code (Text):
    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.
     
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook