
(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 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0))))
(t_2 (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi1) (* (cos phi2) (* t_0 t_0)) (pow (- t_1 t_2) 2.0)))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
(/
(-
1.0
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2))))
2.0)
(pow (- t_2 t_1) 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 = sin((phi1 / 2.0)) * cos((phi2 / 2.0));
double t_2 = cos((phi1 / 2.0)) * sin((phi2 / 2.0));
return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow((t_1 - t_2), 2.0))), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), ((1.0 - ((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2)))) / 2.0), pow((t_2 - t_1), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) t_2 = Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(t_1 - t_2) ^ 2.0))), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), Float64(Float64(1.0 - Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2)))) / 2.0), (Float64(t_2 - t_1) ^ 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[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$1 - t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] + N[Power[N[(t$95$2 - t$95$1), $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 := \sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right)\\
t_2 := \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t\_0 \cdot t\_0\right), {\left(t\_1 - t\_2\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \frac{1 - \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2\right)}{2}, {\left(t\_2 - t\_1\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.5%
Simplified64.5%
div-sub64.5%
sin-diff65.6%
Applied egg-rr65.6%
div-sub65.6%
sin-diff80.3%
Applied egg-rr80.3%
sin-mult80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
cos-sum80.3%
cos-280.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr80.4%
+-inverses80.4%
cos-080.4%
*-commutative80.4%
Simplified80.4%
associate-*r*80.4%
metadata-eval80.4%
*-un-lft-identity80.4%
cos-diff80.9%
Applied egg-rr80.9%
Final simplification80.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0))))
(t_2 (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi1) (* (cos phi2) (* t_0 t_0)) (pow (- t_1 t_2) 2.0)))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
(/ (- 1.0 (cos (* 2.0 (* (- lambda1 lambda2) 0.5)))) 2.0)
(pow (- t_2 t_1) 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 = sin((phi1 / 2.0)) * cos((phi2 / 2.0));
double t_2 = cos((phi1 / 2.0)) * sin((phi2 / 2.0));
return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow((t_1 - t_2), 2.0))), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), ((1.0 - cos((2.0 * ((lambda1 - lambda2) * 0.5)))) / 2.0), pow((t_2 - t_1), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) t_2 = Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(t_1 - t_2) ^ 2.0))), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), Float64(Float64(1.0 - cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5)))) / 2.0), (Float64(t_2 - t_1) ^ 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[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$1 - t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - N[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] + N[Power[N[(t$95$2 - t$95$1), $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 := \sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right)\\
t_2 := \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t\_0 \cdot t\_0\right), {\left(t\_1 - t\_2\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \frac{1 - \cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}{2}, {\left(t\_2 - t\_1\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.5%
Simplified64.5%
div-sub64.5%
sin-diff65.6%
Applied egg-rr65.6%
div-sub65.6%
sin-diff80.3%
Applied egg-rr80.3%
sin-mult80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
cos-sum80.3%
cos-280.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr80.4%
+-inverses80.4%
cos-080.4%
*-commutative80.4%
Simplified80.4%
Final simplification80.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
(t_1 (* (- lambda1 lambda2) 0.5))
(t_2 (sin (* 0.5 (- phi1 phi2))))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (* (sin (/ phi1 2.0)) (cos (/ phi2 2.0))))
(t_5 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -1.8e-6) (not (<= phi1 102000000000.0)))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi1) (pow (sin t_1) 2.0) (pow (- t_4 t_0) 2.0)))
(sqrt
(-
1.0
(fma
t_3
(/ (- 1.0 (cos (* 2.0 t_1))) 2.0)
(pow (- t_0 t_4) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
t_2
t_2
(*
(cos phi1)
(*
(cos phi2)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0)))))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* t_5 t_5) t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 / 2.0)) * sin((phi2 / 2.0));
double t_1 = (lambda1 - lambda2) * 0.5;
double t_2 = sin((0.5 * (phi1 - phi2)));
double t_3 = cos(phi1) * cos(phi2);
double t_4 = sin((phi1 / 2.0)) * cos((phi2 / 2.0));
double t_5 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1.8e-6) || !(phi1 <= 102000000000.0)) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi1), pow(sin(t_1), 2.0), pow((t_4 - t_0), 2.0))), sqrt((1.0 - fma(t_3, ((1.0 - cos((2.0 * t_1))) / 2.0), pow((t_0 - t_4), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_2, t_2, (cos(phi1) * (cos(phi2) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0))))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_5 * t_5) * t_3)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0))) t_1 = Float64(Float64(lambda1 - lambda2) * 0.5) t_2 = sin(Float64(0.5 * Float64(phi1 - phi2))) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) t_5 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -1.8e-6) || !(phi1 <= 102000000000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), (sin(t_1) ^ 2.0), (Float64(t_4 - t_0) ^ 2.0))), sqrt(Float64(1.0 - fma(t_3, Float64(Float64(1.0 - cos(Float64(2.0 * t_1))) / 2.0), (Float64(t_0 - t_4) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(t_2, t_2, Float64(cos(phi1) * Float64(cos(phi2) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0))))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(t_5 * t_5) * t_3)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.8e-6], N[Not[LessEqual[phi1, 102000000000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[t$95$1], $MachinePrecision], 2.0], $MachinePrecision] + N[Power[N[(t$95$4 - t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 * N[(N[(1.0 - N[Cos[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] + N[Power[N[(t$95$0 - t$95$4), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 * t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$5 * t$95$5), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\\
t_1 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
t_2 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := \sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right)\\
t_5 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1.8 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 102000000000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, {\sin t\_1}^{2}, {\left(t\_4 - t\_0\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_3, \frac{1 - \cos \left(2 \cdot t\_1\right)}{2}, {\left(t\_0 - t\_4\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_2, t\_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}\right)\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(t\_5 \cdot t\_5\right) \cdot t\_3}}\right)\\
\end{array}
\end{array}
if phi1 < -1.79999999999999992e-6 or 1.02e11 < phi1 Initial program 50.7%
Simplified50.7%
div-sub50.7%
sin-diff53.0%
Applied egg-rr53.0%
div-sub53.0%
sin-diff83.1%
Applied egg-rr83.1%
sin-mult83.1%
div-inv83.1%
metadata-eval83.1%
div-inv83.1%
metadata-eval83.1%
cos-sum83.1%
cos-283.1%
div-inv83.1%
metadata-eval83.1%
Applied egg-rr83.1%
+-inverses83.1%
cos-083.1%
*-commutative83.1%
Simplified83.1%
Taylor expanded in phi2 around 0 64.3%
if -1.79999999999999992e-6 < phi1 < 1.02e11Initial program 76.7%
associate-*l*76.7%
Simplified76.7%
expm1-log1p-u76.7%
div-inv76.7%
metadata-eval76.7%
Applied egg-rr76.7%
expm1-log1p-u76.7%
unpow276.7%
fma-define76.7%
pow276.7%
div-inv76.7%
metadata-eval76.7%
associate-*r*76.7%
Applied egg-rr76.7%
metadata-eval76.7%
div-inv76.7%
div-sub76.7%
sin-diff77.3%
Applied egg-rr77.3%
Final simplification71.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
(t_1 (* (cos (* phi2 0.5)) (sin (* phi1 0.5))))
(t_2
(*
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (- t_1 t_0) 2.0)))
(sqrt (- 1.0 (+ t_2 (pow (- t_0 t_1) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5)) * sin((phi2 * 0.5));
double t_1 = cos((phi2 * 0.5)) * sin((phi1 * 0.5));
double t_2 = cos(phi1) * (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0));
return R * (2.0 * atan2(sqrt((t_2 + pow((t_1 - t_0), 2.0))), sqrt((1.0 - (t_2 + pow((t_0 - t_1), 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
real(8) :: t_1
real(8) :: t_2
t_0 = cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0))
t_1 = cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))
t_2 = cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_2 + ((t_1 - t_0) ** 2.0d0))), sqrt((1.0d0 - (t_2 + ((t_0 - t_1) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5));
double t_1 = Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5));
double t_2 = Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((t_1 - t_0), 2.0))), Math.sqrt((1.0 - (t_2 + Math.pow((t_0 - t_1), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)) t_1 = math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5)) t_2 = math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((t_1 - t_0), 2.0))), math.sqrt((1.0 - (t_2 + math.pow((t_0 - t_1), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5))) t_1 = Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) t_2 = Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(t_1 - t_0) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_2 + (Float64(t_0 - t_1) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi1 * 0.5)) * sin((phi2 * 0.5)); t_1 = cos((phi2 * 0.5)) * sin((phi1 * 0.5)); t_2 = cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)); tmp = R * (2.0 * atan2(sqrt((t_2 + ((t_1 - t_0) ^ 2.0))), sqrt((1.0 - (t_2 + ((t_0 - t_1) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(t$95$1 - t$95$0), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[(t$95$0 - t$95$1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\\
t_2 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(t\_1 - t\_0\right)}^{2}}}{\sqrt{1 - \left(t\_2 + {\left(t\_0 - t\_1\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.5%
Simplified64.5%
div-sub64.5%
sin-diff65.6%
Applied egg-rr65.6%
div-sub65.6%
sin-diff80.3%
Applied egg-rr80.3%
Taylor expanded in phi1 around 0 80.2%
Final simplification80.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))) (t_1 (* t_0 t_0)))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) t_1)
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
t_1
(pow (sin (/ (- phi2 phi1) 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 = t_0 * t_0;
return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * t_1), pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0))), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), t_1, pow(sin(((phi2 - phi1) / 2.0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * t_0) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * t_1), (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))), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), t_1, (sin(Float64(Float64(phi2 - phi1) / 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[(t$95$0 * t$95$0), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + 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] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(N[(phi2 - phi1), $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 := t\_0 \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot 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}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_1, {\sin \left(\frac{\phi_2 - \phi_1}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.5%
Simplified64.5%
div-sub64.5%
sin-diff65.6%
Applied egg-rr65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)))
(sqrt (- 1.0 (+ t_0 (pow (sin (* 0.5 (- phi2 phi1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0));
return R * (2.0 * atan2(sqrt((t_0 + pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0))), sqrt((1.0 - (t_0 + pow(sin((0.5 * (phi2 - phi1))), 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 = cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_0 + (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0))), sqrt((1.0d0 - (t_0 + (sin((0.5d0 * (phi2 - phi1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0))), Math.sqrt((1.0 - (t_0 + Math.pow(Math.sin((0.5 * (phi2 - phi1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0))), math.sqrt((1.0 - (t_0 + math.pow(math.sin((0.5 * (phi2 - phi1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_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 - Float64(t_0 + (sin(Float64(0.5 * Float64(phi2 - phi1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)); tmp = R * (2.0 * atan2(sqrt((t_0 + (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0))), sqrt((1.0 - (t_0 + (sin((0.5 * (phi2 - phi1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + 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 - N[(t$95$0 + N[Power[N[Sin[N[(0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + {\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 - \left(t\_0 + {\sin \left(0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.5%
Simplified64.5%
div-sub64.5%
sin-diff65.6%
Applied egg-rr65.6%
Taylor expanded in phi1 around 0 65.6%
Final simplification65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
(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 (fma t_1 (* t_0 t_0) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(* R 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 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 - fma(t_1, (t_0 * t_0), pow(sin(((phi1 - phi2) / 2.0)), 2.0))))) * (R * 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(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 - fma(t_1, Float64(t_0 * t_0), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))) * Float64(R * 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[(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[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $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\\
\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 - \mathsf{fma}\left(t\_1, t\_0 \cdot t\_0, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 64.5%
associate-*r*64.5%
*-commutative64.5%
Simplified64.6%
add-sqr-sqrt64.6%
pow1/264.6%
pow1/264.6%
pow-prod-down62.9%
Applied egg-rr62.9%
unpow1/262.9%
unpow262.9%
rem-sqrt-square65.2%
*-commutative65.2%
*-commutative65.2%
Simplified65.2%
Final simplification65.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(fabs
(fma
(pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)
t_0
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* t_1 t_1) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(fabs(fma(pow(sin(((lambda1 - lambda2) * 0.5)), 2.0), t_0, pow(sin((0.5 * (phi1 - phi2))), 2.0)))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_1 * t_1) * t_0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(abs(fma((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0), t_0, (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(t_1 * t_1) * t_0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $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$0 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$1 * t$95$1), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
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\_0, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(t\_1 \cdot t\_1\right) \cdot t\_0}}\right)
\end{array}
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
expm1-log1p-u64.5%
div-inv64.5%
metadata-eval64.5%
Applied egg-rr64.5%
add-sqr-sqrt64.5%
pow1/264.5%
pow1/264.5%
pow-prod-down62.8%
Applied egg-rr62.9%
unpow1/262.9%
unpow262.9%
rem-sqrt-square65.2%
*-commutative65.2%
*-commutative65.2%
Simplified65.2%
Final simplification65.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (- lambda1 lambda2) 0.5)) (t_1 (sin (* 0.5 (- phi1 phi2)))))
(*
R
(*
2.0
(atan2
(sqrt (fma t_1 t_1 (* (cos phi1) (* (cos phi2) (pow (sin t_0) 2.0)))))
(sqrt
(+
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) (/ (+ (cos (* 2.0 t_0)) -1.0) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * 0.5;
double t_1 = sin((0.5 * (phi1 - phi2)));
return R * (2.0 * atan2(sqrt(fma(t_1, t_1, (cos(phi1) * (cos(phi2) * pow(sin(t_0), 2.0))))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((2.0 * t_0)) + -1.0) / 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * 0.5) t_1 = sin(Float64(0.5 * Float64(phi1 - phi2))) return Float64(R * Float64(2.0 * atan(sqrt(fma(t_1, t_1, Float64(cos(phi1) * Float64(cos(phi2) * (sin(t_0) ^ 2.0))))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(2.0 * t_0)) + -1.0) / 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 * t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_1, t\_1, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin t\_0}^{2}\right)\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \frac{\cos \left(2 \cdot t\_0\right) + -1}{2}}}\right)
\end{array}
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
expm1-log1p-u64.5%
div-inv64.5%
metadata-eval64.5%
Applied egg-rr64.5%
expm1-log1p-u64.5%
unpow264.5%
fma-define64.5%
pow264.5%
div-inv64.5%
metadata-eval64.5%
associate-*r*64.5%
Applied egg-rr64.5%
sin-mult80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
cos-sum80.3%
cos-280.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr64.6%
+-inverses80.4%
cos-080.4%
*-commutative80.4%
Simplified64.6%
Final simplification64.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* t_2 t_2) (* (cos phi1) (cos phi2)))))
(if (or (<= phi2 -95.0) (not (<= phi2 1.7e-7)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (- 1.0 t_0) t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_3))
(sqrt
(- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 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 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (t_2 * t_2) * (cos(phi1) * cos(phi2));
double tmp;
if ((phi2 <= -95.0) || !(phi2 <= 1.7e-7)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt(((1.0 - t_0) - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - ((cos(phi1) * t_1) + 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) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (t_2 * t_2) * (cos(phi1) * cos(phi2))
if ((phi2 <= (-95.0d0)) .or. (.not. (phi2 <= 1.7d-7))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((1.0d0 - t_0) - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0d0 - ((cos(phi1) * t_1) + (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.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (t_2 * t_2) * (Math.cos(phi1) * Math.cos(phi2));
double tmp;
if ((phi2 <= -95.0) || !(phi2 <= 1.7e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt(((1.0 - t_0) - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_3)), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (t_2 * t_2) * (math.cos(phi1) * math.cos(phi2)) tmp = 0 if (phi2 <= -95.0) or not (phi2 <= 1.7e-7): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt(((1.0 - t_0) - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_3)), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 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)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(t_2 * t_2) * Float64(cos(phi1) * cos(phi2))) tmp = 0.0 if ((phi2 <= -95.0) || !(phi2 <= 1.7e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_0) - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); 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) * 0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (t_2 * t_2) * (cos(phi1) * cos(phi2)); tmp = 0.0; if ((phi2 <= -95.0) || ~((phi2 <= 1.7e-7))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((1.0 - t_0) - t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); 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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$2 * t$95$2), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -95.0], N[Not[LessEqual[phi2, 1.7e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $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{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(t\_2 \cdot t\_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\\
\mathbf{if}\;\phi_2 \leq -95 \lor \neg \left(\phi_2 \leq 1.7 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - t\_0\right) - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -95 or 1.69999999999999987e-7 < phi2 Initial program 49.7%
associate-*l*49.7%
Simplified49.7%
expm1-log1p-u49.7%
div-inv49.7%
metadata-eval49.7%
Applied egg-rr49.7%
Taylor expanded in phi1 around 0 50.8%
if -95 < phi2 < 1.69999999999999987e-7Initial program 80.0%
associate-*l*80.0%
Simplified80.1%
Taylor expanded in phi2 around 0 80.1%
Final simplification65.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* t_1 t_1) (* (cos phi1) (cos phi2)))))))
(if (or (<= phi1 -8e-7) (not (<= phi1 42.0)))
(*
R
(*
2.0
(atan2 (sqrt (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0))) t_2)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
t_2))))))
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 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_1 * t_1) * (cos(phi1) * cos(phi2)))));
double tmp;
if ((phi1 <= -8e-7) || !(phi1 <= 42.0)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -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) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - ((t_1 * t_1) * (cos(phi1) * cos(phi2)))))
if ((phi1 <= (-8d-7)) .or. (.not. (phi1 <= 42.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_1 * t_1) * (Math.cos(phi1) * Math.cos(phi2)))));
double tmp;
if ((phi1 <= -8e-7) || !(phi1 <= 42.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_1 * t_1) * (math.cos(phi1) * math.cos(phi2))))) tmp = 0 if (phi1 <= -8e-7) or not (phi1 <= 42.0): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), t_2)) 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(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(t_1 * t_1) * Float64(cos(phi1) * cos(phi2))))) tmp = 0.0 if ((phi1 <= -8e-7) || !(phi1 <= 42.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), t_2))); 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(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((t_1 * t_1) * (cos(phi1) * cos(phi2))))); tmp = 0.0; if ((phi1 <= -8e-7) || ~((phi1 <= 42.0))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0))), t_2)); else tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))), t_2)); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$1 * t$95$1), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -8e-7], N[Not[LessEqual[phi1, 42.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $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{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(t\_1 \cdot t\_1\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}\\
\mathbf{if}\;\phi_1 \leq -8 \cdot 10^{-7} \lor \neg \left(\phi_1 \leq 42\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{t\_2}\right)\\
\end{array}
\end{array}
if phi1 < -7.9999999999999996e-7 or 42 < phi1 Initial program 51.1%
associate-*l*51.1%
Simplified51.1%
expm1-log1p-u51.1%
div-inv51.1%
metadata-eval51.1%
Applied egg-rr51.1%
Taylor expanded in phi2 around 0 52.0%
if -7.9999999999999996e-7 < phi1 < 42Initial program 77.1%
associate-*l*77.1%
Simplified77.1%
expm1-log1p-u77.1%
div-inv77.1%
metadata-eval77.1%
Applied egg-rr77.1%
Taylor expanded in phi1 around 0 76.2%
Final simplification64.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi2) t_0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -3e-19) (not (<= phi1 3.6e-7)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* t_2 t_2) (* (cos phi1) (cos phi2))))))))
(*
R
(*
2.0
(atan2
(hypot (sin (* 0.5 (- phi1 phi2))) (sqrt (* (cos phi1) t_1)))
(sqrt (- 1.0 (+ t_1 (pow (sin (* phi2 -0.5)) 2.0))))))))))
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 = cos(phi2) * t_0;
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -3e-19) || !(phi1 <= 3.6e-7)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_2 * t_2) * (cos(phi1) * cos(phi2)))))));
} else {
tmp = R * (2.0 * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt((cos(phi1) * t_1))), sqrt((1.0 - (t_1 + pow(sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
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.cos(phi2) * t_0;
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -3e-19) || !(phi1 <= 3.6e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_2 * t_2) * (Math.cos(phi1) * Math.cos(phi2)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.cos(phi1) * t_1))), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.cos(phi2) * t_0 t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -3e-19) or not (phi1 <= 3.6e-7): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((t_2 * t_2) * (math.cos(phi1) * math.cos(phi2))))))) else: tmp = R * (2.0 * math.atan2(math.hypot(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.cos(phi1) * t_1))), math.sqrt((1.0 - (t_1 + 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) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi2) * t_0) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -3e-19) || !(phi1 <= 3.6e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(t_2 * t_2) * Float64(cos(phi1) * cos(phi2)))))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(cos(phi1) * t_1))), sqrt(Float64(1.0 - Float64(t_1 + (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) * 0.5)) ^ 2.0; t_1 = cos(phi2) * t_0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -3e-19) || ~((phi1 <= 3.6e-7))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((t_2 * t_2) * (cos(phi1) * cos(phi2))))))); else tmp = R * (2.0 * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt((cos(phi1) * t_1))), sqrt((1.0 - (t_1 + (sin((phi2 * -0.5)) ^ 2.0)))))); 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[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3e-19], N[Not[LessEqual[phi1, 3.6e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(t$95$2 * t$95$2), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + 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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_2 \cdot t\_0\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -3 \cdot 10^{-19} \lor \neg \left(\phi_1 \leq 3.6 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(t\_2 \cdot t\_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sqrt{\cos \phi_1 \cdot t\_1}\right)}{\sqrt{1 - \left(t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -2.99999999999999993e-19 or 3.59999999999999994e-7 < phi1 Initial program 51.4%
associate-*l*51.4%
Simplified51.4%
expm1-log1p-u51.4%
div-inv51.4%
metadata-eval51.4%
Applied egg-rr51.4%
Taylor expanded in phi2 around 0 51.5%
if -2.99999999999999993e-19 < phi1 < 3.59999999999999994e-7Initial program 77.7%
associate-*l*77.7%
Simplified77.6%
expm1-log1p-u77.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr77.6%
Taylor expanded in phi1 around inf 77.6%
+-commutative77.6%
*-commutative77.6%
unpow277.6%
*-commutative77.6%
rem-square-sqrt60.5%
hypot-undefine60.5%
Simplified60.5%
Taylor expanded in phi1 around 0 60.5%
Taylor expanded in phi1 around 0 60.5%
Final simplification56.0%
(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 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* (* t_0 t_0) t_1)))
(sqrt
(+
(- 1.0 t_2)
(*
t_1
(/ (+ (cos (* 2.0 (* (- lambda1 lambda2) 0.5))) -1.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);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + ((t_0 * t_0) * t_1))), sqrt(((1.0 - t_2) + (t_1 * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) + -1.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
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + ((t_0 * t_0) * t_1))), sqrt(((1.0d0 - t_2) + (t_1 * ((cos((2.0d0 * ((lambda1 - lambda2) * 0.5d0))) + (-1.0d0)) / 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));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + ((t_0 * t_0) * t_1))), Math.sqrt(((1.0 - t_2) + (t_1 * ((Math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) + -1.0) / 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + ((t_0 * t_0) * t_1))), math.sqrt(((1.0 - t_2) + (t_1 * ((math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) + -1.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)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(Float64(t_0 * t_0) * t_1))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_1 * Float64(Float64(cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5))) + -1.0) / 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + ((t_0 * t_0) * t_1))), sqrt(((1.0 - t_2) + (t_1 * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) + -1.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]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + -1.0), $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\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(t\_0 \cdot t\_0\right) \cdot t\_1}}{\sqrt{\left(1 - t\_2\right) + t\_1 \cdot \frac{\cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right) + -1}{2}}}\right)
\end{array}
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
sin-mult80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
cos-sum80.3%
cos-280.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr64.6%
+-inverses80.4%
cos-080.4%
*-commutative80.4%
Simplified64.6%
Final simplification64.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi2) t_1)))
(if (or (<= phi1 -3e-19) (not (<= phi1 42.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* t_0 t_0) (* (cos phi1) (cos phi2)))
(pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(hypot (sin (* 0.5 (- phi1 phi2))) (sqrt (* (cos phi1) t_2)))
(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 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi2) * t_1;
double tmp;
if ((phi1 <= -3e-19) || !(phi1 <= 42.0)) {
tmp = R * (2.0 * atan2(sqrt((((t_0 * t_0) * (cos(phi1) * cos(phi2))) + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt((cos(phi1) * t_2))), sqrt((1.0 - (t_2 + pow(sin((phi2 * -0.5)), 2.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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi2) * t_1;
double tmp;
if ((phi1 <= -3e-19) || !(phi1 <= 42.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((((t_0 * t_0) * (Math.cos(phi1) * Math.cos(phi2))) + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.cos(phi1) * t_2))), 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 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi2) * t_1 tmp = 0 if (phi1 <= -3e-19) or not (phi1 <= 42.0): tmp = R * (2.0 * math.atan2(math.sqrt((((t_0 * t_0) * (math.cos(phi1) * math.cos(phi2))) + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.hypot(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.cos(phi1) * t_2))), 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 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi2) * t_1) tmp = 0.0 if ((phi1 <= -3e-19) || !(phi1 <= 42.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))) + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(cos(phi1) * t_2))), 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 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = cos(phi2) * t_1; tmp = 0.0; if ((phi1 <= -3e-19) || ~((phi1 <= 42.0))) tmp = R * (2.0 * atan2(sqrt((((t_0 * t_0) * (cos(phi1) * cos(phi2))) + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt((cos(phi1) * t_2))), 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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi1, -3e-19], N[Not[LessEqual[phi1, 42.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $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[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]], $MachinePrecision] ^ 2], $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 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_2 \cdot t\_1\\
\mathbf{if}\;\phi_1 \leq -3 \cdot 10^{-19} \lor \neg \left(\phi_1 \leq 42\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right) + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sqrt{\cos \phi_1 \cdot t\_2}\right)}{\sqrt{1 - \left(t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -2.99999999999999993e-19 or 42 < phi1 Initial program 51.9%
associate-*l*51.9%
Simplified51.9%
Taylor expanded in phi2 around 0 51.2%
Taylor expanded in phi1 around inf 51.6%
if -2.99999999999999993e-19 < phi1 < 42Initial program 76.8%
associate-*l*76.8%
Simplified76.7%
expm1-log1p-u76.7%
div-inv76.7%
metadata-eval76.7%
Applied egg-rr76.7%
Taylor expanded in phi1 around inf 76.7%
+-commutative76.7%
*-commutative76.7%
unpow276.7%
*-commutative76.7%
rem-square-sqrt59.7%
hypot-undefine59.7%
Simplified59.7%
Taylor expanded in phi1 around 0 59.5%
Taylor expanded in phi1 around 0 59.7%
Final simplification55.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (- lambda1 lambda2) 0.5))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin t_0) 2.0))
(t_4
(sqrt (- 1.0 (+ (* (cos phi1) t_3) (pow (sin (* phi1 0.5)) 2.0)))))
(t_5 (* (cos phi2) t_3)))
(if (<= phi1 -3e-19)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (/ (- 1.0 (cos (* 2.0 t_0))) 2.0))))
t_4)))
(if (<= phi1 3.4e-6)
(*
R
(*
2.0
(atan2
(hypot (sin (* 0.5 (- phi1 phi2))) (sqrt (* (cos phi1) t_5)))
(sqrt (- 1.0 (+ t_5 (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (* t_2 t_2) t_1) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * 0.5;
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(t_0), 2.0);
double t_4 = sqrt((1.0 - ((cos(phi1) * t_3) + pow(sin((phi1 * 0.5)), 2.0))));
double t_5 = cos(phi2) * t_3;
double tmp;
if (phi1 <= -3e-19) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((1.0 - cos((2.0 * t_0))) / 2.0)))), t_4));
} else if (phi1 <= 3.4e-6) {
tmp = R * (2.0 * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt((cos(phi1) * t_5))), sqrt((1.0 - (t_5 + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((((t_2 * t_2) * t_1) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * 0.5;
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(t_0), 2.0);
double t_4 = Math.sqrt((1.0 - ((Math.cos(phi1) * t_3) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))));
double t_5 = Math.cos(phi2) * t_3;
double tmp;
if (phi1 <= -3e-19) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((1.0 - Math.cos((2.0 * t_0))) / 2.0)))), t_4));
} else if (phi1 <= 3.4e-6) {
tmp = R * (2.0 * Math.atan2(Math.hypot(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.cos(phi1) * t_5))), Math.sqrt((1.0 - (t_5 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((((t_2 * t_2) * t_1) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * 0.5 t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(t_0), 2.0) t_4 = math.sqrt((1.0 - ((math.cos(phi1) * t_3) + math.pow(math.sin((phi1 * 0.5)), 2.0)))) t_5 = math.cos(phi2) * t_3 tmp = 0 if phi1 <= -3e-19: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((1.0 - math.cos((2.0 * t_0))) / 2.0)))), t_4)) elif phi1 <= 3.4e-6: tmp = R * (2.0 * math.atan2(math.hypot(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.cos(phi1) * t_5))), math.sqrt((1.0 - (t_5 + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((((t_2 * t_2) * t_1) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * 0.5) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(t_0) ^ 2.0 t_4 = sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_3) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))) t_5 = Float64(cos(phi2) * t_3) tmp = 0.0 if (phi1 <= -3e-19) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(1.0 - cos(Float64(2.0 * t_0))) / 2.0)))), t_4))); elseif (phi1 <= 3.4e-6) tmp = Float64(R * Float64(2.0 * atan(hypot(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(cos(phi1) * t_5))), sqrt(Float64(1.0 - Float64(t_5 + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(t_2 * t_2) * t_1) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * 0.5; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(t_0) ^ 2.0; t_4 = sqrt((1.0 - ((cos(phi1) * t_3) + (sin((phi1 * 0.5)) ^ 2.0)))); t_5 = cos(phi2) * t_3; tmp = 0.0; if (phi1 <= -3e-19) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * ((1.0 - cos((2.0 * t_0))) / 2.0)))), t_4)); elseif (phi1 <= 3.4e-6) tmp = R * (2.0 * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt((cos(phi1) * t_5))), sqrt((1.0 - (t_5 + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((((t_2 * t_2) * t_1) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[phi1, -3e-19], 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] + N[(t$95$1 * N[(N[(1.0 - N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.4e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$5), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + 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[N[Sqrt[N[(N[(N[(t$95$2 * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin t\_0}^{2}\\
t_4 := \sqrt{1 - \left(\cos \phi_1 \cdot t\_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}\\
t_5 := \cos \phi_2 \cdot t\_3\\
\mathbf{if}\;\phi_1 \leq -3 \cdot 10^{-19}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1 \cdot \frac{1 - \cos \left(2 \cdot t\_0\right)}{2}}}{t\_4}\right)\\
\mathbf{elif}\;\phi_1 \leq 3.4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sqrt{\cos \phi_1 \cdot t\_5}\right)}{\sqrt{1 - \left(t\_5 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(t\_2 \cdot t\_2\right) \cdot t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_4}\right)\\
\end{array}
\end{array}
if phi1 < -2.99999999999999993e-19Initial program 55.0%
associate-*l*55.0%
Simplified55.0%
Taylor expanded in phi2 around 0 54.0%
sin-mult83.2%
div-inv83.2%
metadata-eval83.2%
div-inv83.2%
metadata-eval83.2%
cos-sum83.2%
cos-283.2%
div-inv83.2%
metadata-eval83.2%
Applied egg-rr53.8%
+-inverses83.2%
cos-083.2%
*-commutative83.2%
Simplified53.8%
if -2.99999999999999993e-19 < phi1 < 3.40000000000000006e-6Initial program 77.7%
associate-*l*77.7%
Simplified77.6%
expm1-log1p-u77.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr77.6%
Taylor expanded in phi1 around inf 77.6%
+-commutative77.6%
*-commutative77.6%
unpow277.6%
*-commutative77.6%
rem-square-sqrt60.5%
hypot-undefine60.5%
Simplified60.5%
Taylor expanded in phi1 around 0 60.5%
Taylor expanded in phi1 around 0 60.5%
if 3.40000000000000006e-6 < phi1 Initial program 47.8%
associate-*l*47.8%
Simplified47.8%
Taylor expanded in phi2 around 0 47.5%
unpow247.5%
sin-mult47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
div-sub47.3%
+-inverses47.3%
+-inverses47.3%
+-inverses47.3%
cos-047.3%
metadata-eval47.3%
distribute-lft-out47.3%
metadata-eval47.3%
*-rgt-identity47.3%
Simplified47.3%
Final simplification55.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (- lambda1 lambda2) 0.5)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (/ (- 1.0 (cos (* 2.0 t_0))) 2.0))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin t_0) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * 0.5;
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * ((1.0 - cos((2.0 * t_0))) / 2.0)))), sqrt((1.0 - ((cos(phi1) * pow(sin(t_0), 2.0)) + pow(sin((phi1 * 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 = (lambda1 - lambda2) * 0.5d0
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * ((1.0d0 - cos((2.0d0 * t_0))) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * (sin(t_0) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * 0.5;
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * ((1.0 - Math.cos((2.0 * t_0))) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(t_0), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * 0.5 return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * ((1.0 - math.cos((2.0 * t_0))) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(t_0), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * 0.5) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(1.0 - cos(Float64(2.0 * t_0))) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(t_0) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * 0.5; tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * ((1.0 - cos((2.0 * t_0))) / 2.0)))), sqrt((1.0 - ((cos(phi1) * (sin(t_0) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $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] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(1.0 - N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]), $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 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \frac{1 - \cos \left(2 \cdot t\_0\right)}{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin t\_0}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
Taylor expanded in phi2 around 0 49.4%
sin-mult80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
cos-sum80.3%
cos-280.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr47.7%
+-inverses80.4%
cos-080.4%
*-commutative80.4%
Simplified47.7%
Final simplification47.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* t_0 t_0) (* (cos phi1) (cos phi2)))))
(pow
(pow (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)) 1.5)
0.3333333333333333))))))
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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), pow(pow((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), 1.5), 0.3333333333333333)));
}
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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), (((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) ** 1.5d0) ** 0.3333333333333333d0)))
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((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (Math.cos(phi1) * Math.cos(phi2))))), Math.pow(Math.pow((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)), 1.5), 0.3333333333333333)));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (math.cos(phi1) * math.cos(phi2))))), math.pow(math.pow((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)), 1.5), 0.3333333333333333)))
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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))))), ((Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) ^ 1.5) ^ 0.3333333333333333)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), (((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) ^ 1.5) ^ 0.3333333333333333))); 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Power[N[Power[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 1.5], $MachinePrecision], 0.3333333333333333], $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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}{{\left({\left(1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)}^{1.5}\right)}^{0.3333333333333333}}\right)
\end{array}
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
Taylor expanded in phi2 around 0 49.4%
Taylor expanded in phi1 around 0 35.0%
add-cbrt-cube34.9%
pow1/335.0%
add-sqr-sqrt35.0%
pow135.0%
pow1/235.0%
pow-prod-up35.0%
*-commutative35.0%
metadata-eval35.0%
Applied egg-rr35.0%
Final simplification35.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* t_0 t_0) (* (cos phi1) (cos phi2)))))
(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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), 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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), 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((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (Math.cos(phi1) * Math.cos(phi2))))), 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((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (math.cos(phi1) * math.cos(phi2))))), 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))))), 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(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
Taylor expanded in phi2 around 0 49.4%
Taylor expanded in phi1 around 0 35.0%
Final simplification35.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (* phi1 0.5)))
(t_2 (+ (* (cos phi1) t_0) (pow t_1 2.0))))
(if (or (<= (- lambda1 lambda2) -8e-43)
(not (<= (- lambda1 lambda2) 3e-35)))
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_0)))))
(*
R
(*
2.0
(atan2
(* phi2 (- (* 0.5 (cos (* phi1 0.5))) (/ t_1 phi2)))
(sqrt (- 1.0 t_2))))))))
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 = sin((phi1 * 0.5));
double t_2 = (cos(phi1) * t_0) + pow(t_1, 2.0);
double tmp;
if (((lambda1 - lambda2) <= -8e-43) || !((lambda1 - lambda2) <= 3e-35)) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2((phi2 * ((0.5 * cos((phi1 * 0.5))) - (t_1 / phi2))), sqrt((1.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) * 0.5d0)) ** 2.0d0
t_1 = sin((phi1 * 0.5d0))
t_2 = (cos(phi1) * t_0) + (t_1 ** 2.0d0)
if (((lambda1 - lambda2) <= (-8d-43)) .or. (.not. ((lambda1 - lambda2) <= 3d-35))) then
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2((phi2 * ((0.5d0 * cos((phi1 * 0.5d0))) - (t_1 / phi2))), sqrt((1.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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin((phi1 * 0.5));
double t_2 = (Math.cos(phi1) * t_0) + Math.pow(t_1, 2.0);
double tmp;
if (((lambda1 - lambda2) <= -8e-43) || !((lambda1 - lambda2) <= 3e-35)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2((phi2 * ((0.5 * Math.cos((phi1 * 0.5))) - (t_1 / phi2))), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin((phi1 * 0.5)) t_2 = (math.cos(phi1) * t_0) + math.pow(t_1, 2.0) tmp = 0 if ((lambda1 - lambda2) <= -8e-43) or not ((lambda1 - lambda2) <= 3e-35): tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2((phi2 * ((0.5 * math.cos((phi1 * 0.5))) - (t_1 / phi2))), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(phi1 * 0.5)) t_2 = Float64(Float64(cos(phi1) * t_0) + (t_1 ^ 2.0)) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -8e-43) || !(Float64(lambda1 - lambda2) <= 3e-35)) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi2 * Float64(Float64(0.5 * cos(Float64(phi1 * 0.5))) - Float64(t_1 / phi2))), sqrt(Float64(1.0 - t_2))))); 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 * 0.5)); t_2 = (cos(phi1) * t_0) + (t_1 ^ 2.0); tmp = 0.0; if (((lambda1 - lambda2) <= -8e-43) || ~(((lambda1 - lambda2) <= 3e-35))) tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2((phi2 * ((0.5 * cos((phi1 * 0.5))) - (t_1 / phi2))), sqrt((1.0 - t_2)))); 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[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -8e-43], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 3e-35]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi2 * N[(N[(0.5 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 / phi2), $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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_2 := \cos \phi_1 \cdot t\_0 + {t\_1}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -8 \cdot 10^{-43} \lor \neg \left(\lambda_1 - \lambda_2 \leq 3 \cdot 10^{-35}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_2 \cdot \left(0.5 \cdot \cos \left(\phi_1 \cdot 0.5\right) - \frac{t\_1}{\phi_2}\right)}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -8.00000000000000062e-43 or 2.99999999999999989e-35 < (-.f64 lambda1 lambda2) Initial program 59.7%
associate-*l*59.7%
Simplified59.7%
Taylor expanded in phi2 around 0 48.4%
Taylor expanded in phi1 around 0 35.4%
log1p-expm1-u35.4%
log1p-undefine35.4%
div-inv35.4%
metadata-eval35.4%
Applied egg-rr35.4%
Taylor expanded in phi2 around 0 35.7%
if -8.00000000000000062e-43 < (-.f64 lambda1 lambda2) < 2.99999999999999989e-35Initial program 80.5%
associate-*l*80.5%
Simplified80.5%
Taylor expanded in phi2 around 0 52.9%
Taylor expanded in phi2 around 0 52.5%
*-commutative52.5%
associate-*r*52.5%
*-commutative52.5%
Simplified52.5%
Taylor expanded in phi2 around inf 35.2%
+-commutative35.2%
mul-1-neg35.2%
unsub-neg35.2%
Simplified35.2%
Final simplification35.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= phi1 -2.8e+44)
(*
R
(*
2.0
(atan2
(* phi2 (- (* 0.5 (cos (* phi1 0.5))) (/ t_0 phi2)))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow t_0 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (phi1 <= -2.8e+44) {
tmp = R * (2.0 * atan2((phi2 * ((0.5 * cos((phi1 * 0.5))) - (t_0 / phi2))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - t_1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (phi1 <= (-2.8d+44)) then
tmp = r * (2.0d0 * atan2((phi2 * ((0.5d0 * cos((phi1 * 0.5d0))) - (t_0 / phi2))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (t_0 ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - t_1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((phi1 * 0.5));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (phi1 <= -2.8e+44) {
tmp = R * (2.0 * Math.atan2((phi2 * ((0.5 * Math.cos((phi1 * 0.5))) - (t_0 / phi2))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - t_1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if phi1 <= -2.8e+44: tmp = R * (2.0 * math.atan2((phi2 * ((0.5 * math.cos((phi1 * 0.5))) - (t_0 / phi2))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(t_0, 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - t_1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (phi1 <= -2.8e+44) tmp = Float64(R * Float64(2.0 * atan(Float64(phi2 * Float64(Float64(0.5 * cos(Float64(phi1 * 0.5))) - Float64(t_0 / phi2))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (t_0 ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - t_1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if (phi1 <= -2.8e+44) tmp = R * (2.0 * atan2((phi2 * ((0.5 * cos((phi1 * 0.5))) - (t_0 / phi2))), sqrt((1.0 - ((cos(phi1) * t_1) + (t_0 ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - t_1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -2.8e+44], N[(R * N[(2.0 * N[ArcTan[N[(phi2 * N[(N[(0.5 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -2.8 \cdot 10^{+44}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_2 \cdot \left(0.5 \cdot \cos \left(\phi_1 \cdot 0.5\right) - \frac{t\_0}{\phi_2}\right)}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {t\_0}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - t\_1}}\right)\\
\end{array}
\end{array}
if phi1 < -2.8000000000000001e44Initial program 55.3%
associate-*l*55.3%
Simplified55.3%
Taylor expanded in phi2 around 0 55.5%
Taylor expanded in phi2 around 0 57.0%
*-commutative57.0%
associate-*r*57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in phi2 around inf 27.3%
+-commutative27.3%
mul-1-neg27.3%
unsub-neg27.3%
Simplified27.3%
if -2.8000000000000001e44 < phi1 Initial program 66.9%
associate-*l*66.9%
Simplified66.8%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi1 around 0 38.8%
log1p-expm1-u38.8%
log1p-undefine35.8%
div-inv35.8%
metadata-eval35.8%
Applied egg-rr35.8%
Taylor expanded in phi1 around 0 37.0%
Final simplification35.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (sin (* phi1 0.5))))
(if (<= phi1 -2.2e+35)
(*
R
(*
2.0
(atan2
(* phi2 (- (* 0.5 (cos (* phi1 0.5))) (/ t_1 phi2)))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow t_1 2.0)))))))
(*
(* R 2.0)
(atan2
(hypot
(sin (* 0.5 (- phi1 phi2)))
(sqrt (* (* (cos phi1) (cos phi2)) (- 0.5 (/ t_0 2.0)))))
(sqrt (+ 0.5 (* 0.5 t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin((phi1 * 0.5));
double tmp;
if (phi1 <= -2.2e+35) {
tmp = R * (2.0 * atan2((phi2 * ((0.5 * cos((phi1 * 0.5))) - (t_1 / phi2))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(t_1, 2.0))))));
} else {
tmp = (R * 2.0) * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt(((cos(phi1) * cos(phi2)) * (0.5 - (t_0 / 2.0))))), sqrt((0.5 + (0.5 * t_0))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin((phi1 * 0.5));
double tmp;
if (phi1 <= -2.2e+35) {
tmp = R * (2.0 * Math.atan2((phi2 * ((0.5 * Math.cos((phi1 * 0.5))) - (t_1 / phi2))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(t_1, 2.0))))));
} else {
tmp = (R * 2.0) * Math.atan2(Math.hypot(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt(((Math.cos(phi1) * Math.cos(phi2)) * (0.5 - (t_0 / 2.0))))), Math.sqrt((0.5 + (0.5 * t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin((phi1 * 0.5)) tmp = 0 if phi1 <= -2.2e+35: tmp = R * (2.0 * math.atan2((phi2 * ((0.5 * math.cos((phi1 * 0.5))) - (t_1 / phi2))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(t_1, 2.0)))))) else: tmp = (R * 2.0) * math.atan2(math.hypot(math.sin((0.5 * (phi1 - phi2))), math.sqrt(((math.cos(phi1) * math.cos(phi2)) * (0.5 - (t_0 / 2.0))))), math.sqrt((0.5 + (0.5 * t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = sin(Float64(phi1 * 0.5)) tmp = 0.0 if (phi1 <= -2.2e+35) tmp = Float64(R * Float64(2.0 * atan(Float64(phi2 * Float64(Float64(0.5 * cos(Float64(phi1 * 0.5))) - Float64(t_1 / phi2))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (t_1 ^ 2.0))))))); else tmp = Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(0.5 - Float64(t_0 / 2.0))))), sqrt(Float64(0.5 + Float64(0.5 * t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin((phi1 * 0.5)); tmp = 0.0; if (phi1 <= -2.2e+35) tmp = R * (2.0 * atan2((phi2 * ((0.5 * cos((phi1 * 0.5))) - (t_1 / phi2))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (t_1 ^ 2.0)))))); else tmp = (R * 2.0) * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt(((cos(phi1) * cos(phi2)) * (0.5 - (t_0 / 2.0))))), sqrt((0.5 + (0.5 * t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.2e+35], N[(R * N[(2.0 * N[ArcTan[N[(phi2 * N[(N[(0.5 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 / phi2), $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[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(t$95$0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\phi_1 \leq -2.2 \cdot 10^{+35}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_2 \cdot \left(0.5 \cdot \cos \left(\phi_1 \cdot 0.5\right) - \frac{t\_1}{\phi_2}\right)}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {t\_1}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 - \frac{t\_0}{2}\right)}\right)}{\sqrt{0.5 + 0.5 \cdot t\_0}}\\
\end{array}
\end{array}
if phi1 < -2.1999999999999999e35Initial program 55.0%
associate-*l*55.0%
Simplified55.0%
Taylor expanded in phi2 around 0 55.2%
Taylor expanded in phi2 around 0 56.7%
*-commutative56.7%
associate-*r*56.7%
*-commutative56.7%
Simplified56.7%
Taylor expanded in phi2 around inf 26.8%
+-commutative26.8%
mul-1-neg26.8%
unsub-neg26.8%
Simplified26.8%
if -2.1999999999999999e35 < phi1 Initial program 67.0%
associate-*l*67.0%
Simplified67.0%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi1 around 0 38.9%
sin-mult79.3%
div-inv79.3%
metadata-eval79.3%
div-inv79.3%
metadata-eval79.3%
cos-sum79.2%
cos-279.3%
div-inv79.3%
metadata-eval79.3%
Applied egg-rr36.8%
+-inverses79.3%
cos-079.3%
*-commutative79.3%
Simplified36.8%
Applied egg-rr32.4%
unpow132.4%
associate-*r*32.4%
*-commutative32.4%
*-commutative32.4%
*-commutative32.4%
Simplified32.4%
Final simplification31.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(*
(* R 2.0)
(atan2
(hypot
(sin (* 0.5 (- phi1 phi2)))
(sqrt (* (* (cos phi1) (cos phi2)) (- 0.5 (/ t_0 2.0)))))
(sqrt (+ 0.5 (* 0.5 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
return (R * 2.0) * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt(((cos(phi1) * cos(phi2)) * (0.5 - (t_0 / 2.0))))), sqrt((0.5 + (0.5 * t_0))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
return (R * 2.0) * Math.atan2(Math.hypot(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt(((Math.cos(phi1) * Math.cos(phi2)) * (0.5 - (t_0 / 2.0))))), Math.sqrt((0.5 + (0.5 * t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) return (R * 2.0) * math.atan2(math.hypot(math.sin((0.5 * (phi1 - phi2))), math.sqrt(((math.cos(phi1) * math.cos(phi2)) * (0.5 - (t_0 / 2.0))))), math.sqrt((0.5 + (0.5 * t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) return Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(0.5 - Float64(t_0 / 2.0))))), sqrt(Float64(0.5 + Float64(0.5 * t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = (R * 2.0) * atan2(hypot(sin((0.5 * (phi1 - phi2))), sqrt(((cos(phi1) * cos(phi2)) * (0.5 - (t_0 / 2.0))))), sqrt((0.5 + (0.5 * t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(t$95$0 / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right), \sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 - \frac{t\_0}{2}\right)}\right)}{\sqrt{0.5 + 0.5 \cdot t\_0}}
\end{array}
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
Taylor expanded in phi2 around 0 49.4%
Taylor expanded in phi1 around 0 35.0%
sin-mult80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
cos-sum80.3%
cos-280.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr33.4%
+-inverses80.4%
cos-080.4%
*-commutative80.4%
Simplified33.4%
Applied egg-rr28.7%
unpow128.7%
associate-*r*28.7%
*-commutative28.7%
*-commutative28.7%
*-commutative28.7%
Simplified28.7%
Final simplification28.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi2 (cos (* phi1 0.5))))
(t_1
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0))))))
(if (<= phi2 -6.5e-175)
(* R (* 2.0 (atan2 (* -0.5 t_0) t_1)))
(* R (* 2.0 (atan2 (* 0.5 t_0) t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi2 * cos((phi1 * 0.5));
double t_1 = sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))));
double tmp;
if (phi2 <= -6.5e-175) {
tmp = R * (2.0 * atan2((-0.5 * t_0), t_1));
} else {
tmp = R * (2.0 * atan2((0.5 * t_0), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = phi2 * cos((phi1 * 0.5d0))
t_1 = sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))
if (phi2 <= (-6.5d-175)) then
tmp = r * (2.0d0 * atan2(((-0.5d0) * t_0), t_1))
else
tmp = r * (2.0d0 * atan2((0.5d0 * t_0), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi2 * Math.cos((phi1 * 0.5));
double t_1 = 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))));
double tmp;
if (phi2 <= -6.5e-175) {
tmp = R * (2.0 * Math.atan2((-0.5 * t_0), t_1));
} else {
tmp = R * (2.0 * Math.atan2((0.5 * t_0), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi2 * math.cos((phi1 * 0.5)) t_1 = 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)))) tmp = 0 if phi2 <= -6.5e-175: tmp = R * (2.0 * math.atan2((-0.5 * t_0), t_1)) else: tmp = R * (2.0 * math.atan2((0.5 * t_0), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi2 * cos(Float64(phi1 * 0.5))) t_1 = sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))) tmp = 0.0 if (phi2 <= -6.5e-175) tmp = Float64(R * Float64(2.0 * atan(Float64(-0.5 * t_0), t_1))); else tmp = Float64(R * Float64(2.0 * atan(Float64(0.5 * t_0), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi2 * cos((phi1 * 0.5)); t_1 = sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))); tmp = 0.0; if (phi2 <= -6.5e-175) tmp = R * (2.0 * atan2((-0.5 * t_0), t_1)); else tmp = R * (2.0 * atan2((0.5 * t_0), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi2 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[phi2, -6.5e-175], N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * t$95$0), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(0.5 * t$95$0), $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \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)}\\
\mathbf{if}\;\phi_2 \leq -6.5 \cdot 10^{-175}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot t\_0}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{0.5 \cdot t\_0}{t\_1}\right)\\
\end{array}
\end{array}
if phi2 < -6.5000000000000005e-175Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
Taylor expanded in phi2 around 0 43.1%
Taylor expanded in phi2 around 0 42.2%
*-commutative42.2%
associate-*r*42.2%
*-commutative42.2%
Simplified42.2%
Taylor expanded in phi2 around -inf 12.8%
if -6.5000000000000005e-175 < phi2 Initial program 65.5%
associate-*l*65.5%
Simplified65.5%
Taylor expanded in phi2 around 0 53.6%
Taylor expanded in phi2 around 0 53.5%
*-commutative53.5%
associate-*r*53.5%
*-commutative53.5%
Simplified53.5%
Taylor expanded in phi2 around inf 11.6%
Final simplification12.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* -0.5 (* phi2 (cos (* phi1 0.5))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((-0.5 * (phi2 * cos((phi1 * 0.5)))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 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(((-0.5d0) * (phi2 * cos((phi1 * 0.5d0)))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 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((-0.5 * (phi2 * Math.cos((phi1 * 0.5)))), 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))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((-0.5 * (phi2 * math.cos((phi1 * 0.5)))), 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))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi2 * cos(Float64(phi1 * 0.5)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((-0.5 * (phi2 * cos((phi1 * 0.5)))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi2 * N[Cos[N[(phi1 * 0.5), $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]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\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)
\end{array}
Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
Taylor expanded in phi2 around 0 49.4%
Taylor expanded in phi2 around 0 49.0%
*-commutative49.0%
associate-*r*49.0%
*-commutative49.0%
Simplified49.0%
Taylor expanded in phi2 around -inf 7.7%
Final simplification7.7%
herbie shell --seed 2024132
(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))))))))))