[Maxima] Using a function as an input to a procedure?

Stavros Macrakis macrakis at alum.mit.edu
Fri May 2 08:44:50 CDT 2008

On Fri, May 2, 2008 at 5:25 AM, Alasdair McAndrew <amca01 at gmail.com> wrote:
> a small procedure which produces the difference between an integral and its trapezoidal approximation; such as:
> dt(f,a,b):=float(abs(integrate(f(s),s,a,b)-(f(a)+f(b))*(b-a)/2));
> But this doesn't work

It works for me in Maxima 5.14/GCL

     dt(sin,2,3) => 0.0486
     dt(sin,%pi*7/8,%pi) =>  9.8075E-4
           Is  e  positive, negative, or zero? p;
                 =>  abs(0.5 e sin(e) + cos(e) - 1.0)

Could you please tell us the full procedure you followed that gave the error?

By the way, "f" is a bad name for a function parameter, because f will
often be user-defined, and in Maxima semantics, explicitly defined
functions (user-defined or system-defined) take priority over
functional values.


More information about the Maxima mailing list