On 03/04/2013 11:10 AM, Jeroen Demeyer wrote:
> Fair enough, but what if I want the "domain: real" behaviour in Sage? In
> other words, what should do to have (abs(cos(t))^2).simplify() return
> "cos(t)^2"?
>
> sage: maxima('domain: real;')
> real
> sage: var("t")
> t
> sage: assume(t, "real")
> sage: (abs(cos(t))^2).simplify()
> abs(cos(t))^2
>
This is what I use in my ~/.sage, without any error checking:
def set_simplification_domain(d):
"""
Set Maxima's simplification domain.
INPUT:
- ``d`` -- The domain, either 'real' or 'complex'.
TESTS:
With the default 'complex' domain, we don't simplify this::
sage: (abs(x)^2).simplify()
abs(x)^2
But in the 'real' domain, we do::
sage: set_simplification_domain('real')
'real'
sage: (abs(x)^2).simplify()
x^2
sage: set_simplification_domain('complex')
'complex'
"""
cmd = 'domain: %s;' % d
result = maxima_lib._eval_line(cmd)
return result
At some point, I had a patch that made this available through e.g.,
sage: maxima_lib.domain = 'real'
with appropriate error checking. But I couldn't figure out how to
document the property, which does one thing as a getter and another as a
setter.
Plus, fooling with the maxima domain feels kind of hacky. Users
shouldn't have to configure the underlying libraries that sage uses,
although it would be nice to have the option in the meantime.
The super-feature that would obviate twiddling the domain would be to
determine whether or not all terms in an expression are real, and set
the maxima domain automatically when manipulating pure-real expressions.
--
You received this message because you are subscribed to the Google Groups
"sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-support?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.