[#11890] Ruby and Solaris door library — "Hiro Asari" <asari.ruby@...>

Hi, there. This is my first patch against ruby. I think I followed

19 messages 2007/08/13
[#11892] Re: Ruby and Solaris door library — Daniel Berger <djberg96@...> 2007/08/14

Hiro Asari wrote:

[#11899] pack/unpack 64bit Integers — Hadmut Danisch <hadmut@...>

Hi,

13 messages 2007/08/14
[#11903] Re: pack/unpack 64bit Integers — Brian Candler <B.Candler@...> 2007/08/15

On Wed, Aug 15, 2007 at 06:50:01AM +0900, Hadmut Danisch wrote:

[#11948] Fibers in Ruby 1.9? — David Flanagan <david@...>

I just noticed that my ruby1.9 build of August 17th includes a Fiber

22 messages 2007/08/22
[#11949] Re: Fibers in Ruby 1.9? — Daniel Berger <djberg96@...> 2007/08/22

David Flanagan wrote:

[#11950] Re: Fibers in Ruby 1.9? — "Francis Cianfrocca" <garbagecat10@...> 2007/08/22

On 8/22/07, Daniel Berger <djberg96@gmail.com> wrote:

[#11952] Re: Fibers in Ruby 1.9? — MenTaLguY <mental@...> 2007/08/22

On Wed, 22 Aug 2007 20:50:12 +0900, "Francis Cianfrocca" <garbagecat10@gmail.com> wrote:

[#11988] String#length not working properly in Ruby 1.9 — "Vincent Isambart" <vincent.isambart@...>

I saw that Matz just merged his M17N implementation in the trunk.

17 messages 2007/08/25
[#11991] Re: String#length not working properly in Ruby 1.9 — "Michael Neumann" <mneumann@...> 2007/08/25

On Sat, 25 Aug 2007 10:54:20 +0200, Yukihiro Matsumoto

[#11992] Re: String#length not working properly in Ruby 1.9 — Yukihiro Matsumoto <matz@...> 2007/08/25

Hi,

[#12042] Encodings of string literals; explicit codepoint escapes? — David Flanagan <david@...>

This message contains queries that probably only Matz can answer:

16 messages 2007/08/31
[#12043] Re: Encodings of string literals; explicit codepoint escapes? — Yukihiro Matsumoto <matz@...> 2007/08/31

Hi,

Re: Inverse Square Root

From: "Josef 'Jupp' Schugt" <jupp@...>
Date: 2007-08-25 17:01:20 UTC
List: ruby-core #11995
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Dave Pederson wrote:
> I was wondering if it is possible to include the quake fast inverse
> square root function in ruby?

I oppose this for three reasons:

1. Computing inverse square roots is already possible in Ruby with just
   one operation using the exponentiation operator

       ruby -e 'puts 0.0025 ** -0.50'
       20.0

   or with two operations using division and Math.sqrt

       ruby -e 'puts 1.0 / Math.sqrt(0.0025)'
       20.0

2. The fast computation of an inverse square root is too rarely used to
   be implemented as part of a general purpose language.

3. The algorithm is mediocre at best. Better ones with faster
   convergence are available - without much search one can find one that
   converges cubically (the one you proposed only converges
   quadratically):

   Task: Given $S$ compute $\frac{1}{\sqrt{S}}$.

   Solution: Starting from $x_0$ let

       \begin{equation}
           y_n = S \cdot {x_n}^2,
       \end{equation}

   and

       \begin{equation}
           x_{n+1} = \frac{x_n}{8} \cdot (15 - y_n \cdot (10 - 3 y_n))
       \end{equation}

   which can be evaluated in this way:

       void main() {
           double s = 0.0025;
           double x = 0.0, xn = 1.0, yn;
           while (x != xn) {
               yn = s * xn * xn;
               x = xn;
               xn *= 0.125 * (15.0 - yn * (10.0 - 3.0 * yn));
               printf("%.16f\n", xn);
           }
       }

   This algorithm can be found in Wikipedia at

       http://en.wikipedia.org/wiki/Methods_of_computing_square_roots


Please note that  20 = sqrt(400) = isqrt(1/400) = isqrt(0.0025).

Have fun,

Josef 'Jupp' Schugt
- --
Blog available at http://www.mynetcologne.de/~nc-schugtjo/blog/
PGP key with id 6CC6574F available at http://wwwkeys.de.pgp.net/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFG0GBbrhv7B2zGV08RAs0xAKCvVgf2K6jeKM3Qj5PinwfbP3sPEwCg6luF
OTscjST6YUwX9D8YjZXpkDg=
=iRgR
-----END PGP SIGNATURE-----

In This Thread