Subject: how to define operators acting on functions
From: Richard Fateman
Date: Sun, 25 Nov 2007 09:55:23 -0800
You might look at this..
http://citeseer.ist.psu.edu/250086.html
or the full text at
http://http.cs.berkeley.edu/~fateman/papers/divdiff.pdf
which explore computing divided differences in a more meaningful way, I
think.
For example, you don't usually want to compute (sin(x+h)-sin(x))/h that way,
explicitly.
That form is computationally a bad idea, since if h is small, it is a
difference of two
nearly equal quantities, divided by a small quantity leading to poor
results.
The paper shows maxima programs that will compute that divided difference of
sin as
2*sin(h/2)*(cos((2*x+h)/2)/h
This is equivalent algebraically, and tremendously advantageous numerically.
That paper uses expressions rather than functions, since Maxima (Macsyma)
understands simplification of expressions better than manipulation of
lambda-expressions.
Tell us if this is useful!
RJF
> -----Original Message-----
> From: maxima-bounces at math.utexas.edu
> [mailto:maxima-bounces at math.utexas.edu] On Behalf Of Harald Geyer
> Sent: Sunday, November 25, 2007 5:15 AM
> To: Ugur G?ney
> Cc: maxima at math.utexas.edu
> Subject: Re: [Maxima] how to define operators acting on functions
>
> Hi ugur,
>
> > # I'm trying to define forward difference operator in
> maxima. Forward
> > difference op is defined such that: delta y(x) = y(x+h) - y(x)
> > # I wrote:
> > delta(y):=y(x+h)-y(x);
> > # This works fine for the first order. But when I tried to
> apply delta^2 to
> > any function, it gives an error:
>
> so let's take your problem apart:
>
> Your delta function expects a function name as argument but returns
> an expression. So what will happen, when evaluating
>
> > (%i5) delta(delta(sin));
>
> First the inner function is evualated and you get
> delta(sin(x + h) - sin(x))
>
> Now maxima doesn't know how to apply delta to this, so it gives
> you an error
>
> > y evaluates to sin(x + h) - sin(x)
> > Improper name or value in functional position.
> > #0: delta(y=sin(x+h)-sin(x))
> > -- an error. To debug this try debugmode(true);
>
> I think you have two options to fix this:
> a) Make delta return a function (i.e. a lambda expression)
> b) Make delta operate on expressions instread of function names
> (you might use subst() to construct you result)
>
> HTH,
> Harald
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>