Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2010

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

Search the Archive

Re: More /.{I->-1} craziness, con brio

  • To: mathgroup at smc.vnet.net
  • Subject: [mg106595] Re: More /.{I->-1} craziness, con brio
  • From: Richard Fateman <fateman at cs.berkeley.edu>
  • Date: Sun, 17 Jan 2010 07:13:36 -0500 (EST)
  • References: <200912300915.EAA17299@smc.vnet.net> <hhhmn8$o9t$1@smc.vnet.net> <his71l$lad$1@smc.vnet.net>

(con brio, musical notation for With Vigor).

With[{I=-I}, 3+4 I]  returns 3-4 I,    so clearly this could be used, as 
  someone mentioned waay back in this thread. Or can it?

Let us try   v=3+4I;   With[{I=-I},v]  returns 3+4I.

oops.  and

With[{1/5=OneFifth}, 3/5]

which gives an error message, that says that you can't use 1/5 as a 
local variable because it is not a symbol.

It is true that Head[1/5] is Rational, and hence 1/5 is not a symbol.
But Head[I] is Complex, and is not a symbol either, and so should
not be allowed.  I suppose one could argue that error message is just 
wrong. (but if you care, the explanation is below.)

But here is another one, in which we use E and Pi, each of which is a 
Symbol.

With[{E = Pi}, E^x + Exp[x] + E + Cos[E]]

returns

-1 + E^x + Pi + Pi^x

Look at it carefully and see if you agree.

But if we do it in 2 steps,
   v= E^x + Exp[x] + E + Cos[E]; With[{E=Pi},v]
then we get.. E + 2*E^x + Cos[E]

Now here's an explanation -- "With" is just a different implementation 
of Module with more efficient local variables, and that last expression 
is really something like this (we make up local variable name 1234 ..)

Module[{E$1234=Pi},  E$1234^x+Exp[x]+E$1234+Cos[E$1234]]
hence Exp[x] is unchanged..

The second version with v= ...


Module[{E$1235=Pi},  E^x+Exp[x]+E+Cos[E]]

so NOTHING is changed.  (returning to I=-I, the name I$1236 is a symbol...)

Anyway, the point here is that even if you think the smoke has cleared, 
you might be mistaken.

  I think that Mathematica is too complicated to explain accurately to 
novices or it should be taught in high school.

On the other hand, pointing out that there are computer programs that 
can do parts of symbolic mathematics generally (e.g. algebra, geometry, 
trigonometry, calculus) is probably worth mentioning to students who are 
keen to understand math, computing, and their relationship.

I heartily disagree with the sentiment that computer algebra or for that 
matter, programming, has to be nearly so complicated.  To quote 
Spiderman (or is it his Uncle Ben??),

"With [sic?!] great power comes great responsibility".

He didn't say "With great power comes great complexity".

RJF


  • Prev by Date: Re: AstronomicalData - solar ecliptic longitude
  • Next by Date: Re: Re: Simplify with NestedLessLess?
  • Previous by thread: Re: Re: Testing Mathematica Expressions?
  • Next by thread: Re: Re: More /.{I->-1} craziness, con brio