0
$\begingroup$

Here is a differential equation

x''[t] - eps (a^2 - x[t]^2) x'[t] + w^2*x[t] == 0

boundary conditions are

x[0]=0,
v[0]=0.001

i want to substitute x'[t] to v[t] and then NDSolve the equation to respect of x and v.

Right now my code looks like this

NDSolve[{
  x''[t] - eps (a^2 - x[t]^2) x'[t] + w^2*x[t] == 0 /. {x'[t] -> v[t], x''[t] -> v'[t]}
  x[0] == 0,
  v[0] == 0.001},
 {x[t], v[t]}, {t, 0, 10}]

and it obviously doesnt work. I suppose that ./ substitution isn't enough and I need to make more equations but i don't know how to do it.

$\endgroup$
2
$\begingroup$

First, when you want to solve for two variables,x and v, you need two equations. Add x'[t] == v[t] .

Second, with NDSolve, all parameters, w,a,eps, have to be given numerical values.

ndsol[w_, a_, eps_] := 
   NDSolve[{x''[t] - eps (a^2 - x[t]^2) x'[t] + w^2*x[t] == 
      0 /. {x'[t] -> v[t], x''[t] -> v'[t]}, x'[t] == v[t], x[0] == 0, 
      v[0] == 0.001}, {x, v}, {t, 0, 10}]

Plot[Evaluate[v[t] /. ndsol[3, 2, -3]], {t, 0, 10}]

And exactly the same

Plot[Evaluate[x'[t] /. ndsol[3, 2, -3]], {t, 0, 10}]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.