# Best Symbolic Language

1. Dec 8, 2009

### Phrak

What would be the friendliest programming language available for perform symbolic manipulaiton of mathematical expressions (on a PC)?

Mathematica seems to the most popular, but seems to contain a few quirks, though I've only studied over couple dozen hours.

On the list of possible choices I have Lisp, Prolog and Snobol and Mathematica.

2. Dec 9, 2009

### Staff: Mentor

I am highly biased but I would pick Mathematica without hesitation.

3. Dec 11, 2009

### Phrak

I've been reading the online and .pdf text found http://www.mathprogramming-intro.org/" [Broken]. You might even find it a good read if you are interested in the Mathematica kernel, and aren't altogether familiar already.

I'm slightly familiar with symbolic language structure, after an introduction to lisp in 1984-1987. There's a great deal of similarity in the languages, having many shared notions emerging from MIT in the early 80's, as I recollect. Anyway, I was involved in the hardware side of dedicated lisp processors with embedded mathematica engines, so not required to know much at-all of lisp, and none of mathematica.

There seems to be an unavoidable exception involving the Set[] function (=).

If given, for example:

ClearAll[a,z,x,y];
a = z * Sin[x+y];
FullForm[a]

the returned value is:

Times[z, Sin [Plus[x, y]]].

Why doesn't 'a' simply evaluate t 'a'? Mathematica doesn't design return a as the leaf of

Set[a, Times[z, Sin [Plus[x, y]]]].

If this expression is given an L-value, we could write

b = a = z * Sin[x+y],

or

b = (a = z * Sin[x+y])

if the syntax is legal.

But asking mathematica to evaluate b would just return

