I was hoping to publish every Saturday, but this past Saturday I got sidetracked. So without further ado, I bring you the next installment in the trigonometry series of articles.

Each of the six basic trigonometric functions has an inverse function. The inverse functions for sine, cosine, and tangent (arcsine, arcosine, and arctangent, respectively) are already defined natively in PHP. In ASP, only the inverse function for tangent (arctangent) is defined, but we will create an adapter for it to be consistent with the abbreviation in PHP. We also need to define some constants that are already present in PHP but not in ASP.

#### ASP

`Const M_PI = 3.14159265358979323846`

`Const M_PI_2 = M_PI / 2`

`function asin(x)`

`asin = atn(x / sqr(1 - x ^ 2))`

`end function`

`function acos(x)`

`acos = M_PI_2 - asin(x)`

`end function`

`function atan(x)`

`atan = atn(x)`

`end function`

As you can probably guess, the inverse functions for cosecant, secant, and cotangent are arccosecant, arcsecant, and arccotangent.

#### ASP

`function acsc(x)`

`acsc = asin(1 / x)`

`end function`

`function asec(x)`

`asec = M_PI_2 - acsc(x)`

`end function`

`function acot(x)`

`acot = M_PI_2 - atn(x)`

`end function`

#### PHP

`function acsc($x)`

`{`

`return asin(1 / $x);`

`}`

`function asec($x)`

`{`

`return (M_PI_2 - acsc($x));`

`}`

`function acot($x)`

`{`

`return (M_PI_2 - atan($x));`

`}`

Next time we'll do something different for a change. I promise.

## No comments:

Post a Comment