romberg

From WeBWorK_wiki
Jump to navigation Jump to search


romberg

Description

Implements the romberg integration method. (Richardson acceleration applied to the trapezoid rule.) The first three arguments are required.

Syntax

$area = romberg($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
levels The number of levels of iteration used in applying the romberg method. 6

Returns

A number representing the definite integral.

Examples

$area = romberg(sub { my $x=shift; $x**3;}, 0, 5, level =>3); # evaluation of x^3 on the interval from 0 to 5.