Haversine
Details

- Mathematical function, suitable for both symbolic and numerical manipulation.
- The haversine function is defined by
.
- The argument of haversine is assumed to be in radians. (Multiply by Degree to convert from degrees.)
- Haversine[z] is the entire function of z with no branch cut discontinuities.
- Haversine can be evaluated to arbitrary numerical precision.
- Haversine automatically threads over lists. »
- Haversine can be used with Interval and CenteredInterval objects. »
Examples
open allclose allBasic Examples (4)Summary of the most common use cases

https://wolfram.com/xid/0h2q2hqwgu-k3f0cr

Plot over a subset of the reals:

https://wolfram.com/xid/0h2q2hqwgu-h40caa

Plot over a subset of the complexes:

https://wolfram.com/xid/0h2q2hqwgu-kiedlx


https://wolfram.com/xid/0h2q2hqwgu-lelxri

Scope (39)Survey of the scope of standard use cases
Numerical Evaluation (6)

https://wolfram.com/xid/0h2q2hqwgu-l274ju


https://wolfram.com/xid/0h2q2hqwgu-b0wt9

The precision of the output tracks the precision of the input:

https://wolfram.com/xid/0h2q2hqwgu-y7k4a


https://wolfram.com/xid/0h2q2hqwgu-hfml09

Evaluate efficiently at high precision:

https://wolfram.com/xid/0h2q2hqwgu-di5gcr


https://wolfram.com/xid/0h2q2hqwgu-bq2c6r

Compute the elementwise values of an array using automatic threading:

https://wolfram.com/xid/0h2q2hqwgu-thgd2

Or compute the matrix Haversine function using MatrixFunction:

https://wolfram.com/xid/0h2q2hqwgu-o5jpo

Haversine can be used with Interval and CenteredInterval objects:

https://wolfram.com/xid/0h2q2hqwgu-h0d6g


https://wolfram.com/xid/0h2q2hqwgu-dj6d9x

Or compute average-case statistical intervals using Around:

https://wolfram.com/xid/0h2q2hqwgu-cw18bq

Specific Values (3)
The values of Haversine at fixed points:

https://wolfram.com/xid/0h2q2hqwgu-ft9f33


https://wolfram.com/xid/0h2q2hqwgu-m5p0tw

Find the first positive extremum of Haversine using Solve:

https://wolfram.com/xid/0h2q2hqwgu-f2hrld


https://wolfram.com/xid/0h2q2hqwgu-oyn5tf


https://wolfram.com/xid/0h2q2hqwgu-bv6k7w

Visualization (3)
Plot the Haversine function:

https://wolfram.com/xid/0h2q2hqwgu-ecj8m7

Plot the real part of Haversine(z):

https://wolfram.com/xid/0h2q2hqwgu-bo5grg

Plot the imaginary part of Haversine(z):

https://wolfram.com/xid/0h2q2hqwgu-sd9k1


https://wolfram.com/xid/0h2q2hqwgu-epb4bn

Function Properties (13)
Haversine is defined for all real and complex values:

https://wolfram.com/xid/0h2q2hqwgu-cl7ele


https://wolfram.com/xid/0h2q2hqwgu-de3irc

Haversine achieves all values between zero and one, inclusive, on the reals:

https://wolfram.com/xid/0h2q2hqwgu-evf2yr

The range for complex values is the whole plane:

https://wolfram.com/xid/0h2q2hqwgu-fphbrc

Haversine is periodic with period :

https://wolfram.com/xid/0h2q2hqwgu-ewxrep

Expand using ComplexExpand assuming real variables x and y:

https://wolfram.com/xid/0h2q2hqwgu-j370ou

Haversine has the mirror property :

https://wolfram.com/xid/0h2q2hqwgu-heoddu

Haversine is an analytic function:

https://wolfram.com/xid/0h2q2hqwgu-h5x4l2

Haversine is neither non-decreasing nor non-increasing:

https://wolfram.com/xid/0h2q2hqwgu-g6kynf

Haversine is not injective:

https://wolfram.com/xid/0h2q2hqwgu-gi38d7


https://wolfram.com/xid/0h2q2hqwgu-ctca0g

Haversine is not surjective:

https://wolfram.com/xid/0h2q2hqwgu-hkqec4


