
(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 32 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 (cos (/ phi2 2.0)))
(t_1 (cos (/ phi1 2.0)))
(t_2 (sin (/ phi2 2.0)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sin (/ phi1 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (- (* t_4 t_0) (* t_1 t_2)) 2.0)
(* t_3 (* (* (pow (cbrt (cos phi1)) 3.0) (cos phi2)) t_3))))
(sqrt
(-
1.0
(+
(pow (fma t_4 t_0 (* t_2 (- t_1))) 2.0)
(* t_3 (* t_3 (* (cos phi1) (cos phi2))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 / 2.0));
double t_1 = cos((phi1 / 2.0));
double t_2 = sin((phi2 / 2.0));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sin((phi1 / 2.0));
return R * (2.0 * atan2(sqrt((pow(((t_4 * t_0) - (t_1 * t_2)), 2.0) + (t_3 * ((pow(cbrt(cos(phi1)), 3.0) * cos(phi2)) * t_3)))), sqrt((1.0 - (pow(fma(t_4, t_0, (t_2 * -t_1)), 2.0) + (t_3 * (t_3 * (cos(phi1) * cos(phi2)))))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 / 2.0)) t_1 = cos(Float64(phi1 / 2.0)) t_2 = sin(Float64(phi2 / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sin(Float64(phi1 / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_4 * t_0) - Float64(t_1 * t_2)) ^ 2.0) + Float64(t_3 * Float64(Float64((cbrt(cos(phi1)) ^ 3.0) * cos(phi2)) * t_3)))), sqrt(Float64(1.0 - Float64((fma(t_4, t_0, Float64(t_2 * Float64(-t_1))) ^ 2.0) + Float64(t_3 * Float64(t_3 * Float64(cos(phi1) * cos(phi2)))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$4 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$3 * N[(N[(N[Power[N[Power[N[Cos[phi1], $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$4 * t$95$0 + N[(t$95$2 * (-t$95$1)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$3 * N[(t$95$3 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\phi_2}{2}\right)\\
t_1 := \cos \left(\frac{\phi_1}{2}\right)\\
t_2 := \sin \left(\frac{\phi_2}{2}\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sin \left(\frac{\phi_1}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_4 \cdot t\_0 - t\_1 \cdot t\_2\right)}^{2} + t\_3 \cdot \left(\left({\left(\sqrt[3]{\cos \phi_1}\right)}^{3} \cdot \cos \phi_2\right) \cdot t\_3\right)}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_4, t\_0, t\_2 \cdot \left(-t\_1\right)\right)\right)}^{2} + t\_3 \cdot \left(t\_3 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 63.6%
div-sub63.6%
sin-diff64.5%
Applied egg-rr64.5%
div-sub63.6%
sin-diff64.5%
Applied egg-rr76.3%
fmm-def76.3%
distribute-rgt-neg-in76.3%
Simplified76.3%
add-cube-cbrt76.4%
pow376.4%
Applied egg-rr76.4%
Final simplification76.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (/ phi1 2.0)))
(t_1 (sin (/ phi2 2.0)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* t_2 (* (cos phi1) (cos phi2)))))
(t_4 (sin (/ phi1 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* t_4 (cos (/ phi2 2.0))) (* t_0 t_1)) 2.0) t_3))
(sqrt
(-
1.0
(+
t_3
(pow
(fma t_4 (log1p (expm1 (cos (* phi2 0.5)))) (* t_1 (- t_0)))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 / 2.0));
double t_1 = sin((phi2 / 2.0));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * (t_2 * (cos(phi1) * cos(phi2)));
double t_4 = sin((phi1 / 2.0));
return R * (2.0 * atan2(sqrt((pow(((t_4 * cos((phi2 / 2.0))) - (t_0 * t_1)), 2.0) + t_3)), sqrt((1.0 - (t_3 + pow(fma(t_4, log1p(expm1(cos((phi2 * 0.5)))), (t_1 * -t_0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 / 2.0)) t_1 = sin(Float64(phi2 / 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(t_2 * Float64(cos(phi1) * cos(phi2)))) t_4 = sin(Float64(phi1 / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_4 * cos(Float64(phi2 / 2.0))) - Float64(t_0 * t_1)) ^ 2.0) + t_3)), sqrt(Float64(1.0 - Float64(t_3 + (fma(t_4, log1p(expm1(cos(Float64(phi2 * 0.5)))), Float64(t_1 * Float64(-t_0))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(t$95$2 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$4 * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[Power[N[(t$95$4 * N[Log[1 + N[(Exp[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] + N[(t$95$1 * (-t$95$0)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\phi_1}{2}\right)\\
t_1 := \sin \left(\frac{\phi_2}{2}\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(t\_2 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_4 := \sin \left(\frac{\phi_1}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_4 \cdot \cos \left(\frac{\phi_2}{2}\right) - t\_0 \cdot t\_1\right)}^{2} + t\_3}}{\sqrt{1 - \left(t\_3 + {\left(\mathsf{fma}\left(t\_4, \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \left(\phi_2 \cdot 0.5\right)\right)\right), t\_1 \cdot \left(-t\_0\right)\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.6%
div-sub63.6%
sin-diff64.5%
Applied egg-rr64.5%
div-sub63.6%
sin-diff64.5%
Applied egg-rr76.3%
fmm-def76.3%
distribute-rgt-neg-in76.3%
Simplified76.3%
log1p-expm1-u76.4%
div-inv76.4%
metadata-eval76.4%
Applied egg-rr76.4%
Final simplification76.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (/ phi1 2.0)))
(t_1 (sin (/ phi2 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ phi1 2.0)))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (* t_4 (* t_4 t_2)))
(t_6 (cos (/ phi2 2.0)))
(t_7 (pow (- (* t_3 t_6) (* t_0 t_1)) 2.0))
(t_8 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= t_4 -0.3) (not (<= t_4 2e-11)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_7 t_5))
(sqrt
(fabs (- 1.0 (fma t_8 t_2 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_7 (* (cos phi2) t_8)))
(sqrt (- 1.0 (+ (pow (fma t_3 t_6 (* t_1 (- t_0))) 2.0) t_5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 / 2.0));
double t_1 = sin((phi2 / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin((phi1 / 2.0));
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_4 * (t_4 * t_2);
double t_6 = cos((phi2 / 2.0));
double t_7 = pow(((t_3 * t_6) - (t_0 * t_1)), 2.0);
double t_8 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((t_4 <= -0.3) || !(t_4 <= 2e-11)) {
tmp = R * (2.0 * atan2(sqrt((t_7 + t_5)), sqrt(fabs((1.0 - fma(t_8, t_2, pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_7 + (cos(phi2) * t_8))), sqrt((1.0 - (pow(fma(t_3, t_6, (t_1 * -t_0)), 2.0) + t_5)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 / 2.0)) t_1 = sin(Float64(phi2 / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(phi1 / 2.0)) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = Float64(t_4 * Float64(t_4 * t_2)) t_6 = cos(Float64(phi2 / 2.0)) t_7 = Float64(Float64(t_3 * t_6) - Float64(t_0 * t_1)) ^ 2.0 t_8 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((t_4 <= -0.3) || !(t_4 <= 2e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_7 + t_5)), sqrt(abs(Float64(1.0 - fma(t_8, t_2, (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_7 + Float64(cos(phi2) * t_8))), sqrt(Float64(1.0 - Float64((fma(t_3, t_6, Float64(t_1 * Float64(-t_0))) ^ 2.0) + t_5)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * N[(t$95$4 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Power[N[(N[(t$95$3 * t$95$6), $MachinePrecision] - N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$8 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[t$95$4, -0.3], N[Not[LessEqual[t$95$4, 2e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$7 + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(t$95$8 * t$95$2 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$7 + N[(N[Cos[phi2], $MachinePrecision] * t$95$8), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$3 * t$95$6 + N[(t$95$1 * (-t$95$0)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\phi_1}{2}\right)\\
t_1 := \sin \left(\frac{\phi_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\phi_1}{2}\right)\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := t\_4 \cdot \left(t\_4 \cdot t\_2\right)\\
t_6 := \cos \left(\frac{\phi_2}{2}\right)\\
t_7 := {\left(t\_3 \cdot t\_6 - t\_0 \cdot t\_1\right)}^{2}\\
t_8 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;t\_4 \leq -0.3 \lor \neg \left(t\_4 \leq 2 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7 + t\_5}}{\sqrt{\left|1 - \mathsf{fma}\left(t\_8, t\_2, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7 + \cos \phi_2 \cdot t\_8}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_3, t\_6, t\_1 \cdot \left(-t\_0\right)\right)\right)}^{2} + t\_5\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.299999999999999989 or 1.99999999999999988e-11 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 55.7%
div-sub55.7%
sin-diff56.6%
Applied egg-rr56.6%
associate-*r*56.6%
+-commutative56.6%
fma-undefine56.6%
add-sqr-sqrt56.6%
pow1/256.6%
Applied egg-rr57.4%
unpow1/257.4%
unpow257.4%
rem-sqrt-square57.4%
*-commutative57.4%
*-commutative57.4%
Simplified57.4%
if -0.299999999999999989 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 1.99999999999999988e-11Initial program 79.0%
div-sub79.0%
sin-diff79.7%
Applied egg-rr79.7%
div-sub79.0%
sin-diff79.7%
Applied egg-rr92.3%
fmm-def92.4%
distribute-rgt-neg-in92.4%
Simplified92.4%
add-cube-cbrt92.4%
pow392.4%
Applied egg-rr92.4%
Taylor expanded in phi1 around 0 91.9%
Final simplification69.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (/ phi2 2.0)))
(t_1 (cos (/ phi1 2.0)))
(t_2 (sin (/ phi2 2.0)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* t_3 (* (cos phi1) (cos phi2)))))
(t_5 (sin (/ phi1 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* t_5 t_0) (* t_1 t_2)) 2.0) t_4))
(sqrt (- 1.0 (+ (pow (fma t_5 t_0 (* t_2 (- t_1))) 2.0) t_4))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 / 2.0));
double t_1 = cos((phi1 / 2.0));
double t_2 = sin((phi2 / 2.0));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * (t_3 * (cos(phi1) * cos(phi2)));
double t_5 = sin((phi1 / 2.0));
return R * (2.0 * atan2(sqrt((pow(((t_5 * t_0) - (t_1 * t_2)), 2.0) + t_4)), sqrt((1.0 - (pow(fma(t_5, t_0, (t_2 * -t_1)), 2.0) + t_4)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 / 2.0)) t_1 = cos(Float64(phi1 / 2.0)) t_2 = sin(Float64(phi2 / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(t_3 * Float64(cos(phi1) * cos(phi2)))) t_5 = sin(Float64(phi1 / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_5 * t_0) - Float64(t_1 * t_2)) ^ 2.0) + t_4)), sqrt(Float64(1.0 - Float64((fma(t_5, t_0, Float64(t_2 * Float64(-t_1))) ^ 2.0) + t_4)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(t$95$3 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$5 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$5 * t$95$0 + N[(t$95$2 * (-t$95$1)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\phi_2}{2}\right)\\
t_1 := \cos \left(\frac{\phi_1}{2}\right)\\
t_2 := \sin \left(\frac{\phi_2}{2}\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(t\_3 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_5 := \sin \left(\frac{\phi_1}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_5 \cdot t\_0 - t\_1 \cdot t\_2\right)}^{2} + t\_4}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_5, t\_0, t\_2 \cdot \left(-t\_1\right)\right)\right)}^{2} + t\_4\right)}}\right)
\end{array}
\end{array}
Initial program 63.6%
div-sub63.6%
sin-diff64.5%
Applied egg-rr64.5%
div-sub63.6%
sin-diff64.5%
Applied egg-rr76.3%
fmm-def76.3%
distribute-rgt-neg-in76.3%
Simplified76.3%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(t_2
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)))
(if (or (<= lambda1 -32000.0) (not (<= lambda1 0.000125)))
(*
R
(*
2.0
(atan2
(sqrt
(+ (* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0))) t_2))
(sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt t_1)
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
t_2)))))))))
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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))));
double t_2 = pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
double tmp;
if ((lambda1 <= -32000.0) || !(lambda1 <= 0.000125)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))) + t_2)), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + 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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))))
t_2 = ((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0
if ((lambda1 <= (-32000.0d0)) .or. (.not. (lambda1 <= 0.000125d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))) + t_2)), sqrt((1.0d0 - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))) + 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(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2))));
double t_2 = Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
double tmp;
if ((lambda1 <= -32000.0) || !(lambda1 <= 0.000125)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))) + t_2)), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))) + t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) t_2 = math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) tmp = 0 if (lambda1 <= -32000.0) or not (lambda1 <= 0.000125): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))) + t_2)), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) + t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2))))) t_2 = Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0 tmp = 0.0 if ((lambda1 <= -32000.0) || !(lambda1 <= 0.000125)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))) + t_2)), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))); t_2 = ((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0; tmp = 0.0; if ((lambda1 <= -32000.0) || ~((lambda1 <= 0.000125))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))) + t_2)), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))) + t_2))))); 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[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[lambda1, -32000.0], N[Not[LessEqual[lambda1, 0.000125]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -32000 \lor \neg \left(\lambda_1 \leq 0.000125\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right) + t\_2}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + t\_2\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -32000 or 1.25e-4 < lambda1 Initial program 44.4%
div-sub44.4%
sin-diff45.2%
Applied egg-rr45.2%
Taylor expanded in lambda2 around 0 45.4%
div-sub44.4%
sin-diff45.2%
Applied egg-rr53.3%
if -32000 < lambda1 < 1.25e-4Initial program 79.3%
div-sub79.3%
sin-diff80.2%
Applied egg-rr80.2%
div-sub79.3%
sin-diff80.2%
Applied egg-rr95.2%
fmm-def95.2%
distribute-rgt-neg-in95.2%
Simplified95.2%
Taylor expanded in lambda1 around 0 95.1%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_0 t_1)))))
(if (or (<= lambda2 -6e+16) (not (<= lambda2 0.016)))
(*
R
(*
2.0
(atan2
(sqrt t_2)
(sqrt
(fabs
(-
1.0
(fma
(pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)
t_1
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)))
(sqrt (- 1.0 t_2))))))))
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);
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * t_1));
double tmp;
if ((lambda2 <= -6e+16) || !(lambda2 <= 0.016)) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt(fabs((1.0 - fma(pow(sin(((lambda1 - lambda2) * 0.5)), 2.0), t_1, pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))) + pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0))), sqrt((1.0 - t_2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_0 * t_1))) tmp = 0.0 if ((lambda2 <= -6e+16) || !(lambda2 <= 0.016)) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(abs(Float64(1.0 - fma((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0), t_1, (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))) + (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0))), sqrt(Float64(1.0 - t_2))))); end return 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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -6e+16], N[Not[LessEqual[lambda2, 0.016]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_0 \cdot t\_1\right)\\
\mathbf{if}\;\lambda_2 \leq -6 \cdot 10^{+16} \lor \neg \left(\lambda_2 \leq 0.016\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{\left|1 - \mathsf{fma}\left({\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, t\_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right) + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if lambda2 < -6e16 or 0.016 < lambda2 Initial program 50.5%
div-sub50.5%
sin-diff51.3%
Applied egg-rr51.3%
associate-*r*51.3%
+-commutative51.3%
fma-undefine51.3%
add-sqr-sqrt51.3%
pow1/251.3%
Applied egg-rr51.9%
unpow1/251.9%
unpow251.9%
rem-sqrt-square51.9%
*-commutative51.9%
*-commutative51.9%
Simplified51.9%
if -6e16 < lambda2 < 0.016Initial program 76.9%
div-sub76.9%
sin-diff77.9%
Applied egg-rr77.9%
Taylor expanded in lambda2 around 0 76.5%
div-sub76.9%
sin-diff77.9%
Applied egg-rr91.3%
Final simplification71.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(t_2
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0))
(t_3
(+ (* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0))) t_2))
(t_4 (sqrt t_1)))
(if (<= lambda1 -32000.0)
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_1)))))
(if (<= lambda1 0.000125)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
t_2))))))
(* R (* 2.0 (atan2 t_4 (sqrt (- 1.0 t_3)))))))))
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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))));
double t_2 = pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
double t_3 = (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))) + t_2;
double t_4 = sqrt(t_1);
double tmp;
if (lambda1 <= -32000.0) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_1))));
} else if (lambda1 <= 0.000125) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + t_2)))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_3))));
}
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 = (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))))
t_2 = ((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0
t_3 = (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))) + t_2
t_4 = sqrt(t_1)
if (lambda1 <= (-32000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - t_1))))
else if (lambda1 <= 0.000125d0) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))) + t_2)))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - t_3))))
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.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2))));
double t_2 = Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
double t_3 = (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))) + t_2;
double t_4 = Math.sqrt(t_1);
double tmp;
if (lambda1 <= -32000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - t_1))));
} else if (lambda1 <= 0.000125) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))) + t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) t_2 = math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) t_3 = (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))) + t_2 t_4 = math.sqrt(t_1) tmp = 0 if lambda1 <= -32000.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - t_1)))) elif lambda1 <= 0.000125: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) + t_2))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2))))) t_2 = Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0 t_3 = Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))) + t_2) t_4 = sqrt(t_1) tmp = 0.0 if (lambda1 <= -32000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_1))))); elseif (lambda1 <= 0.000125) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))); t_2 = ((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0; t_3 = (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))) + t_2; t_4 = sqrt(t_1); tmp = 0.0; if (lambda1 <= -32000.0) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_1)))); elseif (lambda1 <= 0.000125) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))) + t_2))))); else tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_3)))); 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[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[t$95$1], $MachinePrecision]}, If[LessEqual[lambda1, -32000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 0.000125], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
t_3 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right) + t\_2\\
t_4 := \sqrt{t\_1}\\
\mathbf{if}\;\lambda_1 \leq -32000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 0.000125:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if lambda1 < -32000Initial program 40.9%
div-sub40.9%
sin-diff41.6%
Applied egg-rr41.6%
Taylor expanded in lambda2 around 0 41.9%
div-sub40.9%
sin-diff41.6%
Applied egg-rr50.5%
if -32000 < lambda1 < 1.25e-4Initial program 79.3%
div-sub79.3%
sin-diff80.2%
Applied egg-rr80.2%
div-sub79.3%
sin-diff80.2%
Applied egg-rr95.2%
fmm-def95.2%
distribute-rgt-neg-in95.2%
Simplified95.2%
Taylor expanded in lambda1 around 0 95.1%
if 1.25e-4 < lambda1 Initial program 47.3%
div-sub47.3%
sin-diff48.2%
Applied egg-rr48.2%
div-sub47.3%
sin-diff48.2%
Applied egg-rr55.5%
fmm-def55.5%
distribute-rgt-neg-in55.5%
Simplified55.5%
Taylor expanded in lambda2 around 0 55.5%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_0 (* (cos phi1) (cos phi2)))))))
(* 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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))));
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 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))))
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 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2))));
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 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) 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((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2))))) 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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))); 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[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.6%
div-sub63.6%
sin-diff64.5%
Applied egg-rr64.5%
div-sub63.6%
sin-diff64.5%
Applied egg-rr76.3%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_0 t_1))))
(sqrt
(fabs
(-
1.0
(fma
(pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)
t_1
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))))
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);
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_0 * t_1)))), sqrt(fabs((1.0 - fma(pow(sin(((lambda1 - lambda2) * 0.5)), 2.0), t_1, pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_0 * t_1)))), sqrt(abs(Float64(1.0 - fma((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0), t_1, (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))) 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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_0 \cdot t\_1\right)}}{\sqrt{\left|1 - \mathsf{fma}\left({\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, t\_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 63.6%
div-sub63.6%
sin-diff64.5%
Applied egg-rr64.5%
associate-*r*64.5%
+-commutative64.5%
fma-undefine64.4%
add-sqr-sqrt64.4%
pow1/264.4%
Applied egg-rr64.9%
unpow1/264.9%
unpow264.9%
rem-sqrt-square64.9%
*-commutative64.9%
*-commutative64.9%
Simplified64.9%
Final simplification64.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt (+ 1.0 (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) 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 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - 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 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1)), sqrt((1.0d0 + (((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - 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 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)), Math.sqrt((1.0 + (((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1)), math.sqrt((1.0 + (((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 63.6%
div-sub63.6%
sin-diff64.5%
Applied egg-rr64.5%
unpow264.5%
sin-mult64.5%
div-inv64.5%
metadata-eval64.5%
div-inv64.5%
metadata-eval64.5%
div-inv64.5%
metadata-eval64.5%
div-inv64.5%
metadata-eval64.5%
Applied egg-rr64.5%
div-sub64.5%
+-inverses64.5%
cos-064.5%
metadata-eval64.5%
distribute-lft-out64.5%
metadata-eval64.5%
*-rgt-identity64.5%
Simplified64.5%
Final simplification64.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt
(fabs
(fma
(pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)
t_1
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))
(sqrt
(-
1.0
(+ (* t_0 (* t_0 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
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);
return R * (2.0 * atan2(sqrt(fabs(fma(pow(sin(((lambda1 - lambda2) * 0.5)), 2.0), t_1, pow(sin((0.5 * (phi1 - phi2))), 2.0)))), sqrt((1.0 - ((t_0 * (t_0 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(abs(fma((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0), t_1, (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) 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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Abs[N[(N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left|\mathsf{fma}\left({\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, t\_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}{\sqrt{1 - \left(t\_0 \cdot \left(t\_0 \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.6%
add-log-exp62.2%
div-inv62.2%
metadata-eval62.2%
Applied egg-rr62.2%
Applied egg-rr63.3%
unpow1/263.3%
unpow263.3%
rem-sqrt-square64.0%
fma-undefine64.0%
*-commutative64.0%
fma-undefine64.0%
Simplified64.0%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (* (- lambda1 lambda2) 0.5)))
(t_2 (pow t_1 2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 t_3))
(t_5 (* (cos phi1) (cos phi2))))
(if (<= t_3 -0.6)
(* (* R 2.0) (atan2 (sqrt t_2) (sqrt (- 1.0 (fma t_5 t_4 t_0)))))
(if (<= t_3 0.2333)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_3 (* t_3 t_5)) t_0))
(sqrt (- 1.0 (+ t_2 (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
(* R 2.0)
(atan2
t_1
(sqrt
(-
1.0
(fma
t_5
t_4
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) * 0.5));
double t_2 = pow(t_1, 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * t_3;
double t_5 = cos(phi1) * cos(phi2);
double tmp;
if (t_3 <= -0.6) {
tmp = (R * 2.0) * atan2(sqrt(t_2), sqrt((1.0 - fma(t_5, t_4, t_0))));
} else if (t_3 <= 0.2333) {
tmp = R * (2.0 * atan2(sqrt(((t_3 * (t_3 * t_5)) + t_0)), sqrt((1.0 - (t_2 + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = (R * 2.0) * atan2(t_1, sqrt((1.0 - fma(t_5, t_4, pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_2 = t_1 ^ 2.0 t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * t_3) t_5 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (t_3 <= -0.6) tmp = Float64(Float64(R * 2.0) * atan(sqrt(t_2), sqrt(Float64(1.0 - fma(t_5, t_4, t_0))))); elseif (t_3 <= 0.2333) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_3 * Float64(t_3 * t_5)) + t_0)), sqrt(Float64(1.0 - Float64(t_2 + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(Float64(R * 2.0) * atan(t_1, sqrt(Float64(1.0 - fma(t_5, t_4, (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$3, -0.6], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 * t$95$4 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.2333], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$3 * N[(t$95$3 * t$95$5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(t$95$5 * t$95$4 + N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_2 := {t\_1}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot t\_3\\
t_5 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;t\_3 \leq -0.6:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - \mathsf{fma}\left(t\_5, t\_4, t\_0\right)}}\\
\mathbf{elif}\;t\_3 \leq 0.2333:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 \cdot \left(t\_3 \cdot t\_5\right) + t\_0}}{\sqrt{1 - \left(t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \mathsf{fma}\left(t\_5, t\_4, {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right)}}\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.599999999999999978Initial program 52.5%
associate-*r*52.5%
*-commutative52.5%
Simplified52.5%
Taylor expanded in phi2 around 0 45.4%
fma-define45.4%
*-commutative45.4%
Simplified45.4%
Taylor expanded in phi1 around 0 31.7%
if -0.599999999999999978 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.23330000000000001Initial program 78.4%
Taylor expanded in phi1 around 0 63.8%
Taylor expanded in phi2 around 0 56.3%
if 0.23330000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 52.0%
associate-*r*52.0%
*-commutative52.0%
Simplified52.0%
Taylor expanded in phi2 around 0 41.9%
fma-define41.9%
*-commutative41.9%
Simplified41.9%
Taylor expanded in phi1 around 0 30.8%
div-sub52.0%
sin-diff52.8%
Applied egg-rr32.6%
Final simplification42.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* phi2 -0.5)) 2.0))
(t_2 (sin (* (- lambda1 lambda2) 0.5)))
(t_3 (pow t_2 2.0))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (* (cos phi1) (cos phi2))))
(if (<= t_4 -0.6)
(* (* R 2.0) (atan2 (sqrt t_3) (sqrt (- 1.0 (fma t_5 (* t_4 t_4) t_0)))))
(if (<= t_4 0.2333)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_4 (* t_4 t_5)) t_0))
(sqrt (- 1.0 (+ t_3 t_1))))))
(*
(* R 2.0)
(atan2
t_2
(sqrt (- 1.0 (+ t_1 (pow (cbrt (* (cos phi2) t_3)) 3.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(sin((phi2 * -0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) * 0.5));
double t_3 = pow(t_2, 2.0);
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = cos(phi1) * cos(phi2);
double tmp;
if (t_4 <= -0.6) {
tmp = (R * 2.0) * atan2(sqrt(t_3), sqrt((1.0 - fma(t_5, (t_4 * t_4), t_0))));
} else if (t_4 <= 0.2333) {
tmp = R * (2.0 * atan2(sqrt(((t_4 * (t_4 * t_5)) + t_0)), sqrt((1.0 - (t_3 + t_1)))));
} else {
tmp = (R * 2.0) * atan2(t_2, sqrt((1.0 - (t_1 + pow(cbrt((cos(phi2) * t_3)), 3.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_3 = t_2 ^ 2.0 t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (t_4 <= -0.6) tmp = Float64(Float64(R * 2.0) * atan(sqrt(t_3), sqrt(Float64(1.0 - fma(t_5, Float64(t_4 * t_4), t_0))))); elseif (t_4 <= 0.2333) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_4 * Float64(t_4 * t_5)) + t_0)), sqrt(Float64(1.0 - Float64(t_3 + t_1)))))); else tmp = Float64(Float64(R * 2.0) * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + (cbrt(Float64(cos(phi2) * t_3)) ^ 3.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[t$95$2, 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$4, -0.6], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 * N[(t$95$4 * t$95$4), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$4, 0.2333], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$4 * N[(t$95$4 * t$95$5), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Power[N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_2 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_3 := {t\_2}^{2}\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;t\_4 \leq -0.6:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \mathsf{fma}\left(t\_5, t\_4 \cdot t\_4, t\_0\right)}}\\
\mathbf{elif}\;t\_4 \leq 0.2333:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 \cdot \left(t\_4 \cdot t\_5\right) + t\_0}}{\sqrt{1 - \left(t\_3 + t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_1 + {\left(\sqrt[3]{\cos \phi_2 \cdot t\_3}\right)}^{3}\right)}}\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.599999999999999978Initial program 52.5%
associate-*r*52.5%
*-commutative52.5%
Simplified52.5%
Taylor expanded in phi2 around 0 45.4%
fma-define45.4%
*-commutative45.4%
Simplified45.4%
Taylor expanded in phi1 around 0 31.7%
if -0.599999999999999978 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.23330000000000001Initial program 78.4%
Taylor expanded in phi1 around 0 63.8%
Taylor expanded in phi2 around 0 56.3%
if 0.23330000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 52.0%
associate-*r*52.0%
*-commutative52.0%
Simplified52.0%
Taylor expanded in phi2 around 0 41.9%
fma-define41.9%
*-commutative41.9%
Simplified41.9%
Taylor expanded in phi1 around 0 30.8%
Taylor expanded in phi1 around 0 31.4%
add-cube-cbrt31.4%
pow331.4%
*-commutative31.4%
metadata-eval31.4%
div-inv31.4%
div-inv31.4%
metadata-eval31.4%
Applied egg-rr31.4%
Final simplification42.3%
(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))
(t_2 (pow (sin (* phi2 -0.5)) 2.0))
(t_3 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_4 (sqrt (- 1.0 (+ t_3 t_1))))
(t_5 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= phi2 -0.000165)
(*
R
(* 2.0 (atan2 (sqrt (+ t_3 (- 0.5 (/ (cos (- phi1 phi2)) 2.0)))) t_4)))
(if (<= phi2 0.0125)
(* R (* 2.0 (atan2 (sqrt (+ t_1 (* (cos phi1) t_5))) t_4)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_2))
(sqrt (- 1.0 (+ (* (cos phi2) t_5) t_2))))))))))
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);
double t_2 = pow(sin((phi2 * -0.5)), 2.0);
double t_3 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_4 = sqrt((1.0 - (t_3 + t_1)));
double t_5 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (phi2 <= -0.000165) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4));
} else if (phi2 <= 0.0125) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * t_5))), t_4));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((1.0 - ((cos(phi2) * t_5) + 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) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_3 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_4 = sqrt((1.0d0 - (t_3 + t_1)))
t_5 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (phi2 <= (-0.000165d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), t_4))
else if (phi2 <= 0.0125d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * t_5))), t_4))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_2)), sqrt((1.0d0 - ((cos(phi2) * t_5) + 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(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_3 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_4 = Math.sqrt((1.0 - (t_3 + t_1)));
double t_5 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (phi2 <= -0.000165) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_4));
} else if (phi2 <= 0.0125) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * t_5))), t_4));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_2)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_5) + t_2)))));
}
return tmp;
}
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) t_2 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_3 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_4 = math.sqrt((1.0 - (t_3 + t_1))) t_5 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if phi2 <= -0.000165: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_4)) elif phi2 <= 0.0125: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * t_5))), t_4)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_2)), math.sqrt((1.0 - ((math.cos(phi2) * t_5) + t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_3 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_4 = sqrt(Float64(1.0 - Float64(t_3 + t_1))) t_5 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (phi2 <= -0.000165) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_4))); elseif (phi2 <= 0.0125) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * t_5))), t_4))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_2)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_5) + t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin((phi2 * -0.5)) ^ 2.0; t_3 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_4 = sqrt((1.0 - (t_3 + t_1))); t_5 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if (phi2 <= -0.000165) tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4)); elseif (phi2 <= 0.0125) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * t_5))), t_4)); else tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((1.0 - ((cos(phi2) * t_5) + t_2))))); 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - N[(t$95$3 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -0.000165], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.0125], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$5), $MachinePrecision] + t$95$2), $MachinePrecision]), $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}\\
t_2 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_3 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_4 := \sqrt{1 - \left(t\_3 + t\_1\right)}\\
t_5 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -0.000165:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_4}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.0125:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot t\_5}}{t\_4}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_2}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_5 + t\_2\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1.65e-4Initial program 47.6%
unpow249.1%
sin-mult48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
Applied egg-rr47.4%
div-sub48.9%
+-inverses48.9%
cos-048.9%
metadata-eval48.9%
distribute-lft-out48.9%
metadata-eval48.9%
*-rgt-identity48.9%
Simplified47.4%
if -1.65e-4 < phi2 < 0.012500000000000001Initial program 74.3%
add-log-exp71.3%
div-inv71.3%
metadata-eval71.3%
Applied egg-rr71.3%
Taylor expanded in phi2 around 0 74.3%
if 0.012500000000000001 < phi2 Initial program 60.3%
Taylor expanded in phi1 around 0 61.3%
Taylor expanded in phi1 around 0 62.4%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (pow (sin (* phi2 -0.5)) 2.0))
(t_5 (* t_2 (* t_3 t_3)))
(t_6 (* t_3 (* t_3 t_2))))
(if (<= phi2 -2.7e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ (- 0.5 (/ (cos (- phi1 phi2)) 2.0)) t_5))
(sqrt (- (- 1.0 t_1) t_5)))))
(if (<= phi2 0.03)
(*
R
(*
2.0
(atan2 (sqrt (+ t_1 (* (cos phi1) t_0))) (sqrt (- 1.0 (+ t_6 t_1))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_6 t_4))
(sqrt (- 1.0 (+ (* (cos phi2) t_0) t_4))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = pow(sin((phi2 * -0.5)), 2.0);
double t_5 = t_2 * (t_3 * t_3);
double t_6 = t_3 * (t_3 * t_2);
double tmp;
if (phi2 <= -2.7e-5) {
tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_5)), sqrt(((1.0 - t_1) - t_5))));
} else if (phi2 <= 0.03) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * t_0))), sqrt((1.0 - (t_6 + t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_6 + t_4)), sqrt((1.0 - ((cos(phi2) * 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) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_5 = t_2 * (t_3 * t_3)
t_6 = t_3 * (t_3 * t_2)
if (phi2 <= (-2.7d-5)) then
tmp = r * (2.0d0 * atan2(sqrt(((0.5d0 - (cos((phi1 - phi2)) / 2.0d0)) + t_5)), sqrt(((1.0d0 - t_1) - t_5))))
else if (phi2 <= 0.03d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * t_0))), sqrt((1.0d0 - (t_6 + t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_6 + t_4)), sqrt((1.0d0 - ((cos(phi2) * 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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_5 = t_2 * (t_3 * t_3);
double t_6 = t_3 * (t_3 * t_2);
double tmp;
if (phi2 <= -2.7e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + t_5)), Math.sqrt(((1.0 - t_1) - t_5))));
} else if (phi2 <= 0.03) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * t_0))), Math.sqrt((1.0 - (t_6 + t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_6 + t_4)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_0) + t_4)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_5 = t_2 * (t_3 * t_3) t_6 = t_3 * (t_3 * t_2) tmp = 0 if phi2 <= -2.7e-5: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + t_5)), math.sqrt(((1.0 - t_1) - t_5)))) elif phi2 <= 0.03: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * t_0))), math.sqrt((1.0 - (t_6 + t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_6 + t_4)), math.sqrt((1.0 - ((math.cos(phi2) * t_0) + t_4))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_5 = Float64(t_2 * Float64(t_3 * t_3)) t_6 = Float64(t_3 * Float64(t_3 * t_2)) tmp = 0.0 if (phi2 <= -2.7e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + t_5)), sqrt(Float64(Float64(1.0 - t_1) - t_5))))); elseif (phi2 <= 0.03) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * t_0))), sqrt(Float64(1.0 - Float64(t_6 + t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + t_4)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_0) + t_4)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sin((phi2 * -0.5)) ^ 2.0; t_5 = t_2 * (t_3 * t_3); t_6 = t_3 * (t_3 * t_2); tmp = 0.0; if (phi2 <= -2.7e-5) tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_5)), sqrt(((1.0 - t_1) - t_5)))); elseif (phi2 <= 0.03) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * t_0))), sqrt((1.0 - (t_6 + t_1))))); else tmp = R * (2.0 * atan2(sqrt((t_6 + t_4)), sqrt((1.0 - ((cos(phi2) * t_0) + t_4))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 * N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.7e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.03], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$6 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$6 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_5 := t\_2 \cdot \left(t\_3 \cdot t\_3\right)\\
t_6 := t\_3 \cdot \left(t\_3 \cdot t\_2\right)\\
\mathbf{if}\;\phi_2 \leq -2.7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_5}}{\sqrt{\left(1 - t\_1\right) - t\_5}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.03:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot t\_0}}{\sqrt{1 - \left(t\_6 + t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6 + t\_4}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_0 + t\_4\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -2.6999999999999999e-5Initial program 47.6%
associate-*l*47.5%
Simplified47.5%
unpow249.1%
sin-mult48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
div-inv48.9%
metadata-eval48.9%
Applied egg-rr47.4%
div-sub48.9%
+-inverses48.9%
cos-048.9%
metadata-eval48.9%
distribute-lft-out48.9%
metadata-eval48.9%
*-rgt-identity48.9%
Simplified47.4%
if -2.6999999999999999e-5 < phi2 < 0.029999999999999999Initial program 74.3%
add-log-exp71.3%
div-inv71.3%
metadata-eval71.3%
Applied egg-rr71.3%
Taylor expanded in phi2 around 0 74.3%
if 0.029999999999999999 < phi2 Initial program 60.3%
Taylor expanded in phi1 around 0 61.3%
Taylor expanded in phi1 around 0 62.4%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* t_1 (* (cos phi1) (cos phi2)))))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_4 (* (cos phi2) t_3))
(t_5 (+ (* (cos phi1) t_3) (pow (sin (* phi1 0.5)) 2.0))))
(if (<= phi1 -3.45e-6)
(*
(atan2
(sqrt t_5)
(sqrt
(- 1.0 (+ (pow (sin (* 0.5 (- phi1 phi2))) 2.0) (* (cos phi1) t_4)))))
(* R 2.0))
(if (<= phi1 0.00145)
(* R (* 2.0 (atan2 (sqrt (+ t_4 t_0)) (sqrt (- 1.0 (+ t_2 t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * (t_1 * (cos(phi1) * cos(phi2)));
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = cos(phi2) * t_3;
double t_5 = (cos(phi1) * t_3) + pow(sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -3.45e-6) {
tmp = atan2(sqrt(t_5), sqrt((1.0 - (pow(sin((0.5 * (phi1 - phi2))), 2.0) + (cos(phi1) * t_4))))) * (R * 2.0);
} else if (phi1 <= 0.00145) {
tmp = R * (2.0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0 - (t_2 + t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - 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)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_1 * (t_1 * (cos(phi1) * cos(phi2)))
t_3 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_4 = cos(phi2) * t_3
t_5 = (cos(phi1) * t_3) + (sin((phi1 * 0.5d0)) ** 2.0d0)
if (phi1 <= (-3.45d-6)) then
tmp = atan2(sqrt(t_5), sqrt((1.0d0 - ((sin((0.5d0 * (phi1 - phi2))) ** 2.0d0) + (cos(phi1) * t_4))))) * (r * 2.0d0)
else if (phi1 <= 0.00145d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0d0 - (t_2 + t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - 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.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)));
double t_3 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = Math.cos(phi2) * t_3;
double t_5 = (Math.cos(phi1) * t_3) + Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -3.45e-6) {
tmp = Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - (Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0) + (Math.cos(phi1) * t_4))))) * (R * 2.0);
} else if (phi1 <= 0.00145) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + t_0)), Math.sqrt((1.0 - (t_2 + t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_5))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2))) t_3 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_4 = math.cos(phi2) * t_3 t_5 = (math.cos(phi1) * t_3) + math.pow(math.sin((phi1 * 0.5)), 2.0) tmp = 0 if phi1 <= -3.45e-6: tmp = math.atan2(math.sqrt(t_5), math.sqrt((1.0 - (math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) + (math.cos(phi1) * t_4))))) * (R * 2.0) elif phi1 <= 0.00145: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + t_0)), math.sqrt((1.0 - (t_2 + t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_5)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2)))) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_4 = Float64(cos(phi2) * t_3) t_5 = Float64(Float64(cos(phi1) * t_3) + (sin(Float64(phi1 * 0.5)) ^ 2.0)) tmp = 0.0 if (phi1 <= -3.45e-6) tmp = Float64(atan(sqrt(t_5), sqrt(Float64(1.0 - Float64((sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0) + Float64(cos(phi1) * t_4))))) * Float64(R * 2.0)); elseif (phi1 <= 0.00145) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + t_0)), sqrt(Float64(1.0 - Float64(t_2 + t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_5))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_1 * (t_1 * (cos(phi1) * cos(phi2))); t_3 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_4 = cos(phi2) * t_3; t_5 = (cos(phi1) * t_3) + (sin((phi1 * 0.5)) ^ 2.0); tmp = 0.0; if (phi1 <= -3.45e-6) tmp = atan2(sqrt(t_5), sqrt((1.0 - ((sin((0.5 * (phi1 - phi2))) ^ 2.0) + (cos(phi1) * t_4))))) * (R * 2.0); elseif (phi1 <= 0.00145) tmp = R * (2.0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0 - (t_2 + t_0))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_5)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.45e-6], N[(N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00145], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot \left(t\_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_4 := \cos \phi_2 \cdot t\_3\\
t_5 := \cos \phi_1 \cdot t\_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -3.45 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2} + \cos \phi_1 \cdot t\_4\right)}} \cdot \left(R \cdot 2\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00145:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + t\_0}}{\sqrt{1 - \left(t\_2 + t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_5}}\right)\\
\end{array}
\end{array}
if phi1 < -3.45e-6Initial program 45.1%
associate-*r*45.1%
*-commutative45.1%
Simplified45.0%
Taylor expanded in phi2 around 0 46.4%
fma-define46.4%
*-commutative46.4%
Simplified46.4%
Taylor expanded in phi1 around 0 46.4%
if -3.45e-6 < phi1 < 0.00145Initial program 74.0%
add-log-exp71.4%
div-inv71.4%
metadata-eval71.4%
Applied egg-rr71.4%
Taylor expanded in phi1 around 0 73.8%
*-commutative73.8%
Simplified73.8%
if 0.00145 < phi1 Initial program 55.5%
Taylor expanded in phi2 around 0 56.5%
unpow256.6%
sin-mult56.7%
div-inv56.7%
metadata-eval56.7%
div-inv56.7%
metadata-eval56.7%
div-inv56.7%
metadata-eval56.7%
div-inv56.7%
metadata-eval56.7%
Applied egg-rr56.5%
div-sub56.7%
+-inverses56.7%
cos-056.7%
metadata-eval56.7%
distribute-lft-out56.7%
metadata-eval56.7%
*-rgt-identity56.7%
Simplified56.5%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_3 (pow (sin (* phi2 -0.5)) 2.0))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_5 (+ t_1 t_4))
(t_6 (sqrt (- 1.0 (+ (* (cos phi2) t_2) t_3)))))
(if (<= phi2 -4.8e-9)
(* R (* 2.0 (atan2 (sqrt t_5) t_6)))
(if (<= phi2 0.00037)
(*
R
(* 2.0 (atan2 (sqrt (+ t_4 (* (cos phi1) t_2))) (sqrt (- 1.0 t_5)))))
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_3)) t_6)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = pow(sin((phi2 * -0.5)), 2.0);
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = t_1 + t_4;
double t_6 = sqrt((1.0 - ((cos(phi2) * t_2) + t_3)));
double tmp;
if (phi2 <= -4.8e-9) {
tmp = R * (2.0 * atan2(sqrt(t_5), t_6));
} else if (phi2 <= 0.00037) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi1) * t_2))), sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), t_6));
}
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) :: t_6
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_3 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_5 = t_1 + t_4
t_6 = sqrt((1.0d0 - ((cos(phi2) * t_2) + t_3)))
if (phi2 <= (-4.8d-9)) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), t_6))
else if (phi2 <= 0.00037d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (cos(phi1) * t_2))), sqrt((1.0d0 - t_5))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_3)), t_6))
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 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = t_1 + t_4;
double t_6 = Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + t_3)));
double tmp;
if (phi2 <= -4.8e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), t_6));
} else if (phi2 <= 0.00037) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (Math.cos(phi1) * t_2))), Math.sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_3)), t_6));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_3 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_5 = t_1 + t_4 t_6 = math.sqrt((1.0 - ((math.cos(phi2) * t_2) + t_3))) tmp = 0 if phi2 <= -4.8e-9: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), t_6)) elif phi2 <= 0.00037: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (math.cos(phi1) * t_2))), math.sqrt((1.0 - t_5)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_3)), t_6)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_3 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_5 = Float64(t_1 + t_4) t_6 = sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + t_3))) tmp = 0.0 if (phi2 <= -4.8e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), t_6))); elseif (phi2 <= 0.00037) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(cos(phi1) * t_2))), sqrt(Float64(1.0 - t_5))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_3)), t_6))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_3 = sin((phi2 * -0.5)) ^ 2.0; t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_5 = t_1 + t_4; t_6 = sqrt((1.0 - ((cos(phi2) * t_2) + t_3))); tmp = 0.0; if (phi2 <= -4.8e-9) tmp = R * (2.0 * atan2(sqrt(t_5), t_6)); elseif (phi2 <= 0.00037) tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi1) * t_2))), sqrt((1.0 - t_5)))); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), t_6)); 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$1 + t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.8e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00037], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_5 := t\_1 + t\_4\\
t_6 := \sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + t\_3\right)}\\
\mathbf{if}\;\phi_2 \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{t\_6}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00037:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + \cos \phi_1 \cdot t\_2}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_3}}{t\_6}\right)\\
\end{array}
\end{array}
if phi2 < -4.8e-9Initial program 47.1%
Taylor expanded in phi1 around 0 46.6%
if -4.8e-9 < phi2 < 3.6999999999999999e-4Initial program 74.7%
add-log-exp71.7%
div-inv71.7%
metadata-eval71.7%
Applied egg-rr71.7%
Taylor expanded in phi2 around 0 74.7%
if 3.6999999999999999e-4 < phi2 Initial program 60.3%
Taylor expanded in phi1 around 0 61.3%
Taylor expanded in phi1 around 0 62.4%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_3 (pow (sin (* phi2 -0.5)) 2.0))
(t_4 (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(t_5 (sqrt (- 1.0 (+ (* (cos phi2) t_2) t_3)))))
(if (<= phi2 -4.8e-9)
(* R (* 2.0 (atan2 t_4 t_5)))
(if (<= phi2 0.000125)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_3)) t_5)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = pow(sin((phi2 * -0.5)), 2.0);
double t_4 = sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_5 = sqrt((1.0 - ((cos(phi2) * t_2) + t_3)));
double tmp;
if (phi2 <= -4.8e-9) {
tmp = R * (2.0 * atan2(t_4, t_5));
} else if (phi2 <= 0.000125) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), 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(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_3 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_4 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
t_5 = sqrt((1.0d0 - ((cos(phi2) * t_2) + t_3)))
if (phi2 <= (-4.8d-9)) then
tmp = r * (2.0d0 * atan2(t_4, t_5))
else if (phi2 <= 0.000125d0) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_3)), 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(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_4 = Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_5 = Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + t_3)));
double tmp;
if (phi2 <= -4.8e-9) {
tmp = R * (2.0 * Math.atan2(t_4, t_5));
} else if (phi2 <= 0.000125) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_3)), t_5));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_3 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_4 = math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) t_5 = math.sqrt((1.0 - ((math.cos(phi2) * t_2) + t_3))) tmp = 0 if phi2 <= -4.8e-9: tmp = R * (2.0 * math.atan2(t_4, t_5)) elif phi2 <= 0.000125: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_3)), t_5)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_3 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_4 = sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) t_5 = sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + t_3))) tmp = 0.0 if (phi2 <= -4.8e-9) tmp = Float64(R * Float64(2.0 * atan(t_4, t_5))); elseif (phi2 <= 0.000125) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_3)), t_5))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_3 = sin((phi2 * -0.5)) ^ 2.0; t_4 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); t_5 = sqrt((1.0 - ((cos(phi2) * t_2) + t_3))); tmp = 0.0; if (phi2 <= -4.8e-9) tmp = R * (2.0 * atan2(t_4, t_5)); elseif (phi2 <= 0.000125) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), t_5)); 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.8e-9], N[(R * N[(2.0 * N[ArcTan[t$95$4 / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.000125], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_4 := \sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
t_5 := \sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + t\_3\right)}\\
\mathbf{if}\;\phi_2 \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{t\_5}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.000125:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_3}}{t\_5}\right)\\
\end{array}
\end{array}
if phi2 < -4.8e-9Initial program 47.1%
Taylor expanded in phi1 around 0 46.6%
if -4.8e-9 < phi2 < 1.25e-4Initial program 74.7%
Taylor expanded in phi2 around 0 74.7%
if 1.25e-4 < phi2 Initial program 60.3%
Taylor expanded in phi1 around 0 61.3%
Taylor expanded in phi1 around 0 62.4%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_3 (pow (sin (* phi2 -0.5)) 2.0))
(t_4 (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (<= phi2 -4.8e-9)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(+
1.0
(- (* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)) t_3))))))
(if (<= phi2 0.00115)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_3))
(sqrt (- 1.0 (+ (* (cos phi2) t_2) t_3))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = pow(sin((phi2 * -0.5)), 2.0);
double t_4 = sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (phi2 <= -4.8e-9) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - t_3)))));
} else if (phi2 <= 0.00115) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt((1.0 - ((cos(phi2) * t_2) + t_3)))));
}
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 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_3 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_4 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if (phi2 <= (-4.8d-9)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)) - t_3)))))
else if (phi2 <= 0.00115d0) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_3)), sqrt((1.0d0 - ((cos(phi2) * t_2) + t_3)))))
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 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_4 = Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (phi2 <= -4.8e-9) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 + ((Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - t_3)))));
} else if (phi2 <= 0.00115) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_3)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + t_3)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_3 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_4 = math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if phi2 <= -4.8e-9: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 + ((math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - t_3))))) elif phi2 <= 0.00115: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_3)), math.sqrt((1.0 - ((math.cos(phi2) * t_2) + t_3))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_3 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_4 = sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if (phi2 <= -4.8e-9) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 + Float64(Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)) - t_3)))))); elseif (phi2 <= 0.00115) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_3)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + t_3)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_3 = sin((phi2 * -0.5)) ^ 2.0; t_4 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if (phi2 <= -4.8e-9) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - t_3))))); elseif (phi2 <= 0.00115) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt((1.0 - ((cos(phi2) * t_2) + t_3))))); 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.8e-9], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00115], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_4 := \sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\phi_2 \leq -4.8 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 + \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right) - t\_3\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00115:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_3}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + t\_3\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -4.8e-9Initial program 47.1%
Taylor expanded in phi1 around 0 46.6%
unpow246.6%
sin-mult46.6%
*-commutative46.6%
*-commutative46.6%
*-commutative46.6%
*-commutative46.6%
Applied egg-rr46.6%
div-sub46.6%
+-inverses46.6%
cos-046.6%
metadata-eval46.6%
distribute-lft-out46.6%
metadata-eval46.6%
*-rgt-identity46.6%
Simplified46.6%
if -4.8e-9 < phi2 < 0.00115Initial program 74.7%
Taylor expanded in phi2 around 0 74.7%
if 0.00115 < phi2 Initial program 60.3%
Taylor expanded in phi1 around 0 61.3%
Taylor expanded in phi1 around 0 62.4%
Final simplification64.0%
(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_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) 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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - 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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - 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.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
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_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - 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 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.6%
associate-*l*63.6%
Simplified63.6%
unpow264.5%
sin-mult64.5%
div-inv64.5%
metadata-eval64.5%
div-inv64.5%
metadata-eval64.5%
div-inv64.5%
metadata-eval64.5%
div-inv64.5%
metadata-eval64.5%
Applied egg-rr63.7%
div-sub64.5%
+-inverses64.5%
cos-064.5%
metadata-eval64.5%
distribute-lft-out64.5%
metadata-eval64.5%
*-rgt-identity64.5%
Simplified63.7%
Final simplification63.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_3 (* (cos phi2) t_2))
(t_4 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0))))
(if (<= phi1 -2.9e-6)
(*
(atan2
(sqrt t_4)
(sqrt
(- 1.0 (+ (pow (sin (* 0.5 (- phi1 phi2))) 2.0) (* (cos phi1) t_3)))))
(* R 2.0))
(if (<= phi1 0.00066)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (+ 1.0 (- (- (/ (cos phi2) 2.0) 0.5) t_3))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.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 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = cos(phi2) * t_2;
double t_4 = (cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -2.9e-6) {
tmp = atan2(sqrt(t_4), sqrt((1.0 - (pow(sin((0.5 * (phi1 - phi2))), 2.0) + (cos(phi1) * t_3))))) * (R * 2.0);
} else if (phi1 <= 0.00066) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 + (((cos(phi2) / 2.0) - 0.5) - t_3)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), 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(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_3 = cos(phi2) * t_2
t_4 = (cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0)
if (phi1 <= (-2.9d-6)) then
tmp = atan2(sqrt(t_4), sqrt((1.0d0 - ((sin((0.5d0 * (phi1 - phi2))) ** 2.0d0) + (cos(phi1) * t_3))))) * (r * 2.0d0)
else if (phi1 <= 0.00066d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 + (((cos(phi2) / 2.0d0) - 0.5d0) - t_3)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), 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(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = Math.cos(phi2) * t_2;
double t_4 = (Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -2.9e-6) {
tmp = Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - (Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0) + (Math.cos(phi1) * t_3))))) * (R * 2.0);
} else if (phi1 <= 0.00066) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + (((Math.cos(phi2) / 2.0) - 0.5) - t_3)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_3 = math.cos(phi2) * t_2 t_4 = (math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0) tmp = 0 if phi1 <= -2.9e-6: tmp = math.atan2(math.sqrt(t_4), math.sqrt((1.0 - (math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) + (math.cos(phi1) * t_3))))) * (R * 2.0) elif phi1 <= 0.00066: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + (((math.cos(phi2) / 2.0) - 0.5) - t_3))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_3 = Float64(cos(phi2) * t_2) t_4 = Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0)) tmp = 0.0 if (phi1 <= -2.9e-6) tmp = Float64(atan(sqrt(t_4), sqrt(Float64(1.0 - Float64((sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0) + Float64(cos(phi1) * t_3))))) * Float64(R * 2.0)); elseif (phi1 <= 0.00066) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(phi2) / 2.0) - 0.5) - t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.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 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_3 = cos(phi2) * t_2; t_4 = (cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0); tmp = 0.0; if (phi1 <= -2.9e-6) tmp = atan2(sqrt(t_4), sqrt((1.0 - ((sin((0.5 * (phi1 - phi2))) ^ 2.0) + (cos(phi1) * t_3))))) * (R * 2.0); elseif (phi1 <= 0.00066) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 + (((cos(phi2) / 2.0) - 0.5) - t_3))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.9e-6], N[(N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00066], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[phi2], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := \cos \phi_2 \cdot t\_2\\
t_4 := \cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -2.9 \cdot 10^{-6}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2} + \cos \phi_1 \cdot t\_3\right)}} \cdot \left(R \cdot 2\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00066:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\left(\frac{\cos \phi_2}{2} - 0.5\right) - t\_3\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if phi1 < -2.9000000000000002e-6Initial program 45.1%
associate-*r*45.1%
*-commutative45.1%
Simplified45.0%
Taylor expanded in phi2 around 0 46.4%
fma-define46.4%
*-commutative46.4%
Simplified46.4%
Taylor expanded in phi1 around 0 46.4%
if -2.9000000000000002e-6 < phi1 < 6.6e-4Initial program 74.0%
Taylor expanded in phi1 around 0 73.7%
unpow273.7%
sin-mult73.7%
*-commutative73.7%
*-commutative73.7%
*-commutative73.7%
*-commutative73.7%
Applied egg-rr73.7%
+-inverses73.7%
cos-073.7%
distribute-lft-out73.7%
metadata-eval73.7%
*-commutative73.7%
mul-1-neg73.7%
cos-neg73.7%
div-sub73.7%
metadata-eval73.7%
Simplified73.7%
if 6.6e-4 < phi1 Initial program 55.5%
Taylor expanded in phi2 around 0 56.5%
unpow256.6%
sin-mult56.7%
div-inv56.7%
metadata-eval56.7%
div-inv56.7%
metadata-eval56.7%
div-inv56.7%
metadata-eval56.7%
div-inv56.7%
metadata-eval56.7%
Applied egg-rr56.5%
div-sub56.7%
+-inverses56.7%
cos-056.7%
metadata-eval56.7%
distribute-lft-out56.7%
metadata-eval56.7%
*-rgt-identity56.7%
Simplified56.5%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi1 -3.45e-6) (not (<= phi1 0.00066)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (+ 1.0 (- (- (/ (cos phi2) 2.0) 0.5) (* (cos phi2) t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -3.45e-6) || !(phi1 <= 0.00066)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 + (((cos(phi2) / 2.0) - 0.5) - (cos(phi2) * 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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if ((phi1 <= (-3.45d-6)) .or. (.not. (phi1 <= 0.00066d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 + (((cos(phi2) / 2.0d0) - 0.5d0) - (cos(phi2) * 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(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -3.45e-6) || !(phi1 <= 0.00066)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + (((Math.cos(phi2) / 2.0) - 0.5) - (Math.cos(phi2) * t_2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi1 <= -3.45e-6) or not (phi1 <= 0.00066): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + (((math.cos(phi2) / 2.0) - 0.5) - (math.cos(phi2) * t_2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi1 <= -3.45e-6) || !(phi1 <= 0.00066)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(phi2) / 2.0) - 0.5) - Float64(cos(phi2) * t_2))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if ((phi1 <= -3.45e-6) || ~((phi1 <= 0.00066))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 + (((cos(phi2) / 2.0) - 0.5) - (cos(phi2) * t_2)))))); 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[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.45e-6], N[Not[LessEqual[phi1, 0.00066]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[phi2], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -3.45 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 0.00066\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\left(\frac{\cos \phi_2}{2} - 0.5\right) - \cos \phi_2 \cdot t\_2\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3.45e-6 or 6.6e-4 < phi1 Initial program 50.5%
Taylor expanded in phi2 around 0 51.2%
unpow252.3%
sin-mult52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
Applied egg-rr51.0%
div-sub52.3%
+-inverses52.3%
cos-052.3%
metadata-eval52.3%
distribute-lft-out52.3%
metadata-eval52.3%
*-rgt-identity52.3%
Simplified51.0%
if -3.45e-6 < phi1 < 6.6e-4Initial program 74.0%
Taylor expanded in phi1 around 0 73.7%
unpow273.7%
sin-mult73.7%
*-commutative73.7%
*-commutative73.7%
*-commutative73.7%
*-commutative73.7%
Applied egg-rr73.7%
+-inverses73.7%
cos-073.7%
distribute-lft-out73.7%
metadata-eval73.7%
*-commutative73.7%
mul-1-neg73.7%
cos-neg73.7%
div-sub73.7%
metadata-eval73.7%
Simplified73.7%
Final simplification63.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(if (or (<= phi1 -3.45e-6) (not (<= phi1 0.00066)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(+
1.0
(-
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double tmp;
if ((phi1 <= -3.45e-6) || !(phi1 <= 0.00066)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - pow(sin((phi2 * -0.5)), 2.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) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
if ((phi1 <= (-3.45d-6)) .or. (.not. (phi1 <= 0.00066d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)) - (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
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 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double tmp;
if ((phi1 <= -3.45e-6) || !(phi1 <= 0.00066)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + ((Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) tmp = 0 if (phi1 <= -3.45e-6) or not (phi1 <= 0.00066): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + ((math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) tmp = 0.0 if ((phi1 <= -3.45e-6) || !(phi1 <= 0.00066)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)) - (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); tmp = 0.0; if ((phi1 <= -3.45e-6) || ~((phi1 <= 0.00066))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - (sin((phi2 * -0.5)) ^ 2.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]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -3.45e-6], N[Not[LessEqual[phi1, 0.00066]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
\mathbf{if}\;\phi_1 \leq -3.45 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 0.00066\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right) - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3.45e-6 or 6.6e-4 < phi1 Initial program 50.5%
Taylor expanded in phi2 around 0 51.2%
unpow252.3%
sin-mult52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
Applied egg-rr51.0%
div-sub52.3%
+-inverses52.3%
cos-052.3%
metadata-eval52.3%
distribute-lft-out52.3%
metadata-eval52.3%
*-rgt-identity52.3%
Simplified51.0%
if -3.45e-6 < phi1 < 6.6e-4Initial program 74.0%
Taylor expanded in phi1 around 0 73.7%
unpow273.7%
sin-mult73.7%
*-commutative73.7%
*-commutative73.7%
*-commutative73.7%
*-commutative73.7%
Applied egg-rr73.7%
div-sub73.7%
+-inverses73.7%
cos-073.7%
metadata-eval73.7%
distribute-lft-out73.7%
metadata-eval73.7%
*-rgt-identity73.7%
Simplified73.7%
Final simplification63.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0)))))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi2 -4.8e-9) (not (<= phi2 7e-8)))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (+ (* (cos phi2) t_2) (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (0.5 - (cos((phi1 - phi2)) / 2.0))));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -4.8e-9) || !(phi2 <= 7e-8)) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi2) * t_2) + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0))))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if ((phi2 <= (-4.8d-9)) .or. (.not. (phi2 <= 7d-8))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - ((cos(phi2) * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
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.sqrt(((t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0))));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -4.8e-9) || !(phi2 <= 7e-8)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi2 <= -4.8e-9) or not (phi2 <= 7e-8): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - ((math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi2 <= -4.8e-9) || !(phi2 <= 7e-8)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (0.5 - (cos((phi1 - phi2)) / 2.0)))); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if ((phi2 <= -4.8e-9) || ~((phi2 <= 7e-8))) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi2) * t_2) + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.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]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -4.8e-9], N[Not[LessEqual[phi2, 7e-8]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -4.8 \cdot 10^{-9} \lor \neg \left(\phi_2 \leq 7 \cdot 10^{-8}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -4.8e-9 or 7.00000000000000048e-8 < phi2 Initial program 53.1%
Taylor expanded in phi1 around 0 53.4%
unpow254.7%
sin-mult54.7%
div-inv54.7%
metadata-eval54.7%
div-inv54.7%
metadata-eval54.7%
div-inv54.7%
metadata-eval54.7%
div-inv54.7%
metadata-eval54.7%
Applied egg-rr53.2%
div-sub54.7%
+-inverses54.7%
cos-054.7%
metadata-eval54.7%
distribute-lft-out54.7%
metadata-eval54.7%
*-rgt-identity54.7%
Simplified53.2%
if -4.8e-9 < phi2 < 7.00000000000000048e-8Initial program 75.2%
Taylor expanded in phi2 around 0 75.2%
unpow275.2%
sin-mult75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
Applied egg-rr67.7%
div-sub75.2%
+-inverses75.2%
cos-075.2%
metadata-eval75.2%
distribute-lft-out75.2%
metadata-eval75.2%
*-rgt-identity75.2%
Simplified67.7%
Final simplification60.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2)))))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi1 -5e-14) (not (<= phi1 1.3e-40)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (+ t_2 (pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -5e-14) || !(phi1 <= 1.3e-40)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_2 + pow(sin((phi2 * -0.5)), 2.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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if ((phi1 <= (-5d-14)) .or. (.not. (phi1 <= 1.3d-40))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (t_2 + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
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 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -5e-14) || !(phi1 <= 1.3e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (t_2 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi1 <= -5e-14) or not (phi1 <= 1.3e-40): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (t_2 + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi1 <= -5e-14) || !(phi1 <= 1.3e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_2 + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if ((phi1 <= -5e-14) || ~((phi1 <= 1.3e-40))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (t_2 + (sin((phi2 * -0.5)) ^ 2.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]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -5e-14], N[Not[LessEqual[phi1, 1.3e-40]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-14} \lor \neg \left(\phi_1 \leq 1.3 \cdot 10^{-40}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -5.0000000000000002e-14 or 1.3000000000000001e-40 < phi1 Initial program 51.6%
Taylor expanded in phi2 around 0 48.9%
unpow253.2%
sin-mult53.3%
div-inv53.3%
metadata-eval53.3%
div-inv53.3%
metadata-eval53.3%
div-inv53.3%
metadata-eval53.3%
div-inv53.3%
metadata-eval53.3%
Applied egg-rr48.7%
div-sub53.3%
+-inverses53.3%
cos-053.3%
metadata-eval53.3%
distribute-lft-out53.3%
metadata-eval53.3%
*-rgt-identity53.3%
Simplified48.7%
if -5.0000000000000002e-14 < phi1 < 1.3000000000000001e-40Initial program 75.7%
Taylor expanded in phi1 around 0 75.7%
Taylor expanded in phi2 around 0 58.1%
Final simplification53.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (* (- lambda1 lambda2) 0.5))))
(if (<= t_0 1e-89)
(*
R
(*
2.0
(atan2
(* phi1 (- (/ (sin (* phi2 0.5)) phi1) (* 0.5 (cos (* phi2 0.5)))))
(sqrt
(-
1.0
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))
(*
(* R 2.0)
(atan2
t_1
(sqrt
(-
1.0
(+
(pow (sin (* phi2 -0.5)) 2.0)
(pow (cbrt (* (cos phi2) (pow t_1 2.0))) 3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sin(((lambda1 - lambda2) * 0.5));
double tmp;
if (t_0 <= 1e-89) {
tmp = R * (2.0 * atan2((phi1 * ((sin((phi2 * 0.5)) / phi1) - (0.5 * cos((phi2 * 0.5))))), sqrt((1.0 - ((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = (R * 2.0) * atan2(t_1, sqrt((1.0 - (pow(sin((phi2 * -0.5)), 2.0) + pow(cbrt((cos(phi2) * pow(t_1, 2.0))), 3.0)))));
}
return tmp;
}
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.sin(((lambda1 - lambda2) * 0.5));
double tmp;
if (t_0 <= 1e-89) {
tmp = R * (2.0 * Math.atan2((phi1 * ((Math.sin((phi2 * 0.5)) / phi1) - (0.5 * Math.cos((phi2 * 0.5))))), Math.sqrt((1.0 - ((t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = (R * 2.0) * Math.atan2(t_1, Math.sqrt((1.0 - (Math.pow(Math.sin((phi2 * -0.5)), 2.0) + Math.pow(Math.cbrt((Math.cos(phi2) * Math.pow(t_1, 2.0))), 3.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) tmp = 0.0 if (t_0 <= 1e-89) tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(Float64(sin(Float64(phi2 * 0.5)) / phi1) - Float64(0.5 * cos(Float64(phi2 * 0.5))))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); else tmp = Float64(Float64(R * 2.0) * atan(t_1, sqrt(Float64(1.0 - Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + (cbrt(Float64(cos(phi2) * (t_1 ^ 2.0))) ^ 3.0)))))); end return 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 1e-89], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] / phi1), $MachinePrecision] - N[(0.5 * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Power[N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq 10^{-89}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(\frac{\sin \left(\phi_2 \cdot 0.5\right)}{\phi_1} - 0.5 \cdot \cos \left(\phi_2 \cdot 0.5\right)\right)}{\sqrt{1 - \left(t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left({\sin \left(\phi_2 \cdot -0.5\right)}^{2} + {\left(\sqrt[3]{\cos \phi_2 \cdot {t\_1}^{2}}\right)}^{3}\right)}}\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 1.00000000000000004e-89Initial program 68.2%
div-sub68.2%
sin-diff69.1%
Applied egg-rr69.1%
Taylor expanded in phi1 around 0 54.8%
associate-*r*54.8%
Simplified54.8%
Taylor expanded in phi1 around -inf 19.7%
mul-1-neg19.7%
distribute-rgt-neg-in19.7%
+-commutative19.7%
mul-1-neg19.7%
unsub-neg19.7%
*-commutative19.7%
*-commutative19.7%
Simplified19.7%
if 1.00000000000000004e-89 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 58.6%
associate-*r*58.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in phi2 around 0 43.6%
fma-define43.6%
*-commutative43.6%
Simplified43.6%
Taylor expanded in phi1 around 0 28.8%
Taylor expanded in phi1 around 0 29.2%
add-cube-cbrt29.2%
pow329.2%
*-commutative29.2%
metadata-eval29.2%
div-inv29.2%
div-inv29.2%
metadata-eval29.2%
Applied egg-rr29.2%
Final simplification24.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- lambda1 lambda2) 0.5)))
(t_1 (pow (sin (* phi2 -0.5)) 2.0))
(t_2 (* (cos phi2) (pow t_0 2.0))))
(if (<= (sin (/ (- lambda1 lambda2) 2.0)) -0.015)
(*
(* R 2.0)
(atan2
(sin (* 0.5 (pow (cbrt (- lambda1 lambda2)) 3.0)))
(sqrt (- 1.0 (+ t_2 t_1)))))
(* (* R 2.0) (atan2 t_0 (sqrt (- 1.0 (+ t_1 (pow (cbrt t_2) 3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
double t_1 = pow(sin((phi2 * -0.5)), 2.0);
double t_2 = cos(phi2) * pow(t_0, 2.0);
double tmp;
if (sin(((lambda1 - lambda2) / 2.0)) <= -0.015) {
tmp = (R * 2.0) * atan2(sin((0.5 * pow(cbrt((lambda1 - lambda2)), 3.0))), sqrt((1.0 - (t_2 + t_1))));
} else {
tmp = (R * 2.0) * atan2(t_0, sqrt((1.0 - (t_1 + pow(cbrt(t_2), 3.0)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) * 0.5));
double t_1 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_2 = Math.cos(phi2) * Math.pow(t_0, 2.0);
double tmp;
if (Math.sin(((lambda1 - lambda2) / 2.0)) <= -0.015) {
tmp = (R * 2.0) * Math.atan2(Math.sin((0.5 * Math.pow(Math.cbrt((lambda1 - lambda2)), 3.0))), Math.sqrt((1.0 - (t_2 + t_1))));
} else {
tmp = (R * 2.0) * Math.atan2(t_0, Math.sqrt((1.0 - (t_1 + Math.pow(Math.cbrt(t_2), 3.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_1 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_2 = Float64(cos(phi2) * (t_0 ^ 2.0)) tmp = 0.0 if (sin(Float64(Float64(lambda1 - lambda2) / 2.0)) <= -0.015) tmp = Float64(Float64(R * 2.0) * atan(sin(Float64(0.5 * (cbrt(Float64(lambda1 - lambda2)) ^ 3.0))), sqrt(Float64(1.0 - Float64(t_2 + t_1))))); else tmp = Float64(Float64(R * 2.0) * atan(t_0, sqrt(Float64(1.0 - Float64(t_1 + (cbrt(t_2) ^ 3.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], -0.015], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sin[N[(0.5 * N[Power[N[Power[N[(lambda1 - lambda2), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Power[t$95$2, 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_1 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_2 := \cos \phi_2 \cdot {t\_0}^{2}\\
\mathbf{if}\;\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \leq -0.015:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot {\left(\sqrt[3]{\lambda_1 - \lambda_2}\right)}^{3}\right)}{\sqrt{1 - \left(t\_2 + t\_1\right)}}\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{1 - \left(t\_1 + {\left(\sqrt[3]{t\_2}\right)}^{3}\right)}}\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.014999999999999999Initial program 59.4%
associate-*r*59.4%
*-commutative59.4%
Simplified59.5%
Taylor expanded in phi2 around 0 48.9%
fma-define48.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi1 around 0 2.0%
Taylor expanded in phi1 around 0 2.0%
add-cube-cbrt9.8%
pow39.5%
Applied egg-rr9.5%
if -0.014999999999999999 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 65.6%
associate-*r*65.6%
*-commutative65.6%
Simplified65.6%
Taylor expanded in phi2 around 0 39.3%
fma-define39.3%
*-commutative39.3%
Simplified39.3%
Taylor expanded in phi1 around 0 22.5%
Taylor expanded in phi1 around 0 22.9%
add-cube-cbrt22.9%
pow322.9%
*-commutative22.9%
metadata-eval22.9%
div-inv22.9%
div-inv22.9%
metadata-eval22.9%
Applied egg-rr22.9%
Final simplification18.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (* (- lambda1 lambda2) 0.5))))
(if (<= t_0 1e-89)
(*
R
(*
2.0
(atan2
(* -0.5 (* phi1 (cos (* phi2 0.5))))
(sqrt
(-
1.0
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))
(*
(* R 2.0)
(atan2
t_1
(sqrt
(-
1.0
(+
(pow (sin (* phi2 -0.5)) 2.0)
(pow (cbrt (* (cos phi2) (pow t_1 2.0))) 3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sin(((lambda1 - lambda2) * 0.5));
double tmp;
if (t_0 <= 1e-89) {
tmp = R * (2.0 * atan2((-0.5 * (phi1 * cos((phi2 * 0.5)))), sqrt((1.0 - ((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = (R * 2.0) * atan2(t_1, sqrt((1.0 - (pow(sin((phi2 * -0.5)), 2.0) + pow(cbrt((cos(phi2) * pow(t_1, 2.0))), 3.0)))));
}
return tmp;
}
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.sin(((lambda1 - lambda2) * 0.5));
double tmp;
if (t_0 <= 1e-89) {
tmp = R * (2.0 * Math.atan2((-0.5 * (phi1 * Math.cos((phi2 * 0.5)))), Math.sqrt((1.0 - ((t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = (R * 2.0) * Math.atan2(t_1, Math.sqrt((1.0 - (Math.pow(Math.sin((phi2 * -0.5)), 2.0) + Math.pow(Math.cbrt((Math.cos(phi2) * Math.pow(t_1, 2.0))), 3.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) tmp = 0.0 if (t_0 <= 1e-89) tmp = Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi1 * cos(Float64(phi2 * 0.5)))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); else tmp = Float64(Float64(R * 2.0) * atan(t_1, sqrt(Float64(1.0 - Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + (cbrt(Float64(cos(phi2) * (t_1 ^ 2.0))) ^ 3.0)))))); end return 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 1e-89], N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi1 * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[Power[N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 3.0], $MachinePrecision]), $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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
\mathbf{if}\;t\_0 \leq 10^{-89}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot 0.5\right)\right)}{\sqrt{1 - \left(t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - \left({\sin \left(\phi_2 \cdot -0.5\right)}^{2} + {\left(\sqrt[3]{\cos \phi_2 \cdot {t\_1}^{2}}\right)}^{3}\right)}}\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 1.00000000000000004e-89Initial program 68.2%
div-sub68.2%
sin-diff69.1%
Applied egg-rr69.1%
Taylor expanded in phi1 around 0 54.8%
associate-*r*54.8%
Simplified54.8%
Taylor expanded in phi1 around -inf 8.5%
*-commutative8.5%
Simplified8.5%
if 1.00000000000000004e-89 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 58.6%
associate-*r*58.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in phi2 around 0 43.6%
fma-define43.6%
*-commutative43.6%
Simplified43.6%
Taylor expanded in phi1 around 0 28.8%
Taylor expanded in phi1 around 0 29.2%
add-cube-cbrt29.2%
pow329.2%
*-commutative29.2%
metadata-eval29.2%
div-inv29.2%
div-inv29.2%
metadata-eval29.2%
Applied egg-rr29.2%
Final simplification18.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 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
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
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));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 63.6%
Taylor expanded in phi1 around 0 50.6%
Taylor expanded in phi2 around 0 33.7%
Final simplification33.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_0 1e-89)
(*
R
(*
2.0
(atan2
(* -0.5 (* phi1 (cos (* phi2 0.5))))
(sqrt
(-
1.0
(+
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))
(*
(* R 2.0)
(atan2
(sin (* (- lambda1 lambda2) 0.5))
(sqrt
(+
1.0
(-
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(pow (sin (* phi2 -0.5)) 2.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 <= 1e-89) {
tmp = R * (2.0 * atan2((-0.5 * (phi1 * cos((phi2 * 0.5)))), sqrt((1.0 - ((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = (R * 2.0) * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - pow(sin((phi2 * -0.5)), 2.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 <= 1d-89) then
tmp = r * (2.0d0 * atan2(((-0.5d0) * (phi1 * cos((phi2 * 0.5d0)))), sqrt((1.0d0 - ((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
else
tmp = (r * 2.0d0) * atan2(sin(((lambda1 - lambda2) * 0.5d0)), sqrt((1.0d0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)) - (sin((phi2 * (-0.5d0))) ** 2.0d0)))))
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 <= 1e-89) {
tmp = R * (2.0 * Math.atan2((-0.5 * (phi1 * Math.cos((phi2 * 0.5)))), Math.sqrt((1.0 - ((t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = (R * 2.0) * Math.atan2(Math.sin(((lambda1 - lambda2) * 0.5)), Math.sqrt((1.0 + ((Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - Math.pow(Math.sin((phi2 * -0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 1e-89: tmp = R * (2.0 * math.atan2((-0.5 * (phi1 * math.cos((phi2 * 0.5)))), math.sqrt((1.0 - ((t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2)))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))))) else: tmp = (R * 2.0) * math.atan2(math.sin(((lambda1 - lambda2) * 0.5)), math.sqrt((1.0 + ((math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - math.pow(math.sin((phi2 * -0.5)), 2.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 <= 1e-89) tmp = Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi1 * cos(Float64(phi2 * 0.5)))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); else tmp = Float64(Float64(R * 2.0) * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), sqrt(Float64(1.0 + Float64(Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)) - (sin(Float64(phi2 * -0.5)) ^ 2.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 <= 1e-89) tmp = R * (2.0 * atan2((-0.5 * (phi1 * cos((phi2 * 0.5)))), sqrt((1.0 - ((t_0 * (t_0 * (cos(phi1) * cos(phi2)))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); else tmp = (R * 2.0) * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - (sin((phi2 * -0.5)) ^ 2.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, 1e-89], N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi1 * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t\_0 \leq 10^{-89}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot 0.5\right)\right)}{\sqrt{1 - \left(t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}{\sqrt{1 + \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right) - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 1.00000000000000004e-89Initial program 68.2%
div-sub68.2%
sin-diff69.1%
Applied egg-rr69.1%
Taylor expanded in phi1 around 0 54.8%
associate-*r*54.8%
Simplified54.8%
Taylor expanded in phi1 around -inf 8.5%
*-commutative8.5%
Simplified8.5%
if 1.00000000000000004e-89 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 58.6%
associate-*r*58.6%
*-commutative58.6%
Simplified58.6%
Taylor expanded in phi2 around 0 43.6%
fma-define43.6%
*-commutative43.6%
Simplified43.6%
Taylor expanded in phi1 around 0 28.8%
Taylor expanded in phi1 around 0 29.2%
unpow245.8%
sin-mult45.8%
*-commutative45.8%
*-commutative45.8%
*-commutative45.8%
*-commutative45.8%
Applied egg-rr29.2%
div-sub45.8%
+-inverses45.8%
cos-045.8%
metadata-eval45.8%
distribute-lft-out45.8%
metadata-eval45.8%
*-rgt-identity45.8%
Simplified29.2%
Final simplification18.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(* R 2.0)
(atan2
(sin (* (- lambda1 lambda2) 0.5))
(sqrt
(+
1.0
(-
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(pow (sin (* phi2 -0.5)) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return (R * 2.0) * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - pow(sin((phi2 * -0.5)), 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 * 2.0d0) * atan2(sin(((lambda1 - lambda2) * 0.5d0)), sqrt((1.0d0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)) - (sin((phi2 * (-0.5d0))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return (R * 2.0) * Math.atan2(Math.sin(((lambda1 - lambda2) * 0.5)), Math.sqrt((1.0 + ((Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - Math.pow(Math.sin((phi2 * -0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return (R * 2.0) * math.atan2(math.sin(((lambda1 - lambda2) * 0.5)), math.sqrt((1.0 + ((math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - math.pow(math.sin((phi2 * -0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(Float64(R * 2.0) * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), sqrt(Float64(1.0 + Float64(Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)) - (sin(Float64(phi2 * -0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = (R * 2.0) * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - (sin((phi2 * -0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}{\sqrt{1 + \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right) - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}
\end{array}
Initial program 63.6%
associate-*r*63.6%
*-commutative63.6%
Simplified63.6%
Taylor expanded in phi2 around 0 42.4%
fma-define42.4%
*-commutative42.4%
Simplified42.4%
Taylor expanded in phi1 around 0 16.0%
Taylor expanded in phi1 around 0 16.2%
unpow250.6%
sin-mult50.6%
*-commutative50.6%
*-commutative50.6%
*-commutative50.6%
*-commutative50.6%
Applied egg-rr16.2%
div-sub50.6%
+-inverses50.6%
cos-050.6%
metadata-eval50.6%
distribute-lft-out50.6%
metadata-eval50.6%
*-rgt-identity50.6%
Simplified16.2%
Final simplification16.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (sin (* (- lambda1 lambda2) 0.5)))) (* (* R 2.0) (atan2 t_0 (sqrt (- 1.0 (pow t_0 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
return (R * 2.0) * atan2(t_0, sqrt((1.0 - pow(t_0, 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
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) * 0.5d0))
code = (r * 2.0d0) * atan2(t_0, sqrt((1.0d0 - (t_0 ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) * 0.5));
return (R * 2.0) * Math.atan2(t_0, Math.sqrt((1.0 - Math.pow(t_0, 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) return (R * 2.0) * math.atan2(t_0, math.sqrt((1.0 - math.pow(t_0, 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) return Float64(Float64(R * 2.0) * atan(t_0, sqrt(Float64(1.0 - (t_0 ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)); tmp = (R * 2.0) * atan2(t_0, sqrt((1.0 - (t_0 ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{1 - {t\_0}^{2}}}
\end{array}
\end{array}
Initial program 63.6%
associate-*r*63.6%
*-commutative63.6%
Simplified63.6%
Taylor expanded in phi2 around 0 42.4%
fma-define42.4%
*-commutative42.4%
Simplified42.4%
Taylor expanded in phi1 around 0 16.0%
Taylor expanded in phi1 around 0 16.2%
Taylor expanded in phi2 around 0 16.0%
Final simplification16.0%
herbie shell --seed 2024172
(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))))))))))