symtegration-0.4.0: Library for symbolic integration of mathematical expressions.
CopyrightCopyright 2024 Yoo Chung
LicenseApache-2.0
Maintainerdev@chungyc.org
Safe HaskellNone
LanguageGHC2021

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

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}\).