[R-sig-teaching] Plot f(x) = x^(1/5)

bob at statland.org bob at statland.org
Tue May 17 16:23:38 CEST 2016


Forwarded message:
> >
> > > System is working correctly. A negative number cannot be raised to a
> > > fractional power:
> > >
> > > > (-2)^(1/5)
> > > [1] NaN

Well, maybe we should say that _R_ can't raise a negative number to a
fractional power.  Neither I nor the TI calculators have any trouble
doing it;-) I'd say R is funtioning as designed, but it was designed
to respond INcorrectly;-)

This R exchange

> (-2)^5
[1] -32

shows that -2 is a fifth root of -32 while this exchange

> (-32)^(1/5)
[1] NaN

shows that R cannot find that root.  The various suggestions for
dealing with this amount to asking R a different question which we
know has the same answer as the intended question (which R won't
answer).

On one level you could view this as a coding/implementation issue.  I
have not looked at R's code, but the usual computer way to handle
exponents involves taking the log of the argument.  This does not
return the correct answer when the argument is negative.  That's
annoying.  The TI graphing calculators were developed with an
incredible amount of input from secondary math. teachers.  They
complained loudly about calculators returning wrong answers or
non-answers to problems to which students knew the right answers.  TI
did a LOT of work on this.  I wish R (and lots of scientific software)
would do likewise.

On another level, involving exponentiation is not entirely avoidable.
For rational numbers like 1/5 we can (and usually do) interpret
(-32)^(1/5) as a name for a real number that when raised to the fifth
power gives -32.  Another name for one such number is -2.  But if we want
to use an irrational exponent, say (-32)^pi we can't interpret it that
way.  (How do we multiply pi numbers together?)  So eventually we have
to either exponentiate or have a funciton that is undefined at many
points.  At lesat in theory.  As far as computers and calculators are
concerned, they cannot represent irrational numbers anyway --
eveything is a rational approximation.  

So I think the defect is in R, not in the original posted question. 

------->  First-time AP Stats. teacher?  Help is on the way! See
http://courses.ncssm.edu/math/Stat_Inst/Stats2007/Bob%20Hayden/Relief.html
      _
     | |          Robert W. Hayden
     | |          614 Nashua Street #119
    /  |          Milford, New Hampshire 03055  USA
   |   |          
   |   |          email: bob@ the site below
  /  x |          website: http://statland.org
 |     /          
 ''''''



More information about the R-sig-teaching mailing list