Socket
Book a DemoInstallSign in
Socket

integrate-simpson

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

integrate-simpson

Integrate a function of one variable using Simpson's Rule

latest
Source
npmnpm
Version
1.0.4
Version published
Maintainers
1
Created
Source

integrate-simpson Build Status npm version Dependency Status

Integrate a function of one variable using Simpson's Rule

Introduction

This module computes the integral

undefined

using Simpson's Rule that approximates the function with quadratic segments. The summation is computed using the formula

undefined

where undefined for undefined with undefined.

This method is simple and easy to control but not particularly efficient. For an adaptive version of the same algorithm see scijs/integrate-adaptive-simpson.

Install

$ npm install integrate-simpson

Example

var simpson = require('integrate-simpson')

// Integrate sin(x) from 0 to pi using ten intervals
simpson( Math.sin, 0, Math.PI, 10 )
// => 2.000006784441801

API

require('integrate-simpson')( f, a, b, n )

Arguments:

  • f: The function to be integrated. A function of one variable that returns a value.
  • a: The lower limit of integration, undefined.
  • b: The upper limit of integration, undefined.
  • n: The number of intervals, equal to the number of quadratic segments. Results in undefined function evaluations.

Returns: The value of the integral

Credits

(c) 2015 Ricky Reusser. MIT License

Keywords

scijs

FAQs

Package last updated on 01 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts