2017 © Pedro Peláez
 

library fx

Simple math functions

image

jstewmc/fx

Simple math functions

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

The README.md

f(x)

Simple math functions., (*1)

use Jstewmc\Fx;

(new Constant(1))(3);         // returns 1
(new Equality())(3);          // returns 3
(new Linear(1, 2))(3);        // returns 5 (1 * 3 + 2)
(new Quadratic(1, 2, 3))(4);  // returns 27 (1 * 4 ^ 2 + 2 * 4 + 3)
(new Power(1, 2))(3);         // returns 9 (1 * 3 ^ 2)
(new Exponential(1))(2);      // returns 1 (1 ^ 2)

This library supports the following functions:, (*2)

  • constant, c = x
  • equality, y = x
  • linear, y = mx + b
  • quadratic, y = ax2 + bx + c
  • power, y = cxp
  • exponential, y = bx

Constant

A constant function where c = x:, (*3)

use Jstewmc\Fx

$fx = new Constant(1);

$fx(1);  // returns 1
$fx(2);  // returns 1
$fx(3);  // returns 1

Equality

An equality where y = x:, (*4)

use Jstewmc\Fx;

$fx = new Equality();

$fx(1);  // returns 1
$fx(2);  // returns 2
$fx(3);  // returns 3

Linear

A linear function is y = mx + b, where m is the slope and b is the y-intercept:, (*5)

use Jstewmc\Fx;

$fx = new Linear(1, 2);

$fx(1);  // returns 3 (1 * 1 + 2)
$fx(2);  // returns 4 (1 * 2 + 2)
$fx(3);  // returns 5 (1 * 3 + 2)

Quadratic

A univariate, standard-form quadratic function is y = ax2 + bx + c, where a, b, and c are constants_ (aka, the _quadratic coefficient, the linear coefficient, and the constant, respectively):, (*6)

use Jstewmc\Fx;

$fx = new Quadratic(1, 2, 3);

$fx(1);  // returns 5 (1 * 1 ^ 2 + 2 * 1 + 3)
$fx(2);  // returns 11 (1 * 2 ^ 2 + 2 * 2 + 3)
$fx(3);  // returns 18 (1 * 3 ^ 2 + 2 * 3 + 3)

Power

A power function is y = cxp, where c is a constant, and p is the power:, (*7)

use Jstewmc\Fx;

$fx = new Power(1, 2);

$fx(1);  // returns 1 (1 * 1 ^ 2)
$fx(2);  // returns 4 (1 * 2 ^ 2)
$fx(3);  // returns 9 (1 * 3 ^ 2)

Exponential

An exponential function is y = bx, where b is a constant:, (*8)

use Jstewmc\Fx;

$fx = new Exponential(2);

$fx(1);  // returns 2 (2 ^ 1)
$fx(2);  // returns 4 (2 ^ 2)
$fx(3);  // returns 8 (2 ^ 3)

That's it!, (*9)

License

MIT, (*10)

Author

Jack Clayton, (*11)

Version

1.0.0, August 13, 2016

  • Major release
  • Update composer.json

0.3.1, August 13, 2016

  • Update Fx parent class to be an interface

0.3.0, August 6, 2016

  • Add Fx parent class

0.2.0, August 6, 2016

  • Update README examples
  • Add Equality function
  • Add Constant function

0.1.0, July 30, 2016

  • Initial release

The Versions

14/08 2016

dev-master

9999999-dev

Simple math functions

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

function php jstewmc linear qaudratic

14/08 2016

v1.0.0

1.0.0.0

Simple math functions

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

function php jstewmc linear qaudratic

13/08 2016

v0.3.1

0.3.1.0

Simple math functions

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

function php jstewmc linear qaudratic

07/08 2016

v0.3.0

0.3.0.0

Simple math functions

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

function php jstewmc linear qaudratic

07/08 2016

v0.2.0

0.2.0.0

Simple math functions

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

function php jstewmc linear qaudratic

30/07 2016

v0.1.0

0.1.0.0

Simple math functions

  Sources   Download

The Requires

  • php ^7.0

 

The Development Requires

by Jack Clayton

function php jstewmc linear qaudratic