2017 © Pedro Peláez
 

library piecewise-fx

Piecewise math functions

image

jstewmc/piecewise-fx

Piecewise math functions

  • Sunday, August 14, 2016
  • by Jstewmc
  • Repository
  • 1 Watchers
  • 0 Stars
  • 12 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

piecewise-f(x)

Piecewise math functions., (*1)

use Jstewmc\Fx\{Constant, Linear};
use Jstewmc\Interval\Interval;
use Jstewmc\PiecewiseFx;

// define our sub-functions...
//     y = 1     | 1 <= x <= 3
//     y = x - 2 | 3 < x <= 6
//     y = 4     | 6 < x <= 9
//
$subFxs = [
    new SubFx(
        new Interval('[1, 3]'),
        new Constant(1)
    ),
    new SubFx(
        new Interval('(3, 6]'),
        new Linear(1, -2)
    ),
    new SubFx(
        new Interval('(6, 9]'),
        new Constant(4)
    )
];

// define our piecewise fx
$fx = new PiecewiseFx($subFxs);

$fx(0);   // returns null
$fx(1);   // returns 1
$fx(2);   // returns 1
$fx(3);   // returns 1
$fx(4);   // returns 2
$fx(5);   // returns 3 
$fx(6);   // returns 4
$fx(7);   // returns 4
$fx(8);   // returns 4
$fx(9);   // returns 4
$fx(10);  // returns null

A piecewise function is a function composed of multiple sub-functions, each of which applies to an interval of the function's domain., (*2)

As you can see in the example above, a piecewise function requires an array of sub-functions. Each sub-function, in turn, requires an interval and function. To learn more about intervals and functions, see jstewmc/interval and jstewmc/fx for details, respectively., (*3)

License

MIT, (*4)

Author

Jack Clayton, (*5)

Version

1.0.0, August 13, 2016

  • Major release
  • Update composer.json

0.1.1, August 13, 2016

  • Update composer.json

0.1.0, August 6, 2016

  • Initial release

The Versions

14/08 2016

dev-master

9999999-dev

Piecewise math functions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Clayton

function php jstewmc piecewise

14/08 2016

v1.0.0

1.0.0.0

Piecewise math functions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Clayton

function php jstewmc piecewise

13/08 2016

v0.1.1

0.1.1.0

Piecewise math functions

  Sources   Download

MIT

The Requires

 

The Development Requires

by Jack Clayton

function php jstewmc piecewise

07/08 2016

v0.1.0

0.1.0.0

Piecewise math functions

  Sources   Download

The Requires

 

The Development Requires

by Jack Clayton

function php jstewmc piecewise