POV-Ray : Newsgroups : povray.advanced-users : Square roots of negative numbers in isosurfaces? Server Time
30 Jul 2024 12:23:07 EDT (-0400)
  Square roots of negative numbers in isosurfaces? (Message 21 to 26 of 26)  
<<< Previous 10 Messages Goto Initial 10 Messages
From: Ron Parker
Subject: Re: Square roots of negative numbers in isosurfaces?
Date: 17 Jan 2000 16:32:09
Message: <38838a59@news.povray.org>
On Mon, 17 Jan 2000 16:17:16 -0500, Greg M. Johnson wrote:

>Again, I hound this point not to attack the giants whose shoulder we stand on--pov
>developers--but to have fun at solving a mathematical mystery : what IS pov doing?


void func_exp_xy(void)
 {
  if (((*calc_stack_top)>0) && ((*calc_stack_top)<16) &&
      (FFLOOR(*calc_stack_top)== *calc_stack_top))
   {
    fint= *(calc_stack_top--);
    ftemp1= (*calc_stack_top);
    for (; fint>1; fint--) (*calc_stack_top)*= ftemp1;
   }
  else
   {
    calc_stack_top--;
    *(calc_stack_top)= pow( *(calc_stack_top),*(calc_stack_top+1));
   }
 }

translated:

in the equation x^y,
if y is an integer between 1 and 15 inclusive
  calculate x^y by multiplying x by itself y times.
otherwise,
  call the C function pow(x,y) and return its result
  directly.


Presumably, pow(x,y) itself does something when presented
with invalid parameters, but what that is isn't specified
in the MSVC documentation.  It may be specified in the ANSI
C spec; I haven't checked.

-- 
These are my opinions.  I do NOT speak for the POV-Team.
The superpatch: http://www2.fwi.com/~parkerr/superpatch/
My other stuff: http://www2.fwi.com/~parkerr/traces.html


Post a reply to this message

From: Greg M  Johnson
Subject: Re: Square roots of negative numbers in isosurfaces?
Date: 17 Jan 2000 17:26:46
Message: <38839656.3849FE0C@my-dejanews.com>
Thanks.  But the mystery deepens. I found a web page mentioning an ANSI standard:

http://www.thinkage.com/expl/c/lib/pow.html

|  <math.h>
|  z = pow( x, y );
|  Description:
|  "pow" returns "x" to the power "y". If "x" and "y" are both zero, or if "x" is
|  non-positive and "y" is not an integer, "pow" return -HUGE_VAL and sets
|  "errno" to EDO

I have little understanding of this stuff, but pov seems to be doing something
different.


Ron Parker wrote:

> On Mon, 17 Jan 2000 16:17:16 -0500, Greg M. Johnson wrote:
>
> >Again, I hound this point not to attack the giants whose shoulder we stand on--pov
> >developers--but to have fun at solving a mathematical mystery : what IS pov doing?
>
>   call the C function pow(x,y) and return its result
>   directly.
>
> Presumably, pow(x,y) itself does something when presented
> with invalid parameters, but what that is isn't specified
> in the MSVC documentation.  It may be specified in the ANSI
> C spec; I haven't checked.
>
> --
> These are my opinions.  I do NOT speak for the POV-Team.
> The superpatch: http://www2.fwi.com/~parkerr/superpatch/
> My other stuff: http://www2.fwi.com/~parkerr/traces.html


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Square roots of negative numbers in isosurfaces?
Date: 17 Jan 2000 19:35:05
Message: <3883b539@news.povray.org>
In article <38838a59@news.povray.org> , ron### [at] povrayorg (Ron Parker)
wrote:

> Presumably, pow(x,y) itself does something when presented
> with invalid parameters,

The docs I have say this:

