
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 12 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
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) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 60.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- phi1 phi2) 2.0)))
(t_1 (pow t_0 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2))
(t_4 (+ t_1 (* t_3 t_2)))
(t_5 (sqrt (- 1.0 t_4))))
(if (<= t_2 -0.082)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt t_1))))
(if (<= t_2 3.9e-13)
(* R (* 2.0 (atan2 (sqrt (+ t_1 (* t_3 t_0))) t_5)))
(* R (* 2.0 (atan2 t_2 t_5)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) / 2.0));
double t_1 = pow(t_0, 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double t_4 = t_1 + (t_3 * t_2);
double t_5 = sqrt((1.0 - t_4));
double tmp;
if (t_2 <= -0.082) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(t_1)));
} else if (t_2 <= 3.9e-13) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * t_0))), t_5));
} else {
tmp = R * (2.0 * atan2(t_2, t_5));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0))
t_1 = t_0 ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
t_4 = t_1 + (t_3 * t_2)
t_5 = sqrt((1.0d0 - t_4))
if (t_2 <= (-0.082d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt(t_1)))
else if (t_2 <= 3.9d-13) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_3 * t_0))), t_5))
else
tmp = r * (2.0d0 * atan2(t_2, t_5))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((phi1 - phi2) / 2.0));
double t_1 = Math.pow(t_0, 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double t_4 = t_1 + (t_3 * t_2);
double t_5 = Math.sqrt((1.0 - t_4));
double tmp;
if (t_2 <= -0.082) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt(t_1)));
} else if (t_2 <= 3.9e-13) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_3 * t_0))), t_5));
} else {
tmp = R * (2.0 * Math.atan2(t_2, t_5));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) / 2.0)) t_1 = math.pow(t_0, 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 t_4 = t_1 + (t_3 * t_2) t_5 = math.sqrt((1.0 - t_4)) tmp = 0 if t_2 <= -0.082: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt(t_1))) elif t_2 <= 3.9e-13: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_3 * t_0))), t_5)) else: tmp = R * (2.0 * math.atan2(t_2, t_5)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) t_1 = t_0 ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) t_4 = Float64(t_1 + Float64(t_3 * t_2)) t_5 = sqrt(Float64(1.0 - t_4)) tmp = 0.0 if (t_2 <= -0.082) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(t_1)))); elseif (t_2 <= 3.9e-13) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_3 * t_0))), t_5))); else tmp = Float64(R * Float64(2.0 * atan(t_2, t_5))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)); t_1 = t_0 ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; t_4 = t_1 + (t_3 * t_2); t_5 = sqrt((1.0 - t_4)); tmp = 0.0; if (t_2 <= -0.082) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(t_1))); elseif (t_2 <= 3.9e-13) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * t_0))), t_5)); else tmp = R * (2.0 * atan2(t_2, t_5)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 + N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -0.082], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 3.9e-13], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
t_1 := {t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\\
t_4 := t\_1 + t\_3 \cdot t\_2\\
t_5 := \sqrt{1 - t\_4}\\
\mathbf{if}\;t\_2 \leq -0.082:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{t\_1}}\right)\\
\mathbf{elif}\;t\_2 \leq 3.9 \cdot 10^{-13}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_3 \cdot t\_0}}{t\_5}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{t\_5}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0820000000000000034Initial program 55.7%
Taylor expanded in lambda1 around 0
Applied rewrites17.1%
Taylor expanded in lambda1 around -inf
Applied rewrites18.6%
Taylor expanded in lambda1 around -inf
Applied rewrites20.1%
if -0.0820000000000000034 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 3.90000000000000004e-13Initial program 74.4%
Taylor expanded in lambda1 around 0
Applied rewrites55.0%
Taylor expanded in lambda1 around -inf
Applied rewrites54.4%
if 3.90000000000000004e-13 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 55.4%
Taylor expanded in lambda1 around 0
Applied rewrites29.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- phi1 phi2) 2.0)))
(t_1 (pow t_0 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2))
(t_4 (+ t_1 (* t_3 t_2))))
(if (<= t_2 0.024)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 (+ t_1 (* t_3 t_0)))))))
(* R (* 2.0 (atan2 t_2 (sqrt (- 1.0 t_4))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) / 2.0));
double t_1 = pow(t_0, 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double t_4 = t_1 + (t_3 * t_2);
double tmp;
if (t_2 <= 0.024) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - (t_1 + (t_3 * t_0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - t_4))));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0))
t_1 = t_0 ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
t_4 = t_1 + (t_3 * t_2)
if (t_2 <= 0.024d0) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - (t_1 + (t_3 * t_0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((phi1 - phi2) / 2.0));
double t_1 = Math.pow(t_0, 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double t_4 = t_1 + (t_3 * t_2);
double tmp;
if (t_2 <= 0.024) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - (t_1 + (t_3 * t_0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) / 2.0)) t_1 = math.pow(t_0, 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 t_4 = t_1 + (t_3 * t_2) tmp = 0 if t_2 <= 0.024: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - (t_1 + (t_3 * t_0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) t_1 = t_0 ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) t_4 = Float64(t_1 + Float64(t_3 * t_2)) tmp = 0.0 if (t_2 <= 0.024) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_3 * t_0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)); t_1 = t_0 ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; t_4 = t_1 + (t_3 * t_2); tmp = 0.0; if (t_2 <= 0.024) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - (t_1 + (t_3 * t_0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 + N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, 0.024], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
t_1 := {t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\\
t_4 := t\_1 + t\_3 \cdot t\_2\\
\mathbf{if}\;t\_2 \leq 0.024:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - \left(t\_1 + t\_3 \cdot t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.024Initial program 63.3%
Taylor expanded in lambda1 around 0
Applied rewrites38.3%
Taylor expanded in lambda1 around -inf
Applied rewrites39.3%
if 0.024 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 55.1%
Taylor expanded in lambda1 around 0
Applied rewrites29.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- phi1 phi2) 2.0)))
(t_1 (pow t_0 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (+ t_1 (* (* (* (cos phi1) (cos phi2)) t_2) t_2)))
(t_4 (sqrt (- 1.0 t_3))))
(if (<= t_2 -2e-78)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt t_1))))
(if (<= t_2 2.1e-15)
(* R (* 2.0 (atan2 t_0 t_4)))
(* R (* 2.0 (atan2 t_2 t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) / 2.0));
double t_1 = pow(t_0, 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 + (((cos(phi1) * cos(phi2)) * t_2) * t_2);
double t_4 = sqrt((1.0 - t_3));
double tmp;
if (t_2 <= -2e-78) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt(t_1)));
} else if (t_2 <= 2.1e-15) {
tmp = R * (2.0 * atan2(t_0, t_4));
} else {
tmp = R * (2.0 * atan2(t_2, t_4));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0))
t_1 = t_0 ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_1 + (((cos(phi1) * cos(phi2)) * t_2) * t_2)
t_4 = sqrt((1.0d0 - t_3))
if (t_2 <= (-2d-78)) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt(t_1)))
else if (t_2 <= 2.1d-15) then
tmp = r * (2.0d0 * atan2(t_0, t_4))
else
tmp = r * (2.0d0 * atan2(t_2, t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((phi1 - phi2) / 2.0));
double t_1 = Math.pow(t_0, 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 + (((Math.cos(phi1) * Math.cos(phi2)) * t_2) * t_2);
double t_4 = Math.sqrt((1.0 - t_3));
double tmp;
if (t_2 <= -2e-78) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt(t_1)));
} else if (t_2 <= 2.1e-15) {
tmp = R * (2.0 * Math.atan2(t_0, t_4));
} else {
tmp = R * (2.0 * Math.atan2(t_2, t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) / 2.0)) t_1 = math.pow(t_0, 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_1 + (((math.cos(phi1) * math.cos(phi2)) * t_2) * t_2) t_4 = math.sqrt((1.0 - t_3)) tmp = 0 if t_2 <= -2e-78: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt(t_1))) elif t_2 <= 2.1e-15: tmp = R * (2.0 * math.atan2(t_0, t_4)) else: tmp = R * (2.0 * math.atan2(t_2, t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) t_1 = t_0 ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_1 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_2) * t_2)) t_4 = sqrt(Float64(1.0 - t_3)) tmp = 0.0 if (t_2 <= -2e-78) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(t_1)))); elseif (t_2 <= 2.1e-15) tmp = Float64(R * Float64(2.0 * atan(t_0, t_4))); else tmp = Float64(R * Float64(2.0 * atan(t_2, t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)); t_1 = t_0 ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_1 + (((cos(phi1) * cos(phi2)) * t_2) * t_2); t_4 = sqrt((1.0 - t_3)); tmp = 0.0; if (t_2 <= -2e-78) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt(t_1))); elseif (t_2 <= 2.1e-15) tmp = R * (2.0 * atan2(t_0, t_4)); else tmp = R * (2.0 * atan2(t_2, t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -2e-78], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2.1e-15], N[(R * N[(2.0 * N[ArcTan[t$95$0 / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
t_1 := {t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_1 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) \cdot t\_2\\
t_4 := \sqrt{1 - t\_3}\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-78}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{t\_1}}\right)\\
\mathbf{elif}\;t\_2 \leq 2.1 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{t\_4}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{t\_4}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -2e-78Initial program 58.3%
Taylor expanded in lambda1 around 0
Applied rewrites24.3%
Taylor expanded in lambda1 around -inf
Applied rewrites25.8%
Taylor expanded in lambda1 around -inf
Applied rewrites19.2%
if -2e-78 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 2.09999999999999981e-15Initial program 77.5%
Taylor expanded in lambda1 around 0
Applied rewrites41.0%
if 2.09999999999999981e-15 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 55.4%
Taylor expanded in lambda1 around 0
Applied rewrites29.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) t_0))
(t_2 (sin (/ (- phi1 phi2) 2.0)))
(t_3 (pow t_2 2.0))
(t_4 (sqrt (- 1.0 (+ t_3 (* t_1 t_0))))))
(if (<= t_0 -2e-78)
(* R (* 2.0 (- 1.0 (+ t_3 (* t_1 t_2)))))
(if (<= t_0 2.1e-15)
(* R (* 2.0 (atan2 t_2 t_4)))
(* R (* 2.0 (atan2 t_0 t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * t_0;
double t_2 = sin(((phi1 - phi2) / 2.0));
double t_3 = pow(t_2, 2.0);
double t_4 = sqrt((1.0 - (t_3 + (t_1 * t_0))));
double tmp;
if (t_0 <= -2e-78) {
tmp = R * (2.0 * (1.0 - (t_3 + (t_1 * t_2))));
} else if (t_0 <= 2.1e-15) {
tmp = R * (2.0 * atan2(t_2, t_4));
} else {
tmp = R * (2.0 * atan2(t_0, t_4));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * t_0
t_2 = sin(((phi1 - phi2) / 2.0d0))
t_3 = t_2 ** 2.0d0
t_4 = sqrt((1.0d0 - (t_3 + (t_1 * t_0))))
if (t_0 <= (-2d-78)) then
tmp = r * (2.0d0 * (1.0d0 - (t_3 + (t_1 * t_2))))
else if (t_0 <= 2.1d-15) then
tmp = r * (2.0d0 * atan2(t_2, t_4))
else
tmp = r * (2.0d0 * atan2(t_0, t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * t_0;
double t_2 = Math.sin(((phi1 - phi2) / 2.0));
double t_3 = Math.pow(t_2, 2.0);
double t_4 = Math.sqrt((1.0 - (t_3 + (t_1 * t_0))));
double tmp;
if (t_0 <= -2e-78) {
tmp = R * (2.0 * (1.0 - (t_3 + (t_1 * t_2))));
} else if (t_0 <= 2.1e-15) {
tmp = R * (2.0 * Math.atan2(t_2, t_4));
} else {
tmp = R * (2.0 * Math.atan2(t_0, t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * t_0 t_2 = math.sin(((phi1 - phi2) / 2.0)) t_3 = math.pow(t_2, 2.0) t_4 = math.sqrt((1.0 - (t_3 + (t_1 * t_0)))) tmp = 0 if t_0 <= -2e-78: tmp = R * (2.0 * (1.0 - (t_3 + (t_1 * t_2)))) elif t_0 <= 2.1e-15: tmp = R * (2.0 * math.atan2(t_2, t_4)) else: tmp = R * (2.0 * math.atan2(t_0, t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * t_0) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) t_3 = t_2 ^ 2.0 t_4 = sqrt(Float64(1.0 - Float64(t_3 + Float64(t_1 * t_0)))) tmp = 0.0 if (t_0 <= -2e-78) tmp = Float64(R * Float64(2.0 * Float64(1.0 - Float64(t_3 + Float64(t_1 * t_2))))); elseif (t_0 <= 2.1e-15) tmp = Float64(R * Float64(2.0 * atan(t_2, t_4))); else tmp = Float64(R * Float64(2.0 * atan(t_0, t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * t_0; t_2 = sin(((phi1 - phi2) / 2.0)); t_3 = t_2 ^ 2.0; t_4 = sqrt((1.0 - (t_3 + (t_1 * t_0)))); tmp = 0.0; if (t_0 <= -2e-78) tmp = R * (2.0 * (1.0 - (t_3 + (t_1 * t_2)))); elseif (t_0 <= 2.1e-15) tmp = R * (2.0 * atan2(t_2, t_4)); else tmp = R * (2.0 * atan2(t_0, t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[t$95$2, 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - N[(t$95$3 + N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, -2e-78], N[(R * N[(2.0 * N[(1.0 - N[(t$95$3 + N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 2.1e-15], N[(R * N[(2.0 * N[ArcTan[t$95$2 / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\\
t_2 := \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
t_3 := {t\_2}^{2}\\
t_4 := \sqrt{1 - \left(t\_3 + t\_1 \cdot t\_0\right)}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-78}:\\
\;\;\;\;R \cdot \left(2 \cdot \left(1 - \left(t\_3 + t\_1 \cdot t\_2\right)\right)\right)\\
\mathbf{elif}\;t\_0 \leq 2.1 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{t\_4}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{t\_4}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -2e-78Initial program 58.3%
Taylor expanded in lambda1 around 0
Applied rewrites24.3%
Taylor expanded in lambda1 around -inf
Applied rewrites13.9%
Taylor expanded in lambda1 around -inf
Applied rewrites17.6%
if -2e-78 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 2.09999999999999981e-15Initial program 77.5%
Taylor expanded in lambda1 around 0
Applied rewrites41.0%
if 2.09999999999999981e-15 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 55.4%
Taylor expanded in lambda1 around 0
Applied rewrites29.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- phi1 phi2) 2.0)))
(t_1 (pow t_0 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2))
(t_4 (- 1.0 (+ t_1 (* t_3 t_0)))))
(if (<= t_2 -2e-78)
(* R (* 2.0 t_4))
(if (<= t_2 2.1e-15)
(* R (* 2.0 (atan2 t_0 (sqrt t_4))))
(* R (* 2.0 (atan2 t_2 (sqrt (- 1.0 (+ t_1 (* t_3 t_2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) / 2.0));
double t_1 = pow(t_0, 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double t_4 = 1.0 - (t_1 + (t_3 * t_0));
double tmp;
if (t_2 <= -2e-78) {
tmp = R * (2.0 * t_4);
} else if (t_2 <= 2.1e-15) {
tmp = R * (2.0 * atan2(t_0, sqrt(t_4)));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (t_3 * t_2))))));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0))
t_1 = t_0 ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
t_4 = 1.0d0 - (t_1 + (t_3 * t_0))
if (t_2 <= (-2d-78)) then
tmp = r * (2.0d0 * t_4)
else if (t_2 <= 2.1d-15) then
tmp = r * (2.0d0 * atan2(t_0, sqrt(t_4)))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_1 + (t_3 * t_2))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((phi1 - phi2) / 2.0));
double t_1 = Math.pow(t_0, 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double t_4 = 1.0 - (t_1 + (t_3 * t_0));
double tmp;
if (t_2 <= -2e-78) {
tmp = R * (2.0 * t_4);
} else if (t_2 <= 2.1e-15) {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt(t_4)));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_1 + (t_3 * t_2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) / 2.0)) t_1 = math.pow(t_0, 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 t_4 = 1.0 - (t_1 + (t_3 * t_0)) tmp = 0 if t_2 <= -2e-78: tmp = R * (2.0 * t_4) elif t_2 <= 2.1e-15: tmp = R * (2.0 * math.atan2(t_0, math.sqrt(t_4))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_1 + (t_3 * t_2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) t_1 = t_0 ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) t_4 = Float64(1.0 - Float64(t_1 + Float64(t_3 * t_0))) tmp = 0.0 if (t_2 <= -2e-78) tmp = Float64(R * Float64(2.0 * t_4)); elseif (t_2 <= 2.1e-15) tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(t_4)))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(t_3 * t_2))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)); t_1 = t_0 ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; t_4 = 1.0 - (t_1 + (t_3 * t_0)); tmp = 0.0; if (t_2 <= -2e-78) tmp = R * (2.0 * t_4); elseif (t_2 <= 2.1e-15) tmp = R * (2.0 * atan2(t_0, sqrt(t_4))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (t_3 * t_2)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - N[(t$95$1 + N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, -2e-78], N[(R * N[(2.0 * t$95$4), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 2.1e-15], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[t$95$4], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
t_1 := {t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\\
t_4 := 1 - \left(t\_1 + t\_3 \cdot t\_0\right)\\
\mathbf{if}\;t\_2 \leq -2 \cdot 10^{-78}:\\
\;\;\;\;R \cdot \left(2 \cdot t\_4\right)\\
\mathbf{elif}\;t\_2 \leq 2.1 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_1 + t\_3 \cdot t\_2\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -2e-78Initial program 58.3%
Taylor expanded in lambda1 around 0
Applied rewrites24.3%
Taylor expanded in lambda1 around -inf
Applied rewrites13.9%
Taylor expanded in lambda1 around -inf
Applied rewrites17.6%
if -2e-78 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 2.09999999999999981e-15Initial program 77.5%
Taylor expanded in lambda1 around 0
Applied rewrites77.3%
Taylor expanded in lambda1 around -inf
Applied rewrites77.3%
Taylor expanded in lambda1 around -inf
Applied rewrites40.7%
if 2.09999999999999981e-15 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 55.4%
Taylor expanded in lambda1 around 0
Applied rewrites29.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- phi1 phi2) 2.0)))
(t_1 (pow t_0 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2)))
(if (<= t_2 1.16e-89)
(* R (* 2.0 (- 1.0 (+ t_1 (* t_3 t_0)))))
(* R (* 2.0 (atan2 t_2 (sqrt (- 1.0 (+ t_1 (* t_3 t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) / 2.0));
double t_1 = pow(t_0, 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double tmp;
if (t_2 <= 1.16e-89) {
tmp = R * (2.0 * (1.0 - (t_1 + (t_3 * t_0))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (t_3 * t_2))))));
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0))
t_1 = t_0 ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
if (t_2 <= 1.16d-89) then
tmp = r * (2.0d0 * (1.0d0 - (t_1 + (t_3 * t_0))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_1 + (t_3 * t_2))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((phi1 - phi2) / 2.0));
double t_1 = Math.pow(t_0, 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double tmp;
if (t_2 <= 1.16e-89) {
tmp = R * (2.0 * (1.0 - (t_1 + (t_3 * t_0))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_1 + (t_3 * t_2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) / 2.0)) t_1 = math.pow(t_0, 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 tmp = 0 if t_2 <= 1.16e-89: tmp = R * (2.0 * (1.0 - (t_1 + (t_3 * t_0)))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_1 + (t_3 * t_2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) t_1 = t_0 ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) tmp = 0.0 if (t_2 <= 1.16e-89) tmp = Float64(R * Float64(2.0 * Float64(1.0 - Float64(t_1 + Float64(t_3 * t_0))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(t_3 * t_2))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)); t_1 = t_0 ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; tmp = 0.0; if (t_2 <= 1.16e-89) tmp = R * (2.0 * (1.0 - (t_1 + (t_3 * t_0)))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (t_3 * t_2)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, If[LessEqual[t$95$2, 1.16e-89], N[(R * N[(2.0 * N[(1.0 - N[(t$95$1 + N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
t_1 := {t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\\
\mathbf{if}\;t\_2 \leq 1.16 \cdot 10^{-89}:\\
\;\;\;\;R \cdot \left(2 \cdot \left(1 - \left(t\_1 + t\_3 \cdot t\_0\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_1 + t\_3 \cdot t\_2\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 1.15999999999999993e-89Initial program 62.4%
Taylor expanded in lambda1 around 0
Applied rewrites35.0%
Taylor expanded in lambda1 around -inf
Applied rewrites14.4%
Taylor expanded in lambda1 around -inf
Applied rewrites17.1%
if 1.15999999999999993e-89 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 57.6%
Taylor expanded in lambda1 around 0
Applied rewrites29.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- phi1 phi2) 2.0)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_1 1.16e-89)
(*
R
(*
2.0
(- 1.0 (+ (pow t_0 2.0) (* (* (* (cos phi1) (cos phi2)) t_1) t_0)))))
(* R (* 2.0 t_1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) / 2.0));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_1 <= 1.16e-89) {
tmp = R * (2.0 * (1.0 - (pow(t_0, 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_0))));
} else {
tmp = R * (2.0 * t_1);
}
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
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_1 <= 1.16d-89) then
tmp = r * (2.0d0 * (1.0d0 - ((t_0 ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_1) * t_0))))
else
tmp = r * (2.0d0 * t_1)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((phi1 - phi2) / 2.0));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_1 <= 1.16e-89) {
tmp = R * (2.0 * (1.0 - (Math.pow(t_0, 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_1) * t_0))));
} else {
tmp = R * (2.0 * t_1);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) / 2.0)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_1 <= 1.16e-89: tmp = R * (2.0 * (1.0 - (math.pow(t_0, 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_1) * t_0)))) else: tmp = R * (2.0 * t_1) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_1 <= 1.16e-89) tmp = Float64(R * Float64(2.0 * Float64(1.0 - Float64((t_0 ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_1) * t_0))))); else tmp = Float64(R * Float64(2.0 * t_1)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_1 <= 1.16e-89) tmp = R * (2.0 * (1.0 - ((t_0 ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_1) * t_0)))); else tmp = R * (2.0 * t_1); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, 1.16e-89], N[(R * N[(2.0 * N[(1.0 - N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * t$95$1), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t\_1 \leq 1.16 \cdot 10^{-89}:\\
\;\;\;\;R \cdot \left(2 \cdot \left(1 - \left({t\_0}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) \cdot t\_0\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot t\_1\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 1.15999999999999993e-89Initial program 62.4%
Taylor expanded in lambda1 around 0
Applied rewrites35.0%
Taylor expanded in lambda1 around -inf
Applied rewrites14.4%
Taylor expanded in lambda1 around -inf
Applied rewrites17.1%
if 1.15999999999999993e-89 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 57.6%
Taylor expanded in lambda1 around 0
Applied rewrites28.4%
Taylor expanded in lambda1 around -inf
Applied rewrites26.4%
Taylor expanded in lambda1 around -inf
Applied rewrites22.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_0 1.16e-89)
(* R (* 2.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(* R (* 2.0 t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 1.16e-89) {
tmp = R * (2.0 * pow(sin(((phi1 - phi2) / 2.0)), 2.0));
} else {
tmp = R * (2.0 * t_0);
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_0 <= 1.16d-89) then
tmp = r * (2.0d0 * (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))
else
tmp = r * (2.0d0 * t_0)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 1.16e-89) {
tmp = R * (2.0 * Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0));
} else {
tmp = R * (2.0 * t_0);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 1.16e-89: tmp = R * (2.0 * math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) else: tmp = R * (2.0 * t_0) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 1.16e-89) tmp = Float64(R * Float64(2.0 * (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))); else tmp = Float64(R * Float64(2.0 * t_0)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_0 <= 1.16e-89) tmp = R * (2.0 * (sin(((phi1 - phi2) / 2.0)) ^ 2.0)); else tmp = R * (2.0 * t_0); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 1.16e-89], N[(R * N[(2.0 * N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t\_0 \leq 1.16 \cdot 10^{-89}:\\
\;\;\;\;R \cdot \left(2 \cdot {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot t\_0\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 1.15999999999999993e-89Initial program 62.4%
Taylor expanded in lambda1 around 0
Applied rewrites35.0%
Taylor expanded in lambda1 around -inf
Applied rewrites14.4%
if 1.15999999999999993e-89 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 57.6%
Taylor expanded in lambda1 around 0
Applied rewrites28.4%
Taylor expanded in lambda1 around -inf
Applied rewrites26.4%
Taylor expanded in lambda1 around -inf
Applied rewrites22.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))) (if (<= t_0 2.1e-94) (* R (sin (/ (- phi1 phi2) 2.0))) (* R (* 2.0 t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 2.1e-94) {
tmp = R * sin(((phi1 - phi2) / 2.0));
} else {
tmp = R * (2.0 * t_0);
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_0 <= 2.1d-94) then
tmp = r * sin(((phi1 - phi2) / 2.0d0))
else
tmp = r * (2.0d0 * t_0)
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 2.1e-94) {
tmp = R * Math.sin(((phi1 - phi2) / 2.0));
} else {
tmp = R * (2.0 * t_0);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 2.1e-94: tmp = R * math.sin(((phi1 - phi2) / 2.0)) else: tmp = R * (2.0 * t_0) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 2.1e-94) tmp = Float64(R * sin(Float64(Float64(phi1 - phi2) / 2.0))); else tmp = Float64(R * Float64(2.0 * t_0)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_0 <= 2.1e-94) tmp = R * sin(((phi1 - phi2) / 2.0)); else tmp = R * (2.0 * t_0); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 2.1e-94], N[(R * N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t\_0 \leq 2.1 \cdot 10^{-94}:\\
\;\;\;\;R \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot t\_0\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 2.1000000000000001e-94Initial program 62.4%
Taylor expanded in lambda1 around 0
Applied rewrites35.0%
Taylor expanded in lambda1 around -inf
Applied rewrites36.2%
Taylor expanded in lambda1 around -inf
Applied rewrites8.6%
if 2.1000000000000001e-94 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 57.6%
Taylor expanded in lambda1 around 0
Applied rewrites28.4%
Taylor expanded in lambda1 around -inf
Applied rewrites26.4%
Taylor expanded in lambda1 around -inf
Applied rewrites22.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))) (if (<= t_0 4e-52) (* R (sin (/ (- phi1 phi2) 2.0))) (* R t_0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 4e-52) {
tmp = R * sin(((phi1 - phi2) / 2.0));
} else {
tmp = R * t_0;
}
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
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_0 <= 4d-52) then
tmp = r * sin(((phi1 - phi2) / 2.0d0))
else
tmp = r * t_0
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 4e-52) {
tmp = R * Math.sin(((phi1 - phi2) / 2.0));
} else {
tmp = R * t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 4e-52: tmp = R * math.sin(((phi1 - phi2) / 2.0)) else: tmp = R * t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 4e-52) tmp = Float64(R * sin(Float64(Float64(phi1 - phi2) / 2.0))); else tmp = Float64(R * t_0); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_0 <= 4e-52) tmp = R * sin(((phi1 - phi2) / 2.0)); else tmp = R * t_0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 4e-52], N[(R * N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t\_0 \leq 4 \cdot 10^{-52}:\\
\;\;\;\;R \cdot \sin \left(\frac{\phi_1 - \phi_2}{2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot t\_0\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 4e-52Initial program 63.4%
Taylor expanded in lambda1 around 0
Applied rewrites37.0%
Taylor expanded in lambda1 around -inf
Applied rewrites38.2%
Taylor expanded in lambda1 around -inf
Applied rewrites8.6%
if 4e-52 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 56.0%
Taylor expanded in lambda1 around 0
Applied rewrites25.2%
Taylor expanded in lambda1 around -inf
Applied rewrites23.0%
Taylor expanded in lambda1 around -inf
Applied rewrites9.9%
Taylor expanded in lambda1 around -inf
Applied rewrites17.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (sin (/ (- lambda1 lambda2) 2.0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * sin(((lambda1 - lambda2) / 2.0));
}
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 = r * sin(((lambda1 - lambda2) / 2.0d0))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.sin(((lambda1 - lambda2) / 2.0));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.sin(((lambda1 - lambda2) / 2.0))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * sin(((lambda1 - lambda2) / 2.0)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)
\end{array}
Initial program 60.3%
Taylor expanded in lambda1 around 0
Applied rewrites32.1%
Taylor expanded in lambda1 around -inf
Applied rewrites32.0%
Taylor expanded in lambda1 around -inf
Applied rewrites9.2%
Taylor expanded in lambda1 around -inf
Applied rewrites9.0%
herbie shell --seed 2024313
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Distance on a great circle"
:precision binary64
(* R (* 2.0 (atan2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))) (sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0))) (sin (/ (- lambda1 lambda2) 2.0))))))))))