Here is a small sample of algebraic manipulation functions in Symata
.
using Symata # load Symata and enter symata mode
ex = (x-y)*(z-y) + Sqrt((x-y)*(z-y))
Cse(expr)
recursively replaces subexpressions that occur more than once in expr
with names. The transformed expression is returned with a list of rules that can be used to recover expr
.
Cse(ex)
Applying in order the replacement rules in the second list to the expression in the first list results in the original expression.
To apply the rules, we will use Splat
, which works like this,
f(a,b,Splat([c,d]))
and Fold
, which works like this,
Fold(f, [x,a,b,c])
Apply the replacement rules like this,
Fold(ReplaceAll, Splat(Cse(ex)))[1]
Fold(ReplaceAll, Splat(Cse(ex)))[1] == ex
ClearAll(ex)
Together
and Apart
¶Together
rewrites rational expressions as a single fraction.
Together(1/x + 1/y + 1/z)
Together(1/(x*y) + 1/y^2)
Together(1/(1 + 1/x) + 1/(1 + 1/y))
By default, Together
only works at the topmost level.
Together(Exp(1/x + 1/y))
Together
is applied at all levels if the option Deep
is true.
Together(Exp(1/x + 1/y), Deep => True)
Apart
gives the partial fraction decomposition of a rational expression
Apart(y/(x + 2)/(x + 1), x)
If the denominator has non-rational roots, the option Full => True
must be given.
Apart(y/(x^2 + x + 1), x, Full=>True)
Collect
¶Collect coefficients of powers of x
.
Collect(a*x^2 + b*x^2 + a*x - b*x + c, x)
Collect coefficients of an expression.
Collect(a*x*Log(x) + (b+a)*(x*Log(x)), x*Log(x))
VersionInfo()
symata version 0.3.0-dev.7 julia version 0.6.0-dev.435 python version 2.7.12 sympy version 1.0
Now()