The macro pow(x,y) returns x raised to the power yx xy.
If x is +0.0 and y is negative, then pow returns +inf and signals divide by
zero.  If x is -0.0, and y is integral and negative, then pow signals divide
by zero and returns +inf if y is even, or -inf if y is odd.
The function pow returns NaN and signals invalid if:
both x and y are 0.0, or
x is +-inf and y is 0.0, or
x is 1.0 and y is +-inf, or
x is -0.0 or negative and y is non-integral.


     Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Matt Giwer
Subject: Re: Square roots of negative numbers in isosurfaces?
Date: 18 Jan 2000 00:15:58
Message: <3883F73F.9ED303FD@ij.net>
"Greg M. Johnson" wrote:

> Matt Giwer wrote:
>
> > "Greg M. Johnson" wrote:
> > > what is x^a?
> >     x to the power a or exp( a * log(x) )
> >     If a = 2 then it would be x*x
>
> Nope.  You cannot take the ln(x) of a negative x! Therefore, that's NOT what povray
> is doing!  My guess is

    I do abs(x) when I have such problems. Mathematicians hate me but it usually
works.


> x^a= sign(x)^int(a)* abs(x)^a .

    sign(x) is my second last resort. I'd rather avoid it as it usually does not work
being function specific as to whether or not it works. My last resort is actually
digging into the function and making sense of it.


> My re-writing of the function is "defined" for all values of x and a, whereas x^a is
> NOT.

    The idea of epsilon, for small values of zero, is also a useful compuational
concept. x+.000001 never hurts when folks do theoretical implementations.


> Again, I hound this point not to attack the giants whose shoulder we stand on--pov
> developers--but to have fun at solving a mathematical mystery : what IS pov doing?

    I do not claim to know all the computational tricks, but I think I do. If you are
really into a function you can find more adaptive ways to avoid problems. But I can't
remember the +.000001 trick failing since 1967. You can't publish the trick without
showing it applies but if it works ... So what is your audience?

    I am sure there are but I do not know of any smooth function (not discontinuous
like
1 and 0 binary) that has any problems with evaluation at any point but real zero. And
with a smooth function the small value always works.

    This not new so I guess I am missing your problem. Care to repeat or rephrase?


Post a reply to this message

From: Matt Giwer
Subject: Re: Square roots of negative numbers in isosurfaces?
Date: 18 Jan 2000 00:23:38
Message: <3883F90B.CFEC940E@ij.net>
"Greg M. Johnson" wrote:

> Thanks.  But the mystery deepens. I found a web page mentioning an ANSI standard:
>
> http://www.thinkage.com/expl/c/lib/pow.html
>
> |  <math.h>
> |  z = pow( x, y );
> |  Description:
> |  "pow" returns "x" to the power "y". If "x" and "y" are both zero, or if "x" is
> |  non-positive and "y" is not an integer, "pow" return -HUGE_VAL and sets
> |  "errno" to EDO
>
> I have little understanding of this stuff, but pov seems to be doing something
> different.

    If this is the issue, the current vice the older one that POV implements, is like
exp(4096).

    If that guess is valid ... comments?


Post a reply to this message

From: Ron Parker
Subject: Re: Square roots of negative numbers in isosurfaces?
Date: 18 Jan 2000 08:16:10
Message: <3884679a@news.povray.org>
On Tue, 18 Jan 2000 00:16:47 -0500, Matt Giwer wrote:
>    I am sure there are but I do not know of any smooth function (not discontinuous
like
>1 and 0 binary) that has any problems with evaluation at any point but real zero. And
>with a smooth function the small value always works.

Well, sqrt(x) is undefined for all x<0.  But somehow the isosurface patch
manages to deal with that.  I think the reason is that the processors we 
usually run it on keep going on getting a NaN result.  Try running it on 
an alpha and see how quickly it manages to crash.

-- 
These are my opinions.  I do NOT speak for the POV-Team.
The superpatch: http://www2.fwi.com/~parkerr/superpatch/
My other stuff: http://www2.fwi.com/~parkerr/traces.html


Post a reply to this message

<<< Previous 10 Messages Goto Initial 10 Messages

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