https://wolfram.com/xid/0h2q2hqwgu-b1r9xi

Haversine is non-negative:

https://wolfram.com/xid/0h2q2hqwgu-84dui

Haversine has no singularities or discontinuities:

https://wolfram.com/xid/0h2q2hqwgu-mdtl3h


https://wolfram.com/xid/0h2q2hqwgu-mn5jws

Haversine is neither convex nor concave:

https://wolfram.com/xid/0h2q2hqwgu-kdss3

TraditionalForm formatting:

https://wolfram.com/xid/0h2q2hqwgu-ihw3wi

Differentiation (3)
Integration (3)
Compute the indefinite integral using Integrate:

https://wolfram.com/xid/0h2q2hqwgu-bponid


https://wolfram.com/xid/0h2q2hqwgu-op9yly


https://wolfram.com/xid/0h2q2hqwgu-b9jw7l


https://wolfram.com/xid/0h2q2hqwgu-cas


https://wolfram.com/xid/0h2q2hqwgu-hxu52

Series Expansions (4)
Find the Taylor expansion using Series:

https://wolfram.com/xid/0h2q2hqwgu-ewr1h8

Plots of the first three approximations around :

https://wolfram.com/xid/0h2q2hqwgu-binhar

The general term in the series expansion using SeriesCoefficient:

https://wolfram.com/xid/0h2q2hqwgu-dznx2j

The first-order Fourier series:

https://wolfram.com/xid/0h2q2hqwgu-f64drv

This happens to be the complete series:

https://wolfram.com/xid/0h2q2hqwgu-x7ucv6

The Taylor expansion at a generic point:

https://wolfram.com/xid/0h2q2hqwgu-jwxla7

Haversine can be applied to a power series:

https://wolfram.com/xid/0h2q2hqwgu-oveup

Function Representations (4)
Haversine can be represent in terms of Sin:

https://wolfram.com/xid/0h2q2hqwgu-ffau0o


https://wolfram.com/xid/0h2q2hqwgu-27x57o

Haversine can be represented in terms of MeijerG:

https://wolfram.com/xid/0h2q2hqwgu-bwyltp

Haversine can be represented as a DifferentialRoot:

https://wolfram.com/xid/0h2q2hqwgu-p1kqzy

Applications (1)Sample problems that can be solved with this function
Distance between two points on a sphere:

https://wolfram.com/xid/0h2q2hqwgu-g7b3li
Distance between two cities in kilometers (assuming spherical Earth):

https://wolfram.com/xid/0h2q2hqwgu-d7tqsk

https://wolfram.com/xid/0h2q2hqwgu-if3q7b

Find the distance between the North Pole and the nearest city to it, using the defined function with Haversine:

https://wolfram.com/xid/0h2q2hqwgu-4z8kl

Properties & Relations (2)Properties of the function, and connections to other functions
Derivative of haversine function:

https://wolfram.com/xid/0h2q2hqwgu-d8dizp

Integral of haversine function:

https://wolfram.com/xid/0h2q2hqwgu-dhhzby

Use FunctionExpand to expand Haversine in terms of standard trigonometric functions:

https://wolfram.com/xid/0h2q2hqwgu-en4or3

Wolfram Research (2008), Haversine, Wolfram Language function, https://reference.wolfram.com/language/ref/Haversine.html.
Text
Wolfram Research (2008), Haversine, Wolfram Language function, https://reference.wolfram.com/language/ref/Haversine.html.
Wolfram Research (2008), Haversine, Wolfram Language function, https://reference.wolfram.com/language/ref/Haversine.html.
CMS
Wolfram Language. 2008. "Haversine." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Haversine.html.
Wolfram Language. 2008. "Haversine." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/Haversine.html.
APA
Wolfram Language. (2008). Haversine. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Haversine.html
Wolfram Language. (2008). Haversine. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Haversine.html
BibTeX
@misc{reference.wolfram_2025_haversine, author="Wolfram Research", title="{Haversine}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/Haversine.html}", note=[Accessed: 06-June-2025
]}
BibLaTeX
@online{reference.wolfram_2025_haversine, organization={Wolfram Research}, title={Haversine}, year={2008}, url={https://reference.wolfram.com/language/ref/Haversine.html}, note=[Accessed: 06-June-2025
]}