GONIOLOGY

The first part of this page shows how to program all gonio functions for a programming language, equipped with only a couple of basic math functions.
All functions can be tested with the provided JavaScript calculators.
The second part shows how to solve for angles and sides in all kinds of triangles.
Please note that this page is not a replacement for a math book. If you were looking for explanations, you went out of luck!

Angle conversions
Trigonometric functions
Inverse trigonometric functions
Arctangent2 function
Hyperbolic functions
Inverse hyperbolic functions

Solving triangles: Euclidean
Solving triangles: spherical
Solving triangles: hyperbolic

Most programming languages have at least a couple of transcendental functions in their math libraries, like sine, cosine, arctangent, (natural) logarithm, square root and exponentiation.
All these functions can be programmed with high precision, but why should you do this yourself? If needed, double precision routines can be found in for instance the Slatec library (Fortran; cf. Netlib and other sources).
With only a couple of transcendental functions all other gonio functions can be calculated. Let's see how that is done.

Angle conversions

The circle is divided into 360 degrees, which is equal to 2*pi radians.
A degree is divided into 60 minutes and a minute is divided into 60 seconds.
With this knowledge the conversions can be calculated easily.
The gonio functions of most programming languages work with radians.
The conversion from decimal degrees to degrees:minutes:seconds boils down to:
degrees: take the integer part
minutes: integer part of: (degrees * 60) mod 60
seconds: (degrees * 3600) mod 60
From degrees:minutes:seconds to decimal degrees:
degrees + (minutes + (seconds/60))/60

Angle inputAngle output
Angle type:
degrees
degrees:minutes:seconds
multiple of pi

Input value or formula:

Angle type:
degrees
degrees:minutes:seconds
multiple of pi

Output value:

Trigonometric functions

tangent(x) = tan(x) = sin(x)/cos(x)
cotangent(x) = cotan(x) = cotg(x) = 1/tan(x)
secant(x) = sec(x) = 1/cos(x)
cosecant(x) = cosec(x) = csc(x) = 1/sin(x)
exsecant(x) = exsec(x) = sec(x)-1
coexsecant(x) = coexsec(x) = cosec(x)-1
versine(x) = vers(x) = 1-cos(x)
coversine(x) = covers(x) = 1-sin(x)
haversine(x) = hav(x) = 0.5*vers(x) = (sin(0.5*x))2
hacoversine(x) = hacov(x) = 0.5*covers(x)

Complex
z = x + iy
sin(z) = sin(x)*cosh(y) + i*cos(x)*sinh(y)
cos(z) = cos(x)*cosh(y) - i*sin(x)*sinh(y)
tan(z) = (sin(2*x)+i*sinh(2*y))/(cos(2*x)+cosh(2*y))
cotan(z) = (sin(2*x)-i*sinh(2*y))/(cosh(2*y)-cos(2*x))
Modulus and phase:
|sin(z)| = sqrt(sin(x)*sin(x) + sinh(y)*sinh(y))
arg(sin(z)) = atan(cotan(x)*tanh(y))
|cos(z)| = sqrt(cos(x)*cos(x) + sinh(y)*sinh(y))
arg(cos(z)) = -atan(tan(x)*tanh(y))
|tan(z)| = sqrt((cosh(2*y)-cos(2*x))/(cosh(2*y)+cos(2*x)))
arg(tan(z)) = atan(sinh(2*y)/sin(2*x))

This figure shows the geometrical equivalence of the trigonometric functions: Angle inputScalar output
Function:
Angle type:
degrees
multiple of pi

Input value or formula:

Output value:

Inverse trigonometric functions

