Haversine[z]
gives the haversine function
.
Haversine
Haversine[z]
gives the haversine function
.
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 all close allBasic Examples (4)
Haversine[.5]Plot over a subset of the reals:
Plot[Haversine[z], {z, 0, 5Pi}]Plot over a subset of the complexes:
ComplexPlot3D[Haversine[z], {z, -2π - 2I, 2π + 2I}, PlotLegends -> Automatic]Series[Haversine[x], {x, 0, 7}]Scope (39)
Numerical Evaluation (6)
Haversine[.8]N[Haversine[1 / 7], 50]The precision of the output tracks the precision of the input:
Haversine[0.2000000000000000000]N[Haversine[798 + I]]Evaluate efficiently at high precision:
Haversine[13`100]//TimingHaversine[58`100000];//TimingCompute the elementwise values of an array using automatic threading:
Haversine[ {{5π / 6, 0}, {3π / 2, -π / 2}}]Or compute the matrix Haversine function using MatrixFunction:
MatrixFunction[Haversine[#]&, {{5π / 6, 0}, {3π / 2, -π / 2}}]Haversine can be used with Interval and CenteredInterval objects:
Haversine[Interval[{0.5, 0.6}]]Haversine[CenteredInterval[2, 1 / 100]]Or compute average-case statistical intervals using Around:
Haversine[Around[2, 0.01]]Specific Values (3)
The values of Haversine at fixed points:
Table[Haversine[Pi / n], {n, 1, 4}]Haversine[0]Find the first positive extremum of Haversine using Solve:
Solve[D[Haversine[x], x] == 0 && 0 < x < 2 π, x]xmax = x /. First[%]Plot[Haversine[x], {x, 0, 4Pi}, Epilog -> Style[Point[{xmax, Haversine[xmax]}], PointSize[Large], Red]]Visualization (3)
Plot the Haversine function:
Plot[Haversine[x], {x, -2π, 2π}]Plot the real part of Haversine(z):
ComplexContourPlot[Re[Haversine[z]], {z, -2π - π I, 2π + π I}, Contours -> 24]Plot the imaginary part of Haversine(z):
ComplexContourPlot[Im[Haversine[z]], {z, -2π - π I, 2π + π I}, Contours -> 24]Table[PolarPlot[Haversine[k ϕ], {ϕ, 0, 2 π}, Sequence[Frame -> True, FrameTicks -> {{{-1, -0.5, 0, 0.5, 1}, None}, {{-1, -0.5, 0, 0.5, 1}, None}}, PlotLabel -> "k=" <> ToString[k]]], {k, 1, 8}]Function Properties (13)
Haversine is defined for all real and complex values:
FunctionDomain[Haversine[x], x]FunctionDomain[Haversine[z], z, Complexes]Haversine achieves all values between zero and one, inclusive, on the reals:
FunctionRange[Haversine[x], x, y]The range for complex values is the whole plane:
FunctionRange[Haversine[z], z, y, Complexes]Haversine is periodic with period
:
FunctionPeriod[Haversine[x], x]Expand using ComplexExpand assuming real variables x and y:
ComplexExpand[Haversine[x + I y]]Haversine has the mirror property
:
FullSimplify[Haversine[Conjugate[z]] == Conjugate[Haversine[z]]]Haversine is an analytic function:
FunctionAnalytic[Haversine[x], x]Haversine is neither non-decreasing nor non-increasing:
FunctionMonotonicity[Haversine[x], x]Haversine is not injective:
FunctionInjective[Haversine[x], x]Plot[{Haversine[x], .3}, {x, 0, 4 π}]Haversine is not surjective:
FunctionSurjective[Haversine[x], x]Plot[{Haversine[x], 2}, {x, -5 π, 5 π}]Haversine is non-negative:
FunctionSign[Haversine[x], x]Haversine has no singularities or discontinuities:
FunctionSingularities[Haversine[x], x]FunctionDiscontinuities[Haversine[x], x]Haversine is neither convex nor concave:
FunctionConvexity[Haversine[x], x]TraditionalForm formatting:
Haversine[θ]//TraditionalFormDifferentiation (3)
D[Haversine[z], z]Table[D[Haversine[z], {z, k}], {k, 1, 3}]//FullSimplifyPlot[%, {z, -10, 10}, PlotLegends -> {"First Derivative", "Second Derivative", "Third Derivative"}]The formula for the ![]()
derivative:
D[Haversine[z], {z, k}]// FullSimplifyIntegration (3)
Compute the indefinite integral using Integrate:
Integrate[Haversine[x], x]// FullSimplifyFullSimplify[D[%, x] == Haversine[x]]// FullSimplifyIntegrate[Haversine[x], {x, 0, Pi / 3}]Integrate[Tan[x] Haversine[x] , x]// FullSimplifyIntegrate[Exp[x] Haversine [x], {x, 0, Pi / 2}]// FullSimplifySeries Expansions (4)
Find the Taylor expansion using Series:
Series[Haversine[x], {x, 0, 7}]Plots of the first three approximations around
:
terms = Normal@Table[Series[Haversine[x], {x, 1, m}], {m, 1, 5, 2}];
Plot[{Haversine[x], terms}, {x, -3Pi, 3Pi}, PlotRange -> {-3, 3}]The general term in the series expansion using SeriesCoefficient:
SeriesCoefficient[Haversine[x], {x, 0, n}]The first-order Fourier series:
FourierSeries[Haversine[x], x, 1]This happens to be the complete series:
FullSimplify[% == Haversine[x]]The Taylor expansion at a generic point:
Series[Haversine[x], {x, x0, 2}]// FullSimplifyHaversine can be applied to a power series:
Haversine[x + O[x] ^ 4]Function Representations (4)
Haversine can be represent in terms of Sin:
FullSimplify[Haversine[x] == Sin[x / 2]^2]Haversine[x] == Sum[((-1)^k - 1/2(2k)!)x^2k, {k, 1, ∞}]//FullSimplifyHaversine can be represented in terms of MeijerG:
(1/2) (1 - Sqrt[π] MeijerG[{{}, {}}, {{0}, {(1/2)}}, (x/2), (1/2)]) == Haversine[x]//FullSimplifyHaversine can be represented as a DifferentialRoot:
DifferentialRootReduce[Haversine[x], x]Applications (1)
Distance between two points on a sphere:
SphereDistance[{ϕ1_, θ1_}, {ϕ2_, θ2_}, r_] := r InverseHaversine[Haversine[ϕ1 - ϕ2] + Cos[ϕ1]Cos[ϕ2]Haversine[θ1 - θ2]]Distance between two cities in kilometers (assuming spherical Earth):
SphereDistance[c1_, c2_] := Module[{k1, k2, res}, {k1, k2} = CityData[#, "Coordinates"]& /@ {c1, c2};res = SphereDistance[k1 Degree, k2 Degree, 6378.14];res]SphereDistance["New York", "Tokyo"]Find the distance between the North Pole and the nearest city to it, using the defined function with Haversine:
Min[{SphereDistance[#, "North Pole"]& /@ {"Stockholm", "Oslo", "Helsinki"}}]Properties & Relations (2)
Derivative of haversine function:
D[Haversine[x], x]Integral of haversine function:
Integrate[Haversine[x], x]Use FunctionExpand to expand Haversine in terms of standard trigonometric functions:
Haversine[x]//FunctionExpandSee Also
Related Guides
Related Links
History
Text
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.
APA
Wolfram Language. (2008). Haversine. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/Haversine.html
BibTeX
@misc{reference.wolfram_2026_haversine, author="Wolfram Research", title="{Haversine}", year="2008", howpublished="\url{https://reference.wolfram.com/language/ref/Haversine.html}", note=[Accessed: 12-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_haversine, organization={Wolfram Research}, title={Haversine}, year={2008}, url={https://reference.wolfram.com/language/ref/Haversine.html}, note=[Accessed: 12-June-2026]}