News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

logarithmic instructions in fpu

Started by jalvarado, May 31, 2012, 02:34:52 PM

Previous topic - Next topic

jalvarado

can anybody bring me information and examples of logarithmic  instructions in floating point unit (FPU)

dedndave


jalvarado

thanks is very useful.  :icon14: anyone can bring me more especific examples of using  logarithmic  instructions in fpu??

dedndave

what are you trying to do ?

many times, log values are converted to log base 2, "worked" on, then converted back
so - one of the first things you might want to learn would be converting logs between bases

logb(a) = logc(a) / logc(b)

RuiLoureiro

Quote from: jalvarado on June 09, 2012, 02:52:51 AM
thanks is very useful.  :icon14: anyone can bring me more especific examples of using  logarithmic  instructions in fpu??
What do you mean with "more especific examples" ?
              What do you mean with "using logaritmic instructions" ?
              What do you want to do ?

jalvarado

so im trying to find another example like this http://www.ray.masmcode.com/tutorial/fpuchap13.htm , to understand the logic of the program using  logarithmic  instructions

dedndave

Rui is a good guy to help you, here
he has recently been doing a lot with logs and the FPU

jalvarado


qWord

What did you not understand: the mathematics or it's implementation?
MREAL macros - when you need floating point arithmetic while assembling!

RuiLoureiro

Quote from: jalvarado on June 09, 2012, 03:31:46 AM
so im trying to find another example like this http://www.ray.masmcode.com/tutorial/fpuchap13.htm , to understand the logic of the program using  logarithmic  instructions

Hi jalvarado,
           Sorry but the best person to explain that example is the author
           Raymond.

           Meanwhile one simple problem can be this: how do you know the
exponent y if you know z and x and the equation z=x^y ?

jalvarado

Quote from: qWord on June 09, 2012, 04:10:03 AM
What did you not understand: the mathematics or it's implementation?

it's implementation

qWord

#11
Quote from: dedndave on June 09, 2012, 02:59:09 AMlogb(a) = logc(a) / logc(b)
fld FP8(0.301029995663981) ; 1/log2(10)
fld FP8(0.001) ; test value = 10^-3
fyl2x
fstp realVar ; = log(0.001) = log2(0.001)/log2(10) = -3

;OR: log(x) = log10(2)*log2(x)
fldlg2
fld FP8(0.001)
fyl2x
fstp realVar
MREAL macros - when you need floating point arithmetic while assembling!

RuiLoureiro

jalvarado,
Based on logb(a) = logc(a) / logc(b) given by Dave,

dont forget this 2 important formulas:

            log10(x)= log2(x). (1/log2(10))

            ln(x)      = log2(x). (1/log2(e))

If we have y=(e^x-e^-x)/2, to find x=f(y) we need to use logarithms.