math

Production-oriented mathematical utilities for EZ: numeric helpers, trigonometry, statistics, number theory, random sampling, geometry, and vectors.

0 downloads owners: imabd645 repository

Install

ez install math

Dependencies (1.0.0)

PackageRange
No dependencies.

Readme

EZ Math

math is the production-oriented mathematics package for EZ. Import it with:

use "math"

It has no external dependencies and exports its API into the importing module.

Layout

FileResponsibility
src/constants.ezMathematical constants and tolerance
src/core.ezConversion, rounding, comparisons, and array aggregates
src/trigonometry.ezTrigonometry, inverse trigonometry, logs, and exponentials
src/number_theory.ezInteger algorithms and prime utilities
src/statistics.ezStatistics and descriptive statistics
src/interpolation.ezMapping, interpolation, steps, and easing
src/random.ezSeedable pseudo-random sampling
src/geometry.ezDistance and circle helpers
src/linear_algebra.ezVectors and 2×2 matrices

main.ez is intentionally only an import surface. Consumers must use math,
not a src/ implementation file, to keep future refactors compatible.

Numeric API

round rounds half values away from zero. Aggregate functions require a non-empty
array except sum (zero) and product (one).

Trigonometry and logarithms

sin, cos, tan, asin, acos, atan, and atan2 use radians. Degree
variants are suffixed with d, for example sind(30) and atan2d(1, 1).

ln, log2, log10, log, and exp validate their mathematical domains.
atan2(0, 0), tan at an undefined angle, invalid logarithm bases, and inverse
trigonometric values outside [-1, 1] raise errors instead of returning a
plausible but incorrect number.

Integer algorithms

out gcd(48, 18)          # 6
out lcm(12, 18)          # 36
out factors(360)         # [2, 2, 2, 3, 3, 5]
out fibonacci(10)        # 55
out isPrime(97)          # true

factorial, fibonacci, and factors reject invalid integer domains.

Statistics

s = Statistics([2, 4, 4, 4, 5, 5, 7, 9])
out s.mean()             # 5
out s.median()           # 4.5
out s.stddev()           # 2
out s.percentile(75)     # 5.5

Statistics copies its input array. Empty datasets raise for measurements
whose value is undefined; mode() returns nil for an empty dataset.

Randomness

seedRand, randInt, randFloat, randBool, randChoice, and randNormal
use a deterministic LCG. It is appropriate for games, tests, and simulations;
it is not cryptographically secure. Use secure_token from the web package
or platform cryptography for secrets.

Linear algebra

Vector2, Vector3, and Matrix2x2 provide immutable arithmetic results;
normalize() mutates the vector and returns it. Normalizing a zero vector,
dividing a vector by zero, and inverting a singular matrix raise errors.

Testing

Run the standalone suite with an EZ interpreter that can resolve C:/ezlib:

ez C:\ezlib\math\test_math.ez

Versions

VersionSizeDownloadsPublished
1.0.0 7.5 KB 0 1 hour ago

Integrity

sha256  f3fa128ff8898efc842d4a973659923d3b5a42eb47e2921a54c1a6094554cf93