\[\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\]
↓
\[\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right) \cdot R
\]
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))↓
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(fma
(cos lambda2)
(cos lambda1)
(log1p (expm1 (* (sin lambda1) (sin lambda2)))))
(* (cos phi2) (cos phi1)))))
R))double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
↓
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + (fma(cos(lambda2), cos(lambda1), log1p(expm1((sin(lambda1) * sin(lambda2))))) * (cos(phi2) * cos(phi1))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2)
return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R)
end
↓
function code(R, lambda1, lambda2, phi1, phi2)
return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(fma(cos(lambda2), cos(lambda1), log1p(expm1(Float64(sin(lambda1) * sin(lambda2))))) * Float64(cos(phi2) * cos(phi1))))) * R)
end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
↓
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[Log[1 + N[(Exp[N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
↓
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right) \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right) \cdot R
Alternatives
| Alternative 1 |
|---|
| Error | 6.12% |
|---|
| Cost | 64960 |
|---|
\[R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)
\]
| Alternative 2 |
|---|
| Error | 16.59% |
|---|
| Cost | 58696 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -7.4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\right)}\right)\\
\mathbf{elif}\;\phi_1 \leq 5.8 \cdot 10^{-36}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \sqrt[3]{{\left(\cos \phi_2 \cdot t_0\right)}^{3}}\right)\right)\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 6.12% |
|---|
| Cost | 58688 |
|---|
\[R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\right)
\]
| Alternative 4 |
|---|
| Error | 6.13% |
|---|
| Cost | 58688 |
|---|
\[R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)
\]
| Alternative 5 |
|---|
| Error | 16.58% |
|---|
| Cost | 58632 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\right)}\right)\\
\mathbf{elif}\;\phi_1 \leq 5.8 \cdot 10^{-36}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \sqrt[3]{{\left(\cos \phi_2 \cdot t_0\right)}^{3}}\right)\right)\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 16.13% |
|---|
| Cost | 58436 |
|---|
\[\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot e^{\log \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_1\right)\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 2.2 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_1\right)\right)\right)\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 16.13% |
|---|
| Cost | 58436 |
|---|
\[\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_1\right)\right)\right)}\right)\\
\mathbf{elif}\;\phi_1 \leq 4.6 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_1\right)\right)\right)\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 16.15% |
|---|
| Cost | 52424 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -5.6 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \left(\cos \phi_1 \cdot t_0\right)\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.3 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \mathsf{log1p}\left(\mathsf{expm1}\left(\left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot t_0\right)\right)\right)\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 44.16% |
|---|
| Cost | 39372 |
|---|
\[\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq -0.15:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \cos \phi_1\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 0.85:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_1 \cdot t_1\right) \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 52:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot \left|\cos \lambda_1\right|\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_2 \cdot t_1\right)\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 36.44% |
|---|
| Cost | 39369 |
|---|
\[\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.0049 \lor \neg \left(\phi_1 \leq 9.5 \cdot 10^{-55}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \left(\cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right) \cdot \left(1 + \left(\phi_1 \cdot \phi_1\right) \cdot -0.5\right)\right)\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 36.9% |
|---|
| Cost | 39236 |
|---|
\[\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -5.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \lambda_1 \cdot \cos \phi_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)\right)\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 36.9% |
|---|
| Cost | 39236 |
|---|
\[\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -5.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \lambda_1 \cdot \left(\cos \phi_2 \cdot \cos \phi_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \phi_2\right)\right)\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 36.9% |
|---|
| Cost | 39236 |
|---|
\[\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -5.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \lambda_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \lambda_2 \cdot t_0\right)\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 26.13% |
|---|
| Cost | 39232 |
|---|
\[R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_2 \cdot \cos \phi_1\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\]
| Alternative 15 |
|---|
| Error | 44.21% |
|---|
| Cost | 38980 |
|---|
\[\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \phi_1\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
t_2 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq -0.19:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t_0\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 0.08:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \left(\cos \phi_1 \cdot t_2\right) \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 85000 \lor \neg \left(\phi_2 \leq 7.7 \cdot 10^{+18}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot t_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + t_0\right)\\
\end{array}
\]
| Alternative 16 |
|---|
| Error | 44.23% |
|---|
| Cost | 33480 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
t_2 := R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot \cos \phi_1\right)\\
\mathbf{if}\;\phi_2 \leq -0.38:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\phi_2 \leq 0.0095:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \left(\cos \phi_1 \cdot t_0\right) \cdot \left(1 + -0.5 \cdot \left(\phi_2 \cdot \phi_2\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 85000 \lor \neg \left(\phi_2 \leq 7.1 \cdot 10^{+18}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\]
| Alternative 17 |
|---|
| Error | 50.37% |
|---|
| Cost | 32836 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -0.0036:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\cos \phi_2 \cdot t_0\right)\right)\\
\end{array}
\]
| Alternative 18 |
|---|
| Error | 50.37% |
|---|
| Cost | 32836 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.02:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_2 \cdot t_0\right)\\
\end{array}
\]
| Alternative 19 |
|---|
| Error | 51.96% |
|---|
| Cost | 26372 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.0029:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right)\\
\end{array}
\]
| Alternative 20 |
|---|
| Error | 50.12% |
|---|
| Cost | 26372 |
|---|
\[\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -0.0018:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\cos \phi_1 \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\cos \phi_2 \cdot t_0\right)\right)\\
\end{array}
\]
| Alternative 21 |
|---|
| Error | 61.19% |
|---|
| Cost | 20168 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -6 \cdot 10^{-148}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right)\\
\mathbf{elif}\;\phi_2 \leq 1.45 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right)\\
\end{array}
\]
| Alternative 22 |
|---|
| Error | 64.32% |
|---|
| Cost | 19916 |
|---|
\[\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right)\\
\mathbf{if}\;\phi_2 \leq -1.2 \cdot 10^{-280}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_2 \leq 2.3 \cdot 10^{-209}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{elif}\;\phi_2 \leq 3.5 \cdot 10^{-30}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_2\right)\\
\end{array}
\]
| Alternative 23 |
|---|
| Error | 72.77% |
|---|
| Cost | 19652 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -4.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \lambda_1 \cdot \cos \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\end{array}
\]
| Alternative 24 |
|---|
| Error | 82.12% |
|---|
| Cost | 13376 |
|---|
\[R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)
\]