pi = 4*atan(1)
arcsine(x) = arcsin(x) = asin(x) = atan(x/sqrt(1-x*x)) with |x|<=1
arccosine(x) = arccos(x) = acos(x) = 0.5*pi-arcsin(x) with |x|<=1
arctangent(x) = arctan(x) = atan(x) should be a built-in function
arccotangent(x) = arccotan(x) = arccotg(x) = atan(1/x)
arcsecant(x) = arcsec(x) = arccos(1/x) with |x|>=1
arccosecant(x) = arccosec(x) = arccsc(x) = arcsin(1/x) with |x|>=1
arcversine(x) = arcvers(x) = atan(sqrt(2*x-x*x)/(1-x)) with 0<=x<=2
arccoversine(x) = arccovers(x) = atan((1-x)/sqrt(2*x-x*x)) with 0<=x<=2
archaversine(x) = archav(x) = ahav(x) = invhav(x) = atan(2*sqrt(x-x*x)/(1-2*x)) = 2*arcsin(sqrt(x)) with 0<=x<=1
arcexsecant(x) = arcexsec(x) = atan(sqrt(x*x+2*x)) with x<=-2 or x>=0

Complex
z = x + iy
u = 0.5*sqrt((x+1)*(x+1)+y*y) + 0.5*sqrt((x-1)*(x-1)+y*y)
v = 0.5*sqrt((x+1)*(x+1)+y*y) - 0.5*sqrt((x-1)*(x-1)+y*y)
k = 0 or an integer
arcsin(z) = k*pi + (-1)k*arcsin(v) + (-1)k*i*ln(u+sqrt(u*u-1))
arccos(z) = 2*k*pi +/- (arccos(v) - i*ln(u+sqrt(u*u-1)))
arctan(z) = k*pi + 0.5*atan(2*x/(1-x*x-y*y)) + 0.25*i*ln((x*x+(y+1)*(y+1))/(x*x+(y-1)*(y-1))) with z2 not -1

Scalar inputAngle output
Function:

Input value or formula:

Angle type:
degrees
multiple of pi

Output value:

Arctangent2 function

This is a special arctangent function, used in the conversion of polar coordinates. This function needs 2 arguments. Note that some implementations work with the x-coordinate first, then the y-coordinate. Customary is first y, then x.

```atan2(y,x)
if x=0 then
if y=0 then return error or 0
if y>0 then return pi/2
if y<0 then return -pi/2
if x>0 then return atan(y/x)
if x<0 then
if y>=0 then return atan(y/x)+pi
if y<0 then return atan(y/x)-pi
```
JavaScript has the atan2 function with the correct order of arguments built in.

Scalar inputAngle output
Function: atan2(y,x)

Input values or formulas:
y:
x:

Angle type:
degrees
multiple of pi

Output value:

Hyperbolic functions

hyperbolic sine = sinh(x) = 0.5*(exp(x)-exp(-x))
hyperbolic cosine = cosh(x) = 0.5*(exp(x)+exp(-x))
hyperbolic tangent = tanh(x) = sinh(x)/cosh(x) = (exp(2*x)-1)/(exp(2*x)+1)
hyperbolic cotangent = cotanh(x) = cotgh(x) = 1/tanh(x)
hyperbolic secant = sech(x) = 1/cosh(x)
hyperbolic cosecant = cosech(x) = csch(x) = 1/sinh(x)
hyperbolic versine = versh(x) = 1-cosh(x)
hyperbolic coversine = coversh(x) = 1-sinh(x)
hyperbolic haversine = havh(x) = 0.5*(1-cosh(x)) = -sinh(x/2)*sinh(x/2)

Complex
z = x + iy
sinh(z) = sinh(x)*cos(y) + i*cosh(x)*sin(y)
cosh(z) = cosh(x)*cos(y) + i*sinh(x)*sin(y)
tanh(z) = (sinh(2*x)+i*sin(2*y))/(cosh(2*x)+cos(2*y))
cotanh(z) = (sinh(2*x)-i*sin(2*y))/(cosh(2*x)-cos(2*y))
Modulus and phase:
|sinh(z)| = sqrt(sinh(x)*sinh(x) + sin(y)*sin(y))
arg(sinh(z)) = atan(cotanh(x)*tan(y))
|cosh(z)| = sqrt(sinh(x)*sinh(x) + cos(y)*cos(y))
arg(cosh(z)) = atan(tanh(x)*tan(y))
|tanh(z)| = sqrt((cosh(2*x)-cos(2*y))/(cosh(2*x)+cos(2*y)))
arg(tanh(z)) = atan(sin(2*y)/sinh(2*x))

