Ask Your Question
3

full simplify, sage vs mathematica

asked 2011-10-27 17:38:16 +0100

Xaver gravatar image

updated 2015-08-10 18:54:59 +0100

FrédéricC gravatar image

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 ... (more)

edit retag flag offensive close merge delete

Comments

Is it really fully_simply?

G-Sage gravatar imageG-Sage ( 2011-10-27 17:54:28 +0100 )edit

@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 gravatar imageXaver ( 2011-10-27 19:48:48 +0100 )edit

What is `l` here? A symbolic variable?

benjaminfjones gravatar imagebenjaminfjones ( 2011-10-27 20:42:06 +0100 )edit
1

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 gravatar imagekcrisman ( 2011-10-27 21:51:54 +0100 )edit

@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 gravatar imageG-Sage ( 2011-10-27 22:28:41 +0100 )edit

2 Answers

Sort by » oldest newest most voted
2

answered 2011-10-28 04:21:54 +0100

Xaver gravatar image

updated 2015-08-08 10:29:10 +0100

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).

Update: see this http://thingwy.blogspot.de/

edit flag offensive delete link more

Comments

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 gravatar imageG-Sage ( 2011-10-28 07:45:04 +0100 )edit
1

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 gravatar imagekcrisman ( 2011-10-28 10:03:03 +0100 )edit

@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 gravatar imageG-Sage ( 2011-10-28 16:47:21 +0100 )edit

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

kcrisman gravatar imagekcrisman ( 2011-10-28 23:16:28 +0100 )edit
1

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... anyway, is something like that under development by SAGE members? I'd like to perhaps take part, although I'm probably not qualified... I have some experience with functional programming in mma though. It would be great to be able to completely migrate to SAGE! :)

H. Arponen gravatar imageH. Arponen ( 2012-01-08 11:20:57 +0100 )edit
0

answered 2011-10-27 21:58:51 +0100

kcrisman gravatar image

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.

edit flag offensive delete link more

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: 2011-10-27 17:38:16 +0100

Seen: 18,557 times

Last updated: Aug 08 '15