Times[z, Sin [Plus[x, y]]] as far as I know (I don't yet have a copy of mathematica.)

All and all, this may be outside your interests, but I and very curious whether a symbolic processor is capable of placing the assignment rule on equal par with other rules.

Last edited by a moderator: May 4, 2017
4. Dec 11, 2009

### sokrates

I am highly biased as well, but using Mathematica and Maple

And since you said "friendliest" I say MAPLE. (I only used Maple 13 - and Mathematica 6.0)

BY FAR better than Mathematica, in that context.

Though not in your list, do consider it if you can access it:

I'll just give you an example

To evaluate the following integral:

$$\int^\pi_0 sin(t) dt$$

in Maple:

int(sin(t),t=0..pi);

whereas in Mathematica:

Integrate[Sin[t], {t,0,:pi:}]

This is exactly the way you should write it in Mathematica otherwise it'll yell. For instance you cannot write "sin" and you have to use square brackets instead of the natural parenthesis. In Maple, on the other hand, there's no case sensitivity, the commands are much more straightforward. It'll immediately "get" you because it's meant for "ease" rather than verbose & formal syntax. And needless to say, it can take care of ANYTHING Mathematica handles.

Plus, by just right clicking a certain expression in Maple, you can see the available options,
factoring, integrating , solving , isolating and all other stuff you can imagine, without messing with the help commands or looking up every little thing in google.

It is NOT that popular but it's way better and practical than Mathematica, IMO.

Plus, you can convert expressions to LaTeX for quick formula typing, or to MATLAB or to C++ syntax, where you can check things more quickly if you are familiar with them.

You could immediately post the formulas you are playing with in Maple here, because this website also supports TEX format - you don't even have to learn it. Just copy and paste.

I have tackled research level problems with Maple, and I just love it.

I also recommend the book "Mathematica and Maple" ( I forgot by whom) which shows tricks that you'll never find elsewhere.

Let me know of your final decision!

Last edited: Dec 11, 2009
5. Dec 11, 2009

### Phrak

I've very torn about this. I've become so enamored with mathematica over a few days, that I could be willing to put up with a lot of extra effort and unfriendliness to use it over other languages.

Second to this, I have some pretty odd requirements. I need a language to handle differential geometry. I need to manipulate tensors in eight dimensions, and it could get worse--like sixteen or more. I need to be able to map four dimensional complex-valued tensors to eight dimensional real-valued tensors in eight dimensions. I need to partition tensors in space-time coordinates into subspaces such as space4 and space3time1.

Can maple manage my odd requirements?

Last edited: Dec 11, 2009
6. Dec 11, 2009

### sokrates

Well, honestly that goes way over my experience with Maple, but as far as I know (also from the book I mentioned) if Mathematica can handle it, Maple should be able to as well, in principle.

Of course, for the specific thing you want, you might need additional toolboxes etc... With a quick google search I found separate, stand-alone toolboxes (like atlas) for Maple on what you mention but I don't know whether you need such a thing or not.

If your experience with Mathematica is just a few days long, I'd consider switching. Have you started your work on differential geometry in Matehmatica already? what are the specific functions you are using? I am pretty sure they have Maple equivalents.

Believe me, it's worth the effort. It's one step going back, and hundred yards forward.

7. Dec 11, 2009

### Phrak

This is true.

Egads. Now I'm really torn. I'll do the research on Maple. How much does a private edition cost? Maybe I could buy both.

Last edited: Dec 11, 2009
8. Dec 11, 2009

### Edgardo

This http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems" [Broken] might be helpful.

Last edited by a moderator: May 4, 2017
9. Dec 12, 2009

### Staff: Mentor

I fully agree that the OP should check his options, but the things you mention here I am very aware of and consider them to be a significant advantage of Mathematica over all other math systems. The notational consistency is a big advantage. You always know that a square bracket is a function call and that a parenthesis is defining order of precedence, there is never any ambiguity which saves lots of time in debugging and troubleshooting. You automatically know that any custom function you write will not conflict with any built-in function simply by starting it with a lower case. Also if you don't know the name of a function you can usually guess it immediately. I really value the notational consistency of Mathematica.

10. Dec 12, 2009

### Staff: Mentor

In mathematica there are a variety of set operators depending on what assignment you want made and what you want it associated with and when you want it evaluated. For example, the UpSet operator (^=) associates the assignment with the symbol at the first level in the lhs, and the TagSet operator (/:) associates the assignment with any arbitrary symbol, not necessarily even appearing in the lhs or the rhs. There is also SetDelayed which sets the lhs to the rhs, but defers evaluation of the rhs until the lhs is called. There is also Rule (->) which sets the lhs to the rhs for the purpose of a single expression, but does not associate the rule with either the lhs nor the rhs. Basically, there is a flavor of Set for most needs.

11. Dec 12, 2009

### Phrak

I found a price holiday price break on mathematica 7 home edition for 250,http://www.wolfram.com/holiday/" --either that, or they are set to release version 8.

Dale, after learning more about the evaluation kernel, perhaps I'll be able to say something intelligent about the status of the equal sign in mathematica.

My concerns about mathematica is that I expect a brutal learning curve in comparison to maple, learning how a few hundred rules can be expected to behave, and getting lost in levels and levels of brackets. Does the notebook interface have color code brackets?

Last edited by a moderator: Apr 24, 2017
12. Dec 12, 2009

### sokrates

The notational consistency is usually a nuisance. You don't write the equivalent of a 10,000 line C++ code with these symbolic tools anyway. I don't accept it as an excuse for easy debugging.

Most of the time you are trying to carry out a piece of calculation (otherwise why not Matlab or C++ for extensive programming?), and the interface and strange rules are getting in the way.

Plus, Mathematica makes it really hard to program anything, because of its almost stupid way of outputting results.

Just doing a naive:
Solve x^2 = 4 and feed the result to the following expression needs hours of Google search - with no guarantee of success. You might know the answers if you invested enough time in understanding it, but I am sure it wasn't easy. Well it's not easy for me after 4-5 years of playing with it.

The bottom-line: It's not straightforward. The syntax is very tiresome, error reports are ugly, code writing is close to impossible.

And I was just trying to handle elementary matrix manipulation, ODEs, eigenvalue problems etc... etc...

I accidentally bumped into Maple - and it feels like Linux after Windows. You can't see the difference until you experience it. Phrak needs to consider his options. Seriously.

13. Dec 12, 2009

### Staff: Mentor

That is all opinion and my opinion is exactly opposite. I picked up the syntax very quickly and enjoyed it immensely from day 1 with equal or less of a learning curve than most programming languages. I certainly could solve a polynomial and use the result within the first day using only the built-in help. Perhaps the difference between us is simply that I understand and agree with the philosophy behind the design choices, so they always "clicked" for me.

But I do agree that Phrak should look around and find what works best for him. No tool is "one size fits all", not even my favorite tool.

Last edited: Dec 12, 2009
14. Dec 12, 2009

### Staff: Mentor

Yes.

15. Dec 12, 2009

### sokrates

Sure. And that's all my opinion. I used them both, I like one more.

16. Dec 12, 2009

### Phrak

I hope this does not turn off the discussion, and I appreciate both your remarks; I sprung for mathematica.

My choice is multiple. Beyond being biased toward mathematica from the beginning, I could not discover if maple is capable of manipulating tensor expressions on Riemann manifolds with complex entries using its built in functions, or even if I could build my own using maple.

Secondarily, I have a long standing curiosity to know, in formal code, what it looks like, when we do what we do, in solving algebraic expressions. Maple does have a symbolic module of it's own, but I could not discover how it's implimented.

I also have mathcad for actual numerical results, though for simpler problems. And I still have the choice of purchasing maple and evem matlab, at a later time.

Last edited: Dec 12, 2009
17. Dec 19, 2009

### juliette sekx

I think both are equally powerful. I am just curious to see what more people use, because that's essentially what's going to survive in the end. Could everyone please take 2 seconds to vote for which one they use the most ??

http://users.ox.ac.uk/~hert3229/ [Broken]

Thank you!

Last edited by a moderator: May 4, 2017
18. Dec 19, 2009

### Phrak

This may depend on what you want.

On my PC it took mathematica 14 seconds to generate the Levi-Civita symbol in 8 dimensions using

Code (Text):
Dimensions[Array
[Signature[{#1, #2, #3, #4, #5, #6, #7, #8}] &, {8, 8, 8, 8, 8, 8, 8, 8}]]
I used the Dimensions function so that the print_to_screen of Array doesn't occur and get included in the timing.

Sorry if this doesn't make any sense to those that don't do tensor calculus. I initialized an 8 dimensional array of rank 8 with calculated integer values.

Last edited: Dec 19, 2009
19. Dec 20, 2009

### juliette sekx

@Phrak,

I'm guessing that that's an 8x8x8x8x8x8x8x8 tensor ?

I don't understand your point, how does 14 seconds compare to other software ??

I don't work with tensors much but I know Maple can, given a metric, calculate all Cristoffel symbols, Riemann tensor, Ricci Tensor, Ricci scalar, Einstein Tensor, Weyl Tensor, plus some other things, all in just 0.06 seconds:

with(tensor):coords:=[x,y,u,v]:
g:=array(symmetric,sparse,1..4,1..4);
g[1,1]:=L(u)^2*exp(2*beta(u)):g[2,2]:=L(u)^2*exp(-2*beta(u)):g[3,4]:=-1,g[4,3]:=-1:
metric:=create([-1,-1],eval(g));

tensorsGR(coords,metric,contra_metric,det_met,C1,C2,Rm,Rc,R,G,C):
display_allGR(coords,metric,contra_metric,det_met,C1,C2,Rm,Rc,R,G,C);

20. Dec 20, 2009

### Phrak

That's right, an 8x8x8x8x8x8x8x8 tensor; sixteen milion terms, so I'm concerned over execution time.

Would you like to compare speeds of execution? I'd like to know how mathematica compares to maple in tensor algebra. Since there's a lot of difference in time between 4 and 8 dimensions, even memory managment may enter into how well each manages. I think filling spare arrays compare as the factorial of the dimension; 4! to 8!-- yikes!

Can you see how maple times at generating a completely antisymmetric tensor in eight dimensions?

Last edited: Dec 20, 2009