Hello, I need to implement in fixed-point pow(0.5,x) and pow(x, 0.75) and I was wondering if anyone has some pointers with regards to this? We are dealing with 32-bit words. Any help is greatly appreciated. -- Best regards, Anders Buvarp anders@lsil.com
Fixed-point implementation of pow(0.5,x) and pow(x, 0.75)
Started by ●September 19, 2003
Reply by ●September 20, 20032003-09-20
Anders Buvarp wrote:> Hello, >=20 > I need to implement in fixed-point pow(0.5,x) and pow(x, 0.75) and > I was wondering if anyone has some pointers with regards to this? >=20 > We are dealing with 32-bit words. >=20 > Any help is greatly appreciated. >=20I imagine that a search for sqrt(x) will be more fruitful than one for=20 pow(0.5,x). Try Google, http://www.nr.com/ and http://www.dspguru.com/ The best algorithm for an exact solution will depend on the relative=20 cost of multiplication and division on the target processor. Be aware=20 that there are good ways to approximate sqrt(x=B2 + y=B2). Jerry --=20 Engineering is the art of making what you want from things you can get. =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF
Reply by ●September 22, 20032003-09-22
Jerry Avins wrote:> Anders Buvarp wrote: > >> Hello, >> >> I need to implement in fixed-point pow(0.5,x) and pow(x, 0.75) and >> I was wondering if anyone has some pointers with regards to this? >> >> We are dealing with 32-bit words. >> >> Any help is greatly appreciated. >> > I imagine that a search for sqrt(x) will be more fruitful than one for > pow(0.5,x). Try Google, http://www.nr.com/ and http://www.dspguru.com/pow(0.5,x) returns 0.5^x, not x^0.5. I suppose it's possible that the OP got them backwards though, because sqrt(x) is way more common than 0.5^x. -- Jim Thomas Principal Applications Engineer Bittware, Inc jthomas@bittware.com http://www.bittware.com (703) 779-7770 The problem with the future is that it keeps turning into the present - Hobbes
Reply by ●September 22, 20032003-09-22
Hello Jerry, Thanks for your reply. I need 0.5^x so I don't see the connection with x^0.5. The division here takes 70 longer than the multiply. For x^0.75, I guess I can do sqrt(sqrt(x*x*x)). Thanks again, Anders Jerry Avins wrote:> > Anders Buvarp wrote: > > > Hello, > >
Reply by ●September 22, 20032003-09-22
Hello Jim, Thanks for your reply. It is 0.5^x I need, maybe I can do a look-up table for now. Thanks, Anders Jim Thomas wrote:> > Jerry Avins wrote: > > Anders Buvarp wrote: > > > >> Hello, > >> > >> I need to implement in fixed-point pow(0.5,x) and pow(x, 0.75) and > >> I was wondering if anyone has some pointers with regards to this? > >> > >> We are dealing with 32-bit words. > >> > >> Any help is greatly appreciated. > >> > > I imagine that a search for sqrt(x) will be more fruitful than one for > > pow(0.5,x). Try Google, http://www.nr.com/ and http://www.dspguru.com/ > > pow(0.5,x) returns 0.5^x, not x^0.5. I suppose it's possible that the > OP got them backwards though, because sqrt(x) is way more common than 0.5^x. > > -- > Jim Thomas Principal Applications Engineer Bittware, Inc > jthomas@bittware.com http://www.bittware.com (703) 779-7770 > The problem with the future is that it keeps turning into the present - > Hobbes-- Best regards, Anders Buvarp anders@lsil.com
Reply by ●September 22, 20032003-09-22
Anders Buvarp wrote:> > It is 0.5^x I need, maybe I can do a look-up table for now. >Unless my math is failing me, 0.5^x = 1 / 2^x, so you should be able to do the 2^x with just shifts (or incrementing the exponent if it's floating point) followed by a reciprocal, no ? Paul
Reply by ●September 22, 20032003-09-22
Anders Buvarp wrote:> Hello Jim, >=20 > Thanks for your reply. >=20 > It is 0.5^x I need, maybe I can do a look-up table for now. >=20 > Thanks, > Anders >=20 > Jim Thomas wrote: >=20 >>Jerry Avins wrote: >> >>>Anders Buvarp wrote: >>> >>> >>>>Hello, >>>> >>>>I need to implement in fixed-point pow(0.5,x) and pow(x, 0.75) and >>>>I was wondering if anyone has some pointers with regards to this? >>>> >>>>We are dealing with 32-bit words. >>>> >>>>Any help is greatly appreciated. >>>> >>> >>>I imagine that a search for sqrt(x) will be more fruitful than one for=>>>pow(0.5,x). Try Google, http://www.nr.com/ and http://www.dspguru.com/=>> >>pow(0.5,x) returns 0.5^x, not x^0.5. I suppose it's possible that the >>OP got them backwards though, because sqrt(x) is way more common than 0==2E5^x.>> >>-- >>Jim Thomas Principal Applications Engineer Bittware, Inc >>jthomas@bittware.com http://www.bittware.com (703) 779-7770 >>The problem with the future is that it keeps turning into the present -=>>Hobbes >=20 >=20Would 1/2^x be easier? Excuse me for getting it bass ackwards. Jerry --=20 Engineering is the art of making what you want from things you can get. =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF
Reply by ●September 22, 20032003-09-22
Anders Buvarp <anders@lsil.com> wrote in message news:<3F6F3463.65C9128F@lsil.com>...> Hello Jerry, > > Thanks for your reply. > > I need 0.5^x so I don't see the connection with x^0.5. > > The division here takes 70 longer than the multiply. > > For x^0.75, I guess I can do sqrt(sqrt(x*x*x)). > > Thanks again, > Anders > > Jerry Avins wrote: > > > > Anders Buvarp wrote: > > > > > Hello, > > >Nothing is told about x. if x is negative and integer it is mere a left shift by x. For e.g x= -3 & -4 would give (-1)* 2^3 and 2^4. if x is positive and integer it is 1/2^x and I guess there could some efficient way of division and not too much cycle consuming! if x is floating number then I guess some look up table can appoximate good results - it is interesting see how much memory it eats up! Regards, Santosh
Reply by ●September 23, 20032003-09-23
You could easily get at 'em if you had log/antilog - these usually aren't too bad to implement. Matt Anders Buvarp <anders@lsil.com> wrote in message news:<3F6BB47E.F0EBF176@lsil.com>...> Hello, > > I need to implement in fixed-point pow(0.5,x) and pow(x, 0.75) and > I was wondering if anyone has some pointers with regards to this? > > We are dealing with 32-bit words. > > Any help is greatly appreciated.
Reply by ●September 23, 20032003-09-23
"Anders Buvarp" <anders@lsil.com> wrote in message news:3F6F348E.F8214A04@lsil.com...> Hello Jim, > > Thanks for your reply. > > It is 0.5^x I need, maybe I can do a look-up table for now.Well, 0.5**x (Fortran notation), is just a right shift if x is an integer, and 0.5 is a fixed point number with the binary point far enough not to shift out the only 1. If you want to multiply a fixed point number by 0.5**x, shift it right by x. (snip)> > >> I need to implement in fixed-point pow(0.5,x) and pow(x, 0.75) and > > >> I was wondering if anyone has some pointers with regards to this? > > >> > > >> We are dealing with 32-bit words.It probably isn't hard to write a Newton-Raphson algorithm to do x**0.75. In floating point I might do it sqrt(x)*sqrt(sqrt(x)), or sqrt(sqrt(x*x*x)). The latter might work well in fixed point arithmetic if it can be made not to overflow. If this is homework, please reference the newsgroup. -- glen