> figuring out the magnitude of a frequency after an FFT. I remember someone, > like Newton, having an algorithm that gave closer and closer > approximatations. Newton's method is embodied in this code: translate to your favourite language: #include double sqrt(double x) { double og, ng; short niter; int expon; if(x <= 0.0) return 0.0; /* sqrt(-ve) undefined */ og = x; if(og < 1.0) og = 1.0/og; og = frexp(og, &expon); og = ldexp(og, expon/2); /* make an educated guess - halv e exponent */ if(x < 1.0) og = 1.0/og; for(niter = 0 ; niter < 20 ; niter++) { /* iterate until value converges */ ng = (x/og + og)/2.0; /* new guess calculated as the a verage of the old guess and the original value divided by the old guess */ if(ng == og) /* no change? finis! */ break; og = ng; } return og; } -- Clyde Smith-Stubbs | HI-TECH Software, | Voice: +61 7 3300 5011 clyde@hitech.com.au | P.O. Box 103, Alderley, | Fax: +61 7 3300 5246 http://www.hitech.com.au | QLD, 4051, AUSTRALIA. | BBS: +61 7 3300 5235 ---------------------------------------------------------------------------- FREE! Download our shareware (FREE for noncommercial use) MS-DOS C Compiler! Point your Web browser at http://www.hitech.com.au/