Results 1 to 4 of 4

Thread: Square root???

  1. #1

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190

    Square root???

    Do anyone know how you are calculation the scuare root of a number just using pen and paper....??? Or even Not sure what it is called but 3root?

  2. #2

    Thread Starter
    Retired G&G Mod NoteMe's Avatar
    Join Date
    Oct 2002
    Location
    @ Opera Software
    Posts
    10,190
    I guess I could use Newton Raphsons methid....but is there a formula?

  3. #3
    Frenzied Member
    Join Date
    Jul 1999
    Location
    Huntingdon Valley, PA 19006
    Posts
    1,151
    There is a process which looks a bit like long division that will do square root. It is more painful than the Newton succesive approximations method (assuming that you are good at guessing a first approximation). Given a hand calculator (without built in square root), nobody would consider using the long divison-like method rather than Newton.

    In elementary school they taught the dumb method. My father taught me the Newton method, which I used. This resulted in an argument with my teacher who claimed that Newton was just guess work.

    I ended up being forced to use the method taught in school. On each exam and homework paper involving square root, I wrote Dumb method!!

    BTW: From a logical point of view, both long division and the similar square root method are actually equivalent to an iterative method resulting is successively better approximations.
    Live long & prosper.

    The Dinosaur from prehistoric era prior to computers.

    Eschew obfuscation!
    If a billion people believe a foolish idea, it is still a foolish idea!
    VB.net 2010 Express
    64Bit & 32Bit Windows 7 & Windows XP. I run 4 operating systems on a single PC.

  4. #4
    Addicted Member
    Join Date
    Oct 2003
    Posts
    149

    Square root???

    Here is code to find a square root from quake 3. It gets close to the inverse square root of a number using newtons method so the more iterations the more accurate it is.

    This website explains what this code does and how to do it by hand.
    http://www.magic-software.com/Docum...InverseSqrt.pdf



    code:--------------------------------------------------------------------------------
    float Q_rsqrt( float number )
    {
    long i;
    float x2, y;
    const float threehalfs = 1.5F;

    x2 = number * 0.5F;
    y = number;
    i = * ( long * ) &y; // evil floating point bit level hacking
    i = 0x5f3759df - ( i >> 1 ); // what the ****?
    y = * ( float * ) &i;
    y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
    // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed

    return y;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width