]> gitweb.michael.orlitzky.com - sage.d.git/blob - mjo/symbolic.py
Initial commit.
[sage.d.git] / mjo / symbolic.py
1 from sage.all import *
2 from sage.interfaces.maxima_lib import maxima_lib
3 from sage.symbolic.expression import Expression
4
5
6 def set_simplification_domain(d):
7 """
8 Set Maxima's simplification domain.
9
10 INPUT:
11
12 - d -- The domain, either 'real' or 'complex'.
13
14 """
15 cmd = 'domain: %s;' % d
16 result = maxima_lib._eval_line(cmd)
17 return result
18
19
20 def safe_simplify(expr):
21 """
22 What should be a totally safe simplification operation that works
23 a little better than the plain simplify().
24
25 Uses a top-level function because we can't monkey-patch Cython
26 classes.
27 """
28 expr = expr.simplify_factorial()
29 expr = expr.simplify_log()
30 return expr
31
32
33 def medium_simplify(expr):
34 """
35 A reasonably-safe set of simplifications, much better than
36 simplify() and safer than simplify_full()
37
38 Uses a top-level function because we can't monkey-patch Cython
39 classes.
40 """
41 expr = expr.simplify_factorial()
42 expr = expr.simplify_trig()
43 expr = expr.simplify_rational()
44 expr = expr.simplify_log()
45 return expr