How to crash reduce instantly

Developers
James
2009-10-10
2012-11-20

• James
2009-10-10

As a new user, naively type in the following:

1: 5!&amp;lt;return&gt;

but then, oops, you forget the semicolon:

1: ;&amp;lt;return&gt;

That's it.  Reduce will never return.  &quot;ps&quot; says reduce is in state S, &quot;Interruptible sleep (waiting for an event to complete)&quot;.

This is not a good experience for the naive new user.  And, just as bad, the operator &quot;factorial&quot; is not &quot;discoverable&quot; through this naive action of typing &quot;!&quot;.

Perhaps entering the character &quot;!&quot;, outside of any legitimate context, should trap to an error message about using the operator &quot;factorial&quot; for calculating the factorial of a number.

James

• James
2009-10-12

Well, here's another.  I was looking through &quot;DRAFT: Comparing the speed of programs for sparse polynomial multiplication&quot; by Richard Fateman, July 2, 2002, where he asks &quot;How should one program the multiplication of sparse polynomials?&quot; and examines  p^20 = (1+x+y+z)^20.  There is a particular reference to results produced by Reduce, using the code

on time;
a:=(1+x+y+z)^20\$
length(a*(a+1));

which is all good and well, since it seems to run without problem.

But, if instead, we simply look at the result

(1+x+y+z)^20;

First, on the command line, Reduce outputs

Unrecognised keyword &quot;\math&quot;

and, in the Reduce window, there can be seen, amidst all the polynomial coefficients, &quot;malformed expression&quot;.

If you then scroll upward through the output in the Reduce window, on the command line, Reduce will begin to output additional error messages, and then, finally, terminate altogether, closing the Reduce window.

The resulting command line messages look like this:

Unrecognised keyword &quot;\math&quot;

Unrecognised keyword &quot;\math&quot;

Unrecognised keyword &quot;\math&quot;

TeX syntax problem

&quot;{&quot; expected after keyword &quot;\mathrm&quot;

Unrecognised keyword &quot;\math&quot;

Unrecognised keyword &quot;\m&quot;

&quot;{&quot; expected after keyword &quot;\mathrm&quot;

&quot;{&quot; expected after keyword &quot;\mathrm&quot;

Unrecognised keyword &quot;\mathr&quot;

Unrecognised keyword &quot;\ma&quot;

Aborted

James

• Arthur Norman
2009-10-12

I suspect that the (1+x+y+z)^20 expression is too big for the &quot;fancy&quot; mode display, and that something internal overflows in a clumsy manner and smashes. If you are going to display big things like this then &quot;off fancy;&quot; will stop Reduce trying to display it cleverly and may be more robust.  I will try AT SOME STAGE to look into where the overflow happens or see if I can make the behaviour softer but not this week!

Re the case of an exclamation mark at the end of a line or an otherwise missing semicolon to terminate an input statement, inspiration for a neat resolution has not yet struck me. It counts as bad user input and my bet is that whatever we do SOME ingenious bad user input will lead to confusion. Maybe somebody else can suggest something. Arthur

• James
2009-10-13

I see that, yes, both running as &quot;reduce -w&quot;, or as &quot;reduce&quot; with &quot;off fancy;&quot; will avoid the problem displaying the output.  The most interesting thing to me, though, is that on my old 1.3GHz Athlon, the output from &quot;(1+x+y+z)^20;&quot; is almost instantaneous without the typeset display.  The typeset display otherwise takes about six seconds to format!

BTW, I didn't know about &quot;off fancy&quot;, which is not mentioned in Hearn's Version 3.8 Reduce User's Manual.  Is there some Reduce command which will simply dump all the available commands?

James