Scalar inputScalar output
Function:

Input value or formula:

Output value:

Inverse hyperbolic functions

hyperbolic arcsine = arcsinh(x) = ln(x+sqrt(x*x+1))
hyperbolic arccosine = arccosh(x) = ln(x+sqrt(x*x-1)), with x>=1
hyperbolic arctangent = arctanh(x) 0.5*ln((1+x)/(1-x)), with 0<=|x|<1
hyperbolic arccotangent = arccotanh(x) = arccotgh(x) = arctanh(1/x), with |x|>1
hyperbolic arcsecant = arcsech(x) = arccosh(1/x) = ln(x-sqrt(x*x-1)), with 0<x<=1
hyperbolic arccosecant = arccosech(x) = arccsch(x) = arcsinh(1/x) = ln(sqrt(x*x+1)-x), with x not 0

Scalar inputScalar output
Function:

Input value or formula:

Output value: Solving triangles: Euclidean

Formulae valid for all acute and obtuse triangles.
Degrees are assumed.
Sum of the angles of an Euclidean ('flat') triangle is 180°

Sine rules
a/sin(α) = b/sin(β) = c/sin(γ)

Cosine rules
a2 = b2 + c2 - 2bc.cos(α)
b2 = a2 + c2 - 2ac.cos(β)
c2 = a2 + b2 - 2ab.cos(γ)

Solutions
If necessary, rotate your triangle in order to obtain one of the following cases.

Given: side-angle-side (enclosed angle): b α c
From the cosine rules: a2 = b2 + c2 - 2bc.cos(α)
From the sine rules: sin(β) = b.sin(α)/a, sin(γ) = c.sin(α)/a

Given: side-side-angle (opposite angle): b c β
From the sine rules: sin(γ) = c.sin(β)/b
From the sum of angles: α = 180 - β - γ
From the sine rules: a = c.sin(α)/sin(γ)

Given: angle-side-angle (adjacent angles): α c β
From the sum of angles: γ = 180 - α - β
From the sine rules: a = c.sin(α)/sin(γ), b = c.sin(β)/sin(γ)

Given: side-angle-angle (adjacent & opposite angles): c α γ
From the sum of angles: β = 180 - α - γ
From the sine rules: a = c.sin(α)/sin(γ), b = c.sin(β)/sin(γ)

Given: side-side-side (3 sides): a b c
From the cosine rules: cos(α) = (b2+c2-a2)/2bc
From the sine rules: sin(β) = b.sin(α)/a, sin(γ) = c.sin(α)/a

Given: angle-angle-angle (3 angles): α β γ
Cannot be solved. One of the sides has to be known. Solve this through side-angle-angle or angle-side-angle.

Solving triangles: spherical

Formulae valid for all acute and obtuse triangles.
Degrees are assumed.
Sum of the angles of a spherical triangle is between 180° and 540°, not including
Sum of the sides, expressed as an angle, is less than 360°
To convert a side expressed as an angle to a length:
if side is in radians, multiply by r, the radius of the sphere,
if side is in degrees, multiply by π.r/180

Sine rules
sin(α)/sin(a) = sin(β)/sin(b) = sin(γ)/sin(c)

Cosine rules for the sides
cos(a) = cos(b).cos(c) + sin(b).sin(c).cos(α)
cos(b) = cos(a).cos(c) + sin(a).sin(c).cos(β)
cos(c) = cos(a).cos(b) + sin(a).sin(b).cos(γ)

