On Mon, 17 Sep 2001, Kevin Moll wrote: > On Sun, 16 Sep 2001, Scott Dattalo wrote: > > > On Sun, 16 Sep 2001, David J Binnington wrote: > > > > > Can anybody give me a kick start with this? > > > > David, > > > > > > You can re-write your equation like: > > > > Z = 10*lg(x^2 + y^2)... > > This isn't the intial expression that was asked to be calculated. It is not > x^2, but rather 2^x. You're right. It would appear that not only do I not read the Off Topic messages, I don't read the On Topic ones either! > Actually, the correct equation is much easier to > calculate than the one you've been discussing. Along the same lines as you > mentioned, the correct way to rewrite it is: > > Z = 10*log(2^(x/10)+2^(y/10)) > = 10*log(2^(x/10) (1+2^[(y-x)/10])) > = 10*log{2^(x/10)} + 10*log{1+2^[(y-x)/10]} > = x+10*log{1 + 2^[w/10]} > > where w = y-x. Notice that this is a subtraction, not a division. That > makes life much easier. For this expression, let y be the larger of your 2 > input values. Now you only need one table lookup for f(w) = > 10*log{1+2^[w/10]} and an addition. I doubt that you can code a division, > power, and log routine in 100 instructions, which is what the table will > occupy since w can be at most 100 if x & y are limited to 100. Plus, > execution cycles will consist of a subtraction to calculate w (and possible > negation if x>y), a table lookup and an addition. Or, you could choose to factor the larger of x and y then the difference in the exponent would always be negative. The table only needs to be 16 entries (if linear interpolation is used). Sorry about the foul up. Scott -- http://www.piclist.com#nomail Going offline? Don't AutoReply us! email listserv@mitvma.mit.edu with SET PICList DIGEST in the body