But, if we stop at some x^n we would still have a result up to some precision. The problem is that for many functions, like square root, for exact value this sum has infinite number of members, it does not end at some x^n. I'll try to sum it up here for ones who don't want to go too much into details.Īny mathematical function, with some exceptions, can be represented by a polynomial sum: y = f(x)Ĭan be exactly transformed into: y = a0 + a1*x + a2*(x^2) + a3*(x^3) + a4*(x^4) +. Greg Hewgill and IllidanS4 gave a link with excellent mathematical explanation. He couldn't explain why id's was so excellent iirc. In spite of this, his initial attempt a mathematically 'superior' version of id's sqrt (which came to almost the same constant) proved inferior to the one initially developed by Gary despite being mathematically much 'purer'. X = x * (1.5f - xhalf * x * x) // Newton step, repeating increases accuracy X = *(float*)&i // convert bits back to float I = 0x5f375a86 - (i > 1) // gives initial guess y0 Int i = *(int*)&x // get bits for floating value How the mythical constant was derived is something of a mystery.Ī slightly better constant, developed by an expert mathematician (Chris Lomont) trying to work out how the original algorithm worked is: float InvSqrt(float x) Terje Mathisen and Gary Tarolli both take partial (and very modest) credit for it, as well as crediting some other sources.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |