Ibrahim F Haddad wrote:
Hello all,

I have this equation:
y = x^z * const  (where all variables are floats)

I need to implement it in C.
The program will input for me the value of y and x and the Const.
I need to extract the value of z.

ln z= ln x^z + lnm const
ln y - ln Const = z ln x
z = ln y - ln Const / ln x

now that i have the final equation, what is the
ln function in C? How to call ln from C?
 
 

In C, the natural logarithm is given by the function "log()" and it is defined in the header file "math.h".More precisely, the syntax for the natural logarithm function is:

    #include <math.h>

    double log( double x);   // For natural base e logs

     double log10( double x);   // for base 10 logs

    double exp( double x );   // exponential function, for raising e to the xth power

     double pow( double x, double y);  // returns the value of x raised to the power of y

Try looking at "$ man log", all the details are in there.

Your mathematical expression above "z = lny - ln Const / lnx " can be wrote in C as follows:

 " z = ((log (y) - log( Const)) / log(x)); "

That should do the trick...

/John  < [EMAIL PROTECTED] >
 
 
 

 

-- 
email: [EMAIL PROTECTED]
Local mailserver  , remote 

"They that can give up their liberty to obtain a little temporary safety deserve neither liberty nor safety"--Benjamin Franklin, 1759.
 
  • log Ibrahim F Haddad

Reply via email to