[Maxima] about rk when introducing a function parameter.
villate at fe.up.pt
Tue Aug 12 05:48:50 CDT 2008
On Tue, 2008-08-12 at 18:05 +0800, Xiang Liu wrote:
> k(x):= if oddp(floor(x/3)) then 1 else 0;
> eq:[2.3-k, -x +k];
> sol:rk(eq, [x,y],[3,5],[t, 0, 10, 0.3]);
> I got the result(below), why k was not be taken into computing?
In Maxima, you can have a function k(x) and a symbol k, without
conflict. In your definition of eq, Maxima admits you are referring to a
symbol k (undefined) and not to the function k(x).
If k(x) was a regular function, you could replace k by k(x) in your
definition of eq, and that would solve the problem. However, the "if"
makes k(x) a small program rather than a regular function. Namely, if
you would get:
because the if is evaluated with x=0.
You can solve your problem by avoiding if statements and defining k(x)
as a regular function:
eq:[2.3-k(x), -x +k(x)];
sol:rk(eq, [x,y],[3,5],[t, 0, 10, 0.3])$
More information about the Maxima