.TH log() "" "" "Mathematics Function (libm)"
.PC "Compute natural logarithm"
.B "#include <math.h>"
\fBdouble \fBlog(\fIz\^\fB) double \fIz\^\fB;\fR
.PP
.B log()
returns the natural (base \fIe\fR) logarithm of its argument \fIz\fR.
.SH Example
.II "half life"
.II radiation
The following example
.II "Lal, Sanjay"
is by Sanjay Lal (sanjayl@tor.comm.mot.com).
It returns the amount of a
quantity of radioactive material that remains
after the passage of a period of time.
Use it when planning your next nuclear dump.
It takes three arguments:
the amount of material, in kilograms;
the half life, in years;
and the time passed, in years.
These can be decimal fractions.
.DM
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
.DE
.DM
main(argc, argv)
int argc; char *argv[];
{
	double num, thalf, time;
.DE
.DM
	if (argc != 4) {
		fprintf(stderr,"Usage: %s amount halflife time\en", argv[0]);
		exit (EXIT_FAILURE);
	}
.DE
.DM
	num = atof (argv[1]);
	thalf = atof (argv[2]);
	time = atof (argv[3]);
	printf("%f\en", num * exp ( -log(2.0) * (time / thalf)));
}
.DE
.SH "See Also"
.Xr "log10()," log10
.Xr "libm" libm
.br
\*(AS, \(sc7.5.4.4
.br
\*(PX Standard, \(sc8.1
.SH Diagnostics
When a domain error occurs
(\fIz\fP is less than or equal to zero),
.B log()
sets
.B errno
to
.B EDOM
and returns zero.
