Hi Jack,

jack said:

You're right that equation 2 will "work" in EXCEL although it is still

not really mathematically "pure" or very "elegant".

I suppose that's in the eye of the beholder?

However, I challenge you to try to get Equation 1 to work in EXCEL.

Raising a negative number to a fractional exponent causes an error in

EXCEL. Try it.

Yeah, I see that you're right. This isn't too surprising, though, in that

typically raising negative numbers to fractional exponents ends up with an

imaginary result, and Excel doesn't support complex numbers 'natively' (it

can be done with them with the Analysis ToolPak, but it's still a little

clunky). In fact, looking at equation (1) on the MathWorld site, I believe

you have to look strictly at the real part of the result to get the output

(the square wave) that you're after (and just discard the imaginary part).

The Windows calculator, regular scientific calculators without native

complex number support, and many other applications that you might try to

use with eqn (1) will fail... those guys over at MathWorld aren't bothered

by this because their product, Mathematica, pretty much never fails.

(Mathematica will produce results from expressions that almost any

'everyday' calculator like Excel will barf at, since Mathematica 'knows'

many extensions of 'familiar' functions that make them 'work' in uncommon

domains that high-powered math guys are familiar with... for instance, the

factorial function can be extended to produce results even when its argument

is negative or fractional, even though for the vast majority of people this

is unexpected behavior.)

An implementation using equation (2) is going to be a lot more efficient

than one using eqn (1). An implementation using a boring 'if/then/else'

approach is going to be the most efficient of all. Often the most 'elegant'

mathematical expressions are the most inefficient if you perform the

'straightforward' implementation; this is understandable in that by

'elegant' one oftens means they're trying to hide lots of ugly details in a

few nice, all-powerful functions -- which are inherently slow to evaluate.

---Joel