LOGO-L> Newton with Logo and Real-Types 
Author Message
 LOGO-L> Newton with Logo and Real-Types

It's ugly but it works.

make "x 555.123456789
show (int :x*power 10 4)/power 10 4
555.1234
show (int :x*power 10 5)/power 10 5
555.12345

It's always risky comparing floating point numbers
unless they are derived in EXACTLY the same manner so
you end up with the same approximations (errors).

Quote:

> Hi,

> i've write a short programm that calculate the 0-device with newton.
> x(n+1) = x(n) - f(x) / f'(x)

> I try to check the x(n) and x(n+1), if they are equal, the program
> should be stoped, but it doesn't work.

> My Syntax: until [:xnold=:xn][newton]
> How I can round (?) my variables at 15 numbers after the comma.

> In my Pascal Programm:
> Repeat
>   xold := x;
>   Writeln(x:5:10);
>    x := newton(x);
> until xold = x;

> x and xold are variables of the type "extended", a real type with 20
> numbers after the comma

> Thanks a lot

> Phil
> ---------------------------------------------------------------




---------------------------------------------------------------





Mon, 23 Sep 2002 03:00:00 GMT  
 LOGO-L> Newton with Logo and Real-Types

Quote:
> > My Syntax: until [:xnold=:xn][newton]
> > How I can round (?) my variables at 15 numbers after the comma.

How about

until [1e-15 < abs :xnold - :xn][newton]

Daniel

---------------------------------------------------------------





Tue, 24 Sep 2002 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Newton with Logo and Real-Types

2. LOGO-L> Re: Logo and real simplicity

3. LOGO-L> Re: Logo and real simplicity

4. LOGO-L> Apple logo/MSW Logo

5. LOGO-L> Reseach Machines Logo (RM LOGO)

6. LOGO-L> Re: LOGO-L> Re: Logo and real simplicity

7. LOGO-L> Real World Recursion

8. LOGO-L> [Fwd: Real Cyberschool]

9. LOGO-L> Welcome to logo-l

10. LOGO-L> Re: Dynamic scope in Logo

11. LOGO-L> INFO re SIG-LOGO

12. LOGO-L> Logo speed

 

 
Powered by phpBB® Forum Software