Summary
Vera has basic math functions (abs, min, max, floor, ceil, round, sqrt, pow) but is missing logarithmic functions, trigonometric functions, mathematical constants, and common numeric utilities.
Proposed API
Logarithmic
log(@Float64) -> @Float64 — natural logarithm
log2(@Float64) -> @Float64 — base-2 logarithm
log10(@Float64) -> @Float64 — base-10 logarithm
Trigonometric
sin(@Float64) -> @Float64
cos(@Float64) -> @Float64
tan(@Float64) -> @Float64
asin(@Float64) -> @Float64
acos(@Float64) -> @Float64
atan(@Float64) -> @Float64
atan2(@Float64, @Float64) -> @Float64
Constants
pi() -> @Float64 — 3.14159...
e() -> @Float64 — 2.71828...
Numeric utilities
sign(@Int) -> @Int — returns -1, 0, or 1
clamp(@Int, @Int, @Int) -> @Int — restrict value to [min, max] range
clamp_float(@Float64, @Float64, @Float64) -> @Float64 — float variant
Implementation
- environment.py: Register as pure functions (no effects)
- codegen/api.py: Host imports delegating to Python
math module
- WASM: Most map directly to
f64 operations or can use math.log, math.sin, etc.
- Browser runtime:
Math.log(), Math.sin(), Math.PI, etc.
- Verification: Standard Z3 real arithmetic axioms where available; trig functions are generally uninterpreted in Z3
Priority
Lower priority than array utilities and sleep/random, but these are standard library functions that every language provides. Useful for scientific computation, graphics, audio, and any problem involving geometry or exponential growth.
Summary
Vera has basic math functions (abs, min, max, floor, ceil, round, sqrt, pow) but is missing logarithmic functions, trigonometric functions, mathematical constants, and common numeric utilities.
Proposed API
Logarithmic
log(@Float64) -> @Float64— natural logarithmlog2(@Float64) -> @Float64— base-2 logarithmlog10(@Float64) -> @Float64— base-10 logarithmTrigonometric
sin(@Float64) -> @Float64cos(@Float64) -> @Float64tan(@Float64) -> @Float64asin(@Float64) -> @Float64acos(@Float64) -> @Float64atan(@Float64) -> @Float64atan2(@Float64, @Float64) -> @Float64Constants
pi() -> @Float64— 3.14159...e() -> @Float64— 2.71828...Numeric utilities
sign(@Int) -> @Int— returns -1, 0, or 1clamp(@Int, @Int, @Int) -> @Int— restrict value to [min, max] rangeclamp_float(@Float64, @Float64, @Float64) -> @Float64— float variantImplementation
mathmodulef64operations or can usemath.log,math.sin, etc.Math.log(),Math.sin(),Math.PI, etc.Priority
Lower priority than array utilities and sleep/random, but these are standard library functions that every language provides. Useful for scientific computation, graphics, audio, and any problem involving geometry or exponential growth.