Choosing the Best Symbolic Language for Mathematical Manipulation on a PC

  • Mathematica
  • Thread starter Phrak
  • Start date
  • Tags
    Language
In summary, Mathematica and Maple are both popular choices for performing symbolic manipulation of mathematical expressions on a PC. However, Mathematica may have some quirks and limitations, as noted by some users. Other options include Lisp, Prolog, Snobol, and Mathcad. Maple is often considered to be more user-friendly and practical, with more straightforward commands and less case sensitivity. It also has the ability to handle a wide range of problems, including differential geometry and tensor manipulation in multiple dimensions. While Mathematica may have a larger following, many users prefer Maple for its ease of use and practicality. Ultimately, it may be worth considering both options and doing additional research to determine which would be the best fit for individual needs and preferences.
  • #1
Phrak
4,267
6
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.
 
Physics news on Phys.org
  • #2
I am highly biased but I would pick Mathematica without hesitation.
 
  • #3
DaleSpam said:
I am highly biased but I would pick Mathematica without hesitation.

I've been reading the online and .pdf text found http://www.mathprogramming-intro.org/" . 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:
  • #4
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:

[tex]
\int^\pi_0 sin(t) dt
[/tex]

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:
  • #5
Thanks sokrates. I should have asked about the set: mathematica, maple, MATLAB and mathcad, instead. Are there any I've left out?

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:
  • #6
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
sokrates said:
If your experience with Mathematica is just a few days long, I'd consider switching.

This is true.

Have you started your work on differential geometry in Mathematica 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.

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:
  • #8
This http://en.wikipedia.org/wiki/Comparison_of_computer_algebra_systems" might be helpful.
 
Last edited by a moderator:
  • #9
sokrates said:
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.
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
Phrak said:
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.
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
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:
  • #12
DaleSpam said:
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.

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
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:
  • #14
Phrak said:
Does the notebook interface have color code brackets?
Yes.
 
  • #15
DaleSpam said:
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.

Sure. And that's all my opinion. I used them both, I like one more.
 
  • #16
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:
  • #17
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/

Thank you!
 
Last edited by a moderator:
  • #18
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:
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:
  • #19
@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
juliette sekx said:
@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);

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:
  • #21
Hi Phrak,

In maple you don't need to create the Levi-Civita symbol yourself, it's already intrinsically there in Maple (so you don't have to wait 14 seconds for it to be created, and that's why I was wondering what you were comparing mathematica to)

in Maple if you apply the commands:
Code:
with(Physics);
Setup(dimension=8,signature=`+`);

