POV-Ray : Newsgroups : povray.beta-test : Raising Negative Numbers to a Power Server Time
4 Nov 2024 17:41:47 EST (-0500)
  Raising Negative Numbers to a Power (Message 1 to 9 of 9)  
From: Josh Seagoe
Subject: Raising Negative Numbers to a Power
Date: 1 Oct 2001 20:51:22
Message: <3BB91008.3080505@smileyface.com>
Ok, more specific about what I posted about SuperTorus...

This:
#declare K=function(v,p) { (v^p)^(1/p) }

#debug concat(str(K(1,3), 2, 4), "\n")
#debug concat(str(K(.1,3), 2, 4), "\n")
#debug concat(str(K(-1,3), 2, 4), "\n")
#debug concat(str(K(-.1,3), 2, 4), "\n")


Prints this:
1
.1
-1.#IND
-1.#IND

Instead of the expected:
1
.1
-1
-.1

Even powers & their reciprocals work, anything else doesn't.

(v3.5 beta4, Win2k, PIII)

-josh


Post a reply to this message

From: Mark Wagner
Subject: Re: Raising Negative Numbers to a Power
Date: 1 Oct 2001 22:07:19
Message: <3bb92157@news.povray.org>
Josh Seagoe wrote in message <3BB### [at] smileyfacecom>...
>Ok, more specific about what I posted about SuperTorus...
>
>This:
>#declare K=function(v,p) { (v^p)^(1/p) }
>
>#debug concat(str(K(1,3), 2, 4), "\n")
>#debug concat(str(K(.1,3), 2, 4), "\n")
>#debug concat(str(K(-1,3), 2, 4), "\n")
>#debug concat(str(K(-.1,3), 2, 4), "\n")


Computers can't do exact representations of many fractions, so instead of
trying to guess whether 0.33333333 is supposed to represent 1/3 or not, most
computers simply reject the notion of raising negative numbers to
non-integer powers.

Try using the Windows calculator program to evaluate these.  It's not a
shortcoming in POV-Ray, it's a shortcoming of almost every computer in the
world.

--
Mark


Post a reply to this message

From: Josh Seagoe
Subject: Re: Raising Negative Numbers to a Power
Date: 1 Oct 2001 23:03:20
Message: <3BB92EF6.6070502@smileyface.com>
ok, MegaPov doesn't work with this either.  I only tested it with a 
calculator before and it worked, but that allows complex numbers.

The SuperTorus still doesn't work as it does in MegaPov tho, and it 
looks like the same problem.  eg:

object {
    SuperTorus(1,.4,1.4,1.4,0,2)
    pigment { rgb 1 }
}

MegaPov gives the mathimatically correct result, while POV 3.5 beta 4 
gives the result you'd expect with rounding errors on the exponents.

To get (almost) the same results out of POv 3.5, you have to change the 
function to:
function { (abs((abs(x)^RP + abs(z)^RP)^(1/RP) - RMj)^CP + 
abs(y)^CP)^(1/CP) - RMn}

-josh


Mark Wagner wrote:

> Josh Seagoe wrote in message <3BB### [at] smileyfacecom>...
> 
>>Ok, more specific about what I posted about SuperTorus...
>>
>>This:
>>#declare K=function(v,p) { (v^p)^(1/p) }
>>
>>#debug concat(str(K(1,3), 2, 4), "\n")
>>#debug concat(str(K(.1,3), 2, 4), "\n")
>>#debug concat(str(K(-1,3), 2, 4), "\n")
>>#debug concat(str(K(-.1,3), 2, 4), "\n")
>>
> 
> 
> Computers can't do exact representations of many fractions, so instead of
> trying to guess whether 0.33333333 is supposed to represent 1/3 or not, most
> computers simply reject the notion of raising negative numbers to
> non-integer powers.
> 
> Try using the Windows calculator program to evaluate these.  It's not a
> shortcoming in POV-Ray, it's a shortcoming of almost every computer in the
> world.
> 
> --
> Mark
> 
> 
>


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Raising Negative Numbers to a Power
Date: 2 Oct 2001 17:49:48
Message: <3BBA3674.67833A0C@hotmail.com>
Mark Wagner wrote:
> 
> Josh Seagoe wrote in message <3BB### [at] smileyfacecom>...
> >Ok, more specific about what I posted about SuperTorus...
> >
> >This:
> >#declare K=function(v,p) { (v^p)^(1/p) }
> >
> >#debug concat(str(K(1,3), 2, 4), "\n")
> >#debug concat(str(K(.1,3), 2, 4), "\n")
> >#debug concat(str(K(-1,3), 2, 4), "\n")
> >#debug concat(str(K(-.1,3), 2, 4), "\n")
> 
> Computers can't do exact representations of many fractions, so instead of
> trying to guess whether 0.33333333 is supposed to represent 1/3 or not, most
> computers simply reject the notion of raising negative numbers to
> non-integer powers.
> 
> Try using the Windows calculator program to evaluate these.  It's not a
> shortcoming in POV-Ray, it's a shortcoming of almost every computer in the
> world.

