44
$\begingroup$

I am reading the document How Maple Compares to Mathematica. On page 15 there is an example where Mathematica produces wrong results. Does anybody know why?

MAPLE:

enter image description here

MATHEMATICA:

enter image description here

Also on page 17 the given results are extreme:

enter image description here

Is this really true and if so, why?

$\endgroup$
5
  • 5
    $\begingroup$ See http://www.wolfram.com/mathematica/compare-mathematica/compare-mathematica-and-maple.html for a view from the other side. $\endgroup$
    – Karsten7
    Sep 19, 2014 at 15:31
  • 8
    $\begingroup$ You have to understand that this is marketing stuff, I'm sure the view from the WRI point of view will be totally the opposite. Don't read too much into this. $\endgroup$
    – RunnyKine
    Sep 19, 2014 at 15:32
  • 7
    $\begingroup$ Hard to comment on the polynomial solving without access to the actual test suite. $\endgroup$ Sep 19, 2014 at 16:19
  • $\begingroup$ If you are a beginner or non-academic and like eye candy then Mathematica will work wonders for you, of course it will still work for academics and the learning curve isn't very steep. If you are an advanced student or professional Maple is right up your alley but fair warning it has a steep learning curve. Maple is trying to eye candy up it's software down to mathematica's level to please more of the masses. They both have their weaknesses and strengths but be warned Mathematica doesn't play fair at all in the marketing game. $\endgroup$
    – user21883
    Nov 3, 2014 at 18:08
  • 6
    $\begingroup$ @3Mdude I just wanted to point out the fact that your comment "does not present any evidence", is not backed by a "real account" and is purely opinion. While I believe comments like yours have their uses, perhaps this is not the place for such a comment. Would you consider making your making your narrative more substantial with e.g. references, or taking other action? Possibly people in chat would like to hear about your experiences and it is unfortunate that the system will not allow you to chat until you have more rep :(. $\endgroup$ Nov 24, 2014 at 0:02

3 Answers 3

52
$\begingroup$

The first example seems to intentionally set Mathematica up to "fail" by specifying insufficient input accuracy. With additional precision:

ClearAll[s]
s[i_] := s[i] = 2*s[i - 1] - 3*s[i - 1]^2
s[0] = 0.3`30;
s[40]
0.333333

And Mathematica is capable of far greater precision if necessary:

ClearAll[s]
$RecursionLimit = ∞
s[i_] := s[i] = 2*s[i - 1] - 3*s[i - 1]^2
s[0] = 0.3`5000;
s[8280]
0.333333333333333

By the way this kind of iteration can be nicely written with Nest:

Nest[2 # - 3 #^2 &, 0.3`5000, 8280]
0.333333333333333

I read the section of the linked PDF from which this example comes. I think Maple is simply using machine precision here, e.g.:

Nest[2 # - 3 #^2 &, .3, 40]
0.333333

To imply that this is superior to Mathematica's result while specifically triggering the Mathematica arbitrary precision engine seems disingenuous. Further the paper makes the claim:

The last term in the output says that s40=0.×1062 , which is not a good approximation of 3.

There is nothing in the computation to warn the user that the results may not be reliable at every step.

This is false. Hovering over the pink error box tells you exactly what is going on:

No significant digits are available to display.

I think this is an example of attempting to paint a weakness of Maple as a strength, though admittedly I haven't used Maple in many years so I don't know if it also has generalized precision tracking.

$\endgroup$
2
  • 27
    $\begingroup$ This marketing nonsense never changes. It is always an expert on one software system against a noob on the other. It would make much more sense, if each company would concentrate on improving their software, making it compatible to each other, and letting the user decide which one to use for what. $\endgroup$
    – Karsten7
    Sep 19, 2014 at 16:04
  • $\begingroup$ I have programmed for many years with IDL (Interactive Data Language, for mainly particle detection and tracking in digital Images). I then "quickly" transferred my IDL software to mathematica and it looked so much shorter and nicer. Now I found this document which confused me. $\endgroup$
    – mrz
    Sep 19, 2014 at 16:58
41
$\begingroup$

Without commenting on how much attention one should pay to marketing literature: the second example is somewhat relevant. Mathematica's polynomial factoring algorithm is known to be at least fifteen years behind the state of the art, and things that Maple will factor in seconds will go away (literally) forever in Mathematica. This is, of course, not too surprising: Maple is, at heart, a computer algebra system, while, as people on this forum know well, Wolfram Research has been prioritizing adding snazzy features to strengthening the base. I have nothing against snazzy features, though it annoys me to have to go to other providers if I need to factor a polynomial.

$\endgroup$
10
  • 14
    $\begingroup$ The main statement is correct, or perhaps an underestimate (but you did say "at least"). But factoring is not likely to be the bottleneck in the equation solving. If it is, there is something very skewed about the suite. More likely it might involve systems for which GroebnerBasis hangs, or where root extraction hangs, or perhaps there is another bottleneck I am failing to guess at. For what it's worth, updating the univariate factorization to a 21st century method is on the to-do list. Somewhere. $\endgroup$ Sep 19, 2014 at 17:36
  • 6
    $\begingroup$ @DanielLichtblau A little bird told me that Mark van Hoeij (sp) would be delighted to help you improve the factoring algorithm. Since his is the state of the art, and what the other CAS systems are using... $\endgroup$
    – Igor Rivin
    Sep 19, 2014 at 17:41
  • 12
    $\begingroup$ [This is incredibly embarassing, but...] we actually have an implementation of the van Hoeij algorithm. This was one of our more successful intern projects, from way back in 2003. I was supervisor so I take around epsilon credit. All of which I lose from never having taken the (actually nontrivial) time to integrate it into the system. Mind you, this implementation does not account for later improvements by Novocin and van Hoeij. But it is almost certainly good enough for practical purposes. $\endgroup$ Sep 19, 2014 at 17:48
  • 6
    $\begingroup$ @xzczd from wikipedia: "an arbitrarily small positive quantity is commonly denoted ε" :D $\endgroup$
    – Yves Klett
    Sep 20, 2014 at 8:11
  • 7
    $\begingroup$ @DanielLichtblau I would certainly encourage you to do the needful to integrate it, and while good is the enemy of the best, WRI certainly has the resources to buy itself the bragging rights for "the best implementation of...", which one might argue is important for a core algorithm like polynomial factoring. $\endgroup$
    – Igor Rivin
    Sep 20, 2014 at 16:34
33
$\begingroup$

The critical issue in the first example is that Mathematica is using significance arithmetic to track precision. This is certainly billed as a feature by Wolfram Research. As we see in this example though, it can be portrayed as a weakness. In truth, you might need to know what you're doing to use it correctly. In this answer, I mentioned that significance arithmetic can be problematic in iterative dynamics in the neighborhood of a point a super-attractive fixed point where $f'(x_0)=0$, which is exactly the situation here. To see what's going on, consider the following:

Clear[s];
s[i_] := s[i] = 2*s[i - 1] - 3*s[i - 1]^2;
s[0] = SetPrecision[3/10, 20];
values = Table[s[i], {i, 0, 40, 5}];
precision = Precision /@ values;
Grid[Transpose[{values, precision}],
  Dividers -> All, Alignment -> Left]

enter image description here

As we examine every fifth iterate, we see that it decreases just about linearly.

Differences[precision]
(* Out: {-2.94007, -3.0103, -3.0103, -3.0103, -3.0103, -3.0103, -2.00843, 0.} *)

In fact, if you understand significance arithmetic as described in that answer and the references therein, we expect the significance of each iterate to decrease by about $2\log_{10}(2) \approx 0.60206$ and 5 times this yields the $-3.0103$ that we see above.

However, if we track the significance by examining $f(x)=2x-3x^2$ near $x=1/3$ using the derivative to obtain a first order approximation, we should expect the number of significant digits to increase! Thus, sometimes it is incumbent on the user to increase the significance manually.

By resetting the precision this way, we can emulate the Maple behavior.

Clear[s2];
s2[i_] := s2[i] = SetPrecision[2*s2[i - 1] - 3*s2[i - 1]^2, 20];
s2[0] = SetPrecision[3/10, 20];
values = Table[s2[i], {i, 0, 40, 5}];
precision = Precision /@ values;
Grid[Transpose[{values, precision}],
  Dividers -> All, Alignment -> Left]

enter image description here

To be absolutely clear, though, we are essentially using fixed precision by resetting the precision in this way, though the precision is greater than machine precision. The ability to track the precision can be quite nice and we'd certainly prefer to the conservative estimate that Mathematica gives, rather than an optimistic estimate that returns false precision.

$\endgroup$
3
  • $\begingroup$ Nice answer, but terrible reference. The Wikipedia article is really about "significant figures arithmetic", which has but little intersection with the error estimation process of modern significance arithmetic. $\endgroup$ Sep 19, 2014 at 18:19
  • $\begingroup$ @DanielLichtblau Oops - better? $\endgroup$ Sep 19, 2014 at 19:10
  • 3
    $\begingroup$ Yes. It's vague, but at least accurate. See also this. $\endgroup$ Sep 19, 2014 at 19:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.