Thursday, July 13, 2017

logarithm in c



Example: 
A simple method is to take log of the given number on base 4, and if we get an integer then number is power of 4. i.e log4(n) = log10(n)/log10(4) as per below examples

from stack overflow:

Simple math:
    log2 (x) = logy (x) / logy (2)
where y can be anything, which for standard log functions is either 10 or e.

When working with logarithms on your graphing calculator,
you must remember the "Change of Base Formula":
Remember, the notation:
 log x is with respect to base 10
ln x is with respect to base e

Logarithm basics

https://stackoverflow.com/questions/3064926/how-to-write-log-base2-in-c-c
https://mathbits.com/MathBits/TISection/Algebra2/logarithms.htm

Working with Logarithms
 
logarithm is an exponent.
 
As this example shows, 3 is the exponent to which the base 2 must be raised to create the answer of 8, or  23 = 8.  In general terms:
(where x > 0 and b is a positive constant not equal to 1)

BASE 10:     Logarithms with base 10 are called common logarithms.
           
When the base is not indicated, base 10 is implied.
      
The log key on the graphing calculator will calculate the
                          common (or base 10) logarithm.
                2nd log 
will calculate the antilogarithm or 10x

No comments:

Post a Comment