\[ \begin{array}{c}[lambda1, lambda2] = \mathsf{sort}([lambda1, lambda2])\\ \end{array} \]
\[\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
\]
↓
\[\begin{array}{l}
t_0 := \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)\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\lambda_2 \cdot R\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot R\\
\end{array}
\]
(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
(let* ((t_0
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
(if (<= t_0 0.0) (* lambda2 R) (* t_0 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) {
double t_0 = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
double tmp;
if (t_0 <= 0.0) {
tmp = lambda2 * R;
} else {
tmp = t_0 * R;
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
↓
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
if (t_0 <= 0.0d0) then
tmp = lambda2 * r
else
tmp = t_0 * r
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
↓
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
double tmp;
if (t_0 <= 0.0) {
tmp = lambda2 * R;
} else {
tmp = t_0 * R;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2):
return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
↓
def code(R, lambda1, lambda2, phi1, phi2):
t_0 = math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
tmp = 0
if t_0 <= 0.0:
tmp = lambda2 * R
else:
tmp = t_0 * R
return tmp
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)
t_0 = acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))
tmp = 0.0
if (t_0 <= 0.0)
tmp = Float64(lambda2 * R);
else
tmp = Float64(t_0 * R);
end
return tmp
end
function tmp = code(R, lambda1, lambda2, phi1, phi2)
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
end
↓
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2)
t_0 = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
tmp = 0.0;
if (t_0 <= 0.0)
tmp = lambda2 * R;
else
tmp = t_0 * R;
end
tmp_2 = tmp;
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_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, 0.0], N[(lambda2 * R), $MachinePrecision], N[(t$95$0 * 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
↓
\begin{array}{l}
t_0 := \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)\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;\lambda_2 \cdot R\\
\mathbf{else}:\\
\;\;\;\;t_0 \cdot R\\
\end{array}
Alternatives
| Alternative 1 |
|---|
| Error | 23.9 |
|---|
| Cost | 39368 |
|---|
\[\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t_0 \cdot \cos \lambda_1\right) \cdot R\\
\mathbf{if}\;\phi_1 \leq -680000000000:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\phi_1 \leq 5 \cdot 10^{-32}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + t_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\]
| Alternative 2 |
|---|
| Error | 16.9 |
|---|
| Cost | 39236 |
|---|
\[\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.05 \cdot 10^{-5}:\\
\;\;\;\;\cos^{-1} \left(t_1 + t_0 \cdot \cos \lambda_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(t_1 + t_0 \cdot \cos \lambda_2\right) \cdot R\\
\end{array}
\]
| Alternative 3 |
|---|
| Error | 16.8 |
|---|
| Cost | 39232 |
|---|
\[\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right) \cdot R
\]
| Alternative 4 |
|---|
| Error | 29.8 |
|---|
| Cost | 33096 |
|---|
\[\begin{array}{l}
t_0 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_1 \leq 2500:\\
\;\;\;\;\cos^{-1} \left(\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\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 5 |
|---|
| Error | 29.6 |
|---|
| Cost | 33096 |
|---|
\[\begin{array}{l}
t_0 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{if}\;\phi_2 \leq -8 \cdot 10^{-6}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_2 \leq 8.5 \cdot 10^{+27}:\\
\;\;\;\;\cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 4.2 \cdot 10^{+177}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 6 |
|---|
| Error | 30.0 |
|---|
| Cost | 32840 |
|---|
\[\begin{array}{l}
t_0 := \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \phi_1\right) \cdot R\\
\mathbf{if}\;\phi_1 \leq -0.32:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_1 \leq 0.052:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 7 |
|---|
| Error | 39.3 |
|---|
| Cost | 26568 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -8.5 \cdot 10^{-182}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_2\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right) \cdot R\\
\end{array}
\]
| Alternative 8 |
|---|
| Error | 36.1 |
|---|
| Cost | 26436 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.32:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \left(\lambda_1 - \lambda_2\right) \cdot \cos \phi_2\right) \cdot R\\
\end{array}
\]
| Alternative 9 |
|---|
| Error | 41.8 |
|---|
| Cost | 19784 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.06 \cdot 10^{-188}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 2.9 \cdot 10^{-11}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right) \cdot R\\
\end{array}
\]
| Alternative 10 |
|---|
| Error | 43.5 |
|---|
| Cost | 19652 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.1 \cdot 10^{-188}:\\
\;\;\;\;\cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right) \cdot R\\
\mathbf{elif}\;\phi_2 \leq 4.2 \cdot 10^{-11}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\]
| Alternative 11 |
|---|
| Error | 48.4 |
|---|
| Cost | 13640 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.6 \cdot 10^{-254}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{elif}\;\phi_2 \leq 4.2 \cdot 10^{-11}:\\
\;\;\;\;\cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\end{array}
\]
| Alternative 12 |
|---|
| Error | 47.4 |
|---|
| Cost | 13388 |
|---|
\[\begin{array}{l}
t_0 := \cos^{-1} \cos \lambda_1 \cdot R\\
\mathbf{if}\;\lambda_2 \leq 3.5 \cdot 10^{-135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\lambda_2 \leq 1.8 \cdot 10^{-31}:\\
\;\;\;\;\lambda_2 \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 1.25 \cdot 10^{-5}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \lambda_2 \cdot R\\
\end{array}
\]
| Alternative 13 |
|---|
| Error | 51.8 |
|---|
| Cost | 13256 |
|---|
\[\begin{array}{l}
t_0 := \cos^{-1} \cos \lambda_1 \cdot R\\
\mathbf{if}\;\lambda_1 \leq -1.2 \cdot 10^{-9}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\lambda_1 \leq 1.22 \cdot 10^{-112}:\\
\;\;\;\;\lambda_2 \cdot R\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\]
| Alternative 14 |
|---|
| Error | 46.1 |
|---|
| Cost | 13256 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 2.9 \cdot 10^{-233}:\\
\;\;\;\;\cos^{-1} \cos \lambda_1 \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 7.8 \cdot 10^{-12}:\\
\;\;\;\;\cos^{-1} \cos \phi_1 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \lambda_2 \cdot R\\
\end{array}
\]
| Alternative 15 |
|---|
| Error | 46.3 |
|---|
| Cost | 13256 |
|---|
\[\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 1.56 \cdot 10^{-233}:\\
\;\;\;\;\cos^{-1} \cos \lambda_1 \cdot R\\
\mathbf{elif}\;\lambda_2 \leq 5.8 \cdot 10^{-16}:\\
\;\;\;\;\cos^{-1} \cos \phi_2 \cdot R\\
\mathbf{else}:\\
\;\;\;\;\cos^{-1} \cos \lambda_2 \cdot R\\
\end{array}
\]
| Alternative 16 |
|---|
| Error | 60.0 |
|---|
| Cost | 192 |
|---|
\[\lambda_2 \cdot R
\]