
(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 21 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 (* 0.5 phi2)))
(t_2 (* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* (log1p (expm1 t_0)) t_1) t_2) 2.0) t_4))
(sqrt (- 1.0 (+ t_4 (pow (- (* t_1 t_0) t_2) 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((0.5 * phi2));
double t_2 = cos((phi1 * 0.5)) * sin((0.5 * phi2));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
return R * (2.0 * atan2(sqrt((pow(((log1p(expm1(t_0)) * t_1) - t_2), 2.0) + t_4)), sqrt((1.0 - (t_4 + pow(((t_1 * t_0) - t_2), 2.0))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((phi1 * 0.5));
double t_1 = Math.cos((0.5 * phi2));
double t_2 = Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2));
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((Math.cos(phi1) * Math.cos(phi2)) * t_3);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.log1p(Math.expm1(t_0)) * t_1) - t_2), 2.0) + t_4)), Math.sqrt((1.0 - (t_4 + Math.pow(((t_1 * t_0) - t_2), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.cos((0.5 * phi2)) t_2 = math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_3 * ((math.cos(phi1) * math.cos(phi2)) * t_3) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.log1p(math.expm1(t_0)) * t_1) - t_2), 2.0) + t_4)), math.sqrt((1.0 - (t_4 + math.pow(((t_1 * t_0) - t_2), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(0.5 * phi2)) t_2 = Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2))) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(log1p(expm1(t_0)) * t_1) - t_2) ^ 2.0) + t_4)), sqrt(Float64(1.0 - Float64(t_4 + (Float64(Float64(t_1 * t_0) - t_2) ^ 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[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[(N[(t$95$1 * t$95$0), $MachinePrecision] - t$95$2), $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(0.5 \cdot \phi_2\right)\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(t\_0\right)\right) \cdot t\_1 - t\_2\right)}^{2} + t\_4}}{\sqrt{1 - \left(t\_4 + {\left(t\_1 \cdot t\_0 - t\_2\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 61.0%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr62.3%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr77.5%
log1p-expm1-u77.6%
Applied egg-rr77.6%
Final simplification77.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5)))
(t_1 (cos (* 0.5 phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* (* (cos phi1) (cos phi2)) t_2)))
(t_4 (sin (* phi1 0.5))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (- (* t_1 t_4) (* t_0 (sin (* 0.5 phi2)))) 2.0)))
(sqrt
(-
1.0
(+ t_3 (pow (fma t_1 t_4 (* t_0 (sin (* phi2 -0.5)))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double t_1 = cos((0.5 * phi2));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2);
double t_4 = sin((phi1 * 0.5));
return R * (2.0 * atan2(sqrt((t_3 + pow(((t_1 * t_4) - (t_0 * sin((0.5 * phi2)))), 2.0))), sqrt((1.0 - (t_3 + pow(fma(t_1, t_4, (t_0 * sin((phi2 * -0.5)))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) t_1 = cos(Float64(0.5 * phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) t_4 = sin(Float64(phi1 * 0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (Float64(Float64(t_1 * t_4) - Float64(t_0 * sin(Float64(0.5 * phi2)))) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_3 + (fma(t_1, t_4, Float64(t_0 * sin(Float64(phi2 * -0.5)))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(0.5 * 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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[(N[(t$95$1 * t$95$4), $MachinePrecision] - N[(t$95$0 * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[Power[N[(t$95$1 * t$95$4 + N[(t$95$0 * 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 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(0.5 \cdot \phi_2\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 := \sin \left(\phi_1 \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\left(t\_1 \cdot t\_4 - t\_0 \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(t\_3 + {\left(\mathsf{fma}\left(t\_1, t\_4, t\_0 \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 61.0%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr62.3%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr77.5%
Taylor expanded in phi1 around inf 77.5%
fma-neg77.6%
distribute-rgt-neg-in77.6%
rem-square-sqrt49.0%
unpow249.0%
*-commutative49.0%
sin-neg49.0%
*-commutative49.0%
unpow249.0%
rem-square-sqrt77.6%
*-commutative77.6%
distribute-rgt-neg-in77.6%
metadata-eval77.6%
Simplified77.6%
Final simplification77.6%
(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)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sqrt (+ (* t_0 (* (* (cos phi1) (cos phi2)) t_0)) t_1))))
(if (or (<= lambda1 -2.25e-6) (not (<= lambda1 1.3e-65)))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(fabs
(-
1.0
(fma
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(cos phi1)
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
t_1
(*
(cos phi1)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1));
double tmp;
if ((lambda1 <= -2.25e-6) || !(lambda1 <= 1.3e-65)) {
tmp = R * (2.0 * atan2(t_2, sqrt(fabs((1.0 - fma((cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)), cos(phi1), pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + t_1)) tmp = 0.0 if ((lambda1 <= -2.25e-6) || !(lambda1 <= 1.3e-65)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(abs(Float64(1.0 - fma(Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)), cos(phi1), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = 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]}, If[Or[LessEqual[lambda1, -2.25e-6], N[Not[LessEqual[lambda1, 1.3e-65]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[Abs[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + t\_1}\\
\mathbf{if}\;\lambda_1 \leq -2.25 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 1.3 \cdot 10^{-65}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -2.25000000000000006e-6 or 1.30000000000000005e-65 < lambda1 Initial program 47.4%
div-sub47.4%
sin-diff49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
Applied egg-rr49.0%
div-sub47.4%
sin-diff49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
Applied egg-rr62.5%
add-sqr-sqrt62.5%
pow1/262.5%
pow1/262.5%
Applied egg-rr49.8%
Simplified49.8%
if -2.25000000000000006e-6 < lambda1 < 1.30000000000000005e-65Initial program 78.7%
div-sub78.7%
sin-diff79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
Applied egg-rr79.8%
div-sub78.7%
sin-diff79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
Applied egg-rr97.2%
Taylor expanded in lambda1 around 0 97.3%
Final simplification70.4%
(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)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (+ (* t_0 (* (* (cos phi1) (cos phi2)) t_0)) t_1)))
(if (or (<= lambda1 -1.85e-6) (not (<= lambda1 1.22e-11)))
(*
R
(*
2.0
(atan2
(sqrt t_2)
(sqrt
(fabs
(-
1.0
(fma
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(cos phi1)
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
(sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1;
double tmp;
if ((lambda1 <= -1.85e-6) || !(lambda1 <= 1.22e-11)) {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt(fabs((1.0 - fma((cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)), cos(phi1), pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), sqrt((1.0 - t_2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + t_1) tmp = 0.0 if ((lambda1 <= -1.85e-6) || !(lambda1 <= 1.22e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(abs(Float64(1.0 - fma(Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)), cos(phi1), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), sqrt(Float64(1.0 - t_2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = 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]}, If[Or[LessEqual[lambda1, -1.85e-6], N[Not[LessEqual[lambda1, 1.22e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + t\_1\\
\mathbf{if}\;\lambda_1 \leq -1.85 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 1.22 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.8500000000000001e-6 or 1.2200000000000001e-11 < lambda1 Initial program 46.0%
div-sub46.0%
sin-diff47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr47.6%
div-sub46.0%
sin-diff47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr61.4%
add-sqr-sqrt61.4%
pow1/261.4%
pow1/261.4%
Applied egg-rr48.4%
Simplified48.4%
if -1.8500000000000001e-6 < lambda1 < 1.2200000000000001e-11Initial program 79.5%
div-sub79.5%
sin-diff80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr80.4%
div-sub79.5%
sin-diff80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr97.3%
Taylor expanded in lambda1 around 0 95.7%
Final simplification69.7%
(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)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2
(+
t_1
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
(t_3 (+ (* t_0 (* (* (cos phi1) (cos phi2)) t_0)) t_1))
(t_4 (sqrt t_3)))
(if (<= lambda2 -0.00156)
(* R (* 2.0 (atan2 t_4 (sqrt (- 1.0 t_2)))))
(if (<= lambda2 0.000215)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
1.0
(+
t_1
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))))))
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = t_1 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0)));
double t_3 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1;
double t_4 = sqrt(t_3);
double tmp;
if (lambda2 <= -0.00156) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_2))));
} else if (lambda2 <= 0.000215) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = t_1 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))
t_3 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1
t_4 = sqrt(t_3)
if (lambda2 <= (-0.00156d0)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - t_2))))
else if (lambda2 <= 0.000215d0) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - (t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)));
double t_3 = (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + t_1;
double t_4 = Math.sqrt(t_3);
double tmp;
if (lambda2 <= -0.00156) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - t_2))));
} else if (lambda2 <= 0.000215) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - (t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) t_3 = (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + t_1 t_4 = math.sqrt(t_3) tmp = 0 if lambda2 <= -0.00156: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - t_2)))) elif lambda2 <= 0.000215: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - (t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))) t_3 = Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + t_1) t_4 = sqrt(t_3) tmp = 0.0 if (lambda2 <= -0.00156) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - t_2))))); elseif (lambda2 <= 0.000215) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = t_1 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))); t_3 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + t_1; t_4 = sqrt(t_3); tmp = 0.0; if (lambda2 <= -0.00156) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_2)))); elseif (lambda2 <= 0.000215) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = 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]}, Block[{t$95$4 = N[Sqrt[t$95$3], $MachinePrecision]}, If[LessEqual[lambda2, -0.00156], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 0.000215], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(t$95$1 + 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\\
t_3 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + t\_1\\
t_4 := \sqrt{t\_3}\\
\mathbf{if}\;\lambda_2 \leq -0.00156:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - t\_2}}\right)\\
\mathbf{elif}\;\lambda_2 \leq 0.000215:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if lambda2 < -0.00155999999999999997Initial program 50.2%
div-sub50.2%
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%
div-sub50.2%
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-rr59.4%
Taylor expanded in lambda1 around 0 59.0%
if -0.00155999999999999997 < lambda2 < 2.14999999999999995e-4Initial program 73.4%
div-sub73.4%
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%
div-sub73.4%
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-rr95.4%
Taylor expanded in lambda2 around 0 95.4%
if 2.14999999999999995e-4 < lambda2 Initial program 44.0%
div-sub44.0%
sin-diff46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
Applied egg-rr46.4%
div-sub44.0%
sin-diff46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
Applied egg-rr56.2%
Taylor expanded in lambda1 around 0 56.1%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.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 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.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 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0)
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 = (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.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 = (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.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(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.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 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.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 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 61.0%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr62.3%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr77.5%
Final simplification77.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* (* (cos phi1) (cos phi2)) t_1)) t_0))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
t_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))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_0)), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_0)), sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))) + t_0)))))
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.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + t_0)), Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + t_0)), math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))) + t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + t_0)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) + t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_0)), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))) + t_0))))); 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[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $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) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{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(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + t\_0}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right) + t\_0\right)}}\right)
\end{array}
\end{array}
Initial program 61.0%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr62.3%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr77.5%
Taylor expanded in phi1 around inf 77.5%
Final simplification77.5%
(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
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)))
(sqrt
(fabs
(-
1.0
(fma
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(cos phi1)
(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(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0))), sqrt(fabs((1.0 - fma((cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)), cos(phi1), pow(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)) + (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0))), sqrt(abs(Float64(1.0 - fma(Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)), cos(phi1), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, 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[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $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 := \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) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}, \cos \phi_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 61.0%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr62.3%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr77.5%
add-sqr-sqrt77.5%
pow1/277.5%
pow1/277.5%
Applied egg-rr62.8%
Simplified62.8%
Final simplification62.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_1 + pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * 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
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (t_1 + (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * 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));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (t_1 + Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (t_1 + math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_1 + (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (t_1 + (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_1 + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 61.0%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr62.3%
Final simplification62.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt
(-
1.0
(+
t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0));
return R * (2.0 * atan2(sqrt((t_0 + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - (t_0 + pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * 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 = cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_0 + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt((1.0d0 - (t_0 + (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((1.0 - (t_0 + Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((1.0 - (t_0 + math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_0 + (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)); tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt((1.0 - (t_0 + (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(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[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(t\_0 + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 61.0%
div-sub61.0%
sin-diff62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
div-inv62.3%
metadata-eval62.3%
Applied egg-rr62.3%
Taylor expanded in phi1 around 0 62.3%
Final simplification62.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- (+ 1.0 (/ (+ (cos (- phi1 phi2)) -1.0) 2.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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) + -1.0) / 2.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(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 + ((cos((phi1 - phi2)) + (-1.0d0)) / 2.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.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) + -1.0) / 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) + -1.0) / 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) + -1.0) / 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) + -1.0) / 2.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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 + \frac{\cos \left(\phi_1 - \phi_2\right) + -1}{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 61.0%
associate-*l*61.0%
Simplified61.0%
unpow261.0%
sin-mult61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr61.1%
+-inverses61.1%
cos-061.1%
distribute-lft-out61.1%
metadata-eval61.1%
*-rgt-identity61.1%
Simplified61.1%
Final simplification61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (* (cos phi1) t_0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (sqrt (+ t_1 (pow (sin (* phi1 0.5)) 2.0))))
(t_4 (pow (cos (* phi1 0.5)) 2.0)))
(if (<= phi1 -0.00027)
(*
R
(*
2.0
(atan2
t_3
(sqrt
(- t_4 (* (cos phi1) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0))))))))
(if (<= phi1 0.00018)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_2 (* (* (cos phi1) (cos phi2)) t_2))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* 0.5 phi2)) 2.0) (* (cos phi2) t_0))))))
(* R (* 2.0 (atan2 t_3 (exp (* 0.5 (log (- t_4 t_1)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = cos(phi1) * t_0;
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((t_1 + pow(sin((phi1 * 0.5)), 2.0)));
double t_4 = pow(cos((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -0.00027) {
tmp = R * (2.0 * atan2(t_3, sqrt((t_4 - (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0)))))));
} else if (phi1 <= 0.00018) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((0.5 * phi2)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(t_3, exp((0.5 * log((t_4 - t_1))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = cos(phi1) * t_0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt((t_1 + (sin((phi1 * 0.5d0)) ** 2.0d0)))
t_4 = cos((phi1 * 0.5d0)) ** 2.0d0
if (phi1 <= (-0.00027d0)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((t_4 - (cos(phi1) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0)))))))
else if (phi1 <= 0.00018d0) then
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((0.5d0 * phi2)) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(t_3, exp((0.5d0 * log((t_4 - t_1))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.cos(phi1) * t_0;
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt((t_1 + Math.pow(Math.sin((phi1 * 0.5)), 2.0)));
double t_4 = Math.pow(Math.cos((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -0.00027) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((t_4 - (Math.cos(phi1) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0)))))));
} else if (phi1 <= 0.00018) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((0.5 * phi2)), 2.0) - (Math.cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.exp((0.5 * Math.log((t_4 - t_1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_1 = math.cos(phi1) * t_0 t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((t_1 + math.pow(math.sin((phi1 * 0.5)), 2.0))) t_4 = math.pow(math.cos((phi1 * 0.5)), 2.0) tmp = 0 if phi1 <= -0.00027: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((t_4 - (math.cos(phi1) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))))) elif phi1 <= 0.00018: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((0.5 * phi2)), 2.0) - (math.cos(phi2) * t_0))))) else: tmp = R * (2.0 * math.atan2(t_3, math.exp((0.5 * math.log((t_4 - t_1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = Float64(cos(phi1) * t_0) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0))) t_4 = cos(Float64(phi1 * 0.5)) ^ 2.0 tmp = 0.0 if (phi1 <= -0.00027) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(t_4 - Float64(cos(phi1) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0)))))))); elseif (phi1 <= 0.00018) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(0.5 * phi2)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, exp(Float64(0.5 * log(Float64(t_4 - t_1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_1 = cos(phi1) * t_0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt((t_1 + (sin((phi1 * 0.5)) ^ 2.0))); t_4 = cos((phi1 * 0.5)) ^ 2.0; tmp = 0.0; if (phi1 <= -0.00027) tmp = R * (2.0 * atan2(t_3, sqrt((t_4 - (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))))); elseif (phi1 <= 0.00018) tmp = R * (2.0 * atan2(sqrt(((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((0.5 * phi2)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(t_3, exp((0.5 * log((t_4 - t_1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -0.00027], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(t$95$4 - N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00018], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Exp[N[(0.5 * N[Log[N[(t$95$4 - t$95$1), $MachinePrecision]], $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)}^{2}\\
t_1 := \cos \phi_1 \cdot t\_0\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}\\
t_4 := {\cos \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -0.00027:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{t\_4 - \cos \phi_1 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00018:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{e^{0.5 \cdot \log \left(t\_4 - t\_1\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -2.70000000000000003e-4Initial program 51.7%
Taylor expanded in phi2 around 0 53.2%
+-commutative53.2%
associate--r+53.2%
unpow253.2%
1-sub-sin53.3%
unpow253.3%
*-commutative53.3%
Simplified53.3%
Taylor expanded in phi2 around 0 54.8%
*-commutative54.8%
metadata-eval54.8%
div-inv54.8%
pow254.8%
sin-mult54.9%
Applied egg-rr54.9%
div-sub54.9%
+-inverses54.9%
+-inverses54.9%
+-inverses54.9%
cos-054.9%
metadata-eval54.9%
associate-*r*54.9%
metadata-eval54.9%
*-lft-identity54.9%
Simplified54.9%
if -2.70000000000000003e-4 < phi1 < 1.80000000000000011e-4Initial program 75.1%
Taylor expanded in phi1 around 0 75.0%
+-commutative75.0%
associate--r+75.1%
unpow275.1%
1-sub-sin75.2%
unpow275.2%
*-commutative75.2%
metadata-eval75.2%
distribute-rgt-neg-in75.2%
cos-neg75.2%
Simplified75.2%
if 1.80000000000000011e-4 < phi1 Initial program 44.7%
Taylor expanded in phi2 around 0 46.3%
+-commutative46.3%
associate--r+46.3%
unpow246.3%
1-sub-sin46.3%
unpow246.3%
*-commutative46.3%
Simplified46.3%
Taylor expanded in phi2 around 0 47.0%
add-cbrt-cube12.1%
pow312.5%
Applied egg-rr12.5%
pow1/212.5%
rem-cbrt-cube47.0%
pow-to-exp47.0%
Applied egg-rr47.0%
Final simplification62.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) t_0))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * t_0)) + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_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((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * t_0)) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * t_0)) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * t_0)) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * t_0)) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * t_0)) + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$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)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_0}}\right)
\end{array}
\end{array}
Initial program 61.0%
Taylor expanded in phi2 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi1 around inf 48.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sqrt (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))
(if (or (<= (- lambda1 lambda2) -1e+15)
(not (<= (- lambda1 lambda2) 200.0)))
(* R (* 2.0 (atan2 t_1 (sqrt (- 1.0 t_0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = sqrt(((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0)));
double tmp;
if (((lambda1 - lambda2) <= -1e+15) || !((lambda1 - lambda2) <= 200.0)) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi1 * 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) :: t_1
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = sqrt(((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0)))
if (((lambda1 - lambda2) <= (-1d+15)) .or. (.not. ((lambda1 - lambda2) <= 200.0d0))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi1 * 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.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.sqrt(((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0)));
double tmp;
if (((lambda1 - lambda2) <= -1e+15) || !((lambda1 - lambda2) <= 200.0)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_1 = math.sqrt(((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0))) tmp = 0 if ((lambda1 - lambda2) <= -1e+15) or not ((lambda1 - lambda2) <= 200.0): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = sqrt(Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -1e+15) || !(Float64(lambda1 - lambda2) <= 200.0)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_1 = sqrt(((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0))); tmp = 0.0; if (((lambda1 - lambda2) <= -1e+15) || ~(((lambda1 - lambda2) <= 200.0))) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+15], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 200.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$0), $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)}^{2}\\
t_1 := \sqrt{\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+15} \lor \neg \left(\lambda_1 - \lambda_2 \leq 200\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t\_0}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1e15 or 200 < (-.f64 lambda1 lambda2) Initial program 54.9%
Taylor expanded in phi2 around 0 43.6%
+-commutative43.6%
associate--r+43.6%
unpow243.6%
1-sub-sin43.7%
unpow243.7%
*-commutative43.7%
Simplified43.7%
Taylor expanded in phi2 around 0 44.0%
Taylor expanded in phi1 around 0 31.9%
if -1e15 < (-.f64 lambda1 lambda2) < 200Initial program 78.1%
Taylor expanded in phi2 around 0 63.5%
+-commutative63.5%
associate--r+63.5%
unpow263.5%
1-sub-sin63.6%
unpow263.6%
*-commutative63.6%
Simplified63.6%
Taylor expanded in phi2 around 0 59.6%
Taylor expanded in phi1 around 0 57.4%
Final simplification38.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi1 0.5)) 2.0))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1)))))
(if (or (<= phi1 -2e-8) (not (<= phi1 1.85e+50)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi1) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
t_2)))
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_0)) t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi1 * 0.5)), 2.0);
double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)));
double tmp;
if ((phi1 <= -2e-8) || !(phi1 <= 1.85e+50)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_0)), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0)) ** 2.0d0
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))
if ((phi1 <= (-2d-8)) .or. (.not. (phi1 <= 1.85d+50))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_0)), t_2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)));
double tmp;
if ((phi1 <= -2e-8) || !(phi1 <= 1.85e+50)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_0)), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))) tmp = 0 if (phi1 <= -2e-8) or not (phi1 <= 1.85e+50): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_0)), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1))) tmp = 0.0 if ((phi1 <= -2e-8) || !(phi1 <= 1.85e+50)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_0)), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)) ^ 2.0; t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))); tmp = 0.0; if ((phi1 <= -2e-8) || ~((phi1 <= 1.85e+50))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_2)); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_0)), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -2e-8], N[Not[LessEqual[phi1, 1.85e+50]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_1}\\
\mathbf{if}\;\phi_1 \leq -2 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 1.85 \cdot 10^{+50}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0}}{t\_2}\right)\\
\end{array}
\end{array}
if phi1 < -2e-8 or 1.85e50 < phi1 Initial program 50.0%
Taylor expanded in phi2 around 0 51.5%
+-commutative51.5%
associate--r+51.5%
unpow251.5%
1-sub-sin51.5%
unpow251.5%
*-commutative51.5%
Simplified51.5%
Taylor expanded in phi2 around 0 52.8%
*-commutative52.8%
metadata-eval52.8%
div-inv52.8%
pow252.8%
sin-mult52.8%
Applied egg-rr52.8%
div-sub52.8%
+-inverses52.8%
+-inverses52.8%
+-inverses52.8%
cos-052.8%
metadata-eval52.8%
associate-*r*52.8%
metadata-eval52.8%
*-lft-identity52.8%
Simplified52.8%
if -2e-8 < phi1 < 1.85e50Initial program 70.1%
Taylor expanded in phi2 around 0 46.7%
+-commutative46.7%
associate--r+46.7%
unpow246.7%
1-sub-sin46.7%
unpow246.7%
*-commutative46.7%
Simplified46.7%
Taylor expanded in phi2 around 0 44.2%
Taylor expanded in phi1 around 0 44.3%
Final simplification48.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (0.5d0 - (cos((lambda1 - lambda2)) / 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(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}\right)
\end{array}
Initial program 61.0%
Taylor expanded in phi2 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi2 around 0 48.1%
*-commutative48.1%
metadata-eval48.1%
div-inv48.1%
pow248.1%
sin-mult48.1%
Applied egg-rr48.1%
div-sub48.1%
+-inverses48.1%
+-inverses48.1%
+-inverses48.1%
cos-048.1%
metadata-eval48.1%
associate-*r*48.1%
metadata-eval48.1%
*-lft-identity48.1%
Simplified48.1%
Final simplification48.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (/ (+ (cos phi1) 1.0) 2.0) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * atan2(sqrt((t_0 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((((cos(phi1) + 1.0) / 2.0) - t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt((t_0 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((((cos(phi1) + 1.0d0) / 2.0d0) - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((((Math.cos(phi1) + 1.0) / 2.0) - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((((math.cos(phi1) + 1.0) / 2.0) - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(Float64(cos(phi1) + 1.0) / 2.0) - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0); tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((((cos(phi1) + 1.0) / 2.0) - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\frac{\cos \phi_1 + 1}{2} - t\_0}}\right)
\end{array}
\end{array}
Initial program 61.0%
Taylor expanded in phi2 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi2 around 0 48.1%
add-cbrt-cube29.5%
pow330.0%
Applied egg-rr30.0%
rem-cbrt-cube48.1%
unpow248.1%
cos-mult48.1%
Applied egg-rr48.1%
distribute-lft-out48.1%
metadata-eval48.1%
*-rgt-identity48.1%
+-inverses48.1%
cos-048.1%
Simplified48.1%
Final simplification48.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * atan2(sqrt((t_0 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_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((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_0 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$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)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_0}}\right)
\end{array}
\end{array}
Initial program 61.0%
Taylor expanded in phi2 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in phi1 around 0 38.9%
Final simplification38.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))), sqrt((1.0 - t_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((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $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)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 61.0%
Taylor expanded in phi2 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in phi1 around 0 33.2%
Final simplification33.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- lambda1 lambda2)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (lambda1 - lambda2))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin((0.5d0 * (lambda1 - lambda2))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin((0.5 * (lambda1 - lambda2))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (lambda1 - lambda2))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(lambda1 - lambda2))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (lambda1 - lambda2))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}\right)
\end{array}
Initial program 61.0%
Taylor expanded in phi2 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in phi1 around 0 16.8%
*-commutative48.1%
metadata-eval48.1%
div-inv48.1%
pow248.1%
sin-mult48.1%
Applied egg-rr16.8%
div-sub48.1%
+-inverses48.1%
+-inverses48.1%
+-inverses48.1%
cos-048.1%
metadata-eval48.1%
associate-*r*48.1%
metadata-eval48.1%
*-lft-identity48.1%
Simplified16.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (let* ((t_0 (sin (* 0.5 (- lambda1 lambda2))))) (* R (* 2.0 (atan2 t_0 (sqrt (- 1.0 (pow t_0 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
return R * (2.0 * atan2(t_0, sqrt((1.0 - pow(t_0, 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin((0.5d0 * (lambda1 - lambda2)))
code = r * (2.0d0 * atan2(t_0, sqrt((1.0d0 - (t_0 ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * (lambda1 - lambda2)));
return R * (2.0 * Math.atan2(t_0, Math.sqrt((1.0 - Math.pow(t_0, 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (lambda1 - lambda2))) return R * (2.0 * math.atan2(t_0, math.sqrt((1.0 - math.pow(t_0, 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(1.0 - (t_0 ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))); tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - (t_0 ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[Power[t$95$0, 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)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{1 - {t\_0}^{2}}}\right)
\end{array}
\end{array}
Initial program 61.0%
Taylor expanded in phi2 around 0 48.8%
+-commutative48.8%
associate--r+48.8%
unpow248.8%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
Simplified48.9%
Taylor expanded in phi2 around 0 48.1%
Taylor expanded in phi1 around 0 16.8%
Taylor expanded in phi1 around 0 16.7%
herbie shell --seed 2024129
(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))))))))))