Cosine rules for the angles
cos(α) = -cos(β).cos(γ) + sin(β).sin(γ).cos(a)
cos(β) = -cos(α).cos(γ) + sin(α).sin(γ).cos(b)
cos(γ) = -cos(α).cos(β) + sin(α).sin(β).cos(c)

Solutions
If necessary, rotate your triangle in order to obtain one of the following cases.

Given: side-angle-side (enclosed angle): b α c
From the cosine rules for the sides: cos(a) = cos(b).cos(c) + sin(b).sin(c).cos(α)
From the sine rules: sin(β) = sin(α).sin(b)/sin(a), sin(γ) = sin(α).sin(c)/sin(a)

Given: side-side-angle (opposite angle): b c β
From the sine rules: sin(γ) = sin(β).sin(c)/sin(b)
From the cosine rules for the sides, using the cosine rule for the angles for cos(α):
cos(a) = [cos(b).cos(c) - sin(b).sin(c).cos(β).cos(γ)]/[1 - sin(b).sin(c).sin(β).sin(γ)]
From the cosine rules for the angles: cos(α) = -cos(β).cos(γ) + sin(β).sin(γ).cos(a)

Given: angle-side-angle (adjacent angles): α c β
From the cosine rules for the angles: cos(γ) = -cos(α).cos(β) + sin(α).sin(β).cos(c)
From the sine rules: sin(a) = sin(α).sin(c)/sin(γ), sin(b) = sin(β).sin(c)/sin(γ)

Given: side-angle-angle (adjacent & opposite angles): c α γ
From the sine rules: sin(a) = sin(α).sin(c)/sin(γ)
From the cosine rules for the sides, using the cosine rule for the angles for cos(β):
cos(b) = [cos(a).cos(c) - sin(a).sin(c).cos(α).cos(γ)]/[1 - sin(a).sin(c).sin(α).sin(γ)]
From the cosine rules for the angles: cos(β) = -cos(α).cos(γ) + sin(α).sin(γ).cos(b)

Given: side-side-side (3 sides): a b c
From the cosine rules for the sides: cos(α) = [cos(a) - cos(b).cos(c)]/[sin(b).sin(c)]
From the sine rules: sin(β) = sin(α).sin(b)/sin(a), sin(γ) = sin(α).sin(c)/sin(a)

Given: angle-angle-angle (3 angles): α β γ
From the cosine rules for the angles: cos(a) = [cos(α) + cos(β).cos(γ)]/[sin(β).sin(γ)]
From the sine rules: sin(b) = sin(β).sin(a)/sin(α), sin(c) = sin(γ).sin(a)/sin(α)

Solving triangles: hyperbolic

Formulae valid for all acute and obtuse triangles.
Degrees are assumed.
Sum of the angles of a hyperbolic triangle is less than 180°

Sine rules
sinh(a)/sin(α) = sinh(b)/sin(β) = sinh(c)/sin(γ)

Cosine rules for the sides
cosh(a) = cosh(b).cosh(c) - sinh(b).sinh(c).cos(α)
cosh(b) = cosh(a).cosh(c) - sinh(a).sinh(c).cos(β)
cosh(c) = cosh(a).cosh(b) - sinh(a).sinh(b).cos(γ)

Cosine rules for the angles
cos(α) = -cos(β).cos(γ) + sin(β).sin(γ).cosh(a)
cos(β) = -cos(α).cos(γ) + sin(α).sin(γ).cosh(b)
cos(γ) = -cos(α).cos(β) + sin(α).sin(β).cosh(c)

Solutions
If necessary, rotate your triangle in order to obtain one of the following cases.

Given: side-angle-side (enclosed angle): b α c
From the cosine rules for the sides: cosh(a) = cosh(b).cosh(c) - sinh(b).sinh(c).cos(α)
From the sine rules: sin(β) = sin(α).sinh(b)/sinh(a), sin(γ) = sin(α).sinh(c)/sinh(a)

