
(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 25 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 (* phi1 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* (* (cos phi1) (cos phi2)) t_2)))
(t_4 (cos (* 0.5 phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* t_4 t_0) (* (sin (* 0.5 phi2)) t_1)) 2.0) t_3))
(sqrt
(-
1.0
(+ t_3 (pow (fma t_0 t_4 (* t_1 (sin (* phi2 -0.5)))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2);
double t_4 = cos((0.5 * phi2));
return R * (2.0 * atan2(sqrt((pow(((t_4 * t_0) - (sin((0.5 * phi2)) * t_1)), 2.0) + t_3)), sqrt((1.0 - (t_3 + pow(fma(t_0, t_4, (t_1 * sin((phi2 * -0.5)))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) t_4 = cos(Float64(0.5 * phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_4 * t_0) - Float64(sin(Float64(0.5 * phi2)) * t_1)) ^ 2.0) + t_3)), sqrt(Float64(1.0 - Float64(t_3 + (fma(t_0, t_4, Float64(t_1 * sin(Float64(phi2 * -0.5)))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$4 * t$95$0), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[Power[N[(t$95$0 * t$95$4 + N[(t$95$1 * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\right)\\
t_4 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t_4 \cdot t_0 - \sin \left(0.5 \cdot \phi_2\right) \cdot t_1\right)}^{2} + t_3}}{\sqrt{1 - \left(t_3 + {\left(\mathsf{fma}\left(t_0, t_4, t_1 \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.9%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr66.0%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr81.8%
Taylor expanded in phi1 around inf 81.8%
*-commutative81.8%
fma-neg81.8%
distribute-rgt-neg-in81.8%
sin-neg81.8%
distribute-lft-neg-in81.8%
metadata-eval81.8%
*-commutative81.8%
Simplified81.8%
Final simplification81.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) 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(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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 = (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * 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.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * 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((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * 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 = (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
Initial program 64.9%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr66.0%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr81.8%
Final simplification81.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (+ t_0 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))))
(if (or (<= lambda2 -61000000.0) (not (<= lambda2 3.1e-18)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0)))))
(sqrt (- 1.0 t_2)))))
(*
R
(*
2.0
(atan2
(sqrt t_2)
(sqrt
(-
1.0
(+
t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1));
double tmp;
if ((lambda2 <= -61000000.0) || !(lambda2 <= 3.1e-18)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))), sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))
if ((lambda2 <= (-61000000.0d0)) .or. (.not. (lambda2 <= 3.1d-18))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), sqrt((1.0d0 - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 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.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1));
double tmp;
if ((lambda2 <= -61000000.0) || !(lambda2 <= 3.1e-18)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), Math.sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) tmp = 0 if (lambda2 <= -61000000.0) or not (lambda2 <= 3.1e-18): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), math.sqrt((1.0 - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1))) tmp = 0.0 if ((lambda2 <= -61000000.0) || !(lambda2 <= 3.1e-18)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), sqrt(Float64(1.0 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)); tmp = 0.0; if ((lambda2 <= -61000000.0) || ~((lambda2 <= 3.1e-18))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0))))), sqrt((1.0 - t_2)))); else tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -61000000.0], N[Not[LessEqual[lambda2, 3.1e-18]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t_0 + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)\\
\mathbf{if}\;\lambda_2 \leq -61000000 \lor \neg \left(\lambda_2 \leq 3.1 \cdot 10^{-18}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{1 - t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2}}{\sqrt{1 - \left(t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -6.1e7 or 3.10000000000000007e-18 < lambda2 Initial program 53.1%
div-sub53.1%
sin-diff54.4%
div-inv54.4%
metadata-eval54.4%
div-inv54.4%
metadata-eval54.4%
div-inv54.4%
metadata-eval54.4%
div-inv54.4%
metadata-eval54.4%
Applied egg-rr54.4%
div-sub53.1%
sin-diff54.4%
div-inv54.4%
metadata-eval54.4%
div-inv54.4%
metadata-eval54.4%
div-inv54.4%
metadata-eval54.4%
div-inv54.4%
metadata-eval54.4%
Applied egg-rr64.1%
Taylor expanded in lambda1 around 0 63.9%
*-commutative63.9%
associate-*l*63.9%
*-commutative63.9%
Simplified63.9%
if -6.1e7 < lambda2 < 3.10000000000000007e-18Initial program 75.4%
div-sub75.4%
sin-diff76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
Applied egg-rr76.4%
div-sub75.4%
sin-diff76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
Applied egg-rr97.6%
Taylor expanded in lambda2 around 0 97.6%
Final simplification81.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sqrt (+ t_0 (* t_1 (* (* (cos phi1) (cos phi2)) t_1))))))
(if (or (<= lambda2 -3.7e-5) (not (<= lambda2 3.1e-18)))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
t_0
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))));
double tmp;
if ((lambda2 <= -3.7e-5) || !(lambda2 <= 3.1e-18)) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))))
if ((lambda2 <= (-3.7d-5)) .or. (.not. (lambda2 <= 3.1d-18))) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 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.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((t_0 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1))));
double tmp;
if ((lambda2 <= -3.7e-5) || !(lambda2 <= 3.1e-18)) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((t_0 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)))) tmp = 0 if (lambda2 <= -3.7e-5) or not (lambda2 <= 3.1e-18): tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(t_0 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))) tmp = 0.0 if ((lambda2 <= -3.7e-5) || !(lambda2 <= 3.1e-18)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))); tmp = 0.0; if ((lambda2 <= -3.7e-5) || ~((lambda2 <= 3.1e-18))) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $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[(t$95$0 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -3.7e-5], N[Not[LessEqual[lambda2, 3.1e-18]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{t_0 + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -3.7 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 3.1 \cdot 10^{-18}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -3.69999999999999981e-5 or 3.10000000000000007e-18 < lambda2 Initial program 52.7%
div-sub52.7%
sin-diff53.9%
div-inv53.9%
metadata-eval53.9%
div-inv53.9%
metadata-eval53.9%
div-inv53.9%
metadata-eval53.9%
div-inv53.9%
metadata-eval53.9%
Applied egg-rr53.9%
div-sub52.7%
sin-diff53.9%
div-inv53.9%
metadata-eval53.9%
div-inv53.9%
metadata-eval53.9%
div-inv53.9%
metadata-eval53.9%
div-inv53.9%
metadata-eval53.9%
Applied egg-rr63.7%
Taylor expanded in lambda1 around 0 63.7%
*-commutative63.6%
associate-*l*63.6%
*-commutative63.6%
Simplified63.7%
if -3.69999999999999981e-5 < lambda2 < 3.10000000000000007e-18Initial program 76.0%
div-sub76.0%
sin-diff76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
Applied egg-rr76.9%
div-sub76.0%
sin-diff76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
Applied egg-rr98.2%
Taylor expanded in lambda2 around 0 98.2%
Final simplification81.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* t_1 t_2)))
(t_4 (+ t_0 t_3))
(t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_6 (sqrt (- 1.0 t_4))))
(if (<= lambda1 -3.6e-19)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (* t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
t_6)))
(if (<= lambda1 9.5e-84)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_6)))
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 (+ t_3 t_5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * (t_1 * t_2);
double t_4 = t_0 + t_3;
double t_5 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_6 = sqrt((1.0 - t_4));
double tmp;
if (lambda1 <= -3.6e-19) {
tmp = R * (2.0 * atan2(sqrt((t_5 + (t_1 * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), t_6));
} else if (lambda1 <= 9.5e-84) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))), t_6));
} else {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - (t_3 + t_5)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_2 * (t_1 * t_2)
t_4 = t_0 + t_3
t_5 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_6 = sqrt((1.0d0 - t_4))
if (lambda1 <= (-3.6d-19)) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (t_1 * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), t_6))
else if (lambda1 <= 9.5d-84) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_6))
else
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - (t_3 + t_5)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * (t_1 * t_2);
double t_4 = t_0 + t_3;
double t_5 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_6 = Math.sqrt((1.0 - t_4));
double tmp;
if (lambda1 <= -3.6e-19) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + (t_1 * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), t_6));
} else if (lambda1 <= 9.5e-84) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), t_6));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - (t_3 + t_5)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_2 * (t_1 * t_2) t_4 = t_0 + t_3 t_5 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_6 = math.sqrt((1.0 - t_4)) tmp = 0 if lambda1 <= -3.6e-19: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + (t_1 * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), t_6)) elif lambda1 <= 9.5e-84: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), t_6)) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - (t_3 + t_5))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(t_1 * t_2)) t_4 = Float64(t_0 + t_3) t_5 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_6 = sqrt(Float64(1.0 - t_4)) tmp = 0.0 if (lambda1 <= -3.6e-19) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + Float64(t_1 * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), t_6))); elseif (lambda1 <= 9.5e-84) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), t_6))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - Float64(t_3 + t_5)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_2 * (t_1 * t_2); t_4 = t_0 + t_3; t_5 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_6 = sqrt((1.0 - t_4)); tmp = 0.0; if (lambda1 <= -3.6e-19) tmp = R * (2.0 * atan2(sqrt((t_5 + (t_1 * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), t_6)); elseif (lambda1 <= 9.5e-84) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_6)); else tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - (t_3 + t_5))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 + t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -3.6e-19], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[(t$95$1 * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 9.5e-84], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_2 \cdot \left(t_1 \cdot t_2\right)\\
t_4 := t_0 + t_3\\
t_5 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_6 := \sqrt{1 - t_4}\\
\mathbf{if}\;\lambda_1 \leq -3.6 \cdot 10^{-19}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_5 + t_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{t_6}\right)\\
\mathbf{elif}\;\lambda_1 \leq 9.5 \cdot 10^{-84}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{t_6}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4}}{\sqrt{1 - \left(t_3 + t_5\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -3.6000000000000001e-19Initial program 50.5%
div-sub50.5%
sin-diff51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
div-inv51.5%
metadata-eval51.5%
Applied egg-rr51.5%
Taylor expanded in phi1 around inf 51.6%
associate-*r*51.6%
*-commutative51.6%
*-commutative51.6%
Simplified51.6%
if -3.6000000000000001e-19 < lambda1 < 9.49999999999999941e-84Initial program 78.4%
div-sub78.4%
sin-diff79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
Applied egg-rr79.7%
div-sub78.4%
sin-diff79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
Applied egg-rr99.0%
Taylor expanded in lambda1 around 0 97.6%
*-commutative97.6%
associate-*l*97.6%
*-commutative97.6%
Simplified97.6%
if 9.49999999999999941e-84 < lambda1 Initial program 56.7%
div-sub56.7%
sin-diff57.6%
div-inv57.6%
metadata-eval57.6%
div-inv57.6%
metadata-eval57.6%
div-inv57.6%
metadata-eval57.6%
div-inv57.6%
metadata-eval57.6%
Applied egg-rr57.7%
Final simplification74.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 t_2)))
(if (or (<= (- lambda1 lambda2) -0.5) (not (<= (- lambda1 lambda2) 5e+29)))
(*
(atan2
(sqrt (fma t_1 t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(fma t_1 t_3 (- 0.5 (/ (+ t_1 (* (sin phi1) (sin phi2))) 2.0))))))
(* R 2.0))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (- 1.0 (+ t_0 (* t_2 (* t_1 t_2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * t_2;
double tmp;
if (((lambda1 - lambda2) <= -0.5) || !((lambda1 - lambda2) <= 5e+29)) {
tmp = atan2(sqrt(fma(t_1, t_3, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_1, t_3, (0.5 - ((t_1 + (sin(phi1) * sin(phi2))) / 2.0)))))) * (R * 2.0);
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((1.0 - (t_0 + (t_2 * (t_1 * t_2)))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * t_2) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -0.5) || !(Float64(lambda1 - lambda2) <= 5e+29)) tmp = Float64(atan(sqrt(fma(t_1, t_3, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_1, t_3, Float64(0.5 - Float64(Float64(t_1 + Float64(sin(phi1) * sin(phi2))) / 2.0)))))) * Float64(R * 2.0)); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_2 * Float64(t_1 * t_2)))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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[(t$95$2 * t$95$2), $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.5], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e+29]], $MachinePrecision]], N[(N[ArcTan[N[Sqrt[N[(t$95$1 * t$95$3 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 * t$95$3 + N[(0.5 - N[(N[(t$95$1 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_2 \cdot t_2\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.5 \lor \neg \left(\lambda_1 - \lambda_2 \leq 5 \cdot 10^{+29}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_1, t_3, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_1, t_3, 0.5 - \frac{t_1 + \sin \phi_1 \cdot \sin \phi_2}{2}\right)}} \cdot \left(R \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - \left(t_0 + t_2 \cdot \left(t_1 \cdot t_2\right)\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -0.5 or 5.0000000000000001e29 < (-.f64 lambda1 lambda2) Initial program 58.9%
associate-*r*58.9%
*-commutative58.9%
Simplified58.9%
unpow258.9%
sin-mult58.9%
div-inv58.9%
metadata-eval58.9%
div-inv58.9%
metadata-eval58.9%
div-inv58.9%
metadata-eval58.9%
div-inv58.9%
metadata-eval58.9%
Applied egg-rr58.9%
div-sub58.9%
+-inverses58.9%
cos-058.9%
metadata-eval58.9%
distribute-lft-out58.9%
metadata-eval58.9%
*-rgt-identity58.9%
Simplified58.9%
cos-diff60.2%
Applied egg-rr60.2%
if -0.5 < (-.f64 lambda1 lambda2) < 5.0000000000000001e29Initial program 77.6%
div-sub77.6%
sin-diff78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
Applied egg-rr78.4%
div-sub77.6%
sin-diff78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
Applied egg-rr98.6%
Taylor expanded in phi1 around 0 95.7%
Final simplification71.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 t_2)))
(if (or (<= (- lambda1 lambda2) -0.5) (not (<= (- lambda1 lambda2) 5e+29)))
(*
(atan2
(sqrt (fma t_1 t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(fma t_1 t_3 (- 0.5 (/ (+ t_1 (* (sin phi1) (sin phi2))) 2.0))))))
(* R 2.0))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_1 t_2))))
(sqrt
(-
1.0
(+
t_0
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * t_2;
double tmp;
if (((lambda1 - lambda2) <= -0.5) || !((lambda1 - lambda2) <= 5e+29)) {
tmp = atan2(sqrt(fma(t_1, t_3, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_1, t_3, (0.5 - ((t_1 + (sin(phi1) * sin(phi2))) / 2.0)))))) * (R * 2.0);
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - (t_0 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * t_2) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -0.5) || !(Float64(lambda1 - lambda2) <= 5e+29)) tmp = Float64(atan(sqrt(fma(t_1, t_3, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_1, t_3, Float64(0.5 - Float64(Float64(t_1 + Float64(sin(phi1) * sin(phi2))) / 2.0)))))) * Float64(R * 2.0)); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_1 * t_2)))), sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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[(t$95$2 * t$95$2), $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.5], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e+29]], $MachinePrecision]], N[(N[ArcTan[N[Sqrt[N[(t$95$1 * t$95$3 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 * t$95$3 + N[(0.5 - N[(N[(t$95$1 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_2 \cdot t_2\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.5 \lor \neg \left(\lambda_1 - \lambda_2 \leq 5 \cdot 10^{+29}\right):\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_1, t_3, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_1, t_3, 0.5 - \frac{t_1 + \sin \phi_1 \cdot \sin \phi_2}{2}\right)}} \cdot \left(R \cdot 2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_1 \cdot t_2\right)}}{\sqrt{1 - \left(t_0 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -0.5 or 5.0000000000000001e29 < (-.f64 lambda1 lambda2) Initial program 58.9%
associate-*r*58.9%
*-commutative58.9%
Simplified58.9%
unpow258.9%
sin-mult58.9%
div-inv58.9%
metadata-eval58.9%
div-inv58.9%
metadata-eval58.9%
div-inv58.9%
metadata-eval58.9%
div-inv58.9%
metadata-eval58.9%
Applied egg-rr58.9%
div-sub58.9%
+-inverses58.9%
cos-058.9%
metadata-eval58.9%
distribute-lft-out58.9%
metadata-eval58.9%
*-rgt-identity58.9%
Simplified58.9%
cos-diff60.2%
Applied egg-rr60.2%
if -0.5 < (-.f64 lambda1 lambda2) < 5.0000000000000001e29Initial program 77.6%
div-sub77.6%
sin-diff78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
Applied egg-rr78.4%
div-sub77.6%
sin-diff78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
div-inv78.4%
metadata-eval78.4%
Applied egg-rr98.6%
Taylor expanded in phi1 around 0 95.8%
Final simplification71.6%
(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
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt
(-
1.0
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0)
(* t_1 (* t_0 t_1))))))))))
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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((1.0 - (pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0) + (t_1 * (t_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 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt((1.0d0 - ((((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0) + (t_1 * (t_0 * t_1)))))))
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);
double t_1 = 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 * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((1.0 - (Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0) + (t_1 * (t_0 * t_1)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = 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 * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((1.0 - (math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) + (t_1 * (t_0 * t_1)))))))
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(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64(1.0 - Float64((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(t_1 * Float64(t_0 * t_1)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt((1.0 - ((((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0) + (t_1 * (t_0 * t_1))))))); 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[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - \left({\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2} + t_1 \cdot \left(t_0 \cdot t_1\right)\right)}}\right)
\end{array}
\end{array}
Initial program 64.9%
div-sub64.9%
sin-diff66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
div-inv66.0%
metadata-eval66.0%
Applied egg-rr66.0%
Taylor expanded in phi1 around inf 66.0%
associate-*r*66.0%
*-commutative66.0%
*-commutative66.0%
Simplified66.0%
Final simplification66.0%
(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 (+ (* t_1 (* t_0 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(exp
(log1p
(-
(fma
t_0
(+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))
(pow (sin (* 0.5 (- phi1 phi2))) 2.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(((t_1 * (t_0 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(exp(log1p(-fma(t_0, (0.5 + (-0.5 * cos((lambda1 - lambda2)))), pow(sin((0.5 * (phi1 - phi2))), 2.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(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(exp(log1p(Float64(-fma(t_0, Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.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[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Exp[N[Log[1 + (-N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision])], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \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{t_1 \cdot \left(t_0 \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{e^{\mathsf{log1p}\left(-\mathsf{fma}\left(t_0, 0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right)}}}\right)
\end{array}
\end{array}
Initial program 64.9%
Applied egg-rr65.0%
Final simplification65.0%
(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 (+ (* t_1 (* t_0 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))
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(((t_1 * (t_0 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2)))))))));
}
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 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - (t_0 * (0.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))))))))
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);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))
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(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64(t_0 * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2))))))))); 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[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $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{t_1 \cdot \left(t_0 \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - t_0 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)
\end{array}
\end{array}
Initial program 64.9%
associate--r+64.9%
associate-*l*64.9%
cancel-sign-sub-inv64.9%
div-inv64.9%
metadata-eval64.9%
sqr-sin-a65.0%
cancel-sign-sub-inv65.0%
metadata-eval65.0%
cos-264.9%
Applied egg-rr65.0%
Final simplification65.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(if (or (<= phi2 -8.3e-7) (not (<= phi2 2.9e+20)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* (cos phi2) t_2)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* (* (cos phi1) (cos phi2)) t_0)) t_1))
(sqrt
(- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -8.3e-7) || !(phi2 <= 2.9e+20)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi2) * t_2))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
if ((phi2 <= (-8.3d-7)) .or. (.not. (phi2 <= 2.9d+20))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi2) * t_2))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -8.3e-7) || !(phi2 <= 2.9e+20)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi2) * t_2))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + t_1)), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi2 <= -8.3e-7) or not (phi2 <= 2.9e+20): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi2) * t_2))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + t_1)), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 tmp = 0.0 if ((phi2 <= -8.3e-7) || !(phi2 <= 2.9e+20)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi2) * t_2))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = 0.0; if ((phi2 <= -8.3e-7) || ~((phi2 <= 2.9e+20))) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi2) * t_2))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -8.3e-7], N[Not[LessEqual[phi2, 2.9e+20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -8.3 \cdot 10^{-7} \lor \neg \left(\phi_2 \leq 2.9 \cdot 10^{+20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \cos \phi_2 \cdot t_2}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + t_1}}{\sqrt{1 - \left(\cos \phi_1 \cdot t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -8.29999999999999994e-7 or 2.9e20 < phi2 Initial program 54.0%
div-sub54.0%
sin-diff56.1%
div-inv56.1%
metadata-eval56.1%
div-inv56.1%
metadata-eval56.1%
div-inv56.1%
metadata-eval56.1%
div-inv56.1%
metadata-eval56.1%
Applied egg-rr56.1%
Taylor expanded in phi1 around 0 55.2%
Taylor expanded in phi1 around inf 55.2%
*-commutative84.4%
fma-neg84.5%
distribute-rgt-neg-in84.5%
sin-neg84.5%
distribute-lft-neg-in84.5%
metadata-eval84.5%
*-commutative84.5%
Simplified55.2%
Taylor expanded in phi1 around 0 54.0%
Simplified54.1%
if -8.29999999999999994e-7 < phi2 < 2.9e20Initial program 75.6%
Taylor expanded in phi2 around 0 75.6%
Final simplification64.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_3 (* (cos phi2) t_2))
(t_4 (sqrt (+ (* t_1 (* (* (cos phi1) (cos phi2)) t_1)) t_0))))
(if (<= phi2 -8.3e-7)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_3))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(if (<= phi2 2.9e+20)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2 t_4 (sqrt (- 1.0 (+ t_3 (pow (sin (* phi2 -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 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_3 = cos(phi2) * t_2;
double t_4 = sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_0));
double tmp;
if (phi2 <= -8.3e-7) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else if (phi2 <= 2.9e+20) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_3 + pow(sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_3 = cos(phi2) * t_2
t_4 = sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_0))
if (phi2 <= (-8.3d-7)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_3)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else if (phi2 <= 2.9d+20) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - (t_3 + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_3 = Math.cos(phi2) * t_2;
double t_4 = Math.sqrt(((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + t_0));
double tmp;
if (phi2 <= -8.3e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_3)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else if (phi2 <= 2.9e+20) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - (t_3 + Math.pow(Math.sin((phi2 * -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.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_3 = math.cos(phi2) * t_2 t_4 = math.sqrt(((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + t_0)) tmp = 0 if phi2 <= -8.3e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_3)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) elif phi2 <= 2.9e+20: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - (t_3 + math.pow(math.sin((phi2 * -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) / 2.0)) t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_3 = Float64(cos(phi2) * t_2) t_4 = sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + t_0)) tmp = 0.0 if (phi2 <= -8.3e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); elseif (phi2 <= 2.9e+20) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(t_3 + (sin(Float64(phi2 * -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) / 2.0)); t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_3 = cos(phi2) * t_2; t_4 = sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_0)); tmp = 0.0; if (phi2 <= -8.3e-7) tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); elseif (phi2 <= 2.9e+20) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_3 + (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[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -8.3e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 2.9e+20], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(t$95$3 + 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{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_3 := \cos \phi_2 \cdot t_2\\
t_4 := \sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + t_0}\\
\mathbf{if}\;\phi_2 \leq -8.3 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{elif}\;\phi_2 \leq 2.9 \cdot 10^{+20}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{1 - \left(\cos \phi_1 \cdot t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{1 - \left(t_3 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -8.29999999999999994e-7Initial program 49.9%
div-sub49.9%
sin-diff51.6%
div-inv51.6%
metadata-eval51.6%
div-inv51.6%
metadata-eval51.6%
div-inv51.6%
metadata-eval51.6%
div-inv51.6%
metadata-eval51.6%
Applied egg-rr51.6%
Taylor expanded in phi1 around 0 50.3%
Taylor expanded in phi1 around inf 50.3%
*-commutative82.2%
fma-neg82.3%
distribute-rgt-neg-in82.3%
sin-neg82.3%
distribute-lft-neg-in82.3%
metadata-eval82.3%
*-commutative82.3%
Simplified50.3%
Taylor expanded in phi1 around 0 49.1%
Simplified49.2%
if -8.29999999999999994e-7 < phi2 < 2.9e20Initial program 75.6%
Taylor expanded in phi2 around 0 75.6%
if 2.9e20 < phi2 Initial program 58.9%
Taylor expanded in phi1 around 0 60.1%
Final simplification64.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2))))
(t_1 (sin (* 0.5 (- phi1 phi2))))
(t_2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow t_0 2.0))))))
(if (<= phi1 -1.7e+175)
(*
(atan2
(hypot t_1 (* t_0 (sqrt (* (cos phi1) (cos phi2)))))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))
(pow t_1 2.0)))))
(* R 2.0))
(if (<= phi1 2.1e-5)
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
double t_1 = sin((0.5 * (phi1 - phi2)));
double t_2 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(t_0, 2.0))));
double tmp;
if (phi1 <= -1.7e+175) {
tmp = atan2(hypot(t_1, (t_0 * sqrt((cos(phi1) * cos(phi2))))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))), pow(t_1, 2.0))))) * (R * 2.0);
} else if (phi1 <= 2.1e-5) {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) t_1 = sin(Float64(0.5 * Float64(phi1 - phi2))) t_2 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (t_0 ^ 2.0)))) tmp = 0.0 if (phi1 <= -1.7e+175) tmp = Float64(atan(hypot(t_1, Float64(t_0 * sqrt(Float64(cos(phi1) * cos(phi2))))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2))))), (t_1 ^ 2.0))))) * Float64(R * 2.0)); elseif (phi1 <= 2.1e-5) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.7e+175], N[(N[ArcTan[N[Sqrt[t$95$1 ^ 2 + N[(t$95$0 * N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.1e-5], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
t_2 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {t_0}^{2}}\\
\mathbf{if}\;\phi_1 \leq -1.7 \cdot 10^{+175}:\\
\;\;\;\;\tan^{-1}_* \frac{\mathsf{hypot}\left(t_1, t_0 \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {t_1}^{2}\right)}} \cdot \left(R \cdot 2\right)\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{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)\\
\end{array}
\end{array}
if phi1 < -1.70000000000000014e175Initial program 67.4%
associate-*r*67.4%
*-commutative67.4%
Simplified67.5%
Applied egg-rr6.1%
expm1-def25.5%
expm1-log1p36.7%
Simplified36.7%
if -1.70000000000000014e175 < phi1 < 2.09999999999999988e-5Initial program 74.1%
div-sub74.1%
sin-diff74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
Applied egg-rr74.4%
Taylor expanded in phi1 around 0 71.8%
Taylor expanded in phi1 around inf 71.8%
*-commutative81.4%
fma-neg81.4%
distribute-rgt-neg-in81.4%
sin-neg81.4%
distribute-lft-neg-in81.4%
metadata-eval81.4%
*-commutative81.4%
Simplified71.8%
Taylor expanded in phi1 around 0 70.9%
Simplified70.9%
if 2.09999999999999988e-5 < phi1 Initial program 43.3%
Taylor expanded in lambda2 around 0 40.5%
Taylor expanded in lambda1 around 0 31.4%
Taylor expanded in phi1 around 0 31.1%
*-commutative31.1%
metadata-eval31.1%
div-inv31.1%
div-sub31.1%
sin-diff32.1%
Applied egg-rr32.1%
Final simplification56.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2))))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow t_0 2.0))))))
(if (<= phi1 -1.7e+175)
(*
(* R 2.0)
(atan2
(hypot (sin (* phi1 0.5)) (* t_0 (sqrt (* (cos phi1) (cos phi2)))))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(if (<= phi1 2.1e-5)
(*
R
(*
2.0
(atan2
t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
double t_1 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(t_0, 2.0))));
double tmp;
if (phi1 <= -1.7e+175) {
tmp = (R * 2.0) * atan2(hypot(sin((phi1 * 0.5)), (t_0 * sqrt((cos(phi1) * cos(phi2))))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))), pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else if (phi1 <= 2.1e-5) {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) t_1 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (t_0 ^ 2.0)))) tmp = 0.0 if (phi1 <= -1.7e+175) tmp = Float64(Float64(R * 2.0) * atan(hypot(sin(Float64(phi1 * 0.5)), Float64(t_0 * sqrt(Float64(cos(phi1) * cos(phi2))))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2))))), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); elseif (phi1 <= 2.1e-5) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.7e+175], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] ^ 2 + N[(t$95$0 * N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.1e-5], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {t_0}^{2}}\\
\mathbf{if}\;\phi_1 \leq -1.7 \cdot 10^{+175}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\phi_1 \cdot 0.5\right), t_0 \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{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)\\
\end{array}
\end{array}
if phi1 < -1.70000000000000014e175Initial program 67.4%
associate-*r*67.4%
*-commutative67.4%
Simplified67.5%
Applied egg-rr6.1%
expm1-def25.5%
expm1-log1p36.7%
Simplified36.7%
Taylor expanded in phi2 around 0 36.7%
if -1.70000000000000014e175 < phi1 < 2.09999999999999988e-5Initial program 74.1%
div-sub74.1%
sin-diff74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
Applied egg-rr74.4%
Taylor expanded in phi1 around 0 71.8%
Taylor expanded in phi1 around inf 71.8%
*-commutative81.4%
fma-neg81.4%
distribute-rgt-neg-in81.4%
sin-neg81.4%
distribute-lft-neg-in81.4%
metadata-eval81.4%
*-commutative81.4%
Simplified71.8%
Taylor expanded in phi1 around 0 70.9%
Simplified70.9%
if 2.09999999999999988e-5 < phi1 Initial program 43.3%
Taylor expanded in lambda2 around 0 40.5%
Taylor expanded in lambda1 around 0 31.4%
Taylor expanded in phi1 around 0 31.1%
*-commutative31.1%
metadata-eval31.1%
div-inv31.1%
div-sub31.1%
sin-diff32.1%
Applied egg-rr32.1%
Final simplification56.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2))))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow t_0 2.0)))))
(t_2 (sin (* phi1 0.5))))
(if (<= phi1 -1.7e+175)
(*
(* R 2.0)
(atan2
(hypot t_2 (* t_0 (sqrt (* (cos phi1) (cos phi2)))))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))
(pow t_2 2.0))))))
(if (<= phi1 2.1e-5)
(*
R
(*
2.0
(atan2
t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
double t_1 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(t_0, 2.0))));
double t_2 = sin((phi1 * 0.5));
double tmp;
if (phi1 <= -1.7e+175) {
tmp = (R * 2.0) * atan2(hypot(t_2, (t_0 * sqrt((cos(phi1) * cos(phi2))))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))), pow(t_2, 2.0)))));
} else if (phi1 <= 2.1e-5) {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) t_1 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (t_0 ^ 2.0)))) t_2 = sin(Float64(phi1 * 0.5)) tmp = 0.0 if (phi1 <= -1.7e+175) tmp = Float64(Float64(R * 2.0) * atan(hypot(t_2, Float64(t_0 * sqrt(Float64(cos(phi1) * cos(phi2))))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2))))), (t_2 ^ 2.0)))))); elseif (phi1 <= 2.1e-5) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.7e+175], N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[t$95$2 ^ 2 + N[(t$95$0 * N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.1e-5], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {t_0}^{2}}\\
t_2 := \sin \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\phi_1 \leq -1.7 \cdot 10^{+175}:\\
\;\;\;\;\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t_2, t_0 \cdot \sqrt{\cos \phi_1 \cdot \cos \phi_2}\right)}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {t_2}^{2}\right)}}\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{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)\\
\end{array}
\end{array}
if phi1 < -1.70000000000000014e175Initial program 67.4%
associate-*r*67.4%
*-commutative67.4%
Simplified67.5%
Applied egg-rr6.1%
expm1-def25.5%
expm1-log1p36.7%
Simplified36.7%
Taylor expanded in phi2 around 0 36.7%
Taylor expanded in phi2 around 0 36.7%
if -1.70000000000000014e175 < phi1 < 2.09999999999999988e-5Initial program 74.1%
div-sub74.1%
sin-diff74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
Applied egg-rr74.4%
Taylor expanded in phi1 around 0 71.8%
Taylor expanded in phi1 around inf 71.8%
*-commutative81.4%
fma-neg81.4%
distribute-rgt-neg-in81.4%
sin-neg81.4%
distribute-lft-neg-in81.4%
metadata-eval81.4%
*-commutative81.4%
Simplified71.8%
Taylor expanded in phi1 around 0 70.9%
Simplified70.9%
if 2.09999999999999988e-5 < phi1 Initial program 43.3%
Taylor expanded in lambda2 around 0 40.5%
Taylor expanded in lambda1 around 0 31.4%
Taylor expanded in phi1 around 0 31.1%
*-commutative31.1%
metadata-eval31.1%
div-inv31.1%
div-sub31.1%
sin-diff32.1%
Applied egg-rr32.1%
Final simplification56.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2
(sqrt
(+ t_1 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))
(if (<= phi1 -1.85e+67)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* (* (cos phi1) (cos phi2)) t_0)) t_1))
(sqrt (pow (cos (* phi1 0.5)) 2.0)))))
(if (<= phi1 2.1e-5)
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sqrt((t_1 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))));
double tmp;
if (phi1 <= -1.85e+67) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt(pow(cos((phi1 * 0.5)), 2.0))));
} else if (phi1 <= 2.1e-5) {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sqrt((t_1 + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))))
if (phi1 <= (-1.85d+67)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
else if (phi1 <= 2.1d-5) then
tmp = r * (2.0d0 * atan2(t_2, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sqrt((t_1 + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0))));
double tmp;
if (phi1 <= -1.85e+67) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + t_1)), Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
} else if (phi1 <= 2.1e-5) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 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(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sqrt((t_1 + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))) tmp = 0 if phi1 <= -1.85e+67: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + t_1)), math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) elif phi1 <= 2.1e-5: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 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(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sqrt(Float64(t_1 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))) tmp = 0.0 if (phi1 <= -1.85e+67) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); elseif (phi1 <= 2.1e-5) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sqrt((t_1 + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))); tmp = 0.0; if (phi1 <= -1.85e+67) tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1)), sqrt((cos((phi1 * 0.5)) ^ 2.0)))); elseif (phi1 <= 2.1e-5) tmp = R * (2.0 * atan2(t_2, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 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[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.85e+67], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.1e-5], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sqrt{t_1 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}\\
\mathbf{if}\;\phi_1 \leq -1.85 \cdot 10^{+67}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + t_1}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{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)\\
\end{array}
\end{array}
if phi1 < -1.8499999999999999e67Initial program 57.5%
Taylor expanded in lambda2 around 0 38.4%
Taylor expanded in lambda1 around 0 29.8%
Taylor expanded in phi2 around 0 29.8%
unpow229.8%
1-sub-sin30.0%
unpow230.0%
Simplified30.0%
if -1.8499999999999999e67 < phi1 < 2.09999999999999988e-5Initial program 78.6%
div-sub78.6%
sin-diff78.8%
div-inv78.8%
metadata-eval78.8%
div-inv78.8%
metadata-eval78.8%
div-inv78.8%
metadata-eval78.8%
div-inv78.8%
metadata-eval78.8%
Applied egg-rr78.8%
Taylor expanded in phi1 around 0 77.9%
Taylor expanded in phi1 around inf 77.9%
*-commutative82.5%
fma-neg82.5%
distribute-rgt-neg-in82.5%
sin-neg82.5%
distribute-lft-neg-in82.5%
metadata-eval82.5%
*-commutative82.5%
Simplified77.9%
Taylor expanded in phi1 around 0 77.7%
Simplified77.7%
if 2.09999999999999988e-5 < phi1 Initial program 43.3%
Taylor expanded in lambda2 around 0 40.5%
Taylor expanded in lambda1 around 0 31.4%
Taylor expanded in phi1 around 0 31.1%
*-commutative31.1%
metadata-eval31.1%
div-inv31.1%
div-sub31.1%
sin-diff32.1%
Applied egg-rr32.1%
Final simplification56.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(if (or (<= phi2 -3.45e+59) (not (<= phi2 2.9e+20)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_0))
(sqrt
(-
(pow (cos (* phi1 -0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -3.45e+59) || !(phi2 <= 2.9e+20)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), sqrt((pow(cos((phi1 * -0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)
if ((phi2 <= (-3.45d+59)) .or. (.not. (phi2 <= 2.9d+20))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_0)), sqrt(((cos((phi1 * (-0.5d0))) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 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.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -3.45e+59) || !(phi2 <= 2.9e+20)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), Math.sqrt((Math.pow(Math.cos((phi1 * -0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi2 <= -3.45e+59) or not (phi2 <= 2.9e+20): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), math.sqrt((math.pow(math.cos((phi1 * -0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) tmp = 0.0 if ((phi2 <= -3.45e+59) || !(phi2 <= 2.9e+20)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt(Float64((cos(Float64(phi1 * -0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0); tmp = 0.0; if ((phi2 <= -3.45e+59) || ~((phi2 <= 2.9e+20))) tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt(((cos((phi1 * -0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -3.45e+59], N[Not[LessEqual[phi2, 2.9e+20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -3.45 \cdot 10^{+59} \lor \neg \left(\phi_2 \leq 2.9 \cdot 10^{+20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0}}{\sqrt{{\cos \left(\phi_1 \cdot -0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -3.4499999999999999e59 or 2.9e20 < phi2 Initial program 53.6%
Taylor expanded in lambda2 around 0 42.6%
Taylor expanded in lambda1 around 0 34.9%
Taylor expanded in phi1 around 0 34.8%
Taylor expanded in phi1 around 0 35.5%
if -3.4499999999999999e59 < phi2 < 2.9e20Initial program 74.7%
div-sub74.7%
sin-diff74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
Taylor expanded in phi1 around 0 57.9%
Taylor expanded in phi1 around inf 57.9%
*-commutative79.7%
fma-neg79.7%
distribute-rgt-neg-in79.7%
sin-neg79.7%
distribute-lft-neg-in79.7%
metadata-eval79.7%
*-commutative79.7%
Simplified57.9%
Taylor expanded in phi2 around 0 56.0%
Simplified56.0%
Final simplification46.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))
(t_3 (cos (* phi1 0.5))))
(if (<= phi1 -8.8e+66)
(* R (* 2.0 (atan2 (sqrt (+ t_2 t_0)) (sqrt (pow t_3 2.0)))))
(if (<= phi1 2.4e+83)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (+ (sin (* phi1 0.5)) (* -0.5 (* phi2 t_3))) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1);
double t_3 = cos((phi1 * 0.5));
double tmp;
if (phi1 <= -8.8e+66) {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_0)), sqrt(pow(t_3, 2.0))));
} else if (phi1 <= 2.4e+83) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow((sin((phi1 * 0.5)) + (-0.5 * (phi2 * t_3))), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 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) / 2.0d0))
t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1)
t_3 = cos((phi1 * 0.5d0))
if (phi1 <= (-8.8d+66)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_0)), sqrt((t_3 ** 2.0d0))))
else if (phi1 <= 2.4d+83) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + ((sin((phi1 * 0.5d0)) + ((-0.5d0) * (phi2 * t_3))) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 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.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1);
double t_3 = Math.cos((phi1 * 0.5));
double tmp;
if (phi1 <= -8.8e+66) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_0)), Math.sqrt(Math.pow(t_3, 2.0))));
} else if (phi1 <= 2.4e+83) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((Math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * t_3))), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 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.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1) t_3 = math.cos((phi1 * 0.5)) tmp = 0 if phi1 <= -8.8e+66: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_0)), math.sqrt(math.pow(t_3, 2.0)))) elif phi1 <= 2.4e+83: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * t_3))), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 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) / 2.0)) t_2 = Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) t_3 = cos(Float64(phi1 * 0.5)) tmp = 0.0 if (phi1 <= -8.8e+66) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_0)), sqrt((t_3 ^ 2.0))))); elseif (phi1 <= 2.4e+83) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(sin(Float64(phi1 * 0.5)) + Float64(-0.5 * Float64(phi2 * t_3))) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 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) / 2.0)); t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1); t_3 = cos((phi1 * 0.5)); tmp = 0.0; if (phi1 <= -8.8e+66) tmp = R * (2.0 * atan2(sqrt((t_2 + t_0)), sqrt((t_3 ^ 2.0)))); elseif (phi1 <= 2.4e+83) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + ((sin((phi1 * 0.5)) + (-0.5 * (phi2 * t_3))) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -8.8e+66], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[t$95$3, 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.4e+83], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)\\
t_3 := \cos \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\phi_1 \leq -8.8 \cdot 10^{+66}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0}}{\sqrt{{t_3}^{2}}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.4 \cdot 10^{+83}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot t_3\right)\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -8.7999999999999994e66Initial program 57.5%
Taylor expanded in lambda2 around 0 38.4%
Taylor expanded in lambda1 around 0 29.8%
Taylor expanded in phi2 around 0 29.8%
unpow229.8%
1-sub-sin30.0%
unpow230.0%
Simplified30.0%
if -8.7999999999999994e66 < phi1 < 2.39999999999999991e83Initial program 73.5%
div-sub73.5%
sin-diff74.2%
div-inv74.2%
metadata-eval74.2%
div-inv74.2%
metadata-eval74.2%
div-inv74.2%
metadata-eval74.2%
div-inv74.2%
metadata-eval74.2%
Applied egg-rr74.2%
Taylor expanded in phi1 around 0 72.5%
Taylor expanded in phi1 around inf 72.5%
*-commutative82.8%
fma-neg82.8%
distribute-rgt-neg-in82.8%
sin-neg82.8%
distribute-lft-neg-in82.8%
metadata-eval82.8%
*-commutative82.8%
Simplified72.5%
Taylor expanded in phi1 around 0 71.9%
Simplified71.9%
if 2.39999999999999991e83 < phi1 Initial program 46.7%
Taylor expanded in lambda2 around 0 44.1%
Taylor expanded in lambda1 around 0 33.5%
Taylor expanded in phi2 around 0 33.8%
Final simplification56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (<= lambda1 0.021)
(*
R
(* 2.0 (atan2 t_1 (sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(-
1.0
(*
(sin (* 0.5 lambda1))
(* (cos phi1) (sin (* 0.5 (- lambda1 lambda2)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (lambda1 <= 0.021) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((0.5 * lambda1)) * (cos(phi1) * sin((0.5 * (lambda1 - lambda2)))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if (lambda1 <= 0.021d0) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin((0.5d0 * lambda1)) * (cos(phi1) * sin((0.5d0 * (lambda1 - lambda2)))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (lambda1 <= 0.021) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - (Math.sin((0.5 * lambda1)) * (Math.cos(phi1) * Math.sin((0.5 * (lambda1 - lambda2)))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if lambda1 <= 0.021: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - (math.sin((0.5 * lambda1)) * (math.cos(phi1) * math.sin((0.5 * (lambda1 - lambda2))))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if (lambda1 <= 0.021) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - Float64(sin(Float64(0.5 * lambda1)) * Float64(cos(phi1) * sin(Float64(0.5 * Float64(lambda1 - lambda2)))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if (lambda1 <= 0.021) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((0.5 * lambda1)) * (cos(phi1) * sin((0.5 * (lambda1 - lambda2))))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, 0.021], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[(N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\lambda_1 \leq 0.021:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - \sin \left(0.5 \cdot \lambda_1\right) \cdot \left(\cos \phi_1 \cdot \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < 0.0210000000000000013Initial program 70.2%
Taylor expanded in lambda2 around 0 52.0%
Taylor expanded in lambda1 around 0 43.1%
if 0.0210000000000000013 < lambda1 Initial program 48.3%
Taylor expanded in lambda2 around 0 47.9%
Taylor expanded in phi1 around 0 42.6%
Taylor expanded in phi2 around 0 34.4%
*-commutative34.4%
associate-*l*34.4%
Simplified34.4%
Final simplification41.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 64.9%
Taylor expanded in lambda2 around 0 51.0%
Taylor expanded in lambda1 around 0 37.9%
Final simplification37.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))
(if (or (<= phi1 -1.2e-93) (not (<= phi1 2e-123)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
t_0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)));
double tmp;
if ((phi1 <= -1.2e-93) || !(phi1 <= 2e-123)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_0));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))
if ((phi1 <= (-1.2d-93)) .or. (.not. (phi1 <= 2d-123))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), t_0))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)));
double tmp;
if ((phi1 <= -1.2e-93) || !(phi1 <= 2e-123)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), t_0));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))) tmp = 0 if (phi1 <= -1.2e-93) or not (phi1 <= 2e-123): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), t_0)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))) tmp = 0.0 if ((phi1 <= -1.2e-93) || !(phi1 <= 2e-123)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), t_0))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))); tmp = 0.0; if ((phi1 <= -1.2e-93) || ~((phi1 <= 2e-123))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_0)); else tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.2e-93], N[Not[LessEqual[phi1, 2e-123]], $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[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}\\
\mathbf{if}\;\phi_1 \leq -1.2 \cdot 10^{-93} \lor \neg \left(\phi_1 \leq 2 \cdot 10^{-123}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{t_0}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{t_0}\right)\\
\end{array}
\end{array}
if phi1 < -1.2000000000000001e-93 or 2.0000000000000001e-123 < phi1 Initial program 55.3%
Taylor expanded in lambda2 around 0 44.5%
Taylor expanded in lambda1 around 0 33.4%
Taylor expanded in phi1 around 0 33.0%
*-commutative33.0%
metadata-eval33.0%
div-inv33.0%
pow233.0%
sin-mult32.6%
Applied egg-rr32.6%
div-sub32.6%
+-inverses32.6%
cos-032.6%
metadata-eval32.6%
distribute-rgt-out32.6%
metadata-eval32.6%
*-rgt-identity32.6%
Simplified32.6%
if -1.2000000000000001e-93 < phi1 < 2.0000000000000001e-123Initial program 83.2%
Taylor expanded in lambda2 around 0 63.4%
Taylor expanded in lambda1 around 0 46.5%
Taylor expanded in phi1 around 0 46.5%
Taylor expanded in phi1 around 0 46.5%
Final simplification37.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(if (or (<= phi2 -235000000000.0) (not (<= phi2 2.9e+20)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_0))
(sqrt (- 1.0 (pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -235000000000.0) || !(phi2 <= 2.9e+20)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), sqrt((1.0 - 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) :: tmp
t_0 = cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)
if ((phi2 <= (-235000000000.0d0)) .or. (.not. (phi2 <= 2.9d+20))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_0)), sqrt((1.0d0 - (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.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -235000000000.0) || !(phi2 <= 2.9e+20)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), Math.sqrt((1.0 - Math.pow(Math.sin((phi1 * 0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi2 <= -235000000000.0) or not (phi2 <= 2.9e+20): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), math.sqrt((1.0 - math.pow(math.sin((phi1 * 0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) tmp = 0.0 if ((phi2 <= -235000000000.0) || !(phi2 <= 2.9e+20)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt(Float64(1.0 - (sin(Float64(phi1 * 0.5)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0); tmp = 0.0; if ((phi2 <= -235000000000.0) || ~((phi2 <= 2.9e+20))) tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt((1.0 - (sin((phi1 * 0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -235000000000.0], N[Not[LessEqual[phi2, 2.9e+20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -235000000000 \lor \neg \left(\phi_2 \leq 2.9 \cdot 10^{+20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0}}{\sqrt{1 - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -2.35e11 or 2.9e20 < phi2 Initial program 53.9%
Taylor expanded in lambda2 around 0 42.8%
Taylor expanded in lambda1 around 0 34.2%
Taylor expanded in phi1 around 0 34.1%
Taylor expanded in phi1 around 0 34.8%
if -2.35e11 < phi2 < 2.9e20Initial program 75.3%
Taylor expanded in lambda2 around 0 58.8%
Taylor expanded in lambda1 around 0 41.4%
Taylor expanded in phi1 around 0 41.0%
Taylor expanded in phi2 around 0 40.9%
Final simplification38.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 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(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := 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[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)
\end{array}
Initial program 64.9%
Taylor expanded in lambda2 around 0 51.0%
Taylor expanded in lambda1 around 0 37.9%
Taylor expanded in phi1 around 0 37.6%
Final simplification37.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin((0.5 * lambda1)), 2.0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 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(sqrt(((cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2} + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)
\end{array}
Initial program 64.9%
Taylor expanded in lambda2 around 0 51.0%
Taylor expanded in lambda1 around 0 37.9%
Taylor expanded in phi1 around 0 37.6%
Taylor expanded in lambda2 around 0 34.8%
Final simplification34.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 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(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := 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[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)
\end{array}
Initial program 64.9%
Taylor expanded in lambda2 around 0 51.0%
Taylor expanded in lambda1 around 0 37.9%
Taylor expanded in phi1 around 0 37.6%
*-commutative37.6%
metadata-eval37.6%
div-inv37.6%
pow237.6%
sin-mult33.9%
Applied egg-rr33.9%
div-sub33.9%
+-inverses33.9%
cos-033.9%
metadata-eval33.9%
distribute-rgt-out33.9%
metadata-eval33.9%
*-rgt-identity33.9%
Simplified33.9%
Final simplification33.9%
herbie shell --seed 2023339
(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))))))))))