Thursday, April 26, 2018

algorithms - Books/resources for implementing various mathematical functions in fixed point arithmetic for DSP purposes


I'm looking for books or resources that cover the following in detail:





  • implementing mathematical functions (e.g., logarithm, exponential, sine, cosine, inverse) in fixed point arithmetic for DSP purposes.




  • techniques like using lookup tables, Taylor series, etc.




I am fairly familiar with C programming and am more interested in the algorithms on how to go about implementing various mathematical functions in an efficient manner.



Answer



the general polynomial form is:



f(u)=Nn=0 an un=a0+(a1+(a2+(a3+...(aN2+(aN1+aNu)u)u ...)u)u)u


the latter form is using Horner's method, which is highly recommended, especially if you're doing this in single-precision floating point.


then for a few specific functions:


square root:


f(x1)x1x2N=4a0=1.0a1=0.49959804148061a2=0.12047308243453a3=0.04585425015501a4=0.01076564682800


if 2x4, use the above to evaluate x2 and multiply that result with 2 to get x. as with log2(x), apply power of 2 scaling to scale the argument to the necessary range.


base 2 logarithm:


xf(x1)log2(x)1x2N=5a0=1.44254494359510a1=0.7181452567504a2=0.45754919692582a3=0.27790534462866a4=0.121797910687826a5=0.02584144982967


base 2 exponential:


f(x)2x0x1N=4a0=1.0a1=0.69303212081966a2=0.24137976293709a3=0.05203236900844a4=0.01355574723481



sine:


xf(x2)sin(π2x)1x1N=4a0=1.57079632679490a1=0.64596406188166a2=0.07969158490912a3=0.00467687997706a4=0.00015303015470


cosine (use sine):


cos(πx)=12sin2(π2x)


tangent:


tan(x)=sin(x)cos(x)


inverse tangent:


xf(x2)arctan(x)1x1N=4a0=1.0a1=0.33288950512027a2=0.08467922817644a3=0.03252232640125a4=0.00749305860992


arctan(x)=π2arctan(1x)1x


arctan(x)=π2arctan(1x)x1



inverse sine:


arcsin(x)=arctan(x1x2)


inverse cosine:


arccos(x)=π2arcsin(x)=π2arctan(x1x2)


No comments:

Post a Comment

periodic trends - Comparing radii in lithium, beryllium, magnesium, aluminium and sodium ions

Apparently the of last four, MgX2+ is closest in radius to LiX+. Is this true, and if so, why would a whole larger shell ($\ce{...