Ask Your Question
0

How to simplify a simple expression

asked 2015-07-24 21:49:45 +0200

Peter Luschny gravatar image

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 flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2015-07-26 14:55:36 +0200

rws gravatar image

updated 2015-07-26 15:45:05 +0200

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

edit flag offensive delete link more

Comments

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.

Peter Luschny gravatar imagePeter Luschny ( 2015-07-26 18:53:20 +0200 )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?)

Peter Luschny gravatar imagePeter Luschny ( 2015-07-26 18:53:49 +0200 )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.

rws gravatar imagerws ( 2015-07-27 09:55:46 +0200 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2015-07-24 21:49:45 +0200

Seen: 1,807 times

Last updated: Jul 26 '15