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

Symtegration.Symbolic.Simplify.Tidy

Description

 
Synopsis

Documentation

tidy :: Expression -> Expression Source #

Tidies up expressions for nicer output.

Assumes that other simplifications have been applied first. In fact, it may undo changes that made other simplifications easier.

What is tidied up

Expand

This section shows examples of what this function tidies up.

>>> toHaskell $ tidy $ "x" + negate "y"
"x - y"
>>> toHaskell $ tidy $ "x" + Number (-2) * "y"
"x - 2 * y"
>>> toHaskell $ tidy $ Number (-1) / Number 2
"negate (1 / 2)"
>>> toHaskell $ tidy $ Number (-1) * "x"
"negate x"
>>> toHaskell $ tidy $ (-"x") * "y"
"negate (x * y)"
>>> toHaskell $ tidy $ "x" * (-"y")
"negate (x * y)"
>>> toHaskell $ tidy $ (-"x") * (-"y")
"x * y"
>>> toHaskell $ tidy $ "x" + ((-"y") + "z")
"x - y + z"