Forum archive 2000-2006

Andrew - Negative numbers to fractional exponents?

Andrew - Negative numbers to fractional exponents?

by Arnold Pizer -
Number of replies: 0
inactiveTopicNegative numbers to fractional exponents? topic started 9/28/2004; 4:09:23 PM
last post 9/29/2004; 9:43:26 PM
userAndrew - Negative numbers to fractional exponents?  blueArrow
9/28/2004; 4:09:23 PM (reads: 1661, responses: 5)
Hey guys- I've run across something weird, and I'm wondering if there's an easy way around it. The answer to one of our problems is (-4)^(2/3). Perl appears to bomb out whenever a negative base is raised to a fractional exponent, and it yields NAN(something somewhere said that it had to do with the internal representation of values that perl uses). Is there a way around this limitation?

Thanks- Andrew

<| Post or View Comments |>


userBill Ziemer - Re: Negative numbers to fractional exponents?  blueArrow
9/29/2004; 4:45:43 PM (reads: 1878, responses: 1)
((-4)**2)**(1/3)

<| Post or View Comments |>


userBill Ziemer - Re: Negative numbers to fractional exponents?  blueArrow
9/29/2004; 4:56:56 PM (reads: 1885, responses: 0)
The real problem is that a negative base to an fractional power yields a complex number: (-4)^(2/3) = (4 e^(i pi))^(2/3) = 4^(2/3) e^(i 2pi/3)

<| Post or View Comments |>


userDoug Drinen - Re: Negative numbers to fractional exponents?  blueArrow
9/29/2004; 5:05:01 PM (reads: 2117, responses: 0)
That works for the purposes of coding the correct answer. But students who enter "(-4)^(2/3)" will still be told that they have entered "nan".

This is not a huge deal, and it's not a WeBWorK problem (it's a perl problem I think). One solution is to tell students to re-write their answer or to use a decimal approximation. But I am constantly reassuring my students that they don't have to worry about these sorts of trivialities, that WeBWorK is very smart and will correctly interpret what they type. In fact, I am constantly telling them *not* to use decimal approximations.

I feel like, if I warn them that WeBWorK isn't smart enough to figure this one out, then they're going to use that as an excuse to give up on other problems before they should ("I know I've got the right answer, but WeBWorK isn't taking it").

Again, no big deal. Just wondering if anyone else had run across this problem and found an effective workaround.

<| Post or View Comments |>


userBill Ziemer - Re: Negative numbers to fractional exponents?  blueArrow
9/29/2004; 5:08:14 PM (reads: 1865, responses: 0)
Yes, it is a perl problem. Perl doesn't deal with complex numbers. One workaround is too manipulate the student's response to a more perl-friendly format, as in

http://webhost.math.rochester.edu/webworkdocs/discuss/msgReader$422#429

<| Post or View Comments |>


userArnold K. Pizer - Re: Negative numbers to fractional exponents?  blueArrow
9/29/2004; 9:43:26 PM (reads: 1877, responses: 0)
I think it is probably best to explain to your students that a^b is basically evaluated as exp(b ln(a)) for b not an integer and thus a should always be positive in an expression of the form a^b. They can test this on their calculators or their own computers. Therefore they have to be smart and enter (-4)^(2/3) as 16^(1/3) or (-7)^(1/3) as -7^(1/3).

Humans can see that (-3)^.2 makes sense but that (-3)^.20000001 does not. You could write a parser that handles e.g. a^(b/c) where all a, b, and c are integers when this expression evaluates to a real number but I don't think it is worth the effort and I don't know any standard computer language that does this.

<| Post or View Comments |>