The rank 8, Euclidean, Levi-Civita symbol is created and accessible (this occurs in real time, the timer didn't even change from 0.00s to 0.01s).

For example, if I want to find the (1,2,3,4,5,6,7,8) component, I type:

Code:
LeviCivita[1, 2, 3, 4, 5, 6, 7, 8];

And I get the answer: 1

Code:
LeviCivita[2, 3, 4, 5, 6, 7, 8, 1];

Gives the answer: -1

Code:
LeviCivita[2, 3, 4, 5, 6, 7, 8, 8]

Gives the answer: 0


This all happens essentially in real time,

After applying all of those commands the timer still hasn't gone up from 0.00s to 0.01s.
 
  • #22
Hi again,
I just tested what would happen if I cranked up the dimension to 30,
and the Levi-Civita symbol still works flawlessly, and reports answers in real time.
 
  • #23
Hi juliette

I've discoverd that mathematica also has a levi-civita function.

Here're some timing results.

Code:
In:=  myTiming[LeviCivitaTensor[8]]
Out=  0.0906

In:=  myTiming[LeviCivitaTensor[9]]
Out=  0.875

In:=  myTiming[LeviCivitaTensor[7]]
Out=  0.0000125

In:=  a = LeviCivitaTensor[7]
In:=  b = LeviCivitaTensor[7]
In:=  myTiming[Dot[a,b]]

Out= 0.219

I'm a bit concerned that my computer can't manage a dot b in eight dimenions without running out of memory, so the test was for 7 dimensions.
 
  • #24
Neat,
So it looks like Mathematica takes 0.8 seconds to make a rank 9 Levi-Civita pseudotensor, while Maple takes less than 0.01 seconds to make one of rank 30.

Also,
Maple's dot product of the rank 30 Levi-Civita with itself takes 0.49 seconds and 6.87MB of memory.

But it just seems to good. What exactly is mathematica's dot product function doing ??
In terms of tensor contractions, how would you write it ??
 
  • #25
They should really be compared on the same machine. Mine is a 2.2GHz AMD Athlon with 1G RAM running 46 processes.

Strange. how do you figure 6.87MB? A rank 30 tensor has 30^30 total entries. A rank 30 levi-civita symbol has 30! nonzero entries.

What does your code look like?
 
Last edited:
  • #26
Mine's 2GHz with 4GB of RAM, and 79 processes.

I got the number 6.87MB from the bottom right corner of maple, it tells you how much memory is being used, and how much CPU time has been used. Another way would be to start the task manager and click on 'processes' and it will say how much memory Maple is taking in total.

I agree that the rank 30 levi-civita should in theory take up a lot more space. I'm not sure how Maple does it, but it's very easy to imagine some ways that it could make use of symmetry/anti-symmetry relations to cut down on the number of slots in memory that it REALLY needs to occupy.

I don't even think it stores all the non-zero entries in a hash table. When I ask it for the [i,j,k,l...n] th entry of the tensor, it may simply be computing the answer by using an appropirate algorithm and the index entries as input. This way, it would just need to store some of the entries of the tensor, and it can figure out the rest based on its knowledge of the structure of the levi-civita object.

To make the tensor all you have to do is:

with(Physics); Setup(dimension = 30, signature = `+`);

Then to access the 1,2,3,...30'th entry of the tensor, you just do:

LeviCivita[seq(i, i = 1 .. 30)];

And it returns the answer 1. If you want a different entry you would do:

LeviCivita[1,2,3,20,30,29,...] for example.

To do the dot product you'd do: LeviCivita.LeviCivita

But I'm not sure if this is the same dot product you're talking about, how would you write it as a tensor contraction ??
 
  • #27
I'm happy to discover I misapplied the dot product. It doesn't behave as I expected for over 3 dimenions, and yields way too many terms. I haven't yet found what built-in function applies to the inner product of sparse tensors (sparse means it has a lot of elements equal to zero).

I had some time to today thinking about how the sparse levi-civita tensor could be generated and stored in a memory-efficient manner. In mathematica all input is stored as acyclic directed trees.

A fully populated tensor would be a tree with 8 branches. Each branch would have 8 limbs, and so on to 8^8 leaves which terminate the tree.

Now consider the levi-civita tensor that only has 8! out of a total of 8^8 elements. If all the leaves of some particular level of a sub-branch contains all zeroes then the branch can terminate in a leaf. Each of these leaves can be represented by zero.

For example, all the levi civita tensors, epsilon212prstu are equal to zero, so all of them can be represnted by a single zero valued leaf.

Anyway, when populated in this way an N dimensional levi-civita tensor would contain:

Number of entries containing plus or minus one:

[tex]N![/tex]

Number of entries containing zero:

[tex]\Sigma_{A=1}^{N-1} \frac{N!}{A!} (N-A)[/tex]

Number of List function entries:

[tex]\Sigma_{P=1}^N \frac{N!}{P!}[/tex]

In eight dimensions the quantites are 40,320, 444,648, and 69,281, respectively. It's a lot less than 16 million, and is probably the way maple stores it's levi-civita. The advantage increases with increasing dimension in the order of factorial/power.
 
Last edited:
  • #28
That's neat.

I was thinking it might also be computing many of those values rather than storing them in memory.

For example, I would guess that you haven't memorized what each element of the 3d levi-civita is, but you'd still be able to tell me what E_{3,1,2} is pretty easily, based on your knowledge of E_{1,2,3} and the symmetry under cyclic permutations. Perhaps maple only stores certain important non-zero elements and then computes what the other ones are the way our brain does.

But what exactly is the dot product between two rank 8 tensors ??

Or more simply, what is the dot product between two rank 8 tensors ??

Let's say the tensors are fully covariant.
 
  • #29
I'm very new at this whole symbolic programming thing. I've had mathematica 2 weeks.

I'd thought a.b was a generalized dot product, but it isn't. The function to use in mathematica is Inner to take an inner product of tensors.
 
  • #30
calculate the Einstein tensor...


Phrak said:
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.
I recommend Mathematica because of the math kernel.

I located a Maple sequence called Einstein(g, Ricci, R) of a tensor_package.

tensor[Einstein] - compute the covariant components of the Einstein tensor.

I am currently using the Mathematica package Calculating the Einstein_Tensor by Pekka Janhunen for General Relativity calculations.

Given an N x N matrix, given a metric with lower indices; and x-, and N-vector (coordinates); EinsteinTensor[g,x] computes the Einstein_tensor (an N x N matrix) with lower indices.

Any recommendations on other Mathematica packages that can calculate the Einstein_tensor?

Reference:
http://library.wolfram.com/infocenter/MathSource/162/"
http://www.maplesoft.com/support/help/AddOns/view.aspx?path=tensor/Einstein"
 
Last edited by a moderator:
  • #31


Orion1 said:

Any recommendations on other Mathematica packages that can calculate the Einstein_tensor?

Just off hand, given the Ricci tensor and metric in covariant form, it shouldn't be too difficult to obtain the Einstein tensor using matrix operations. Both are rank two tensors. It's involves only matrix addition and scalar multiplication of a matrix, plus finding the trace of the Ricci tensor, where the covariant form is implicit.

Ultimately, I plead ignorance of all this for the most part, being fairly new at it. Hope this can help, anyway.
 
Last edited:
  • #32
This is kind of an out of the box suggestion, but what about Wolfram Alpha? It is convenient to have the tools available in any web browser, even an i-phone.

http://www.wolframalpha.com/examples/"
 
Last edited by a moderator:

1. What is the importance of choosing the best symbolic language for mathematical manipulation on a PC?

The choice of symbolic language for mathematical manipulation on a PC is crucial because it affects the efficiency and accuracy of mathematical calculations and simulations. It also determines the ease of use and compatibility with other software and hardware.

2. What are the most commonly used symbolic languages for mathematical manipulation on a PC?

The most commonly used symbolic languages for mathematical manipulation on a PC are MATLAB, Mathematica, Maple, and Python. These languages have powerful built-in functions and libraries for mathematical operations and are widely used in various fields of science and engineering.

3. How do I determine which symbolic language is best for my specific needs?

The best way to determine which symbolic language is best for your needs is to consider the type of mathematical operations you will be performing, the complexity of your calculations, and the compatibility with other software and hardware. You can also try out different languages and compare their features and user-friendliness.

4. Can I use multiple symbolic languages on a PC?

Yes, you can use multiple symbolic languages on a PC. Many software packages allow for integration and interoperability between different languages, allowing you to choose the best language for each specific task.

5. Are there any free options for symbolic languages on a PC?

Yes, there are free options for symbolic languages on a PC, such as Python and Octave. These languages have a wide range of mathematical functions and can be used for various scientific and engineering applications. However, they may not have the same level of support and features as paid options like MATLAB and Mathematica.

Similar threads

  • STEM Academic Advising
Replies
21
Views
2K
  • Programming and Computer Science
Replies
31
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
265
Replies
4
Views
3K
  • STEM Academic Advising
Replies
1
Views
1K
  • STEM Academic Advising
Replies
6
Views
7K
  • Computing and Technology
Replies
1
Views
7K
  • STEM Academic Advising
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
2
Replies
39
Views
4K
Back
Top