MathGroup Archive 2013

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Mathematica and trivial math problems that school children can solve.

For me, there are two questions raised by this:
1) Why do people use a pile-driver when they could use a scalpel?
2) Are simple calculations beneath Mathematica, or beneath students or even
professors? Should they be done "in the head" or on a scrap of paper but not
in Mathematica?

My answer to the first question is because they think of Mathematica as a
super calculator and they are just looking for the right button to push.
Solve or Reduce seems like a reasonable choice. They don't think of
Mathematica as a "piece of paper" on which they can doodle and explore.

My answer to the second question is: calculate everything you can, or that
is appropriate to the problem in hand, in Mathematica. Even the smartest
people make copying errors or calculation mistakes and even if the frequency
of these is low, it is far from ignorable. Calculation within a notebook has
higher integrity, it's neater and it preserves a written record with the
rest of the work. One might get better at using scalpels and even learn
something about the math or the problem.  

So here is how I would approach Andrzej's calculation.

First idea: take the positive root on each side, solve for x and check. This
takes no discernible time. I added an extra zero, but what does that matter?

eqn = (10 x + 2)^200009 == (2 x + 4)^200009
PowerExpand[#^(1/200009)] & /@ %
xsol = Solve[%][[1, 1]]
eqn /. Xsol 

(2 + 10 x)^200009 == (4 + 2 x)^200009 
2 + 10 x == 4 + 2 x 
x -> 1/4 

This raises a question. We've been warned about PowerExand so is it all
right? It is, but we might want to think about the roots of 1.

So here is a doodle. (EvaluateAtPattern is a Presentations routine.)

HoldForm @@ {eqn} /. xsol
% // EvaluateAtPattern[_Plus]
% // ReleaseHold 

(2 + 10 x)^200009  ==  (4 + 2 x)^200009 
(2 + 10/4)^200009 == (4 + 2/4)^200009
(9/2)^200009 == (9/2)^200009 

HoldForm @@ {eqn};
% /. _ + _ x -> y
% // ReleaseHold


This reminds us that if the two sides of the equation are mathematical
expressions that make sense, and they are manifestly the same, then we have
a solution. It doesn't matter how complicated all the stuff is around the
variable parts, all we have to do is make the variable parts equal.

So, doodling some more with a fancier looking equation and getting the
Position of the variable part.

 eqn = E (1 + Log10[BesselJ[5, (3 - 5 x)^\[Pi]]])^23167 == 
   E (1 + Log10[BesselJ[5, (5 + 2 x)^\[Pi]]])^23167;
Part[#, 2, 1, 2, 2, 1, 2, 1] & /@ eqn
Solve[%][[1, 1]]
eqn /. %

3 - 5 x == 5 + 2 x
x -> -(2/7) 

So if we see a complicated equation maybe we should check to see how
complicated it really is.

And this raises a question of whether it is possible to write a routine that
would detect and extract the core of such equations. Do it by eye? Suppose
the expression fills a computer screen?

So I don't think we should denigrate doing simple calculations on
Mathematica, and I don't think Andrzej is doing that at all. There are some
people who do and only approve of very extensive or difficult or
computationally intensive calculations on Mathematica. They think it's macho
to do calculations in your head. 

David Park
djmpark at 

From: Andrzej Kozlowski [mailto:akozlowski at] 

Recently I came across an article in a mathematics and physics journal aimed
at high school students. The main reason why it attracted my attention was
that its theme was computer algebra and, in particular, Mathematica. The
moral of the story was quite sensible: these programs can do wonderful
things but don't expect them to be smart, in the human sense, anyway. The
example that was given was apparently taken from the Internet as a notorious
"breaker" of computer CAS programs. This was the illustration in

Reduce[(10 x + 2)^2009 == (2 x + 4)^2009, x, Reals]

Apparently all CAS programs used to get stuck on this, back in 2009, that
is. Well, it is now 2013 and computers are much faster so actually we get:

Timing[Reduce[(10*x + 2)^2009 == (2*x + 4)^2009, x, Reals]] {6.51, x == 1/4}

So, to produce an illustration suitable for the present day we add an extra
0 inside the exponent:

Reduce[(10 x + 2)^20009 == (2 x + 4)^20009, x, Reals]

Mathematica spends far too long to do this than anyone would care to wait,
while a reasonably smart school high-schooler can do it in no time at all.
So should we be disappointed with Mathematica's performance here? Well, the
first thing I always want to say when someone comes up with examples of this
kind is: don't try to judge CAS programs by the sort of things you can do
very well yourself. Chances are they will come up short (one reason I will
explain below). The right way to judge CAS program (and perhaps all computer
programs) is by testing them on things that we either can't do well or can't
do at all, like solving general a polynomial equations of some large degree.

Of course we can easily see the reason for the problem above. When
Mathematica is given a polynomial equation to solve, the first thing it does
is to expand the polynomials. In the overwhelming majority of cases this
will be the right thing to do and only in some very rare ones, like the
above, there is a better approach.  Does it mean that Mathematica does not
"know" the other approach and that it could not be programmed to use it? Of
course not. In fact, by slightly changing the problem above you can make
Mathematica return the answer almost immediately:

Reduce[(10 x + 2)^(20009 Pi) == (2 x + 4)^(20009 Pi), x,Reals] // Timing

{0.301534, x == 1/4}

All we did above  was make the power non-rational, which prevented
Mathematica from using the expansion method. Obviously, it would be quite
easy to change Reduce, so that it would first look for such special cases
before turning to the standard expansion-based algorithm. 
But would this sort of thing be worth the time spent by the programmer, even
if in this case it is very short? Obviously there are lots of other special
cases, corresponding to various situations where for some reason standard
computer algebra algorithms do not work well or work slowly, but which human
beings have no difficulty with. Should they all be implemented by
"heuristic" techniques?

Of course this sort of thing (using heuristics when there are not good
algorithms) is done quite often. But it is reasonable to do so only if there
is a fairly high chance of this sort of situation arising in the course of
some naturally occurring computation that was not designed to show that
there a human being can beat Mathematica at certain things (actually it is
still very easy to show that and it will surely remain so for many years to
come). It is not worth spending time and effort only to deprive people
certain people of the satisfaction of posting trivial examples of what they
call "bugs" in Mathematica. Computers are not intended to replace us (not
yet, anyway) but to help us.

Andrzej Kozlowski

  • Prev by Date: Re: barchart
  • Next by Date: Re: Stephen Wolfram's recent blog
  • Previous by thread: Mathematica and trivial math problems that school children can solve.
  • Next by thread: Speak Command in Ver 9