full simplify, sage vs mathematica

i like this post (click again to cancel)
1
i dont like this post (click again to cancel)

I have this somewhat lengthy, but in principal trivial expression

sage: B = 1/4*(e^(sqrt(-2*cos(l) + 2)) + 1)*(I*sin(l) -
cos(l))*e^(-1/2*sqrt(-2*cos(l) + 2)) - 1/4*sqrt(-2*cos(l) +
2)*(e^(sqrt(-2*cos(l) + 2))*sin(l)^2/sqrt(-2*cos(l) + 2) +
I*e^(sqrt(-2*cos(l) + 2))*sin(l)*cos(l)/sqrt(-2*cos(l) + 2)
- (I*e^(sqrt(-2*cos(l) + 2)) - I)*sin(l) +
(e^(sqrt(-2*cos(l) + 2)) - 1)*cos(l) - I*e^(sqrt(-2*cos(l) +
2))*sin(l)/sqrt(-2*cos(l) + 2))/(e^(1/2*sqrt(-2*cos(l) +
2))*cos(l) - e^(1/2*sqrt(-2*cos(l) + 2))) +
1/8*sqrt(-2*cos(l) + 2)*((I*e^(sqrt(-2*cos(l) + 2)) -
I)*cos(l) + (e^(sqrt(-2*cos(l) + 2)) - 1)*sin(l) -
I*e^(sqrt(-2*cos(l) + 2)) + I)*(e^(1/2*sqrt(-2*cos(l) +
2))*sin(l)*cos(l)/sqrt(-2*cos(l) + 2) -
2*e^(1/2*sqrt(-2*cos(l) + 2))*sin(l) - e^(1/2*sqrt(-2*cos(l)
+ 2))*sin(l)/sqrt(-2*cos(l) + 2))/(e^(1/2*sqrt(-2*cos(l) +
2))*cos(l) - e^(1/2*sqrt(-2*cos(l) + 2)))^2 -
1/4*((I*e^(sqrt(-2*cos(l) + 2)) - I)*cos(l) +
(e^(sqrt(-2*cos(l) + 2)) - 1)*sin(l) - I*e^(sqrt(-2*cos(l) +
2)) + I)*sin(l)/(sqrt(-2*cos(l) + 2)*(e^(1/2*sqrt(-2*cos(l)
+ 2))*cos(l) - e^(1/2*sqrt(-2*cos(l) + 2))))

My humble understanding of full_simply() is, that it will 'kind of' make the 'simplest looking' expression from that.

sage: B.full_simply()  
1/8*((e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 1)*cos(l)^3 -
3*(e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 1)*cos(l)^2 +
3*(e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 1)*cos(l) +
((-I*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - I)*cos(l)^2 +
(2*I*e^(I*sqrt(cos(l) - 1)*sqrt(2)) + 2*I)*cos(l) -
I*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - I)*sin(l) + sqrt(cos(l) -
1)*((I*sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) -
I*sqrt(2))*cos(l)^2 + (-2*I*sqrt(2)*e^(I*sqrt(cos(l) -
1)*sqrt(2)) + 2*I*sqrt(2))*cos(l) +
((sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - sqrt(2))*cos(l) -
sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) + sqrt(2))*sin(l) +
I*sqrt(2)*e^(I*sqrt(cos(l) - 1)*sqrt(2)) - I*sqrt(2)) -
e^(I*sqrt(cos(l) - 1)*sqrt(2)) - 1)/(e^(1/2*I*sqrt(cos(l) -
1)*sqrt(2))*sin(l)^2 + 2*e^(1/2*I*sqrt(cos(l) -
1)*sqrt(2))*cos(l) - 2*e^(1/2*I*sqrt(cos(l) - 1)*sqrt(2)))

That doesn't look too much simpler. So I compared to Mathematica

sage: B._mathematica_().FullSimplify()
(I*Sin[l/2]^3*(Sqrt[1 - Cos[l]]*Cosh[Sin[l/2]] - 
Sqrt[2]*Sinh[Sqrt[Sin[l/2]^2]]))/(E^((I/2)*l)*(1 - Cos[l])^(3/2))

Does this imply I really have to use Mathematica for such things?

asked Oct 27 '11

Xaver gravatar image Xaver
121 1 4 10

Is it really fully_simply?

