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.Integration.Factor

Description

 
Synopsis

Documentation

factor Source #

Arguments

:: Text

Symbol for the variable.

-> Expression

Term to separate into constant and non-constant portions.

-> (Expression, Expression) 

Factor a multiplicative term into a constant portion and the variable-dependent portion. E.g., \(2a x \sin x\) into \(2a\) and \(x \sin x\) when the variable is \(x\).

>>> let s (x, y) = (toHaskell $ simplify x, toHaskell $ simplify y)
>>> s $ factor "x" $ 2 * ("a" * sin "x")
("2 * a","sin x")
>>> s $ factor "x" $ "a" / "x"
("a","1 / x")

Assumes algebraic ring ordering has been applied to the term.

isConstant Source #

Arguments

:: Text

Symbol for the variable.

-> Expression

Expression to check.

-> Bool

Whether the expression is a constant.

Returns whether an expression contains the variable.

>>> isConstant "x" $ 1 + "x"
False
>>> isConstant "x" $ 1 + "a"
True