Published
Edited
Jul 12, 2018
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
class SimpsonsRule extends DefiniteIntegral
{
constructor()
{
super();
}
compute(f, a, b)
{
let coeff = ( b - a ) / 6;
let midpoint = ( a + b ) / 2;
return coeff * ( f ( a ) + 4 * f ( midpoint ) + f ( b ) )
}
}
Insert cell
(new SimpsonsRule()).compute((x) => Math.sin(x), 0, Math.PI)
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more