PHPackages                             jstewmc/fx - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. jstewmc/fx

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

jstewmc/fx
==========

Simple math functions

v1.0.0(9y ago)0632MITPHPPHP ^7.0

Since Jul 30Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jstewmc/fx)[ Packagist](https://packagist.org/packages/jstewmc/fx)[ RSS](/packages/jstewmc-fx/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (1)Versions (6)Used By (2)

f(x)
====

[](#fx)

Simple math functions.

```
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:

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

Constant
--------

[](#constant)

A constant function where `c = x`:

```
use Jstewmc\Fx

$fx = new Constant(1);

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

Equality
--------

[](#equality)

An equality where `y = x`:

```
use Jstewmc\Fx;

$fx = new Equality();

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

Linear
------

[](#linear)

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

```
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
---------

[](#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):

```
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
-----

[](#power)

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

```
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
-----------

[](#exponential)

An exponential function is `y = bx`, where `b` is a *constant*:

```
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!

License
-------

[](#license)

[MIT](https://github.com/jstewmc/test-case)

Author
------

[](#author)

[Jack Clayton](mailto:clayjs0@gmail.com)

Version
-------

[](#version)

### 1.0.0, August 13, 2016

[](#100-august-13-2016)

- Major release
- Update `composer.json`

### 0.3.1, August 13, 2016

[](#031-august-13-2016)

- Update `Fx` parent class to be an interface

### 0.3.0, August 6, 2016

[](#030-august-6-2016)

- Add `Fx` parent class

### 0.2.0, August 6, 2016

[](#020-august-6-2016)

- Update README examples
- Add `Equality` function
- Add `Constant` function

### 0.1.0, July 30, 2016

[](#010-july-30-2016)

- Initial release

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~3 days

Total

5

Last Release

3608d ago

Major Versions

v0.3.1 → v1.0.02016-08-13

### Community

Maintainers

![](https://www.gravatar.com/avatar/50fecae0a7fd2119681bc133e496e7166b01a59f850a3c909e100bd427c6b28b?d=identicon)[Jstewmc](/maintainers/Jstewmc)

---

Top Contributors

[![jstewmc](https://avatars.githubusercontent.com/u/1192893?v=4)](https://github.com/jstewmc "jstewmc (15 commits)")

---

Tags

phpfunctionlinearjstewmcqaudratic

### Embed Badge

![Health badge](/badges/jstewmc-fx/health.svg)

```
[![Health](https://phpackages.com/badges/jstewmc-fx/health.svg)](https://phpackages.com/packages/jstewmc-fx)
```

###  Alternatives

[laravelista/ekko

Framework agnostic PHP package for marking navigation items active.

277700.4k4](/packages/laravelista-ekko)[nilportugues/php_todo

Looks into the code using a user-defined list of to-do phrases and stops commit if the total amount increased or is above a threshold.

1210.0k](/packages/nilportugues-php-todo)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
