]>
gitweb.michael.orlitzky.com - sage.d.git/blob - symbolic.py
d2a13298bb74dfbcc18a15434b6427d9aaf911cf
2 from sage
.interfaces
.maxima_lib
import maxima_lib
3 from sage
.symbolic
.expression
import Expression
6 def set_simplification_domain(d
):
8 Set Maxima's simplification domain.
12 - ``d`` -- The domain, either 'real' or 'complex'.
16 With the default 'complex' domain, we don't simplify this::
18 sage: (abs(x)^2).simplify()
21 But in the 'real' domain, we do::
23 sage: set_simplification_domain('real')
25 sage: (abs(x)^2).simplify()
27 sage: set_simplification_domain('complex')
31 cmd
= 'domain: %s;' % d
32 result
= maxima_lib
._eval
_line
(cmd
)
36 def safe_simplify(expr
):
38 What should be a totally safe simplification operation that works
39 a little better than the plain simplify().
41 Uses a top-level function because we can't monkey-patch Cython
44 expr
= expr
.simplify_factorial()
45 expr
= expr
.simplify_log()
49 def medium_simplify(expr
):
51 A reasonably-safe set of simplifications, much better than
52 simplify() and safer than simplify_full()
54 Uses a top-level function because we can't monkey-patch Cython
57 expr
= expr
.simplify_factorial()
58 expr
= expr
.simplify_trig()
59 expr
= expr
.simplify_rational()
60 expr
= expr
.simplify_log()