Running a speed and accuracy test on the Quake3 1/sqrt(x) algorithm compared to the Pico built-in sqrt(x) 1) the Q3 algorithm can be used. (integer anf float representation matches the x86 algorithm) 2) without any Newton Iteration it is much faster than the Pico's built-in 1/sqrt(x). 6% Execution time = 6% of Pico library version! 3% The accuracy is +/- 3% 3) starting with the first Newton Iteration the Q3 algorithm is much slower, 3 iterations needed for full accuracy except last 2 bits. 1 Iter: 256% execution time, accuracy ~0.15% 2 Iter: 476% execution time, accuracy ~0.0005% 3 Iter: 676% execution time, accuracy ~0.000015% The Pico seems to take twice the time for one Newton Iteration (3 Multiplications + 1 Subtraction) than for 1 Division + 1 Square root. Weird! static inline FLOAT rand (FLOAT max) { return FLOAT(rand()) * max / FLOAT(RAND_MAX); } static void test_q3_sqrt() { srand(time_us_32()); float n[100]; float s[100]; float t[100]; float u[100]; float v[100]; float w[100]; for (uint i=0; i<100; i++) { n[i] = rand(75000.0f*75000.0f); } uint32 t0 = time_us_32(); for (uint i=0; i<100; i++) { s[i] = 1.0f / sqrt(n[i]); } uint32 t1 = time_us_32(); for (uint i=0; i<100; i++) { t[i] = q3_reverse_sqrt<0>(n[i]); } uint32 t2 = time_us_32(); for (uint i=0; i<100; i++) { u[i] = q3_reverse_sqrt<1>(n[i]); } uint32 t3 = time_us_32(); for (uint i=0; i<100; i++) { v[i] = q3_reverse_sqrt<2>(n[i]); } uint32 t4 = time_us_32(); for (uint i=0; i<100; i++) { w[i] = q3_reverse_sqrt<3>(n[i]); } uint32 t5 = time_us_32(); printf("time sqrt=%uus, q3<0>=%uus, q3<1>=%uus, q3<2>=%uus, q3<3>=%uus\n", t1-t0, (t2-t1), (t3-t2), (t4-t3), (t5-t4)); printf("time sqrt=%uus, q3<0>=%u%%, q3<1>=%u%%, q3<2>=%u%%, q3<3>=%u%%\n", t1-t0, (t2-t1)*100/(t1-t0), (t3-t2)*100/(t1-t0), (t4-t3)*100/(t1-t0), (t5-t4)*100/(t1-t0)); printf("deviation:\n"); for (uint i=0; i<100; i++) { float d0 = t[i] / s[i] * 100 - 100; float d1 = u[i] / s[i] * 100 - 100; float d2 = v[i] / s[i] * 100 - 100; float d3 = w[i] / s[i] * 100 - 100; printf("<0>: %+.6f%%, <1>: %+.6f%%, <2>: %+.6f%%, <3>: %+.6f%%\n",double(d0),double(d1),double(d2),double(d3)); } printf("\n"); } time sqrt=131us, q3<0>=8us, q3<1>=336us, q3<2>=624us, q3<3>=886us time sqrt=131us, q3<0>=6%, q3<1>=256%, q3<2>=476%, q3<3>=676% deviation: <0>: +2.514626%, <1>: -0.095657%, <2>: -0.000137%, <3>: +0.000000% <0>: +1.945831%, <1>: -0.057159%, <2>: -0.000038%, <3>: +0.000015% <0>: +3.228363%, <1>: -0.158020%, <2>: -0.000374%, <3>: +0.000015% <0>: -0.373779%, <1>: -0.002098%, <2>: +0.000000%, <3>: -0.000008% <0>: +2.351593%, <1>: -0.083595%, <2>: -0.000099%, <3>: +0.000000% <0>: +1.560883%, <1>: -0.036728%, <2>: -0.000015%, <3>: +0.000015% <0>: +1.910019%, <1>: -0.055084%, <2>: -0.000053%, <3>: +0.000000% <0>: -3.373650%, <1>: -0.168800%, <2>: -0.000427%, <3>: +0.000000% <0>: -0.522102%, <1>: -0.004074%, <2>: +0.000000%, <3>: +0.000000% <0>: -1.905998%, <1>: -0.054153%, <2>: -0.000046%, <3>: +0.000000% <0>: -2.098427%, <1>: -0.065590%, <2>: -0.000069%, <3>: +0.000000% <0>: -3.424309%, <1>: -0.173882%, <2>: -0.000450%, <3>: +0.000000% <0>: -0.652946%, <1>: -0.006393%, <2>: +0.000000%, <3>: +0.000000% <0>: +1.575974%, <1>: -0.037453%, <2>: -0.000015%, <3>: +0.000015% <0>: +1.112831%, <1>: -0.018646%, <2>: +0.000000%, <3>: +0.000000% <0>: -1.781616%, <1>: -0.047318%, <2>: -0.000038%, <3>: +0.000000% <0>: +3.359970%, <1>: -0.171242%, <2>: -0.000450%, <3>: +0.000015% <0>: -1.008263%, <1>: -0.015205%, <2>: -0.000015%, <3>: +0.000000% <0>: +1.109550%, <1>: -0.018539%, <2>: +0.000000%, <3>: +0.000000% <0>: +0.966965%, <1>: -0.014069%, <2>: -0.000008%, <3>: +0.000015% <0>: +3.250099%, <1>: -0.160156%, <2>: -0.000381%, <3>: +0.000000% <0>: +2.003059%, <1>: -0.060585%, <2>: -0.000053%, <3>: +0.000000% <0>: -3.363350%, <1>: -0.167778%, <2>: -0.000427%, <3>: +0.000000% <0>: +0.195564%, <1>: -0.000572%, <2>: +0.000000%, <3>: +0.000000% <0>: +1.590088%, <1>: -0.038132%, <2>: -0.000015%, <3>: +0.000015% <0>: -0.967476%, <1>: -0.013992%, <2>: +0.000000%, <3>: +0.000000% <0>: -3.360207%, <1>: -0.167458%, <2>: -0.000420%, <3>: +0.000000% <0>: +1.353477%, <1>: -0.027603%, <2>: -0.000015%, <3>: +0.000000% <0>: -0.999245%, <1>: -0.014923%, <2>: -0.000008%, <3>: +0.000015% <0>: +1.555038%, <1>: -0.036453%, <2>: -0.000015%, <3>: +0.000015% <0>: -0.513565%, <1>: -0.003960%, <2>: +0.000000%, <3>: -0.000008% <0>: -1.263115%, <1>: -0.023827%, <2>: -0.000015%, <3>: -0.000008% <0>: -1.957993%, <1>: -0.057129%, <2>: -0.000046%, <3>: +0.000000% <0>: -0.175468%, <1>: -0.000458%, <2>: +0.000015%, <3>: +0.000015% <0>: +2.489761%, <1>: -0.093750%, <2>: -0.000130%, <3>: +0.000015% <0>: -3.370544%, <1>: -0.168503%, <2>: -0.000420%, <3>: -0.000015% <0>: +3.049049%, <1>: -0.140862%, <2>: -0.000298%, <3>: +0.000000% <0>: +2.084816%, <1>: -0.065651%, <2>: -0.000069%, <3>: -0.000008% <0>: +3.283081%, <1>: -0.163452%, <2>: -0.000404%, <3>: +0.000000% <0>: -1.473389%, <1>: -0.032402%, <2>: -0.000015%, <3>: +0.000000% <0>: +3.204193%, <1>: -0.155647%, <2>: -0.000366%, <3>: +0.000015% <0>: +3.239319%, <1>: -0.159096%, <2>: -0.000389%, <3>: +0.000000% <0>: -1.970261%, <1>: -0.057861%, <2>: -0.000053%, <3>: -0.000015% <0>: -0.040138%, <1>: -0.000038%, <2>: -0.000015%, <3>: -0.000015% <0>: +0.138237%, <1>: -0.000290%, <2>: -0.000015%, <3>: +0.000000% <0>: +0.064621%, <1>: -0.000053%, <2>: +0.000000%, <3>: +0.000000% <0>: +3.387131%, <1>: -0.174019%, <2>: -0.000450%, <3>: +0.000015% <0>: +2.173782%, <1>: -0.071388%, <2>: -0.000069%, <3>: +0.000000% <0>: +3.325333%, <1>: -0.167702%, <2>: -0.000420%, <3>: +0.000015% <0>: -3.363731%, <1>: -0.167816%, <2>: -0.000435%, <3>: +0.000000% <0>: -0.256058%, <1>: -0.000977%, <2>: +0.000000%, <3>: +0.000000% <0>: +0.549248%, <1>: -0.004539%, <2>: -0.000008%, <3>: -0.000008% <0>: +3.038361%, <1>: -0.139885%, <2>: -0.000298%, <3>: +0.000000% <0>: -0.330193%, <1>: -0.001633%, <2>: +0.000000%, <3>: +0.000000% <0>: +0.190697%, <1>: -0.000557%, <2>: -0.000008%, <3>: -0.000008% <0>: +3.161789%, <1>: -0.151535%, <2>: -0.000343%, <3>: -0.000008% <0>: +2.628647%, <1>: -0.104561%, <2>: -0.000168%, <3>: +0.000000% <0>: +2.293602%, <1>: -0.079506%, <2>: -0.000092%, <3>: +0.000000% <0>: +0.852753%, <1>: -0.010933%, <2>: +0.000000%, <3>: +0.000000% <0>: +1.203659%, <1>: -0.021820%, <2>: -0.000015%, <3>: +0.000000% <0>: +2.938828%, <1>: -0.130829%, <2>: -0.000259%, <3>: +0.000000% <0>: +1.512238%, <1>: -0.034470%, <2>: -0.000015%, <3>: +0.000015% <0>: +3.180084%, <1>: -0.153290%, <2>: -0.000343%, <3>: +0.000015% <0>: +3.040016%, <1>: -0.140038%, <2>: -0.000298%, <3>: +0.000000% <0>: +1.673088%, <1>: -0.042213%, <2>: -0.000023%, <3>: +0.000000% <0>: +1.746582%, <1>: -0.046021%, <2>: -0.000023%, <3>: +0.000015% <0>: +0.211693%, <1>: -0.000687%, <2>: +0.000000%, <3>: -0.000008% <0>: +3.045143%, <1>: -0.140503%, <2>: -0.000298%, <3>: +0.000015% <0>: -1.682724%, <1>: -0.042236%, <2>: -0.000031%, <3>: -0.000008% <0>: -0.049377%, <1>: -0.000038%, <2>: +0.000000%, <3>: -0.000008% <0>: -2.128799%, <1>: -0.067490%, <2>: -0.000069%, <3>: +0.000015% <0>: +2.091507%, <1>: -0.066071%, <2>: -0.000061%, <3>: +0.000000% <0>: +0.040054%, <1>: -0.000023%, <2>: +0.000000%, <3>: +0.000000% <0>: -2.272896%, <1>: -0.076904%, <2>: -0.000092%, <3>: +0.000000% <0>: +3.062309%, <1>: -0.142113%, <2>: -0.000313%, <3>: -0.000008% <0>: +2.003075%, <1>: -0.060577%, <2>: -0.000053%, <3>: +0.000015% <0>: +2.737282%, <1>: -0.113419%, <2>: -0.000206%, <3>: +0.000000% <0>: +3.022697%, <1>: -0.138435%, <2>: -0.000290%, <3>: -0.000008% <0>: +1.241806%, <1>: -0.023239%, <2>: -0.000015%, <3>: -0.000008% <0>: +2.593254%, <1>: -0.101738%, <2>: -0.000168%, <3>: +0.000000% <0>: -3.378471%, <1>: -0.169296%, <2>: -0.000427%, <3>: +0.000000% <0>: +0.648262%, <1>: -0.006317%, <2>: +0.000000%, <3>: +0.000000% <0>: +1.120140%, <1>: -0.018898%, <2>: +0.000000%, <3>: +0.000000% <0>: +0.387131%, <1>: -0.002243%, <2>: +0.000000%, <3>: +0.000000% <0>: -1.618958%, <1>: -0.039116%, <2>: -0.000023%, <3>: +0.000000% <0>: +3.259407%, <1>: -0.161087%, <2>: -0.000397%, <3>: +0.000000% <0>: -3.364372%, <1>: -0.167885%, <2>: -0.000420%, <3>: +0.000000% <0>: -3.122269%, <1>: -0.144714%, <2>: -0.000313%, <3>: +0.000000% <0>: +1.929787%, <1>: -0.056221%, <2>: -0.000061%, <3>: +0.000000% <0>: +2.274834%, <1>: -0.078217%, <2>: -0.000092%, <3>: +0.000000% <0>: +0.895607%, <1>: -0.012070%, <2>: -0.000008%, <3>: +0.000015% <0>: +2.837944%, <1>: -0.121948%, <2>: -0.000214%, <3>: +0.000000% <0>: -1.775543%, <1>: -0.047012%, <2>: -0.000038%, <3>: -0.000008% <0>: +3.244446%, <1>: -0.159599%, <2>: -0.000366%, <3>: +0.000015% <0>: -0.027161%, <1>: -0.000015%, <2>: +0.000015%, <3>: +0.000000% <0>: -0.552887%, <1>: -0.004578%, <2>: +0.000000%, <3>: +0.000000% <0>: +2.346626%, <1>: -0.083252%, <2>: -0.000107%, <3>: +0.000000% <0>: -2.084961%, <1>: -0.064751%, <2>: -0.000053%, <3>: +0.000000% <0>: -2.231003%, <1>: -0.074104%, <2>: -0.000076%, <3>: -0.000015% <0>: +1.235428%, <1>: -0.022987%, <2>: +0.000000%, <3>: +0.000000%