Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The other examples showed already how to proceed, here is only the explanation for the "poor work" done by the function simplify. Let us define the expression to be simplified to have a handy nickname.

sage: a = 1 + ( 1/2 + i*sqrt(3)/2 )^3                                                                                                       
sage: a.simplify()                                                                                                                          
(1/2*I*sqrt(3) + 1/2)^3 + 1
sage: a.simplify?

So asking for a simplification did not simplify (in the sense of a human). So the last line shows what is doing this method:

sage: a.simplify?                                                                                                                           
Docstring:     
   Return a simplified version of this symbolic expression.

   Note:

     Currently, this just sends the expression to Maxima and converts
     it back to Sage.

   See also:

     "simplify_full()", "simplify_trig()", "simplify_rational()",
     "simplify_rectform()" "simplify_factorial()", "simplify_log()",
     "simplify_real()", "simplify_hypergeometric()",
     "canonicalize_radical()"

and so on. So we obtain a "maxima simplification"". And maxima in known for not trying to touch too much expressions. So the prints just submit this string version of the poorly simplified a. The "See also" part (of the doc string of the simplify function/method) above may be an answer to the question. In such cases, the human part is responsible for the "way to handle expressions". For instance:

If we explicitly expand, we get the result.

sage: a.expand()
0

If we know it should be zero, and are irritated for a second, we can ask for this information explicitly:

sage: a == 0    # this is just an "equation", we have to explicitly bool-evaluate it...                                                     
(1/2*I*sqrt(3) + 1/2)^3 + 1 == 0
sage: bool(_)                                                                                                                               
True

We may try some more simplify methods from the above list...

sage: a.simplify()                                                                                                                          
(1/2*I*sqrt(3) + 1/2)^3 + 1
sage: a.simplify_factorial()                                                                                                                
(1/2*I*sqrt(3) + 1/2)^3 + 1
sage: a.simplify_full()                                                                                                                     
0
sage: a.simplify_rational()                                                                                                                 
0
sage: a.simplify_trig()                                                                                                                     
0
sage: a.canonicalize_radical()                                                                                                              
0

Some of the applied methods make no sense (the factorial and the trig lines), but...

The other examples two answers are already good and compact, they gave examples, and showed already how to proceed, here is only the explanation for the "poor work" done by the function simplify. Let us define the expression to be simplified to have a handy nickname.

sage: a = 1 + ( 1/2 + i*sqrt(3)/2 )^3                                                                                                       
sage: a.simplify()                                                                                                                          
(1/2*I*sqrt(3) + 1/2)^3 + 1
sage: a.simplify?

So asking for a simplification did not simplify (in the sense of a human). So the last line shows what is doing this method:

sage: a.simplify?                                                                                                                           
Docstring:     
   Return a simplified version of this symbolic expression.

   Note:

     Currently, this just sends the expression to Maxima and converts
     it back to Sage.

   See also:

     "simplify_full()", "simplify_trig()", "simplify_rational()",
     "simplify_rectform()" "simplify_factorial()", "simplify_log()",
     "simplify_real()", "simplify_hypergeometric()",
     "canonicalize_radical()"

and so on. So we obtain a "maxima simplification"". And maxima in known for not trying to touch too much expressions. So the prints just submit this string version of the poorly simplified a. The "See also" part (of the doc string of the simplify function/method) above may be an answer to the question. In such cases, the human part is responsible for the "way to handle expressions". For instance:

If we explicitly expand, we get the result.

sage: a.expand()
0

If we know it should be zero, and are irritated for a second, we can ask for this information explicitly:

sage: a == 0    # this is just an "equation", we have to explicitly bool-evaluate it...                                                     
(1/2*I*sqrt(3) + 1/2)^3 + 1 == 0
sage: bool(_)                                                                                                                               
True

We may try some more simplify methods from the above list...

sage: a.simplify()                                                                                                                          
(1/2*I*sqrt(3) + 1/2)^3 + 1
sage: a.simplify_factorial()                                                                                                                
(1/2*I*sqrt(3) + 1/2)^3 + 1
sage: a.simplify_full()                                                                                                                     
0
sage: a.simplify_rational()                                                                                                                 
0
sage: a.simplify_trig()                                                                                                                     
0
sage: a.canonicalize_radical()                                                                                                              
0

Some of the applied methods make no sense (the factorial and the trig lines), but...