Repository navigation
Releases
Correctness, Diamond Deployment, and TrigMath Performance Release
Overview
Trigonometry Master v2.0.0 is a major correctness, deployment, benchmarking, and performance release.
This release turns the project into a more reliable, explicitly scoped, and deployable Solidity trigonometry system. It adds enforced numerical accuracy checks, fixes inverse-trigonometry and threshold bugs, defines special-value and input-range behavior, repairs the Diamond deployment path, improves benchmark methodology, and substantially reduces production gas through TrigMath inlining.
Highlights
- Enforced real trigonometric accuracy assertions instead of record-count-only tests.
- Fixed inverse-sine / inverse-cosine approximation behavior.
- Corrected malformed binary128 threshold constants.
- Added explicit NaN, infinity, domain, pole, signed-zero, and range behavior.
- Added high-resolution raw binary128 characterization with ULP reporting.
- Bounded direct trigonometric argument reduction to finite
|x| <= 2^32. - Fixed the ethers v6
TrigonometryMasterDiamond deployment script. - Added production Diamond gas benchmark coverage.
- Pre-encoded sin/cos Taylor coefficients.
- Added shared internal
sincosevaluation for paired consumers. - Replaced linked
MathLibproduction dispatch with internalTrigMath. - Added bytecode-size guardrails.
- Expanded raw binary128 edge-case and Diamond integration coverage.
- Documented direct versus Diamond deployment tradeoffs.
Correctness Fixes
Accuracy tests now enforce numerical thresholds for:
sincostancotasinacosatan- inverse/round-trip behavior
- domain and pole behavior
Key fixes include:
- Corrected
asinfrom the incorrect formx + x·P(x²)tox + x³·P(x²). - Added an endpoint-stable
acosbranch nearx = 1usingacos(x) = 2·asin(sqrt((1-x)/2)). - Corrected malformed binary128 constants for
1e-6,1e-30,2^-112, and the large-atancutoff. - Fixed signed-zero handling in zero-sensitive logic.
- Hardened Diamond ownership and
diamondCutbehavior.
Input Domain and Special Values
The trigonometric API now has explicit behavior for non-finite and unsupported inputs.
-
sin,cos,tan, andcotreject:- NaN
- ±infinity
- finite
|x| > 2^32
-
asinandacosreturn canonical NaN for:- NaN
- ±infinity
- finite out-of-domain inputs
-
atanreturns:- canonical NaN for NaN
- signed
π/2for ±infinity
-
Finite
tan/cotpoles remain documented NaN cases.
Benchmarking Improvements
Benchmark output now distinguishes:
- transaction receipt gas
estimateGaseth_callresults- harness-direct execution
- Diamond-routed production execution
- deployment and
diamondCutinstallation costs
The benchmark suite no longer treats repeated deterministic calls as independent statistical samples or hides failures as data strings.
Representative local Hardhat production-route receipt gas at π/4:
| Function | Diamond-routed gas |
|---|---|
sin |
43,473 |
cos |
42,504 |
tan |
54,827 |
cot |
54,831 |
These are local Hardhat measurements, not chain-wide gas guarantees.
Performance Improvements
This release substantially reduces production gas and deployment complexity.
Major changes:
- Replaced runtime coefficient construction with audited encoded binary128 constants.
- Added shared internal
sincosevaluation for paired consumers. - Replaced linked
MathLibproduction arithmetic dispatch with internalTrigMath. - Removed production dependency on linked
MathLibdeployment.
Current production size/deployment profile:
| Item | Value |
|---|---|
TrigonometryFacet runtime size |
18,333 bytes |
| EIP-170 headroom | 6,243 bytes |
| Project budget headroom | 4,667 bytes |
TrigonometryFacet deployment gas |
4,013,373 |
Production deployment no longer requires MathLib.
Diamond Deployment
The deployment script now targets the actual TrigonometryMaster Diamond architecture and works with ethers v6.
It deploys and installs:
DiamondCutFacetTrigonometryMasterOwnershipFacetDiamondLoupeFacetTrigonometryFacet
Local deployment validation passed, including facet installation through diamondCut.
Recent local deployment receipt gas:
| Component | Gas |
|---|---|
DiamondCutFacet |
1,022,266 |
TrigonometryMaster |
324,179 |
OwnershipFacet |
166,427 |
DiamondLoupeFacet |
430,473 |
TrigonometryFacet |
4,013,373 |
diamondCut installation |
647,863 |
Test Coverage
The default suite now covers:
- bytecode budget checks
- Diamond safety checks
- Diamond integration, selector installation, loupe, proxy routing, access control, replacement, and removal
- MathLib special-value behavior
- benchmark utility semantics
- harness-observable accuracy
- raw binary128 edge cases
- high-resolution sin/cos characterization
- argument-reduction range validation
The default test suite currently passes:
npm test
# 40 passingv1.1.0.1 - Add Trigonometry Wrapper Library
v1.1.0.1 - Add Trigonometry Wrapper Library
This release adds a unified Trigonometry wrapper library for easier external imports.
Changes
- Added
contracts/libraries/Trigonometry.sol. - Exposed a single import point for:
sincostancotasinacosatan
- Routed calls internally to the existing
TrigonometrySinCos,TrigonometryTanCot, andTrigonometryArclibraries.
Usage
import {Trigonometry} from "@gorkemerdogan/trigonometry-master/contracts/libraries/Trigonometry.sol";v1.0.2.1 - Naming Cleanup
v1.0.2.1 - Naming Cleanup
This release cleans up remaining references from the original SmartSolve project after extracting Trigonometry Master as a standalone library.
Changes
- Removed leftover SmartSolve naming from Trigonometry Master files.
- Aligned contract and project naming with the standalone Trigonometry Master package.
- Improved package consistency for external imports.
Notes
This release does not change the core trigonometric logic.
v1.0.1 - Package Setup
v1.0.1 - Package Setup
This release prepares Trigonometry Master for external usage as a GitHub-based npm dependency.
Changes
- Added npm package metadata.
- Configured package name for external Solidity imports.
- Removed nested package files from the contracts directory.
- Updated Hardhat and TypeScript configuration for stable local testing.
- Prepared the package for imports such as:
import {TrigonometryMaster} from "@gorkemerdogan/trigonometry-master/contracts/TrigonometryMaster.sol";Trigonometry Master v1.0.0 - Initial Release
Trigonometry Master v1.0.0
Initial release of Trigonometry Master, a deterministic quadruple-precision trigonometric library for Ethereum-compatible environments.
Highlights
-
Added support for core trigonometric functions:
sincostancot
-
Added support for inverse trigonometric functions:
arcsinarccosarctan
-
Implemented quadruple-precision arithmetic using
bytes16based on the IEEE-754 binary128 representation. -
Designed the library with stateless, deterministic execution for reproducible results across EVM-compatible nodes.
-
Structured the implementation for modular integration with Diamond Pattern based smart contract systems.
-
Separated trigonometric logic into dedicated modules for:
- sine / cosine
- tangent / cotangent
- inverse trigonometric operations
Intended Scope
This release is intended for research-oriented and engineering-focused smart contract applications that require deterministic and high-precision trigonometric computation.
Typical use cases include:
- on-chain numerical analysis
- optimization algorithms
- differential equation solvers
- geometric computation
- verifiable mathematical research on EVM-based platforms
License
Released under the MIT License.