In C language, the natural logarithm is expressed as log, and the syntax is log(double x), which returns the natural logarithm of a positive real number x with e as the base.
Representation of ln in C language
In C language, the natural logarithm of ln is expressed as log, instead of ln.
log function is the natural logarithm function with e as the base. Its syntax is:
<code class="c">double log(double x);</code>
where:
Example:
<code class="c">#include <stdio.h> #include <math.h> int main() { double x = 2.71828; double result = log(x); printf("ln(%f) = %f\n", x, result); return 0; }</code>
Output:
<code>ln(2.718280) = 1.000000</code>
The above is the detailed content of How to express ln in c language. For more information, please follow other related articles on the PHP Chinese website!