renanbr/numerical-integration

Approximating integrals

0.1.0 2015-09-17 14:28 UTC

This package is auto-updated.

Last update: 2020-10-05 10:01:30 UTC


README

Build Status

This project provides some numerical integration implementations in PHP.

Usage

<?php

use RenanBr\NumericalIntegration\Rule\Simpson;

$estimator = new Simpson();

$estimator->setFunction(function ($degrees) {
    return sin(deg2rad($degrees));
});

// to be more accurate increase the interval quantity (defaults to 300)
// $estimator->setIntervals(1000);

$estimator->estimate(0, 360); // returns float(5.9396931817446E-15)

List of available rules:

  • RenanBr\NumericalIntegration\Rule\Midpoint
  • RenanBr\NumericalIntegration\Rule\Simpson
  • RenanBr\NumericalIntegration\Rule\Trapezoidal

Install

composer require renanbr/numerical-integration