
(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 29 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(-
(- 1.0 t_1)
(log
(+
1.0
(expm1
(*
t_0
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - log((1.0 + expm1((t_0 * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) - Math.log((1.0 + Math.expm1((t_0 * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) - math.log((1.0 + math.expm1((t_0 * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) - log(Float64(1.0 + expm1(Float64(t_0 * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[Log[N[(1.0 + N[(Exp[N[(t$95$0 * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) - \log \left(1 + \mathsf{expm1}\left(t\_0 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}\right)\right)}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr76.9%
associate-*r*76.9%
log1p-expm1-u76.9%
log1p-undefine76.9%
associate-*r*76.9%
pow276.9%
div-inv76.9%
metadata-eval76.9%
*-commutative76.9%
Applied egg-rr76.9%
*-commutative76.9%
metadata-eval76.9%
div-inv76.9%
div-sub76.9%
sin-diff77.6%
Applied egg-rr77.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* t_1 (* t_0 t_0)))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4 (+ t_3 (* t_0 (* t_1 t_0))))
(t_5
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(if (<= (atan2 (sqrt t_4) (sqrt (- 1.0 t_4))) 0.055)
(*
R
(*
2.0
(atan2
(hypot
(sqrt
(*
t_1
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0)))
(sin (* 0.5 (- phi1 phi2))))
(sqrt (- (- 1.0 t_3) t_2)))))
(*
R
(*
2.0
(atan2
(sqrt
(-
t_5
(* t_1 (/ (+ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) -1.0) 2.0))))
(sqrt (- (- 1.0 t_5) t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = t_3 + (t_0 * (t_1 * t_0));
double t_5 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double tmp;
if (atan2(sqrt(t_4), sqrt((1.0 - t_4))) <= 0.055) {
tmp = R * (2.0 * atan2(hypot(sqrt((t_1 * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 - (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0)))), sqrt(((1.0 - t_5) - t_2))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = t_3 + (t_0 * (t_1 * t_0));
double t_5 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double tmp;
if (Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_4))) <= 0.055) {
tmp = R * (2.0 * Math.atan2(Math.hypot(Math.sqrt((t_1 * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0))), Math.sin((0.5 * (phi1 - phi2)))), Math.sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 - (t_1 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0)))), Math.sqrt(((1.0 - t_5) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = t_1 * (t_0 * t_0) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = t_3 + (t_0 * (t_1 * t_0)) t_5 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) tmp = 0 if math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_4))) <= 0.055: tmp = R * (2.0 * math.atan2(math.hypot(math.sqrt((t_1 * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0))), math.sin((0.5 * (phi1 - phi2)))), math.sqrt(((1.0 - t_3) - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 - (t_1 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0)))), math.sqrt(((1.0 - t_5) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(t_1 * Float64(t_0 * t_0)) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = Float64(t_3 + Float64(t_0 * Float64(t_1 * t_0))) t_5 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 tmp = 0.0 if (atan(sqrt(t_4), sqrt(Float64(1.0 - t_4))) <= 0.055) tmp = Float64(R * Float64(2.0 * atan(hypot(sqrt(Float64(t_1 * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0))), sin(Float64(0.5 * Float64(phi1 - phi2)))), sqrt(Float64(Float64(1.0 - t_3) - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 - Float64(t_1 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) + -1.0) / 2.0)))), sqrt(Float64(Float64(1.0 - t_5) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = t_1 * (t_0 * t_0); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_4 = t_3 + (t_0 * (t_1 * t_0)); t_5 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; tmp = 0.0; if (atan2(sqrt(t_4), sqrt((1.0 - t_4))) <= 0.055) tmp = R * (2.0 * atan2(hypot(sqrt((t_1 * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_3) - t_2)))); else tmp = R * (2.0 * atan2(sqrt((t_5 - (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0)))), sqrt(((1.0 - t_5) - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 0.055], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Sqrt[N[(t$95$1 * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2 + N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 - N[(t$95$1 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$5), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := t\_1 \cdot \left(t\_0 \cdot t\_0\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := t\_3 + t\_0 \cdot \left(t\_1 \cdot t\_0\right)\\
t_5 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
\mathbf{if}\;\tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_4}} \leq 0.055:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sqrt{t\_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}}, \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\sqrt{\left(1 - t\_3\right) - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 - t\_1 \cdot \frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right) + -1}{2}}}{\sqrt{\left(1 - t\_5\right) - t\_2}}\right)\\
\end{array}
\end{array}
if (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) < 0.0550000000000000003Initial program 83.2%
associate-*l*83.2%
Simplified83.2%
add-cbrt-cube71.4%
pow371.5%
pow271.5%
div-inv71.5%
metadata-eval71.5%
Applied egg-rr71.5%
Applied egg-rr83.2%
*-commutative83.2%
metadata-eval83.2%
div-inv83.2%
div-sub83.2%
sin-diff83.2%
Applied egg-rr85.4%
if 0.0550000000000000003 < (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) Initial program 60.7%
associate-*l*60.7%
Simplified60.7%
div-sub60.7%
sin-diff61.8%
Applied egg-rr61.8%
div-sub60.7%
sin-diff61.8%
Applied egg-rr76.5%
sin-mult76.5%
div-inv76.5%
metadata-eval76.5%
div-inv76.5%
metadata-eval76.5%
cos-sum76.4%
cos-276.5%
div-inv76.5%
metadata-eval76.5%
Applied egg-rr76.5%
+-inverses76.5%
cos-076.5%
associate-*r*76.5%
Simplified76.5%
Final simplification77.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_1 t_1))))
(sqrt
(-
(-
1.0
(pow
(fma
(sin (* phi1 0.5))
(cos (* phi2 0.5))
(* (sin (* phi2 -0.5)) (cos (* phi1 0.5))))
2.0))
(log
(+
1.0
(expm1 (* t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(fma(sin((phi1 * 0.5)), cos((phi2 * 0.5)), (sin((phi2 * -0.5)) * cos((phi1 * 0.5)))), 2.0)) - log((1.0 + expm1((t_0 * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (fma(sin(Float64(phi1 * 0.5)), cos(Float64(phi2 * 0.5)), Float64(sin(Float64(phi2 * -0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0)) - log(Float64(1.0 + expm1(Float64(t_0 * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[Log[N[(1.0 + N[(Exp[N[(t$95$0 * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right), \sin \left(\phi_2 \cdot -0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}\right) - \log \left(1 + \mathsf{expm1}\left(t\_0 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\right)}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr76.9%
associate-*r*76.9%
log1p-expm1-u76.9%
log1p-undefine76.9%
associate-*r*76.9%
pow276.9%
div-inv76.9%
metadata-eval76.9%
*-commutative76.9%
Applied egg-rr76.9%
Taylor expanded in phi1 around inf 76.9%
Simplified77.0%
Final simplification77.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(-
(- 1.0 t_1)
(log
(+
1.0
(expm1 (* t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - log((1.0 + expm1((t_0 * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) - Math.log((1.0 + Math.expm1((t_0 * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) - math.log((1.0 + math.expm1((t_0 * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) - log(Float64(1.0 + expm1(Float64(t_0 * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[Log[N[(1.0 + N[(Exp[N[(t$95$0 * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) - \log \left(1 + \mathsf{expm1}\left(t\_0 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\right)}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr76.9%
associate-*r*76.9%
log1p-expm1-u76.9%
log1p-undefine76.9%
associate-*r*76.9%
pow276.9%
div-inv76.9%
metadata-eval76.9%
*-commutative76.9%
Applied egg-rr76.9%
Final simplification76.9%
(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 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt
(-
(-
1.0
(pow
(fma
(sin (* phi1 0.5))
(cos (* phi2 0.5))
(* (sin (* phi2 -0.5)) (cos (* phi1 0.5))))
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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt(((1.0 - pow(fma(sin((phi1 * 0.5)), cos((phi2 * 0.5)), (sin((phi2 * -0.5)) * cos((phi1 * 0.5)))), 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((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (fma(sin(Float64(phi1 * 0.5)), cos(Float64(phi2 * 0.5)), Float64(sin(Float64(phi2 * -0.5)) * cos(Float64(phi1 * 0.5)))) ^ 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[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right), \sin \left(\phi_2 \cdot -0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr76.9%
Taylor expanded in phi1 around inf 76.9%
Simplified76.9%
Final simplification76.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(*
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0))))
(* 2.0 (* R (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))) + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
return 2.0 * (R * atan2(sqrt(t_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 = (cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))) + (((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0)
code = 2.0d0 * (r * atan2(sqrt(t_0), 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.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) + Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
return 2.0 * (R * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) + math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) return 2.0 * (R * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0)) return Float64(2.0 * Float64(R * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))) + (((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0); tmp = 2.0 * (R * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(2.0 * N[(R * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
2 \cdot \left(R \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr76.9%
associate-*r*76.9%
log1p-expm1-u76.9%
log1p-undefine76.9%
associate-*r*76.9%
pow276.9%
div-inv76.9%
metadata-eval76.9%
*-commutative76.9%
Applied egg-rr76.9%
Taylor expanded in R around 0 76.9%
Final simplification76.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(if (or (<= phi2 -2.9e-5) (not (<= phi2 3e-9)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_2))
(sqrt
(-
(- 1.0 t_0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double tmp;
if ((phi2 <= -2.9e-5) || !(phi2 <= 3e-9)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi1) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
if ((phi2 <= (-2.9d-5)) .or. (.not. (phi2 <= 3d-9))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0d0 - t_0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double tmp;
if ((phi2 <= -2.9e-5) || !(phi2 <= 3e-9)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt(((1.0 - t_0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) tmp = 0 if (phi2 <= -2.9e-5) or not (phi2 <= 3e-9): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_2)), math.sqrt(((1.0 - t_0) - (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) tmp = 0.0 if ((phi2 <= -2.9e-5) || !(phi2 <= 3e-9)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(Float64(1.0 - t_0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); tmp = 0.0; if ((phi2 <= -2.9e-5) || ~((phi2 <= 3e-9))) tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -2.9e-5], N[Not[LessEqual[phi2, 3e-9]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
\mathbf{if}\;\phi_2 \leq -2.9 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 3 \cdot 10^{-9}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{\left(1 - t\_0\right) - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -2.9e-5 or 2.99999999999999998e-9 < phi2 Initial program 47.2%
associate-*l*47.2%
Simplified47.3%
div-sub47.3%
sin-diff49.1%
Applied egg-rr49.1%
div-sub47.3%
sin-diff49.1%
Applied egg-rr74.8%
Taylor expanded in phi1 around 0 58.0%
*-commutative58.0%
Simplified58.0%
if -2.9e-5 < phi2 < 2.99999999999999998e-9Initial program 79.3%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in phi2 around 0 79.3%
*-commutative79.4%
metadata-eval79.4%
div-inv79.4%
div-sub79.4%
sin-diff80.0%
Applied egg-rr80.0%
Final simplification68.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (- 1.0 t_1))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (* (cos phi1) (cos phi2)) (* t_3 t_3))))
(if (<= phi2 -2.8e-5)
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_4)) (sqrt (- t_2 t_0)))))
(if (<= phi2 3e-9)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_0)) (sqrt (- t_2 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = 1.0 - t_1;
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = (cos(phi1) * cos(phi2)) * (t_3 * t_3);
double tmp;
if (phi2 <= -2.8e-5) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt((t_2 - t_0))));
} else if (phi2 <= 3e-9) {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi1) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_0)), sqrt((t_2 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = 1.0d0 - t_1
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = (cos(phi1) * cos(phi2)) * (t_3 * t_3)
if (phi2 <= (-2.8d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_4)), sqrt((t_2 - t_0))))
else if (phi2 <= 3d-9) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_0)), sqrt((t_2 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = 1.0 - t_1;
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = (Math.cos(phi1) * Math.cos(phi2)) * (t_3 * t_3);
double tmp;
if (phi2 <= -2.8e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_4)), Math.sqrt((t_2 - t_0))));
} else if (phi2 <= 3e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_0)), Math.sqrt((t_2 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = 1.0 - t_1 t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = (math.cos(phi1) * math.cos(phi2)) * (t_3 * t_3) tmp = 0 if phi2 <= -2.8e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_4)), math.sqrt((t_2 - t_0)))) elif phi2 <= 3e-9: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_0)), math.sqrt((t_2 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = Float64(1.0 - t_1) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_3 * t_3)) tmp = 0.0 if (phi2 <= -2.8e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_4)), sqrt(Float64(t_2 - t_0))))); elseif (phi2 <= 3e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_0)), sqrt(Float64(t_2 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = 1.0 - t_1; t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = (cos(phi1) * cos(phi2)) * (t_3 * t_3); tmp = 0.0; if (phi2 <= -2.8e-5) tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt((t_2 - t_0)))); elseif (phi2 <= 3e-9) tmp = R * (2.0 * atan2(sqrt((t_4 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_0)), sqrt((t_2 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.8e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := 1 - t\_1\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_3 \cdot t\_3\right)\\
\mathbf{if}\;\phi_2 \leq -2.8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_4}}{\sqrt{t\_2 - t\_0}}\right)\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0}}{\sqrt{t\_2 - t\_4}}\right)\\
\end{array}
\end{array}
if phi2 < -2.79999999999999996e-5Initial program 46.9%
associate-*l*46.9%
Simplified47.0%
div-sub47.0%
sin-diff48.6%
Applied egg-rr48.6%
div-sub47.0%
sin-diff48.6%
Applied egg-rr74.4%
Taylor expanded in phi1 around 0 58.7%
*-commutative58.7%
Simplified58.7%
if -2.79999999999999996e-5 < phi2 < 2.99999999999999998e-9Initial program 79.3%
associate-*l*79.3%
Simplified79.3%
Taylor expanded in phi2 around 0 79.3%
*-commutative79.4%
metadata-eval79.4%
div-inv79.4%
div-sub79.4%
sin-diff80.0%
Applied egg-rr80.0%
if 2.99999999999999998e-9 < phi2 Initial program 47.6%
associate-*l*47.5%
Simplified47.6%
div-sub47.6%
sin-diff49.8%
Applied egg-rr49.8%
div-sub47.6%
sin-diff49.8%
Applied egg-rr75.3%
Taylor expanded in phi1 around 0 57.4%
*-commutative57.3%
Simplified57.4%
Final simplification68.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1)))
(t_3 (sqrt (+ t_0 t_2))))
(if (<= phi1 -0.165)
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
(- 1.0 t_0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double t_3 = sqrt((t_0 + t_2));
double tmp;
if (phi1 <= -0.165) {
tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_0) - (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
t_3 = sqrt((t_0 + t_2))
if (phi1 <= (-0.165d0)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((1.0d0 - t_0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double t_3 = Math.sqrt((t_0 + t_2));
double tmp;
if (phi1 <= -0.165) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt(((1.0 - t_0) - (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) t_3 = math.sqrt((t_0 + t_2)) tmp = 0 if phi1 <= -0.165: tmp = R * (2.0 * math.atan2(t_3, math.sqrt(((1.0 - t_0) - (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) t_3 = sqrt(Float64(t_0 + t_2)) tmp = 0.0 if (phi1 <= -0.165) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(Float64(1.0 - t_0) - Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); t_3 = sqrt((t_0 + t_2)); tmp = 0.0; if (phi1 <= -0.165) tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.165], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
t_3 := \sqrt{t\_0 + t\_2}\\
\mathbf{if}\;\phi_1 \leq -0.165:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{\left(1 - t\_0\right) - \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_2}}\right)\\
\end{array}
\end{array}
if phi1 < -0.165000000000000008Initial program 48.3%
associate-*l*48.3%
Simplified48.3%
div-sub48.3%
sin-diff50.3%
Applied egg-rr50.3%
div-sub48.3%
sin-diff50.3%
Applied egg-rr80.1%
Taylor expanded in phi2 around 0 61.3%
*-commutative61.3%
Simplified61.3%
if -0.165000000000000008 < phi1 Initial program 68.0%
associate-*l*68.0%
Simplified68.1%
div-sub68.1%
sin-diff68.7%
Applied egg-rr68.7%
Final simplification66.4%
(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 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt (- (- 1.0 (pow (sin (/ (- phi1 phi2) 2.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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.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 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + t_1)), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.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 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + t_1)), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.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 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + t_1)), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.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((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.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[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $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{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
(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 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.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((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.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((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.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((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - 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((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - 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(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - 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((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.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[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - 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{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr62.9%
Final simplification62.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(fabs
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(fabs((1.0 - fma(cos(phi1), (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), 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(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(abs(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)), (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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + 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{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
associate--l-62.0%
+-commutative62.0%
fma-undefine62.0%
add-sqr-sqrt62.0%
pow1/262.0%
pow1/262.0%
Applied egg-rr62.4%
unpow1/262.4%
unpow262.4%
rem-sqrt-square62.4%
*-commutative62.4%
*-commutative62.4%
Simplified62.4%
Final simplification62.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 t_1)))
(*
(atan2
(sqrt (fma t_0 t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (fma t_0 t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(* R 2.0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * t_1;
return atan2(sqrt(fma(t_0, t_2, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_0, t_2, (0.5 - (cos((phi1 - phi2)) / 2.0)))))) * (R * 2.0);
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * t_1) return Float64(atan(sqrt(fma(t_0, t_2, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, t_2, Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))))) * Float64(R * 2.0)) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(t$95$0 * t$95$2 + 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$0 * t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot t\_1\\
\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_0, t\_2, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_0, t\_2, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*r*62.0%
*-commutative62.0%
Simplified62.0%
unpow262.0%
sin-mult62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
Applied egg-rr62.1%
div-sub62.1%
+-inverses62.1%
cos-062.1%
metadata-eval62.1%
distribute-lft-out62.1%
metadata-eval62.1%
*-rgt-identity62.1%
Simplified62.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_3 (* (cos phi1) t_0)))
(if (or (<= phi2 -8.8e-5) (not (<= phi2 0.00085)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (- 1.0 t_2) (* (* (cos phi1) (cos phi2)) (* t_1 t_1)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 t_3))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = cos(phi1) * t_0;
double tmp;
if ((phi2 <= -8.8e-5) || !(phi2 <= 0.00085)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt(((1.0 - t_2) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.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) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_3 = cos(phi1) * t_0
if ((phi2 <= (-8.8d-5)) .or. (.not. (phi2 <= 0.00085d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((1.0d0 - t_2) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = Math.cos(phi1) * t_0;
double tmp;
if ((phi2 <= -8.8e-5) || !(phi2 <= 0.00085)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt(((1.0 - t_2) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_3)), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_3)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_3 = math.cos(phi1) * t_0 tmp = 0 if (phi2 <= -8.8e-5) or not (phi2 <= 0.00085): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt(((1.0 - t_2) - ((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_3)), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + t_3))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_3 = Float64(cos(phi1) * t_0) tmp = 0.0 if ((phi2 <= -8.8e-5) || !(phi2 <= 0.00085)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_2) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_3)), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_3)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_3 = cos(phi1) * t_0; tmp = 0.0; if ((phi2 <= -8.8e-5) || ~((phi2 <= 0.00085))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((1.0 - t_2) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + t_3))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[Or[LessEqual[phi2, -8.8e-5], N[Not[LessEqual[phi2, 0.00085]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_3 := \cos \phi_1 \cdot t\_0\\
\mathbf{if}\;\phi_2 \leq -8.8 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 0.00085\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - t\_2\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_3}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t\_3\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -8.7999999999999998e-5 or 8.49999999999999953e-4 < phi2 Initial program 47.4%
associate-*l*47.4%
Simplified47.5%
add-cbrt-cube47.4%
pow347.4%
pow247.4%
div-inv47.4%
metadata-eval47.4%
Applied egg-rr47.4%
Taylor expanded in phi1 around 0 48.7%
if -8.7999999999999998e-5 < phi2 < 8.49999999999999953e-4Initial program 78.3%
associate-*l*78.3%
Simplified78.3%
Taylor expanded in phi2 around 0 78.3%
Taylor expanded in phi2 around 0 78.3%
*-commutative79.1%
Simplified78.3%
Final simplification62.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* phi1 0.5)) 2.0))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_4 (+ t_1 (* (cos phi1) t_3)))
(t_5 (* (cos phi1) (cos phi2)))
(t_6 (* t_5 (* t_0 t_0))))
(if (<= phi1 -1.3e-10)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- (- 1.0 t_2) t_6)))))
(if (<= phi1 0.0011)
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_5 t_0))))
(sqrt
(- 1.0 (+ (* (cos phi2) t_3) (pow (sin (* phi2 -0.5)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_6 t_1)) (sqrt (- 1.0 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((phi1 * 0.5)), 2.0);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = t_1 + (cos(phi1) * t_3);
double t_5 = cos(phi1) * cos(phi2);
double t_6 = t_5 * (t_0 * t_0);
double tmp;
if (phi1 <= -1.3e-10) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(((1.0 - t_2) - t_6))));
} else if (phi1 <= 0.0011) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_5 * t_0)))), sqrt((1.0 - ((cos(phi2) * t_3) + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_6 + t_1)), sqrt((1.0 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((phi1 * 0.5d0)) ** 2.0d0
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_3 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_4 = t_1 + (cos(phi1) * t_3)
t_5 = cos(phi1) * cos(phi2)
t_6 = t_5 * (t_0 * t_0)
if (phi1 <= (-1.3d-10)) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt(((1.0d0 - t_2) - t_6))))
else if (phi1 <= 0.0011d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_5 * t_0)))), sqrt((1.0d0 - ((cos(phi2) * t_3) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_6 + t_1)), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = t_1 + (Math.cos(phi1) * t_3);
double t_5 = Math.cos(phi1) * Math.cos(phi2);
double t_6 = t_5 * (t_0 * t_0);
double tmp;
if (phi1 <= -1.3e-10) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt(((1.0 - t_2) - t_6))));
} else if (phi1 <= 0.0011) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_5 * t_0)))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_3) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_6 + t_1)), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_3 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_4 = t_1 + (math.cos(phi1) * t_3) t_5 = math.cos(phi1) * math.cos(phi2) t_6 = t_5 * (t_0 * t_0) tmp = 0 if phi1 <= -1.3e-10: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt(((1.0 - t_2) - t_6)))) elif phi1 <= 0.0011: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_5 * t_0)))), math.sqrt((1.0 - ((math.cos(phi2) * t_3) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_6 + t_1)), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_4 = Float64(t_1 + Float64(cos(phi1) * t_3)) t_5 = Float64(cos(phi1) * cos(phi2)) t_6 = Float64(t_5 * Float64(t_0 * t_0)) tmp = 0.0 if (phi1 <= -1.3e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(Float64(1.0 - t_2) - t_6))))); elseif (phi1 <= 0.0011) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_5 * t_0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_3) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + t_1)), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((phi1 * 0.5)) ^ 2.0; t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_3 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_4 = t_1 + (cos(phi1) * t_3); t_5 = cos(phi1) * cos(phi2); t_6 = t_5 * (t_0 * t_0); tmp = 0.0; if (phi1 <= -1.3e-10) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(((1.0 - t_2) - t_6)))); elseif (phi1 <= 0.0011) tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_5 * t_0)))), sqrt((1.0 - ((cos(phi2) * t_3) + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_6 + t_1)), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[(t$95$5 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.3e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - t$95$6), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.0011], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$6 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_4 := t\_1 + \cos \phi_1 \cdot t\_3\\
t_5 := \cos \phi_1 \cdot \cos \phi_2\\
t_6 := t\_5 \cdot \left(t\_0 \cdot t\_0\right)\\
\mathbf{if}\;\phi_1 \leq -1.3 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{\left(1 - t\_2\right) - t\_6}}\right)\\
\mathbf{elif}\;\phi_1 \leq 0.0011:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_0 \cdot \left(t\_5 \cdot t\_0\right)}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_3 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6 + t\_1}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if phi1 < -1.29999999999999991e-10Initial program 48.9%
associate-*l*48.9%
Simplified48.9%
add-cbrt-cube48.9%
pow348.9%
pow248.9%
div-inv48.9%
metadata-eval48.9%
Applied egg-rr48.9%
Taylor expanded in phi2 around 0 50.0%
if -1.29999999999999991e-10 < phi1 < 0.00110000000000000007Initial program 75.6%
clear-num70.7%
inv-pow70.7%
Applied egg-rr70.7%
unpow-170.7%
Simplified70.7%
Taylor expanded in phi1 around 0 75.6%
if 0.00110000000000000007 < phi1 Initial program 49.9%
associate-*l*49.9%
Simplified49.9%
Taylor expanded in phi2 around 0 50.6%
Taylor expanded in phi2 around 0 51.7%
Final simplification62.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1)))
(t_3 (pow (sin (* phi1 0.5)) 2.0))
(t_4 (+ t_3 (* (cos phi1) t_0)))
(t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= phi1 -1.3e-10)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- (- 1.0 t_5) t_2)))))
(if (<= phi1 0.00031)
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 t_5))
(sqrt
(- 1.0 (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_2 t_3)) (sqrt (- 1.0 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double t_3 = pow(sin((phi1 * 0.5)), 2.0);
double t_4 = t_3 + (cos(phi1) * t_0);
double t_5 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -1.3e-10) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(((1.0 - t_5) - t_2))));
} else if (phi1 <= 0.00031) {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_5)), sqrt((1.0 - ((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
t_3 = sin((phi1 * 0.5d0)) ** 2.0d0
t_4 = t_3 + (cos(phi1) * t_0)
t_5 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (phi1 <= (-1.3d-10)) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt(((1.0d0 - t_5) - t_2))))
else if (phi1 <= 0.00031d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_5)), sqrt((1.0d0 - ((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double t_3 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_4 = t_3 + (Math.cos(phi1) * t_0);
double t_5 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -1.3e-10) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt(((1.0 - t_5) - t_2))));
} else if (phi1 <= 0.00031) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_5)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_3)), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) t_3 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_4 = t_3 + (math.cos(phi1) * t_0) t_5 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if phi1 <= -1.3e-10: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt(((1.0 - t_5) - t_2)))) elif phi1 <= 0.00031: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_5)), math.sqrt((1.0 - ((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_3)), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) t_3 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_4 = Float64(t_3 + Float64(cos(phi1) * t_0)) t_5 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (phi1 <= -1.3e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(Float64(1.0 - t_5) - t_2))))); elseif (phi1 <= 0.00031) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_5)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_3)), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); t_3 = sin((phi1 * 0.5)) ^ 2.0; t_4 = t_3 + (cos(phi1) * t_0); t_5 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (phi1 <= -1.3e-10) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(((1.0 - t_5) - t_2)))); elseif (phi1 <= 0.00031) tmp = R * (2.0 * atan2(sqrt((t_2 + t_5)), sqrt((1.0 - ((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -1.3e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$5), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.00031], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
t_3 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_4 := t\_3 + \cos \phi_1 \cdot t\_0\\
t_5 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -1.3 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{\left(1 - t\_5\right) - t\_2}}\right)\\
\mathbf{elif}\;\phi_1 \leq 0.00031:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_5}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_3}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if phi1 < -1.29999999999999991e-10Initial program 48.9%
associate-*l*48.9%
Simplified48.9%
add-cbrt-cube48.9%
pow348.9%
pow248.9%
div-inv48.9%
metadata-eval48.9%
Applied egg-rr48.9%
Taylor expanded in phi2 around 0 50.0%
if -1.29999999999999991e-10 < phi1 < 3.1e-4Initial program 75.6%
associate-*l*75.6%
Simplified75.6%
Taylor expanded in phi1 around 0 75.6%
if 3.1e-4 < phi1 Initial program 49.9%
associate-*l*49.9%
Simplified49.9%
Taylor expanded in phi2 around 0 50.6%
Taylor expanded in phi2 around 0 51.7%
Final simplification62.7%
(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 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (+ 1.0 (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((1.0d0 + (((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((1.0 + (((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((1.0 + (((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(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[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \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{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 62.0%
unpow262.0%
sin-mult62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
Applied egg-rr62.1%
div-sub62.1%
+-inverses62.1%
cos-062.1%
metadata-eval62.1%
distribute-lft-out62.1%
metadata-eval62.1%
*-rgt-identity62.1%
Simplified62.1%
Final simplification62.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt
(+
(- 1.0 t_1)
(*
t_2
(/ (+ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) -1.0) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
code = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0d0 - t_1) + (t_2 * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) + (-1.0d0)) / 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt(((1.0 - t_1) + (t_2 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt(((1.0 - t_1) + (t_2 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_2 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) + -1.0) / 2.0))))))) 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; t_2 = cos(phi1) * cos(phi2); tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) + -1.0) / 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] + -1.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_0 \cdot t\_0\right) + t\_1}}{\sqrt{\left(1 - t\_1\right) + t\_2 \cdot \frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right) + -1}{2}}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
sin-mult74.6%
div-inv74.6%
metadata-eval74.6%
div-inv74.6%
metadata-eval74.6%
cos-sum74.6%
cos-274.6%
div-inv74.6%
metadata-eval74.6%
Applied egg-rr62.1%
+-inverses74.6%
cos-074.6%
associate-*r*74.6%
Simplified62.1%
Final simplification62.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -2.75e-5) (not (<= phi2 0.00175)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0))))
(sqrt (- (- 1.0 t_0) (* (* (cos phi1) (cos phi2)) (* t_2 t_2)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_1))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -2.75e-5) || !(phi2 <= 0.00175)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_2 * t_2))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_1)), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-2.75d-5)) .or. (.not. (phi2 <= 0.00175d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0)))), sqrt(((1.0d0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_2 * t_2))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_1)), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + t_1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -2.75e-5) || !(phi2 <= 0.00175)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0)))), Math.sqrt(((1.0 - t_0) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_2 * t_2))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_1)), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -2.75e-5) or not (phi2 <= 0.00175): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))), math.sqrt(((1.0 - t_0) - ((math.cos(phi1) * math.cos(phi2)) * (t_2 * t_2)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_1)), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -2.75e-5) || !(phi2 <= 0.00175)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_2 * t_2))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_1)), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -2.75e-5) || ~((phi2 <= 0.00175))) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_2 * t_2)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + t_1)), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -2.75e-5], N[Not[LessEqual[phi2, 0.00175]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -2.75 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 0.00175\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - t\_0\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_1}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t\_1\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -2.7500000000000001e-5 or 0.00175000000000000004 < phi2 Initial program 47.4%
associate-*l*47.4%
Simplified47.5%
add-cbrt-cube47.4%
pow347.4%
pow247.4%
div-inv47.4%
metadata-eval47.4%
Applied egg-rr47.4%
Applied egg-rr23.1%
Taylor expanded in lambda2 around 0 14.8%
Taylor expanded in phi1 around 0 37.0%
if -2.7500000000000001e-5 < phi2 < 0.00175000000000000004Initial program 78.3%
associate-*l*78.3%
Simplified78.3%
Taylor expanded in phi2 around 0 78.3%
Taylor expanded in phi2 around 0 78.3%
*-commutative79.1%
Simplified78.3%
Final simplification56.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
(sqrt (- (- 1.0 t_0) (* t_1 (* t_2 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_0 + (t_1 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), sqrt(((1.0d0 - t_0) - (t_1 * (t_2 * t_2))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), Math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), sqrt(Float64(Float64(1.0 - t_0) - Float64(t_1 * Float64(t_2 * t_2))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_1 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{\sqrt{\left(1 - t\_0\right) - t\_1 \cdot \left(t\_2 \cdot t\_2\right)}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
add-cbrt-cube61.3%
pow361.3%
pow261.3%
div-inv61.3%
metadata-eval61.3%
Applied egg-rr61.3%
rem-cbrt-cube62.1%
metadata-eval62.1%
div-inv62.1%
pow262.1%
sin-mult59.8%
Applied egg-rr59.8%
div-sub59.8%
+-inverses59.8%
cos-059.8%
metadata-eval59.8%
associate-*r*59.8%
metadata-eval59.8%
*-lft-identity59.8%
Simplified59.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi1) t_1)))
(if (<= phi2 5.2e+41)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_2))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) t_2))))))
(*
R
(*
2.0
(atan2
(hypot
(sqrt (* (* (cos phi1) (cos phi2)) t_1))
(sin (* 0.5 (- phi1 phi2))))
(sqrt (- (- 1.0 t_0) (* (cos phi2) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi1) * t_1;
double tmp;
if (phi2 <= 5.2e+41) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + t_2)))));
} else {
tmp = R * (2.0 * atan2(hypot(sqrt(((cos(phi1) * cos(phi2)) * t_1)), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - (cos(phi2) * t_1)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi1) * t_1;
double tmp;
if (phi2 <= 5.2e+41) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot(Math.sqrt(((Math.cos(phi1) * Math.cos(phi2)) * t_1)), Math.sin((0.5 * (phi1 - phi2)))), Math.sqrt(((1.0 - t_0) - (Math.cos(phi2) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi1) * t_1 tmp = 0 if phi2 <= 5.2e+41: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_2)), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + t_2))))) else: tmp = R * (2.0 * math.atan2(math.hypot(math.sqrt(((math.cos(phi1) * math.cos(phi2)) * t_1)), math.sin((0.5 * (phi1 - phi2)))), math.sqrt(((1.0 - t_0) - (math.cos(phi2) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi1) * t_1) tmp = 0.0 if (phi2 <= 5.2e+41) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(sqrt(Float64(Float64(cos(phi1) * cos(phi2)) * t_1)), sin(Float64(0.5 * Float64(phi1 - phi2)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(cos(phi2) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = cos(phi1) * t_1; tmp = 0.0; if (phi2 <= 5.2e+41) tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + t_2))))); else tmp = R * (2.0 * atan2(hypot(sqrt(((cos(phi1) * cos(phi2)) * t_1)), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - (cos(phi2) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[phi2, 5.2e+41], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision] ^ 2 + N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_1 \cdot t\_1\\
\mathbf{if}\;\phi_2 \leq 5.2 \cdot 10^{+41}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1}, \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\sqrt{\left(1 - t\_0\right) - \cos \phi_2 \cdot t\_1}}\right)\\
\end{array}
\end{array}
if phi2 < 5.2000000000000001e41Initial program 65.1%
associate-*l*65.1%
Simplified65.1%
Taylor expanded in phi2 around 0 55.2%
Taylor expanded in phi2 around 0 55.0%
*-commutative60.1%
Simplified55.0%
if 5.2000000000000001e41 < phi2 Initial program 50.7%
associate-*l*50.7%
Simplified50.7%
add-cbrt-cube50.7%
pow350.7%
pow250.7%
div-inv50.7%
metadata-eval50.7%
Applied egg-rr50.7%
Applied egg-rr31.6%
Taylor expanded in phi1 around 0 32.0%
*-commutative59.3%
Simplified32.0%
Final simplification50.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sin (* (- lambda1 lambda2) 0.5)))
(t_3 (* (cos phi1) (pow t_2 2.0))))
(if (<= phi2 3e+60)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_3))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) t_3))))))
(*
R
(*
2.0
(atan2
(hypot (* t_2 (sqrt (cos phi2))) (sin (* 0.5 (- phi1 phi2))))
(sqrt (- (- 1.0 t_0) (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sin(((lambda1 - lambda2) * 0.5));
double t_3 = cos(phi1) * pow(t_2, 2.0);
double tmp;
if (phi2 <= 3e+60) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + t_3)))));
} else {
tmp = R * (2.0 * atan2(hypot((t_2 * sqrt(cos(phi2))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sin(((lambda1 - lambda2) * 0.5));
double t_3 = Math.cos(phi1) * Math.pow(t_2, 2.0);
double tmp;
if (phi2 <= 3e+60) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_3)), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_3)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot((t_2 * Math.sqrt(Math.cos(phi2))), Math.sin((0.5 * (phi1 - phi2)))), Math.sqrt(((1.0 - t_0) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sin(((lambda1 - lambda2) * 0.5)) t_3 = math.cos(phi1) * math.pow(t_2, 2.0) tmp = 0 if phi2 <= 3e+60: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_3)), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + t_3))))) else: tmp = R * (2.0 * math.atan2(math.hypot((t_2 * math.sqrt(math.cos(phi2))), math.sin((0.5 * (phi1 - phi2)))), math.sqrt(((1.0 - t_0) - ((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_3 = Float64(cos(phi1) * (t_2 ^ 2.0)) tmp = 0.0 if (phi2 <= 3e+60) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(Float64(t_2 * sqrt(cos(phi2))), sin(Float64(0.5 * Float64(phi1 - phi2)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((lambda1 - lambda2) * 0.5)); t_3 = cos(phi1) * (t_2 ^ 2.0); tmp = 0.0; if (phi2 <= 3e+60) tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + t_3))))); else tmp = R * (2.0 * atan2(hypot((t_2 * sqrt(cos(phi2))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 3e+60], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 * N[Sqrt[N[Cos[phi2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_3 := \cos \phi_1 \cdot {t\_2}^{2}\\
\mathbf{if}\;\phi_2 \leq 3 \cdot 10^{+60}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t\_3\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_2 \cdot \sqrt{\cos \phi_2}, \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\sqrt{\left(1 - t\_0\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)}}\right)\\
\end{array}
\end{array}
if phi2 < 2.9999999999999998e60Initial program 64.8%
associate-*l*64.8%
Simplified64.8%
Taylor expanded in phi2 around 0 53.8%
Taylor expanded in phi2 around 0 53.7%
*-commutative59.3%
Simplified53.7%
if 2.9999999999999998e60 < phi2 Initial program 49.3%
associate-*l*49.3%
Simplified49.3%
add-cbrt-cube49.3%
pow349.3%
pow249.3%
div-inv49.3%
metadata-eval49.3%
Applied egg-rr49.3%
Applied egg-rr31.1%
Taylor expanded in phi1 around 0 31.1%
Final simplification49.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sin (* (- lambda1 lambda2) 0.5)))
(t_3 (* (cos phi1) (pow t_2 2.0))))
(if (<= phi2 5e+44)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_3))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) t_3))))))
(*
R
(*
2.0
(atan2
(hypot (* t_2 (sqrt (cos phi1))) (sin (* 0.5 (- phi1 phi2))))
(sqrt (- (- 1.0 t_0) (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sin(((lambda1 - lambda2) * 0.5));
double t_3 = cos(phi1) * pow(t_2, 2.0);
double tmp;
if (phi2 <= 5e+44) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + t_3)))));
} else {
tmp = R * (2.0 * atan2(hypot((t_2 * sqrt(cos(phi1))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sin(((lambda1 - lambda2) * 0.5));
double t_3 = Math.cos(phi1) * Math.pow(t_2, 2.0);
double tmp;
if (phi2 <= 5e+44) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_3)), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_3)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot((t_2 * Math.sqrt(Math.cos(phi1))), Math.sin((0.5 * (phi1 - phi2)))), Math.sqrt(((1.0 - t_0) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sin(((lambda1 - lambda2) * 0.5)) t_3 = math.cos(phi1) * math.pow(t_2, 2.0) tmp = 0 if phi2 <= 5e+44: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_3)), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + t_3))))) else: tmp = R * (2.0 * math.atan2(math.hypot((t_2 * math.sqrt(math.cos(phi1))), math.sin((0.5 * (phi1 - phi2)))), math.sqrt(((1.0 - t_0) - ((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_3 = Float64(cos(phi1) * (t_2 ^ 2.0)) tmp = 0.0 if (phi2 <= 5e+44) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(Float64(t_2 * sqrt(cos(phi1))), sin(Float64(0.5 * Float64(phi1 - phi2)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((lambda1 - lambda2) * 0.5)); t_3 = cos(phi1) * (t_2 ^ 2.0); tmp = 0.0; if (phi2 <= 5e+44) tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + t_3))))); else tmp = R * (2.0 * atan2(hypot((t_2 * sqrt(cos(phi1))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 5e+44], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_3 := \cos \phi_1 \cdot {t\_2}^{2}\\
\mathbf{if}\;\phi_2 \leq 5 \cdot 10^{+44}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t\_3\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_2 \cdot \sqrt{\cos \phi_1}, \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\sqrt{\left(1 - t\_0\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)}}\right)\\
\end{array}
\end{array}
if phi2 < 4.9999999999999996e44Initial program 65.0%
associate-*l*65.0%
Simplified65.0%
Taylor expanded in phi2 around 0 54.8%
Taylor expanded in phi2 around 0 54.7%
*-commutative59.8%
Simplified54.7%
if 4.9999999999999996e44 < phi2 Initial program 50.4%
associate-*l*50.4%
Simplified50.4%
add-cbrt-cube50.4%
pow350.4%
pow250.4%
div-inv50.4%
metadata-eval50.4%
Applied egg-rr50.4%
Applied egg-rr30.5%
Taylor expanded in phi2 around 0 28.3%
Final simplification49.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi2 2.1e+44)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_1))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) t_1))))))
(*
R
(*
2.0
(atan2
(hypot
(* (sin (* lambda1 0.5)) (sqrt (cos phi1)))
(sin (* 0.5 (- phi1 phi2))))
(sqrt (- (- 1.0 t_0) (* (* (cos phi1) (cos phi2)) (* t_2 t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi2 <= 2.1e+44) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_1)), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + t_1)))));
} else {
tmp = R * (2.0 * atan2(hypot((sin((lambda1 * 0.5)) * sqrt(cos(phi1))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_2 * t_2))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi2 <= 2.1e+44) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_1)), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot((Math.sin((lambda1 * 0.5)) * Math.sqrt(Math.cos(phi1))), Math.sin((0.5 * (phi1 - phi2)))), Math.sqrt(((1.0 - t_0) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_2 * t_2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi2 <= 2.1e+44: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_1)), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + t_1))))) else: tmp = R * (2.0 * math.atan2(math.hypot((math.sin((lambda1 * 0.5)) * math.sqrt(math.cos(phi1))), math.sin((0.5 * (phi1 - phi2)))), math.sqrt(((1.0 - t_0) - ((math.cos(phi1) * math.cos(phi2)) * (t_2 * t_2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi2 <= 2.1e+44) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_1)), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(Float64(sin(Float64(lambda1 * 0.5)) * sqrt(cos(phi1))), sin(Float64(0.5 * Float64(phi1 - phi2)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_2 * t_2))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi2 <= 2.1e+44) tmp = R * (2.0 * atan2(sqrt((t_0 + t_1)), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + t_1))))); else tmp = R * (2.0 * atan2(hypot((sin((lambda1 * 0.5)) * sqrt(cos(phi1))), sin((0.5 * (phi1 - phi2)))), sqrt(((1.0 - t_0) - ((cos(phi1) * cos(phi2)) * (t_2 * t_2)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 2.1e+44], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq 2.1 \cdot 10^{+44}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_1}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\lambda_1 \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}, \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{\sqrt{\left(1 - t\_0\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\end{array}
\end{array}
if phi2 < 2.09999999999999987e44Initial program 65.0%
associate-*l*65.0%
Simplified65.0%
Taylor expanded in phi2 around 0 54.8%
Taylor expanded in phi2 around 0 54.7%
*-commutative59.8%
Simplified54.7%
if 2.09999999999999987e44 < phi2 Initial program 50.4%
associate-*l*50.4%
Simplified50.4%
add-cbrt-cube50.4%
pow350.4%
pow250.4%
div-inv50.4%
metadata-eval50.4%
Applied egg-rr50.4%
Applied egg-rr30.5%
Taylor expanded in lambda2 around 0 18.8%
Taylor expanded in phi2 around 0 27.6%
Final simplification49.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_0))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + 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(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_0)), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 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(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_0)), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_0)), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 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[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t\_0\right)}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi2 around 0 47.5%
*-commutative54.9%
Simplified47.5%
Final simplification47.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(fabs (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + fabs(((cos(phi1) * cos(phi2)) * t_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(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + abs(((cos(phi1) * cos(phi2)) * t_0)))), 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(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + Math.abs(((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + math.fabs(((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + abs(Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + abs(((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[Abs[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]], $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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left|\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right|}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi1 around 0 32.8%
pow132.8%
associate-*r*32.8%
metadata-eval32.8%
pow-prod-up25.9%
pow-prod-down32.7%
Applied egg-rr32.7%
unpow1/232.7%
unpow232.7%
rem-sqrt-square33.3%
*-commutative33.3%
Simplified33.3%
Final simplification33.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* (cos phi2) t_0)))
(sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * t_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(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * t_0))), 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(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * t_0))), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * t_0))), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * t_0))), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * t_0))), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi1 around 0 32.8%
Taylor expanded in phi1 around 0 32.8%
*-commutative54.9%
Simplified32.8%
Final simplification32.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (+ 1.0 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 + ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((1.0d0 + ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((1.0 + ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((1.0 + ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 + Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((1.0 + ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{1 + \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi1 around 0 32.8%
Taylor expanded in phi2 around 0 32.5%
*-commutative54.9%
Simplified32.5%
*-commutative32.5%
metadata-eval32.5%
div-inv32.5%
pow232.5%
sin-mult32.5%
Applied egg-rr32.5%
div-sub32.5%
+-inverses32.5%
cos-032.5%
metadata-eval32.5%
associate-*r*32.5%
metadata-eval32.5%
*-lft-identity32.5%
Simplified32.5%
Final simplification32.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(-
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi1) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) - (cos(phi1) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) - (cos(phi1) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) - (Math.cos(phi1) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) - (math.cos(phi1) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) - Float64(cos(phi1) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) - (cos(phi1) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} - \cos \phi_1 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 62.0%
associate-*l*62.0%
Simplified62.1%
Taylor expanded in phi2 around 0 47.9%
Taylor expanded in phi1 around 0 32.8%
Taylor expanded in phi2 around 0 32.5%
*-commutative54.9%
Simplified32.5%
*-commutative32.5%
metadata-eval32.5%
div-inv32.5%
pow232.5%
sin-mult32.5%
Applied egg-rr30.2%
div-sub32.5%
+-inverses32.5%
cos-032.5%
metadata-eval32.5%
associate-*r*32.5%
metadata-eval32.5%
*-lft-identity32.5%
Simplified30.2%
Final simplification30.2%
herbie shell --seed 2024110
(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))))))))))