Given: side-side-angle (opposite angle): b c β
From the sine rules: sin(γ) = sin(β).sinh(c)/sinh(b)
From the cosine rules for the sides, using the cosine rule for the angles for cos(α):
cosh(a) = [cosh(b).cosh(c) + sinh(b).sinh(c).cos(β).cos(γ)]/[1 + sinh(b).sinh(c).sin(β).sin(γ)]
From the cosine rules for the angles: cos(α) = -cos(β).cos(γ) + sin(β).sin(γ).cosh(a)

Given: angle-side-angle (adjacent angles): α c β
From the cosine rules for the angles: cos(γ) = -cos(α).cos(β) + sin(α).sin(β).cosh(c)
From the sine rules: sinh(a) = sin(α).sinh(c)/sin(γ), sinh(b) = sin(β).sinh(c)/sin(γ)

Given: side-angle-angle (adjacent & opposite angles): c α γ
From the sine rules: sinh(a) = sin(α).sinh(c)/sin(γ)
From the cosine rules for the sides, using the cosine rule for the angles for cos(β):
cosh(b) = [cosh(a).cosh(c) + sinh(a).sinh(c).cos(α).cos(γ)]/[1 + sinh(a).sinh(c).sin(α).sin(γ)]
From the cosine rules for the angles: cos(β) = -cos(α).cos(γ) + sin(α).sin(γ).cosh(b)

Given: side-side-side (3 sides): a b c
From the cosine rules for the sides: cos(α) = [cosh(b).cosh(c) - cosh(a)]/[sinh(b).sinh(c)]
From the sine rules: sin(β) = sin(α).sinh(b)/sinh(a), sin(γ) = sin(α).sinh(c)/sinh(a)

Given: angle-angle-angle (3 angles): α β γ
From the cosine rules for the angles: cosh(a) = [cos(α) + cos(β).cos(γ)]/[sin(β).sin(γ)]
From the sine rules: sinh(b) = sin(β).sinh(a)/sin(α), sinh(c) = sin(γ).sinh(a)/sin(α)

Very nice, but I still don't understand...
This page is what you get. I am not Doctor Math. Please browse through the internet or a good math book of your choice.

I think you made an error...
I am very pleased to know what's wrong. Mail me (mag ook in het Nederlands):

Saves a lot of explanation and fool-proof coding.

What does NaN in the output mean?
Not a number. You must have entered an illegal value.

So I can enter a formula in the input fields; why doesn't this work?
You probably have entered an illegal (JavaScript) function. Something like 1/sqrt(2) or ln(4.5) works. Note that a couple of math functions work as expected (sin, cos, tan, asin, acos, atan, sqrt, exp, ln (= e-log), log (= 10-log), pi; use exp(1) for the value e). This is because I have predefined some functions; for the rest use JavaScript Math.functions.

How does the input type multiple of pi work?
If you would like to enter a value of 0.25*pi radians, you could enter 0.7853981633974483 with the radians button activated, or 0.25*pi, or pi/4; or just 0.25 with the multiple of pi button activated.

No complex numbers for input?
Alas no, only reals.

I need a formula for double angles, derivatives...
Did you know there are math books and other web sites in existence? I don't want to copy what's already there, but some day more will be added to this page.
One good source is: Handbook of mathematical functions, M. Abramowitz, I.A. Stegun, Dover Publications, ISBN 0-486-61272-4.

Legalese?
You know the drill: copyright and all commercial rights are with the author (Oscar van Vlijmen). You receive this as is. The author is not responsible. You can't do anything serious with the information or the calculators. If you build bridges with the aid of this page, they are likely to collapse. Etcetera. But, the author did his best to provide accurate information and scripts.

Waarom geen Nederlandse pagina?
Zucht... Zo veel vragen en zo weinig goeie antwoorden!

© Oscar van Vlijmen, January 2003
Modification date: 2005-12-28

This page is part of the Dutch language site "Eenheden, constanten en conversies" (Units of measurement, constants and conversions).