# Solve first order nonlinear ODE

28 views (last 30 days)
Missael Hernandez on 8 Sep 2020
Hello I am tryin to solve this nonlinear ODE with the IC This is my code
tspan = [0 5];
x0 = 3;
[t,x] = ode45(@(t,x) (x^4)-(7*x^2)+6*x, tspan, x0);
plot(t,x,'b')
My problem is that I get the following error: Warning: Failure at t=2.004757e-02. Unable to meet integration tolerances without reducing the step size below the smallest value allowed (5.551115e-17) at time t. What should I do because the graph of the solution looks worng. Thanks.
##### 2 CommentsShowHide 1 older comment
Missael Hernandez on 8 Sep 2020
Well is should be in the form Wolfram doesn't give the solution Matlab does. Matlab gives this, which I think is wrong Alan Stevens on 8 Sep 2020
The value of x increases far too quickly, and reaches a value beyond the numerics ability to cope with when x(0) > 2. Works just fine if x(0) = 1.5, or 0.5, say.
##### 1 CommentShowHide None
Missael Hernandez on 8 Sep 2020
Thank you for you explanantion!

### More Answers (1)

Sam Chak on 8 Sep 2020
Edited: Sam Chak on 8 Sep 2020
The x(t) response rises rapidly. It cannot go pass t = 0.0463782 sec.
The x(t) response diverges for x(0) > 2 and converges to some steady-state points for x(0) < 2.
tspan = [0 0.046378];
x0 = 2.5;
[t, x] = ode45(@(t,x) (x^4) - (7*x^2) + 6*x, tspan, x0);
plot(t, x, 'b') ##### 2 CommentsShowHide 1 older comment
Missael Hernandez on 8 Sep 2020
Oh ok I see. Thank you guys so much!