.TH tan() "" "" "Mathematics Function (libm)"
.PC "Calculate tangent"
.B "#include <math.h>"
\fBdouble tan(\fIradian\^\fB) double \fIradian\^\fB;\fR
.PP
.B tan()
calculates the tangent of its argument
.IR radian ,
which must be in radian measure.
.SH Example
.II "Gringauz, Dmitry"
.II "Fresnel equation"
The following program implements the Fresnel equation,
which computes the percentage of light or energy reflected from
perfect glass, based on the angle of incidence.
It is by Dmitry Gringauz (dmitry@golem.com).
Be sure to compile it with the options \fB\-f\fR and \fB\-lm\fR.
.DM
#include <math.h>
#include <stdio.h>
.DE
.DM
double deg_to_rad(deg)
double deg;
{	
	return deg*PI/180.0;
} 
.DE
.DM
double rad_to_deg(rad)
double rad;
{
	return rad*180.0/PI;
}
.DE
.DM
main()
{
	double i=0.0; /* incidence angle */
	double Ra=0.0; /* angle of refraction */
	double Rho=0.0; /* % reflection of the beam */
	double Ri=1.52; /* refractive index of glass */
.DE
.DM
	printf("\etAngle\et\etRho\en");
	printf("\et-----\et\et---\en");
.DE
.DM
	for (i = 5.0; i <= 90.0; i = i+5.0) {
		double x = 0.0, y = 0.0; /* temporaries */
.DE
.DM
		/* find the angle of refraction */
		Ra = rad_to_deg(asin( sin(deg_to_rad(i)) / Ri));
.DE
.DM
		/* makes sense to calculate these only once */
		x = deg_to_rad(i - Ra);
		y = deg_to_rad(i + Ra);
.DE
.DM	
		/* find out percent of reflected energy */
		Rho = pow(sin(x), 2.0) / pow(sin(y), 2.0) + 
				pow(tan(x), 2.0) / pow(tan(y), 2.0);
		Rho = Rho/2.0*100.00;
		printf("\et%f\et%f\en", i, Rho);
	} /* for */
} /* main */
.DE
.SH "See Also"
.Xr "libm," libm
.Xr "tanh()" tanh()
.br
\*(AS, \(sc7.5.2.7
.br
\*(PX Standard, \(sc8.1
.SH Diagnostics
.B tan()
returns a very large number where it is singular, and sets
.B errno
to
.BR ERANGE .
