# How to simplify a simple expression

Which kind of simplify do I have to use for this kind of expressions?

251*sin(4/5*pi)^2 + 251/8*sqrt(5) + 753/8
-750751*sin(4/5*pi)^2 - 750751/8*sqrt(5) - 2252253/8
11593285251*sin(4/5*pi)^2 + 11593285251/8*sqrt(5) + 34779855753/8
-613498040952501*sin(4/5*pi)^2 - 613498040952501/8*sqrt(5) - 1840494122857503/8


Interestingly also Maple has problems with these expressions; Mathematica reduces them immediately.

edit retag close merge delete

Sort by » oldest newest most voted

Which simplification do you expect? With ...simplify_full() you get

-750751*sin(4/5*pi)^2 - 750751/8*sqrt(5) - 2252253/8


and

-613486447667250*sin(4/5*pi)^2 - 306743223833625/4*sqrt(5) - 920229671500875/4


respectively.

If you aim to expand sin(4/5*pi) Sage can help you with some tricks. From formula pages we can derive that sin(4/5*pi) is the root of a 4-degree polynomial, so we can find its exact representation by:

sage: ex = sin(4/5*pi)
sage: ex.n(200)
0.58778525229247312916870595463907276859765243764314599107227
sage: _.algebraic_dependency(4)
16*x^4 - 20*x^2 + 5
sage: solve(SR(_),x)
[x == -1/2*sqrt(1/2*sqrt(5) + 5/2), x == 1/2*sqrt(1/2*sqrt(5) + 5/2), x == -1/2*sqrt(-1/2*sqrt(5) + 5/2), x == 1/2*sqrt(-1/2*sqrt(5) + 5/2)]
sage: [eq.rhs().n() for eq in _ ]
[-0.951056516295154, 0.951056516295154, -0.587785252292473, 0.587785252292473]


so sin(4/5*pi) is 1/2*sqrt(-1/2*sqrt(5) + 5/2). Now substitute in the two expressions above, simplify, and get:

sage: (-750751*x^2 - 750751/8*sqrt(5) - 2252253/8).subs(x==1/2*sqrt(-1/2*sqrt(5) + 5/2))
-750751
sage: (-613486447667250*x^2 - 306743223833625/4*sqrt(5) - 920229671500875/4).subs(x==1/2*sqrt(-1/2*sqrt(5) + 5/2))
-613486447667250


It would be easy to add expansions of trig. functions of multiples of pi/5. The ticket is http://trac.sagemath.org/ticket/18954

more

Thanks Ralf for your investigations. These expressions look harmless but yesterday they made the kernel at SMC crash twice because these expressions blow up as the underlying parameter n went up. Maybe Maxima was the culprit.

In fact this shortcoming does affect for example the ability to compute certain exponential generating functions of integer sequences (the given expressions actually represent integers as you saw).

Special attention has to be paid for multiples of pi/p where p is prime. Things work for p in {2,3} but should also expand at least for p in {5,7}. Note that the trig form was actually obtained by simplify_full from exp expressions.

( 2015-07-26 11:53:20 -0600 )edit

Here an illustration of the comment:

(-1/7(2e^(6/7Ipi) + 2e^(4/7Ipi) + 2e^(2/7Ipi) - 5e^(-2/7Ipi) + 2e^(-4/7Ipi) + 2e^(-6/7Ipi) + 2)e^(2/7Ipi)).simplify_full()

(By the way I interrupted the computation and got: "TypeError: ECL says: Console interrupt." The message looks funny to me. A type error?)

( 2015-07-26 11:53:49 -0600 )edit

The typical way of Sage to signal an error in libecl. As to the values of n in pi/n with nice expansion you would be surprised.

( 2015-07-27 02:55:46 -0600 )edit