COHERENT manpages
This page displays the COHERENT manpage for tan() [Calculate tangent].
List of available manpages
Index
tan() -- Mathematics Function (libm)
Calculate tangent
#include <math.h>
double tan(radian) double radian;
tan() calculates the tangent of its argument radian, which must be in
radian measure.
Example
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 -f and -lm.
#include <math.h>
#include <stdio.h>
double deg_to_rad(deg)
double deg;
{
return deg*PI/180.0;
}
double rad_to_deg(rad)
double rad;
{
return rad*180.0/PI;
}
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 */
printf("\tAngle\t\tRho\n");
printf("\t-----\t\t---\n");
for (i = 5.0; i <= 90.0; i = i+5.0) {
double x = 0.0, y = 0.0; /* temporaries */
/* find the angle of refraction */
Ra = rad_to_deg(asin( sin(deg_to_rad(i)) / Ri));
/* makes sense to calculate these only once */
x = deg_to_rad(i - Ra);
y = deg_to_rad(i + Ra);
/* 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("\t%f\t%f\n", i, Rho);
} /* for */
} /* main */
See Also
libm,
tanh()
ANSI Standard, §7.5.2.7
POSIX Standard, §8.1
Diagnostics
tan() returns a very large number where it is singular, and sets errno to
ERANGE.











