Trapezoid

From WeBWorK_wiki
Revision as of 17:53, 18 November 2009 by Aubreyja (talk | contribs) (from ur manpages)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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 key Option value Default
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.