plot_list

From WeBWorK
Jump to: navigation, search


plot_list

Description
Plots a piecewise linear non-parametric curve through a sequence of points.

Syntax

$fun = plot_list([x0,y0,x1,y1,...]);
$fun = plot_list([(x0,y0),(x1,y1),...]);
$fun = plot_list(\@x_y_array);

$fun = plot_list([x0,x1,x2...], [y0,y1,y2,...]);
$fun = plot_list(\@xarray,\@yarray);

Params

Arguments are either a reference to a single array of (x,y) pairs, or references to two pairs of arrays, containing the x values and y values respectively. The x values should be strictly increasing.

Returns

A reference to a function subroutine which accepts a single x argument and returns a y value. The domain of the function is the closed interval between the lowest and highest x values

Examples

$fun = plot_list([(0,1), (1,4), (2,0) ]); # stores a reference to a piecewise linear function in $fun.
$y = &$fun(1.5); # calculates the value of the interpolating piecewise linear function at x=1.5

Notes

This macro is defined in [PGnumericalmacros.pl]
follow us