What initial conditions should I use for my system of differential equations?

In summary, the individual is having trouble using Octave to solve and plot a system of differential equations. The error they are receiving is due to incompatible initial conditions and they are advised to adjust them accordingly.
  • #1
latitude
56
0
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?

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 news on Phys.org
  • #2
The error you're getting is because your initial conditions are not compatible with the equations you defined in your code. Since your equation for dx2 has a negative coefficient, the initial condition for x2 must be greater than 0. Try changing the initial conditions to: x1 = 1x2 = 1x3 = 0
 

1. What is an Octave differential equation?

An Octave differential equation is a mathematical equation that relates the rate of change of a variable to the value of the variable itself. It is written in terms of derivatives and is commonly used to model physical and biological systems.

2. How is an Octave differential equation solved?

Octave differential equations can be solved using various methods, such as separation of variables, integrating factors, and substitution. Numerical methods, such as Euler's method and Runge-Kutta methods, can also be used to approximate solutions.

3. What are the applications of Octave differential equations?

Octave differential equations have a wide range of applications in science and engineering, including physics, chemistry, biology, and economics. They are used to model and predict the behavior of systems, such as population growth, chemical reactions, and electrical circuits.

4. What is the difference between an ordinary and a partial Octave differential equation?

An ordinary differential equation involves only one independent variable, while a partial differential equation involves multiple independent variables. Partial differential equations are typically used to model systems in which the variables vary in more than one dimension.

5. Can Octave differential equations be solved analytically?

Some Octave differential equations can be solved analytically, meaning an exact solution can be found using mathematical techniques. However, in many cases, numerical methods must be used to approximate the solution due to the complexity of the equations.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
994
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
18
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
937
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • Calculus and Beyond Homework Help
Replies
2
Views
1K
  • Calculus and Beyond Homework Help
Replies
0
Views
161
Back
Top