Forum archive 2000-2006

Michael Gage - trapezoid

Michael Gage - trapezoid

by Arnold Pizer -
Number of replies: 0
inactiveTopictrapezoid topic started 8/28/2001; 8:14:51 PM
last post 8/28/2001; 8:14:51 PM
userMichael Gage - trapezoid  blueArrow
8/28/2001; 8:14:51 PM (reads: 3269, responses: 0)

trapezoid

Description
Implements the trapezoid rule. The first three arguments are required.

Syntax

$area = trapezoid($rf_func, $start, $end, %options);

Params

$rf_func refers to a subroutine of one variable defining the function.
$start is the left hand endpoint of the integral.
$end is the right hand endpoint of the integral.

Options

Option keyOption valueDefault
steps,
intervals
The number of intervals in the trapezoid approximation. 30

Returns

A number representing the definite integral

Examples

$area = trapezoid(sub { my $x=shift; $x**2;}, 0, 1, steps =>100); # overkill evaluation of x^2 on the interval from 0 to 1.

See Also

romberg

 

<| Post or View Comments |>