# [Maxima] about rk when introducing a function parameter.

Jaime Villate 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]);
> sol[2];
>
> ----
> I got the result(below), why k was not be taken into computing?
>
> [0.3,0.05*(-2*k+4*(2.3-k)+4.6)+3,0.05*(4*(k-0.15*(2.3-k)-3)+2*k-0.3*(2.3-k)-6)+5]

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 wrote:
[2.3-k(x), -x-k(x)]
you would get:
[2.3, -x]
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: