PBXB64 Science & Math

80+ Functions PBXB64 Addition

A complete scientific computing toolkit built into the compiler. No external libraries needed. Covers trigonometry, linear algebra, statistics, random numbers, hyperbolic functions, statistical distributions, and more.

Function Reference

SIN / COS / TANTrigonometric (radians)
ATN / ATN2Arc-tangent (1-arg, 2-arg)
SINH / COSH / TANHHyperbolic functions
ASINH / ACOSH / ATANHInverse hyperbolic
EXP / LOG / LOG10Exponential, natural log, base-10
SQR / CBRTSquare root, cube root
HYPOTHypotenuse: sqrt(x² + y²)
ABS / FIX / INTAbsolute, truncate, floor
CEIL / FLOOR / ROUNDRounding functions
SGNSign of number
MIN / MAXMinimum / maximum
RND / RNDUNIFORM / RNDNORMALUniform & normal random
RANDOMIZE / RNG SEEDSeed random generator
RNDEXP / RNDPOISSONExponential & Poisson random
DETMatrix determinant
DOT / NORMVector dot product, Euclidean norm
4 * ATN(1)Pi (3.14159...)
DEGREES / RADIANSDegrees ↔ radians
GAMMAP / GAMMAQIncomplete gamma functions
ABS(x - y) < epsNear-equality test

Linear Algebra: DET, DOT, NORM

Matrix & vector operations
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG DIM m(1 TO 2, 1 TO 2) AS DOUBLE ' 2x2 matrix DIM a(1 TO 2) AS DOUBLE ' vectors DIM b(1 TO 2) AS DOUBLE LOCAL det AS DOUBLE LOCAL dot AS DOUBLE m(1, 1) = 4.0 : m(1, 2) = 7.0 m(2, 1) = 2.0 : m(2, 2) = 6.0 det = DET(m()) ' 4*6 - 7*2 = 10 PRINT "Determinant: "; det ' 10 a(1) = 1.0 : a(2) = 2.0 b(1) = 3.0 : b(2) = 4.0 dot = DOT(a(), b()) ' 1*3 + 2*4 = 11 PRINT "Dot product: "; dot ' 11 PRINT "Norm of b: "; NORM(b()) ' sqrt(3^2 + 4^2) = 5 FUNCTION = 0 END FUNCTION

DET computes the determinant of a square matrix, DOT the dot product of two vectors, and NORM the Euclidean length. All three take whole arrays, written as name().

Random Numbers: RNDUNIFORM, RNDNORMAL, RNG SEED

Seeded random generation
#COMPILE EXE #DIM ALL FUNCTION PBMAIN() AS LONG LOCAL r AS DOUBLE LOCAL g AS DOUBLE RNG SEED 12345 ' Reproducible seed r = RNDUNIFORM(0, 1) ' Uniform [0, 1) PRINT "Uniform: "; r g = RNDNORMAL(0, 1) ' Gaussian (mean=0, std=1) PRINT "Gaussian: "; g RNG SEED 12345 ' Same seed again -> same sequence PRINT "Repeat: "; RNDUNIFORM(0, 1) FUNCTION = 0 END FUNCTION

RNG SEED sets a deterministic seed for reproducible results: reseeding with the same value repeats the sequence. RNDUNIFORM(a, b) returns uniformly distributed and RNDNORMAL(mean, sigma) normally distributed random numbers.

Hyperbolic Functions

SINH, COSH, TANH, ASINH, ACOSH, ATANH
FUNCTION PBMAIN() AS LONG LOCAL x AS DOUBLE LOCAL s AS DOUBLE LOCAL c AS DOUBLE x = 1.0 s = SINH(x) ' 1.1752... c = COSH(x) ' 1.5430... PRINT "sinh(1) = "; s PRINT "cosh(1) = "; c PRINT "tanh(1) = "; TANH(x) ' Inverse hyperbolic PRINT "asinh(1.1752) = "; ASINH(s) FUNCTION = 0 END FUNCTION

Full hyperbolic suite including inverse variants. All implemented natively in the runtime.

ATN2 - Two-Argument Arc-Tangent

ATN2 - correct quadrant
FUNCTION PBMAIN() AS LONG LOCAL angle AS DOUBLE angle = ATN2(1.0, 1.0) ' 45 degrees (PI/4) PRINT "ATN2(1, 1) = "; angle angle = ATN2(-1.0, -1.0) ' -135 degrees (-3PI/4) PRINT "ATN2(-1, -1) = "; angle angle = ATN2(0.0, -1.0) ' 180 degrees (PI) PRINT "ATN2(0, -1) = "; angle FUNCTION = 0 END FUNCTION

ATN2(y, x) returns the angle in the correct quadrant, unlike ATN(y/x) which loses quadrant information.

Back to feature list