Forum archive 2000-2006

Michael Gage - javaScript_cubic_spline

Michael Gage - javaScript_cubic_spline

by Arnold Pizer -
Number of replies: 0
inactiveTopicjavaScript_cubic_spline topic started 8/28/2001; 8:29:28 PM
last post 8/28/2001; 8:29:28 PM
userMichael Gage - javaScript_cubic_spline  blueArrow
8/28/2001; 8:29:28 PM (reads: 2100, responses: 0)

javaScript_cubic_spline

Description
Produces a string which defines, in javaScript, a function representing a cubic spline interpolation of the (x,y) points defined.
The function's name is, by default, 'func', but can be specified by an optional parameter.
Placing the string in the header code (HEADER_TEXT($string) ) defines the function 'func'for use javaScript embedded in the text.

Syntax

$string = cubic_spline([$x0,$x1...],[$y0,$y1...], %options);
HEADER_TEXT($string);
$y = &$spline(34);
yields the y value at 34.

Params

References to two arrays, specifying respectively the x, y values to be interpolated by the Hermite polynomial. The x values must be strictly increasing, but this is not checked.

Options

Option keyOption valueDefault
nameThe name of the javaScript function being defined 'func'
llimitThe lower limit of the domain The left most x value supplied in the defining set of points.
rlimitThe upper limit of the domain. The right most x value in the defining set of points.

Returns

Produces a string which defines, in javaScript, a function representing a cubic spline interpolation of the (x,y) points defined.

Examples

needsd more here

Notes

Cubic splines are often used to represent numerical data. This macro defines a javaScript representation of the cubic spline, allowing interaction with the student, directly from the browser, without involving the server. One advantage of using the javaScript_cubic_spline definition of even simple functions such as function func(x) { Sin(3*x);}, is that students cannot easily determine which functions they are dealing with by inspecting the javaScript code embedded in the source for the HTML page.

This subroutine is defined in PGnumericalmacros.pl.

See Also

hermite_spline, Hermite.pm, cubic_spline,HEADER_TEXT,

 

<| Post or View Comments |>