ttaann() -- Mathematics Function (libm)

Calculate tangent
#iinncclluuddee <mmaatthh.hh>
ddoouubbllee ttaann(_r_a_d_i_a_n) ddoouubbllee _r_a_d_i_a_n;

ttaann()  calculates the  tangent of  its  argument _r_a_d_i_a_n,  which must  be in
radian measure.

_E_x_a_m_p_l_e
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f and -llmm.

#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 */

_S_e_e _A_l_s_o
lliibbmm, ttaannhh()
ANSI Standard, section 7.5.2.7
POSIX Standard, section 8.1

_D_i_a_g_n_o_s_t_i_c_s
ttaann() returns a  very large number where it is  singular, and sets eerrrrnnoo to
EERRAANNGGEE.
