|
|
John VanSickle wrote:
> Invisible wrote:
>
>> If you're that hell-bent on avoiding the square root, it can be
>> approximated as follows:
>>
>> Suppose that the most significant non-zero digit of x is in the 2^n
>> place. Let y = x / 2^(n/2). Now Sqrt(x) is approximately x / y.
>>
>> Usually this estimated value is greater than the true square root (but
>> always by less than 45%). However, exact powers of 2 seem to come out
>> slightly below the true value. (By about 10^-16.) I don't know if
>> that's a glitch in my test program or what... It shouldn't be
>> insurmountable though.
>
> One would have to be very hell-bent indeed to employ, in lieu of sqrt(),
> functions that are probably just as computationally expensive, like ln()
> and exp(). Unless you have a quick way of getting n and 2^(n/2) without
> ln() and exp(), you'll need them.
>
> Now if you know the internal representation of your floats (or doubles),
Indeed, the *only* reason you would ever use a construction like this is
because it's very fast and efficient to get at these numbers using the
binary representation of a float.
--
http://blog.orphi.me.uk/
http://www.zazzle.com/MathematicalOrchid*
Post a reply to this message
|
|