| Copyright | Copyright 2025 Yoo Chung |
|---|---|
| License | Apache-2.0 |
| Maintainer | dev@chungyc.org |
| Safe Haskell | Safe-Inferred |
| Language | GHC2021 |
Symtegration.Symbolic.Simplify.NumericFolding
Description
This merges numeric terms as much as it can to simplify expressions. Simplifications are finitely equivalent; i.e., any calculation with finite inputs should result in the equivalent finite input. The changes will also be exact, and no numeric constant will be replaced by an approximate floating-point number.
Synopsis
- simplify :: Expression -> Expression
Documentation
simplify :: Expression -> Expression Source #
Simplifies computations involving numeric constants. Basically, it computes as much as it can as long as any change is exact.
>>>toHaskell $ simplify $ 1 + 4"5">>>toHaskell $ simplify $ 8 ** (1/3)"2">>>toHaskell $ simplify $ 7 ** (1/3)"7 ** (1 / 3)">>>toHaskell $ simplify $ 5 * 10 * "x""50 * x"
It will replace subtraction by addition and square roots by powers of \(\frac{1}{2}\).