My very cheap little Casio fx-82 can do these correctly:

1 +/- ^ 3 = ^ 3 1/x =
Result: -1

0.1 +/- ^ 3 = ^ 3 1/x = 
Result: -0.1


Tor Olav


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Raising Negative Numbers to a Power
Date: 2 Oct 2001 17:58:22
Message: <3bba387e@news.povray.org>
In article <3BBA3674.67833A0C@hotmail.com> , Tor Olav Kristensen 
<tor### [at] hotmailcom>  wrote:

> My very cheap little Casio fx-82 can do these correctly:

Note a serious question: Yes, but how long does it take?  Can it do one
million of them per second?

    Thorsten


Post a reply to this message

From: Anders K 
Subject: Re: Raising Negative Numbers to a Power
Date: 2 Oct 2001 18:49:11
Message: <3bba4467$1@news.povray.org>
> Try using the Windows calculator program to evaluate these.

FYI, Windows calculator evaluates them properly, at least on my computer.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Raising Negative Numbers to a Power
Date: 2 Oct 2001 19:20:27
Message: <3BBA4BB7.423D6F71@hotmail.com>
Thorsten Froehlich wrote:
> 
> In article <3BBA3674.67833A0C@hotmail.com> , Tor Olav Kristensen
> <tor### [at] hotmailcom>  wrote:
> 
> > My very cheap little Casio fx-82 can do these correctly:
> 
> Note a serious question: Yes, but how long does it take?  Can it do one
> million of them per second?

I think not.

But my point was to show that NOT "almost every
computer in the world" has this shortcoming.


Tor Olav


Post a reply to this message

From: Redbeard (MDJohnson)
Subject: Re: Raising Negative Numbers to a Power
Date: 2 Oct 2001 23:31:17
Message: <3bba8685@news.povray.org>
"Tor Olav Kristensen" <tor### [at] hotmailcom> wrote in message
news:3BBA3674.67833A0C@hotmail.com...
>
> My very cheap little Casio fx-82 can do these correctly:
>
> 1 +/- ^ 3 = ^ 3 1/x =
> Result: -1
>
> 0.1 +/- ^ 3 = ^ 3 1/x =
> Result: -0.1
>
>
> Tor Olav

However, calculators are usually set up to do math like people (base 10)
while computers are set up to do math . . . well, like computers (base 2).
So unless we want to set the computer up to do base 10 math (BCD, fixed
point bigints, etc), which is slow for a computer, we have to live with
inaccuracies that we humans sometimes have problems understanding :(

Michael


Post a reply to this message

From: Mark Wagner
Subject: Re: Raising Negative Numbers to a Power
Date: 2 Oct 2001 23:41:36
Message: <3bba88f0@news.povray.org>
Tor Olav Kristensen wrote in message <3BBA4BB7.423D6F71@hotmail.com>...
>
>But my point was to show that NOT "almost every
>computer in the world" has this shortcoming.


That's why I put "almost".  I knew that most scientific and graphing
calculators don't have this problem.  Those are, however, the only
exceptions I know of.

--
Mark


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.