G-Sage (Oct 27 '11)

@G-Sage TAB completion produces both, full_simplify() and simplify_full() and they both return the same results - moreover the doc says:

simplify_full(...) File: sage/symbolic/expression.pyx (starting at line 6553)

Applies simplify_factorial, simplify_trig, simplify_rational,
simplify_radical, simplify_log, and again simplify_rational to
self (in that order).

ALIAS: simplify_full and full_simplify are the same
Xaver (Oct 27 '11)

What is l here? A symbolic variable?

benjaminfjones (Oct 27 '11)

I don't know that an "answer" is really appropriate here. It's pretty well-known among power users that symbolic manipulation is something that Maple and Mma do better than Maxima (which provides our simplification). It's unfortunate, but that is one reason we provide the hooks to other programs.

kcrisman (Oct 27 '11)

@Xaver First, I had a slight typo (extra y), but my question was is it really full_simply? You responded by saying there exists full_simplify. These are different. It's not that important. I just thought it was weird to have full_simply when it's so close to the full phrase.

G-Sage (Oct 27 '11)
see 1 more comment

2 Answers:

i like this answer (click again to cancel)
1
i dont like this answer (click again to cancel)

kcrisman wrote: I don't know that an "answer" is really appropriate here. It's pretty well-known among power users that symbolic manipulation is something that Maple and Mma do better than Maxima (which provides our simplification). It's unfortunate

Actually this is far more of an answer than I was expecting from an open source project. Thank you very much indeed. I am surely not a power user of sage but I am a power user of mathematica with several tens of thousands of lines of code written for research and teaching in theoretical physics over the years and using it surely not only but definitely also for symbolic manipulation. Actually I didn't even know of sage since very recently a student of mine asked about it. Reading the "Tour of Sage" and the "Tutorial" in the docs and the frequently reoccurring benchmarks against mathematica in other parts of the docs, I was mislead to think ".. wow this might be an open source replacement ..". So it played around with sage in my spare time, attempting just some very 1st and trivial things.

Some of my related questions you can find in this forum. I learned, stuff like: sage can't get elementary functions like the log() straight, or, plotting more than just the cos() gets you into trouble, and now I read that I should not use sage for symbolic manipulations.

So yes, you gave an answer - one which will also help my students (which can have their university licenses of mathematica for free anyway).

link

posted Oct 28 '11

Xaver gravatar image Xaver
121 1 4 10
1

But, the point of this is that any one who wants to can create new features. For some things, it's way better than Mathematica already. And, for others, it could be better in the future as people contribute more and more to it. It's only been around for a few years. Mathematica was first released in 1988. If you thought this would be as good as Mathematica in every way, that doesn't make any sense. And, for any one who doesn't end up as a professor, Mathematica is going to cost them $1500, or whatever, maybe that's off. Sage will cost them $0.

G-Sage (Oct 28 '11)

Well, in Sage we like to be honest. And there is a lot of stuff we have that blows Mma out of the water, if you do those things. But remember, some of the questions you are asking are asking something different than Sage is answering. To be quite frank, there is nothing I need to do in my research or teaching that Sage cannot do. To me, the sort of symbolic things you are talking about are relatively arcane (and the things I do are probably arcane to you!). Sorry I can't expand on this but I need to rush off :( the point being that I think you are overstating the case of "very trivial" things Sage cannot do up to certain standards.

kcrisman (Oct 28 '11)

@Xaver And, I would like to add, if it seems like these things are so simple to you, perhaps you can program them to work better? That's the beauty of Sage.

G-Sage (Oct 28 '11)

@G-Sage to be fair, most mathematicians would like to do math, not necessarily program it :) which the BDFL often points out.

kcrisman (Oct 28 '11)

I'd like to try to resurrect this issue, if possible. Similarly to Xaver, I had high hopes for SAGE, but when comparing different symbolic simplification functions, I've come to realize the superiority of MMA's FullSimplify. I don't think there's any program/function that can even come close to that...

H. Arponen (Jan 08 '12)
see 1 more comment
i like this answer (click again to cancel)
0
i dont like this answer (click again to cancel)

On the other hand, I do think it could be useful to apply some simplification rules via substitution. For instance, you have lots of e^(I*sqrt(cos(l) - 1)*sqrt(2)) guys.

var('T')
C = B.substitute_expression(e^(sqrt(-2*cos(l) + 2))==T)

This isn't ideal, but better, I guess. Sometimes this sort of thing is quite helpful, though.

Also, sometimes using factor or expand proves useful.

link

posted Oct 27 '11

kcrisman gravatar image kcrisman
6639 13 66 150

Your answer

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
[hide preview]

Question tools

1 follower

Tags:

Stats:

Asked: Oct 27 '11

Seen: 1,748 times

Last updated: Oct 28 '11

powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.