Subject: green's functions, passing functions to a routine
From: Stavros Macrakis
Date: Mon, 1 Sep 2008 00:49:14 -0400
John,
Though it is possible to work in terms of functions in Maxima, in general it
is easier to work in terms of *expressions*.
So instead of writing
h1(x,t) := ''(ratsimp(integrate(g1(x,t),t))); -- function
approach
you'd write
h1 : ratsimp(integrate(g1,t)) -- expression approach
As for piecewise-defined functions, Maxima is currently rather weak in that
area; integration etc. do not work with them, not even in the most trivial
cases, e.g.
integrate(if x>=0 then 1 else 0, x, 0, 1) => noun form
-- x>=0 over the whole integration interval!
I don't know if there are plans to fix this in the short term.
-s
On Mon, Sep 1, 2008 at 12:35 AM, John Lapeyre <pdl at johnlapeyre.com> wrote:
> I am trying to find convenient ways to deal with a
> one dimensional Green's function problem. Here are some
> questions that came up.
>
> 1) how can one pass functions as arguments to another function?
> Eg,
>
> /*WRONG*/
> ygen(f,x,L) := integrate(f(t)*g2(x,t),t,0,x)
> + integrate(f(t)*g1(x,t),t,x,L);
>
> this does not do what I am trying to do.
>
> 2) I want to integrate g1 and make a function h1 from the
> result. Is there a good idiom? This seems to work ok.
>
> h1(x,t) := ''(ratsimp(integrate(g1(x,t),t)));
>
> 3) Piecewise defined functions.
> f(x) := if x > 3 then 0 else x;
> integrate(f(x),[x,0,4]); /* FAILS */
> fails to give a useful result.
> Of course, eventually, one would like a more complicated
> problem with 3 replaced by say, a.
>