[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Octave-bug-tracker] [bug #32959] lsode use "1/f" instead "f"
From: |
Rik |
Subject: |
[Octave-bug-tracker] [bug #32959] lsode use "1/f" instead "f" |
Date: |
Fri, 08 Apr 2011 22:47:18 +0000 |
User-agent: |
Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.16) Gecko/20110323 Ubuntu/10.04 (lucid) Firefox/3.6.16 |
Follow-up Comment #5, bug #32959 (project octave):
The problem is the order of your arguments in the function which calculates
the derivative. According to the lsode documentation ('help lsode'):
The first argument, FCN, is a string, inline, or function handle
that names the function f to call to compute the vector of right
hand sides for the set of equations. The function must have the
form
XDOT = f (X, T)
in which XDOT and X are vectors and T is a scalar.
In your sample problem you are using Y instead of X as the dependent variable
and X instead of T as the independent variable. Therefore, the functional
form should be
YDOT = f (Y, X)
However, without specific instructions the inline() function orders its inputs
alphabetically. For example,
f = inline ("-x/y")
f = f(x, y) = -x/y
^ NOTE that x is first, and you require f (y, x) according to lsode
# Specify order of arguments
f = inline ("-x/y", "y", "x")
f = f(y, x) = -x/y
^ NOTE y is now first.
# This code now works using 'f' above
x = -5:0.1:5;
y = lsode (f, 5, x);
plot (x,y);
Of course, you can still create a problem with
f = inline ("-y/x", "y", "x");
But, this shouldn't be a surprise because the function that calculates your
derivative (y/x) blows up in the neighborhood of x = 0. You can see this by
using a range which doesn't go over the discontinuity.
f = inline ("-y/x", "y", "x");
x = -5:0.1:-0.1;
y = lsode (f,5,x);
plot (x,y);
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/bugs/?32959>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/