Hi, I've just started using Octave and I'd like to use it to solve and plot a system of differential equations, but I keep getting the same error which I don't understand. What have I done wrong in my code?(adsbygoogle = window.adsbygoogle || []).push({});

Outline:

Initial conditions

x1 = 1

x2 = 1.27 x 10^-6

x3 = 0

t = 0 - 140 days

Equations

dx1 = -0.5*x(1)*x(2)

dx2 = 0.5*x(1)*x(2) - 0.25*x(3)

dx3 = 0.25*x(2)

Code:

%function

function xdot = m (x, t)

xdot = zeros (3,1);

xdot(1) = -0.5*x(1)*x(2);

xdot(2) = 0.5*x(1)*x(2) - 0.25*x(3);

xdot(3) = 0.25*x(2);

endfunction

%initial conditions

x0 = [1;1.27e-06;0];

t = linspace (0,140);

%solve

y = lsode ("m",x0,t)

%plot

plot (y,t)

the error I get says

lsode: repeated convergence failures

Thanks!!

**Physics Forums | Science Articles, Homework Help, Discussion**

Dismiss Notice

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Octave differential equations

Can you offer guidance or do you also need help?

**Physics Forums | Science Articles, Homework Help, Discussion**