POV-Ray : Newsgroups : povray.general : Finite accuracy computing Server Time
7 Nov 2024 02:24:34 EST (-0500)
  Finite accuracy computing (Message 1 to 3 of 3)  
From: Gleb
Subject: Finite accuracy computing
Date: 9 May 2002 10:16:45
Message: <3cda84cd@news.povray.org>
An example from the book "Chaos and Fractals
New Frontiers of Science" shows how unreliable
can be calculations with finite accuracy.

Two different implementations
of the same quadratic law used:
p=p+r*p*(1-p) and

p=(1+r)*p-r*p^2, which is mathematically the same,
but results are far from that.

This simple SDL code is to demonstrate this feature:

//--------------------------8<---------------------
  camera {
    location <0,0.5,-1> look_at 0
  }
   background{rgb 1}
   #local p0=0.01;
   #local p1=p0;
   #local p2=p0;
   #local r=3;

   #local d=0.01;
   #local i=0;

   #declare Object=union{
   #while (abs(p1-p2)<1.3)
     #local p1 = p1+r*p1*(1-p1);
     #local p2 = (1+r)*p2-r*p2*p2;
     sphere{<i/100,p1-p2,0>, d}
     #local i=i+1;
   #end
  }
  #debug concat(str(i,1,0),"\n")

  #declare Object=#object{Object
  #local vv=-(max_extent(Object)-min_extent(Object))/2;
  translate vv-min_extent(Object)
  scale 0.5/vlength(vv)
}
   #object{Object}
//--------------------------8<---------------------

Calculations start with both p1 and p2 = 0.01,
and (under Win32) stop at step 187 when the difference
between them(expected to be always 0) is more then 1.3!
What do you think about it?

Gleb


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Finite accuracy computing
Date: 9 May 2002 12:10:41
Message: <3cda9f81@news.povray.org>
In article <3cda84cd@news.povray.org> , "Gleb" <gk1### [at] sotonacuk> wrote:

> Calculations start with both p1 and p2 = 0.01,
> and (under Win32) stop at step 187 when the difference
> between them(expected to be always 0) is more then 1.3!
> What do you think about it?

Are you surprised about this when using floating-point numbers?

    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: Gleb
Subject: Re: Finite accuracy computing
Date: 10 May 2002 05:35:02
Message: <3cdb9446$1@news.povray.org>
"Thorsten Froehlich" <tho### [at] trfde> wrote in message
news:3cda9f81@news.povray.org...
> In article <3cda84cd@news.povray.org> , "Gleb" <gk1### [at] sotonacuk> wrote:
>
> > Calculations start with both p1 and p2 = 0.01,
> > and (under Win32) stop at step 187 when the difference
> > between them(expected to be always 0) is more then 1.3!
> > What do you think about it?
>
> Are you surprised about this when using floating-point numbers?
>
Both yes and no


Post a reply to this message

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