Why does Maple take (much) more time on calculating than Mathematica? For example, some time ago, I calculate this integration:
although Maple is able to give the correct answer, but it takes about 5 minutes to achieve this answer. However, when I did the same thing in Mathematica, the time spent on calculating is less than one minute. Why is there such a notable distinction between the two computer algebra systems?
PS: Versions of the two softwares that I use are Maple 11 and Mathematica 6.
Differences work both ways
You could ask your question the other way around: "Why does Mathematica takes (much) more time on calculating than Maple?"
For instance, on my system (Windows XP SP2, Pentium 4HT, x86-32, Mathematica 6.0.1, Maple 11.01), it takes about 12 seconds to Mathematica to compute the following integral
whereas Maple needs less than a fifth of a second!
restart;
st := time(); `assuming`([int((a+c-sdfd+34*e)*exp((a+4*c-d+34*e)*x^2+(b-54*c+4*h)*x+c), x = -infinity .. infinity)], [a+4*c-d+34*e < 0]); time()-st;
0.171Most of the time, you will not notice any significant differences in the speed of computation between both systems. Still, it might occur that a specific expression is (much) slower to evaluate in one system than the other. Most of the time, this is due to the way that each systems are going to analyze, simplify, transform, look for patterns, etc., for a given expression, and consequently this is going to influence the choice and order of algorithms that may be applied before finding the solution.
Finally, do not expect that both systems use the same algorithms in the same order, nor that they use what is taught to human beings in a calculus course.
Regards,
--
Jean-Marc
Another case
Indeed, the example you give is just opposite to mine, but more often the case is Maple takes much more time, especially when I want to get a precise symbol number answer. I don't know whether my PC has something that is not suitable for calculating. Another case is to find the ith prime number using ithprime(i), however when the argument is larger than 10^7 or 10^8 there is no response on my PC within 10 minutes. There is really a extraordinary difference indeed.
Dust you are, to dust you shall return.
Integration differences
Mathematica uses a lot of precomputed tables, which result in very fast answers. Of course, it also results in NO answers when you are out of those tables, or even when you ask for minor variations on a problem. Maple uses a lot of algorithms, so that you get more answers, sometimes at considerable computation cost. It is a different strategy.
There are also times where both Maple and Mathematica use outdated algorithms. This is often the case in Maple for integration, and is often the case in Mathematica when it comes to solving differential equations (or even solving systems of equations). In fact, this list could go on and on, with each system having 20-30 different major pieces of functionality in each column.
I prefer Maple's strategy. Table lookup, while potentially fast, is a maintenance and Quality Assurance nightmare [as inttrans as proven beyond a reasonable doubt].
speed of ithprime
I agree with what gulliet said: each of Maple and Mathematica have strengths and weaknesses, and each will best the other on specific computations.
What JacquesC said might be true in general (and is certainly true for ODEs), but it is the opposite of the truth in the example you give of
ithprime. From the code,ithprimeuses a table for numbers up to 22300000; after that, it simply tests every second integer to see if it is prime. Such a simple test is obviously too slow for practical use; so Maple does not have a viable ithprime procedure for numbers much outside the table.Mathematica, in contrast, uses a general procedure based on finding roots and
numtheory:-pi. This requires a fast version ofpi, which exists (see, for example, Bressoud & Wagon: it is due to Legendre) and is implemented in Mathematica, but not in Maple. So this is all an embarrassment for Maple.Returning to the general issue of comparison, I do not know of anyone who has done this for Maple 11 and Mathematica 6. It would take a large effort. For earlier versions of the two, the general consensus seemed to strongly hold that Maple was more reliable. I do not know about speed, but reliability is obviously more important.
algorithms for pi(n)
Wikipedia has a good description of algorithms for pi(n).
From a quick reading, it appears that Mathematica's approach might be suboptimal. It would be nice if Maplesoft would implement a viable general
pi—perhaps following Lehmer, rather than Legendre.Core improvements
Read the tea leaves -- or in this case, the What's New, for say Maple V R4 until Maple 11. Create a nice tally chart of the amount of relative effort spent on different parts of the system and in different categories (core improvements, bug fixing and rationalization, new features asked for by users, ``innovative'' features). You'll see clear and obvious trends [not all linear!], although it will be hard to judge how much bug fixing has really happened.
Note that there is also a strong correlation between this timeline and the professionalization of Maple development. In other words, over that same timeframe, Maple development shifted from being done 90% in research labs, 10% at the company, to 10/90. So a strong shift towards things that can ``sell''.
It is also important to note that the developers (at least the ones I know) at Maplesoft really would love to make a lot of core improvements. They all have long personal lists of improvements that they would really like to see done. But, unlike developers working at Google, their schedule does not allow them the time for that.
That is really one of the huge dilemma facing a company like Maplesoft: how much time should be spent on creating new features that will sell more product versus spending time on core features to make the product better.
It is interesting to contrast Maplesoft's path with Wolfram Research's. Creating a similar tally chart from their What's New for the same period creates a completely different picture, with emphasis over time on completely different areas!
in such a case ...
In such a case I look at simplier cases, may be the indefinite solution. I guess that M has 2 problems (but I am not sure): it will try to find the formal solution has no singularities and the would try to find limits. The first can be avoided (if you know it is allowed) like the following: restart; st:=time(): Int((sin(x)/x)^20,x=-infinity..infinity,'continuous'); evalf(%); time()-st; 0.9635047953 seconds needed = 0.015 However for exponent=100 that does not help: while M finds a solution quickly it hangs up at the limits. To cure that kick off sin and cos terms (as they will vanish), some Sine integrals survive and now see what happens: st:=time(): Int((sin(x)/x)^100,x); V:=value(%): remove(has,V,cos): W:=remove(has,%,sin): limit(W,x=infinity)-limit(W,x=-infinity); `seconds needed`=time()-st; evalf(%%); seconds needed = 0.499 0.4335090115 The answer is given in 1/2 second and evaluating the quite long result (= rational number * Pi) coincides with a purely numerical solution.