
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 32 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (+ t_0 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))))
(if (or (<= lambda2 -6.2e-5) (not (<= lambda2 1700000000.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0)))))
(sqrt (- 1.0 t_2)))))
(*
R
(*
2.0
(atan2
(sqrt t_2)
(sqrt
(-
1.0
(+
t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1));
double tmp;
if ((lambda2 <= -6.2e-5) || !(lambda2 <= 1700000000.0)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))), sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))
if ((lambda2 <= (-6.2d-5)) .or. (.not. (lambda2 <= 1700000000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), sqrt((1.0d0 - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1));
double tmp;
if ((lambda2 <= -6.2e-5) || !(lambda2 <= 1700000000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), Math.sqrt((1.0 - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) tmp = 0 if (lambda2 <= -6.2e-5) or not (lambda2 <= 1700000000.0): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), math.sqrt((1.0 - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1))) tmp = 0.0 if ((lambda2 <= -6.2e-5) || !(lambda2 <= 1700000000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), sqrt(Float64(1.0 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)); tmp = 0.0; if ((lambda2 <= -6.2e-5) || ~((lambda2 <= 1700000000.0))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0))))), sqrt((1.0 - t_2)))); else tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -6.2e-5], N[Not[LessEqual[lambda2, 1700000000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_0 + t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
\mathbf{if}\;\lambda_2 \leq -6.2 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 1700000000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -6.20000000000000027e-5 or 1.7e9 < lambda2 Initial program 46.3%
div-sub46.3%
sin-diff47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
Applied egg-rr47.1%
div-sub46.3%
sin-diff47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
Applied egg-rr55.8%
Taylor expanded in lambda1 around 0 56.0%
associate-*r*56.0%
*-commutative56.0%
associate-*l*56.0%
*-commutative56.0%
Simplified56.0%
if -6.20000000000000027e-5 < lambda2 < 1.7e9Initial program 72.5%
div-sub72.5%
sin-diff73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
Applied egg-rr73.6%
div-sub72.5%
sin-diff73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
Applied egg-rr95.3%
Taylor expanded in lambda2 around 0 95.2%
Final simplification74.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_1 (* t_0 t_1))))
(sqrt
(-
1.0
(+
t_2
(*
t_1
(* t_0 (cbrt (pow (sin (* 0.5 (- lambda1 lambda2))) 3.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 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_1 * (t_0 * t_1)))), sqrt((1.0 - (t_2 + (t_1 * (t_0 * cbrt(pow(sin((0.5 * (lambda1 - lambda2))), 3.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.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_1 * (t_0 * t_1)))), Math.sqrt((1.0 - (t_2 + (t_1 * (t_0 * Math.cbrt(Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 3.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(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_1 * Float64(t_0 * t_1)))), sqrt(Float64(1.0 - Float64(t_2 + Float64(t_1 * Float64(t_0 * cbrt((sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 3.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[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(t$95$1 * N[(t$95$0 * N[Power[N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_1 \cdot \left(t\_0 \cdot t\_1\right)}}{\sqrt{1 - \left(t\_2 + t\_1 \cdot \left(t\_0 \cdot \sqrt[3]{{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{3}}\right)\right)}}\right)
\end{array}
\end{array}
Initial program 58.7%
div-sub58.7%
sin-diff59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
Applied egg-rr59.6%
div-sub58.7%
sin-diff59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
Applied egg-rr74.5%
add-cbrt-cube74.5%
pow374.5%
div-inv74.5%
metadata-eval74.5%
Applied egg-rr74.5%
Final simplification74.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sqrt (- 1.0 (+ t_0 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))))))
(if (or (<= lambda1 -1.85e-6) (not (<= lambda1 8e-12)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
t_2)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((1.0 - (t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))));
double tmp;
if ((lambda1 <= -1.85e-6) || !(lambda1 <= 8e-12)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt((1.0d0 - (t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))))
if ((lambda1 <= (-1.85d-6)) .or. (.not. (lambda1 <= 8d-12))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((1.0 - (t_0 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)))));
double tmp;
if ((lambda1 <= -1.85e-6) || !(lambda1 <= 8e-12)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((1.0 - (t_0 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1))))) tmp = 0 if (lambda1 <= -1.85e-6) or not (lambda1 <= 8e-12): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(1.0 - Float64(t_0 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1))))) tmp = 0.0 if ((lambda1 <= -1.85e-6) || !(lambda1 <= 8e-12)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt((1.0 - (t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))))); tmp = 0.0; if ((lambda1 <= -1.85e-6) || ~((lambda1 <= 8e-12))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), t_2)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.85e-6], N[Not[LessEqual[lambda1, 8e-12]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{1 - \left(t\_0 + t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\right)}\\
\mathbf{if}\;\lambda_1 \leq -1.85 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 8 \cdot 10^{-12}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{t\_2}\right)\\
\end{array}
\end{array}
if lambda1 < -1.8500000000000001e-6 or 7.99999999999999984e-12 < lambda1 Initial program 42.2%
div-sub42.2%
sin-diff43.2%
div-inv43.2%
metadata-eval43.2%
div-inv43.2%
metadata-eval43.2%
div-inv43.2%
metadata-eval43.2%
div-inv43.2%
metadata-eval43.2%
Applied egg-rr43.2%
div-sub42.2%
sin-diff43.2%
div-inv43.2%
metadata-eval43.2%
div-inv43.2%
metadata-eval43.2%
div-inv43.2%
metadata-eval43.2%
div-inv43.2%
metadata-eval43.2%
Applied egg-rr52.6%
Taylor expanded in lambda2 around 0 52.6%
if -1.8500000000000001e-6 < lambda1 < 7.99999999999999984e-12Initial program 76.8%
div-sub76.8%
sin-diff77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr77.6%
div-sub76.8%
sin-diff77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr98.6%
Taylor expanded in lambda1 around 0 97.9%
associate-*r*97.9%
*-commutative97.9%
associate-*l*97.9%
*-commutative97.9%
Simplified97.9%
Final simplification74.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_2 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_3 (+ t_1 t_2))
(t_4 (sqrt (- 1.0 t_3))))
(if (<= lambda2 -6e-11)
(*
R
(* 2.0 (atan2 (sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0)))) t_4)))
(if (<= lambda2 6.6e-7)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
t_4)))
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt
(-
1.0
(+
t_2
(log
(exp (pow (sin (- (* phi1 0.5) (* 0.5 phi2))) 2.0)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_3 = t_1 + t_2;
double t_4 = sqrt((1.0 - t_3));
double tmp;
if (lambda2 <= -6e-11) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4));
} else if (lambda2 <= 6.6e-7) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), t_4));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_2 + log(exp(pow(sin(((phi1 * 0.5) - (0.5 * phi2))), 2.0))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_3 = t_1 + t_2
t_4 = sqrt((1.0d0 - t_3))
if (lambda2 <= (-6d-11)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), t_4))
else if (lambda2 <= 6.6d-7) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), t_4))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_2 + log(exp((sin(((phi1 * 0.5d0) - (0.5d0 * phi2))) ** 2.0d0))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_2 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_3 = t_1 + t_2;
double t_4 = Math.sqrt((1.0 - t_3));
double tmp;
if (lambda2 <= -6e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_4));
} else if (lambda2 <= 6.6e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), t_4));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_2 + Math.log(Math.exp(Math.pow(Math.sin(((phi1 * 0.5) - (0.5 * phi2))), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_2 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_3 = t_1 + t_2 t_4 = math.sqrt((1.0 - t_3)) tmp = 0 if lambda2 <= -6e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_4)) elif lambda2 <= 6.6e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), t_4)) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_2 + math.log(math.exp(math.pow(math.sin(((phi1 * 0.5) - (0.5 * phi2))), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_2 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_3 = Float64(t_1 + t_2) t_4 = sqrt(Float64(1.0 - t_3)) tmp = 0.0 if (lambda2 <= -6e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_4))); elseif (lambda2 <= 6.6e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), t_4))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_2 + log(exp((sin(Float64(Float64(phi1 * 0.5) - Float64(0.5 * phi2))) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_3 = t_1 + t_2; t_4 = sqrt((1.0 - t_3)); tmp = 0.0; if (lambda2 <= -6e-11) tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4)); elseif (lambda2 <= 6.6e-7) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), t_4)); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_2 + log(exp((sin(((phi1 * 0.5) - (0.5 * phi2))) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -6e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 6.6e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Log[N[Exp[N[Power[N[Sin[N[(N[(phi1 * 0.5), $MachinePrecision] - N[(0.5 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_2 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_3 := t\_1 + t\_2\\
t_4 := \sqrt{1 - t\_3}\\
\mathbf{if}\;\lambda_2 \leq -6 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_4}\right)\\
\mathbf{elif}\;\lambda_2 \leq 6.6 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{t\_4}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \left(t\_2 + \log \left(e^{{\sin \left(\phi_1 \cdot 0.5 - 0.5 \cdot \phi_2\right)}^{2}}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -6e-11Initial program 45.5%
div-sub45.5%
sin-diff46.7%
div-inv46.7%
metadata-eval46.7%
div-inv46.7%
metadata-eval46.7%
div-inv46.7%
metadata-eval46.7%
div-inv46.7%
metadata-eval46.7%
Applied egg-rr46.7%
unpow246.7%
sin-mult46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
Applied egg-rr46.8%
div-sub46.8%
+-inverses46.8%
cos-046.8%
metadata-eval46.8%
distribute-lft-out46.8%
metadata-eval46.8%
*-rgt-identity46.8%
Simplified46.8%
if -6e-11 < lambda2 < 6.6000000000000003e-7Initial program 74.1%
div-sub74.1%
sin-diff75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
Applied egg-rr75.2%
div-sub74.1%
sin-diff75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
Applied egg-rr98.3%
Taylor expanded in lambda2 around 0 95.0%
if 6.6000000000000003e-7 < lambda2 Initial program 47.1%
div-sub47.1%
sin-diff47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
Applied egg-rr47.5%
div-sub47.1%
sin-diff47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
Applied egg-rr55.7%
add-log-exp55.7%
sin-diff48.2%
*-commutative48.2%
Applied egg-rr48.2%
Final simplification68.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0)))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0));
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0));
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 58.7%
div-sub58.7%
sin-diff59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
Applied egg-rr59.6%
div-sub58.7%
sin-diff59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
Applied egg-rr74.5%
Final simplification74.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))
(t_3 (+ t_0 t_2))
(t_4 (sqrt t_3)))
(if (<= (- lambda1 lambda2) -4e-8)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(+
(-
2.0
(fma
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(cos phi1)
(pow (sin (* -0.5 (- phi2 phi1))) 2.0)))
-1.0)))))
(if (<= (- lambda1 lambda2) 2e-11)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
1.0
(+
t_0
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1);
double t_3 = t_0 + t_2;
double t_4 = sqrt(t_3);
double tmp;
if ((lambda1 - lambda2) <= -4e-8) {
tmp = R * (2.0 * atan2(t_4, sqrt(((2.0 - fma((cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)), cos(phi1), pow(sin((-0.5 * (phi2 - phi1))), 2.0))) + -1.0))));
} else if ((lambda1 - lambda2) <= 2e-11) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_0 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) t_3 = Float64(t_0 + t_2) t_4 = sqrt(t_3) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -4e-8) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(2.0 - fma(Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)), cos(phi1), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0))) + -1.0))))); elseif (Float64(lambda1 - lambda2) <= 2e-11) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_3))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[t$95$3], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -4e-8], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[(2.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 2e-11], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
t_3 := t\_0 + t\_2\\
t_4 := \sqrt{t\_3}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -4 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{\left(2 - \mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right) + -1}}\right)\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(t\_0 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -4.0000000000000001e-8Initial program 56.6%
expm1-log1p-u56.6%
+-commutative56.6%
associate-*l*56.6%
fma-undefine56.6%
Applied egg-rr56.6%
Simplified56.7%
div-sub56.6%
sin-diff57.2%
div-inv57.2%
metadata-eval57.2%
div-inv57.2%
metadata-eval57.2%
div-inv57.2%
metadata-eval57.2%
div-inv57.2%
metadata-eval57.2%
Applied egg-rr57.9%
if -4.0000000000000001e-8 < (-.f64 lambda1 lambda2) < 1.99999999999999988e-11Initial program 73.8%
div-sub73.8%
sin-diff74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
Applied egg-rr74.5%
div-sub73.8%
sin-diff74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
Applied egg-rr99.0%
Taylor expanded in phi1 around 0 99.0%
if 1.99999999999999988e-11 < (-.f64 lambda1 lambda2) Initial program 51.7%
div-sub51.7%
sin-diff53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
unpow253.1%
sin-mult53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
div-sub53.1%
+-inverses53.1%
cos-053.1%
metadata-eval53.1%
distribute-lft-out53.1%
metadata-eval53.1%
*-rgt-identity53.1%
Simplified53.1%
Final simplification65.6%
(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)))
(t_2
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_3 (+ t_2 t_1)))
(if (or (<= phi1 -0.038) (not (<= phi1 42000000000.0)))
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt
(-
1.0
(+
t_2
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 t_3))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_3 = t_2 + t_1;
double tmp;
if ((phi1 <= -0.038) || !(phi1 <= 42000000000.0)) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_2 + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_3 = t_2 + t_1
if ((phi1 <= (-0.038d0)) .or. (.not. (phi1 <= 42000000000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_2 + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_3 = t_2 + t_1;
double tmp;
if ((phi1 <= -0.038) || !(phi1 <= 42000000000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_2 + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
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) t_2 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_3 = t_2 + t_1 tmp = 0 if (phi1 <= -0.038) or not (phi1 <= 42000000000.0): tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_2 + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_3 = Float64(t_2 + t_1) tmp = 0.0 if ((phi1 <= -0.038) || !(phi1 <= 42000000000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_2 + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_3 = t_2 + t_1; tmp = 0.0; if ((phi1 <= -0.038) || ~((phi1 <= 42000000000.0))) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_2 + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 + t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi1, -0.038], N[Not[LessEqual[phi1, 42000000000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_3 := t\_2 + t\_1\\
\mathbf{if}\;\phi_1 \leq -0.038 \lor \neg \left(\phi_1 \leq 42000000000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \left(t\_2 + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if phi1 < -0.0379999999999999991 or 4.2e10 < phi1 Initial program 46.5%
div-sub46.5%
sin-diff48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
Applied egg-rr48.1%
div-sub46.5%
sin-diff48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
Applied egg-rr74.1%
Taylor expanded in phi2 around 0 60.1%
*-commutative60.1%
Simplified60.1%
if -0.0379999999999999991 < phi1 < 4.2e10Initial program 72.3%
div-sub72.3%
sin-diff72.5%
div-inv72.5%
metadata-eval72.5%
div-inv72.5%
metadata-eval72.5%
div-inv72.5%
metadata-eval72.5%
div-inv72.5%
metadata-eval72.5%
Applied egg-rr72.5%
Final simplification65.9%
(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)))
(t_2
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_3 (+ t_2 t_1)))
(if (or (<= t_0 -0.01) (not (<= t_0 0.02)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_3)))))
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_3 = t_2 + t_1;
double tmp;
if ((t_0 <= -0.01) || !(t_0 <= 0.02)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_3 = t_2 + t_1
if ((t_0 <= (-0.01d0)) .or. (.not. (t_0 <= 0.02d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_3 = t_2 + t_1;
double tmp;
if ((t_0 <= -0.01) || !(t_0 <= 0.02)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
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) t_2 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_3 = t_2 + t_1 tmp = 0 if (t_0 <= -0.01) or not (t_0 <= 0.02): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_3 = Float64(t_2 + t_1) tmp = 0.0 if ((t_0 <= -0.01) || !(t_0 <= 0.02)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_3 = t_2 + t_1; tmp = 0.0; if ((t_0 <= -0.01) || ~((t_0 <= 0.02))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3)))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 + t$95$1), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.01], N[Not[LessEqual[t$95$0, 0.02]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_3 := t\_2 + t\_1\\
\mathbf{if}\;t\_0 \leq -0.01 \lor \neg \left(t\_0 \leq 0.02\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0100000000000000002 or 0.0200000000000000004 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 54.0%
div-sub54.0%
sin-diff55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
Applied egg-rr55.0%
unpow255.0%
sin-mult55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
Applied egg-rr55.0%
div-sub55.0%
+-inverses55.0%
cos-055.0%
metadata-eval55.0%
distribute-lft-out55.0%
metadata-eval55.0%
*-rgt-identity55.0%
Simplified55.0%
if -0.0100000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.0200000000000000004Initial program 72.9%
div-sub72.9%
sin-diff73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
Applied egg-rr73.6%
Taylor expanded in lambda2 around 0 73.7%
Taylor expanded in lambda1 around 0 73.6%
*-commutative73.6%
Simplified73.6%
div-sub72.9%
sin-diff73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
Applied egg-rr96.9%
Final simplification65.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(if (or (<= t_1 -0.01) (not (<= t_1 0.02)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(fabs
(+
(fma
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(cos phi1)
(pow (sin (* -0.5 (- phi2 phi1))) 2.0))
-1.0))))))
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_2)) (sqrt (- 1.0 t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1);
double tmp;
if ((t_1 <= -0.01) || !(t_1 <= 0.02)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(fabs((fma((cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)), cos(phi1), pow(sin((-0.5 * (phi2 - phi1))), 2.0)) + -1.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt((1.0 - t_0))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) tmp = 0.0 if ((t_1 <= -0.01) || !(t_1 <= 0.02)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(abs(Float64(fma(Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)), cos(phi1), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)) + -1.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(1.0 - t_0))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -0.01], N[Not[LessEqual[t$95$1, 0.02]], $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[Abs[N[(N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
\mathbf{if}\;t\_1 \leq -0.01 \lor \neg \left(t\_1 \leq 0.02\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|\mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right) + -1\right|}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{1 - t\_0}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0100000000000000002 or 0.0200000000000000004 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 54.0%
add-sqr-sqrt54.0%
sqrt-unprod54.6%
pow254.6%
Applied egg-rr54.6%
Simplified54.6%
if -0.0100000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.0200000000000000004Initial program 72.9%
div-sub72.9%
sin-diff73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
Applied egg-rr73.6%
Taylor expanded in lambda2 around 0 73.7%
Taylor expanded in lambda1 around 0 73.6%
*-commutative73.6%
Simplified73.6%
div-sub72.9%
sin-diff73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
Applied egg-rr96.9%
Final simplification65.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))
(t_3 (+ t_0 t_2))
(t_4 (sqrt t_3)))
(if (<= (- lambda1 lambda2) -4e-8)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(+
(-
2.0
(fma
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(cos phi1)
(pow (sin (* -0.5 (- phi2 phi1))) 2.0)))
-1.0)))))
(if (<= (- lambda1 lambda2) 2e-11)
(* R (* 2.0 (atan2 t_4 (sqrt (- 1.0 t_0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1);
double t_3 = t_0 + t_2;
double t_4 = sqrt(t_3);
double tmp;
if ((lambda1 - lambda2) <= -4e-8) {
tmp = R * (2.0 * atan2(t_4, sqrt(((2.0 - fma((cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)), cos(phi1), pow(sin((-0.5 * (phi2 - phi1))), 2.0))) + -1.0))));
} else if ((lambda1 - lambda2) <= 2e-11) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) t_3 = Float64(t_0 + t_2) t_4 = sqrt(t_3) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -4e-8) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(2.0 - fma(Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)), cos(phi1), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0))) + -1.0))))); elseif (Float64(lambda1 - lambda2) <= 2e-11) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_3))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[t$95$3], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -4e-8], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[(2.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 2e-11], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
t_3 := t\_0 + t\_2\\
t_4 := \sqrt{t\_3}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -4 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{\left(2 - \mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right) + -1}}\right)\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -4.0000000000000001e-8Initial program 56.6%
expm1-log1p-u56.6%
+-commutative56.6%
associate-*l*56.6%
fma-undefine56.6%
Applied egg-rr56.6%
Simplified56.7%
div-sub56.6%
sin-diff57.2%
div-inv57.2%
metadata-eval57.2%
div-inv57.2%
metadata-eval57.2%
div-inv57.2%
metadata-eval57.2%
div-inv57.2%
metadata-eval57.2%
Applied egg-rr57.9%
if -4.0000000000000001e-8 < (-.f64 lambda1 lambda2) < 1.99999999999999988e-11Initial program 73.8%
div-sub73.8%
sin-diff74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
Applied egg-rr74.5%
Taylor expanded in lambda2 around 0 74.5%
Taylor expanded in lambda1 around 0 74.5%
*-commutative74.5%
Simplified74.5%
div-sub73.8%
sin-diff74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
div-inv74.5%
metadata-eval74.5%
Applied egg-rr99.0%
if 1.99999999999999988e-11 < (-.f64 lambda1 lambda2) Initial program 51.7%
div-sub51.7%
sin-diff53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
unpow253.1%
sin-mult53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
div-sub53.1%
+-inverses53.1%
cos-053.1%
metadata-eval53.1%
distribute-lft-out53.1%
metadata-eval53.1%
*-rgt-identity53.1%
Simplified53.1%
Final simplification65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* t_0 t_2)))
(t_4 (+ t_1 t_3))
(t_5 (* t_0 (* t_2 t_2))))
(if (<= (- lambda1 lambda2) -1000000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_5))
(sqrt (- (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) t_5)))))
(if (<= (- lambda1 lambda2) 2e-11)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * (t_0 * t_2);
double t_4 = t_1 + t_3;
double t_5 = t_0 * (t_2 * t_2);
double tmp;
if ((lambda1 - lambda2) <= -1000000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_5)), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - t_5))));
} else if ((lambda1 - lambda2) <= 2e-11) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_2 * (t_0 * t_2)
t_4 = t_1 + t_3
t_5 = t_0 * (t_2 * t_2)
if ((lambda1 - lambda2) <= (-1000000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_5)), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - t_5))))
else if ((lambda1 - lambda2) <= 2d-11) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * (t_0 * t_2);
double t_4 = t_1 + t_3;
double t_5 = t_0 * (t_2 * t_2);
double tmp;
if ((lambda1 - lambda2) <= -1000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_5)), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_5))));
} else if ((lambda1 - lambda2) <= 2e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_2 * (t_0 * t_2) t_4 = t_1 + t_3 t_5 = t_0 * (t_2 * t_2) tmp = 0 if (lambda1 - lambda2) <= -1000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_5)), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_5)))) elif (lambda1 - lambda2) <= 2e-11: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(t_0 * t_2)) t_4 = Float64(t_1 + t_3) t_5 = Float64(t_0 * Float64(t_2 * t_2)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_5)), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - t_5))))); elseif (Float64(lambda1 - lambda2) <= 2e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_2 * (t_0 * t_2); t_4 = t_1 + t_3; t_5 = t_0 * (t_2 * t_2); tmp = 0.0; if ((lambda1 - lambda2) <= -1000000000.0) tmp = R * (2.0 * atan2(sqrt((t_1 + t_5)), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - t_5)))); elseif ((lambda1 - lambda2) <= 2e-11) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 + t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$5), $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$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 2e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(t\_0 \cdot t\_2\right)\\
t_4 := t\_1 + t\_3\\
t_5 := t\_0 \cdot \left(t\_2 \cdot t\_2\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_5}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_5}}\right)\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1e9Initial program 56.2%
associate-*l*56.2%
Simplified56.2%
div-sub56.2%
sin-diff56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
Applied egg-rr57.5%
if -1e9 < (-.f64 lambda1 lambda2) < 1.99999999999999988e-11Initial program 74.2%
div-sub74.2%
sin-diff74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
Taylor expanded in lambda2 around 0 74.9%
Taylor expanded in lambda1 around 0 74.9%
*-commutative74.9%
Simplified74.9%
div-sub74.2%
sin-diff74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr99.0%
if 1.99999999999999988e-11 < (-.f64 lambda1 lambda2) Initial program 51.7%
div-sub51.7%
sin-diff53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
unpow253.1%
sin-mult53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
div-sub53.1%
+-inverses53.1%
cos-053.1%
metadata-eval53.1%
distribute-lft-out53.1%
metadata-eval53.1%
*-rgt-identity53.1%
Simplified53.1%
Final simplification65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))
(t_3 (+ t_0 t_2))
(t_4 (sqrt t_3)))
(if (<= (- lambda1 lambda2) -1000000000.0)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(if (<= (- lambda1 lambda2) 2e-11)
(* R (* 2.0 (atan2 t_4 (sqrt (- 1.0 t_0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1);
double t_3 = t_0 + t_2;
double t_4 = sqrt(t_3);
double tmp;
if ((lambda1 - lambda2) <= -1000000000.0) {
tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else if ((lambda1 - lambda2) <= 2e-11) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1)
t_3 = t_0 + t_2
t_4 = sqrt(t_3)
if ((lambda1 - lambda2) <= (-1000000000.0d0)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - (cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
else if ((lambda1 - lambda2) <= 2d-11) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1);
double t_3 = t_0 + t_2;
double t_4 = Math.sqrt(t_3);
double tmp;
if ((lambda1 - lambda2) <= -1000000000.0) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else if ((lambda1 - lambda2) <= 2e-11) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1) t_3 = t_0 + t_2 t_4 = math.sqrt(t_3) tmp = 0 if (lambda1 - lambda2) <= -1000000000.0: tmp = R * (2.0 * math.atan2(t_4, math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))) elif (lambda1 - lambda2) <= 2e-11: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) t_3 = Float64(t_0 + t_2) t_4 = sqrt(t_3) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1000000000.0) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); elseif (Float64(lambda1 - lambda2) <= 2e-11) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1); t_3 = t_0 + t_2; t_4 = sqrt(t_3); tmp = 0.0; if ((lambda1 - lambda2) <= -1000000000.0) tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - (cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); elseif ((lambda1 - lambda2) <= 2e-11) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[t$95$3], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1000000000.0], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 2e-11], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
t_3 := t\_0 + t\_2\\
t_4 := \sqrt{t\_3}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1e9Initial program 56.2%
div-sub56.2%
sin-diff56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
Applied egg-rr56.8%
div-sub56.2%
sin-diff56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
div-inv56.8%
metadata-eval56.8%
Applied egg-rr68.6%
add-cbrt-cube68.6%
pow368.6%
div-inv68.6%
metadata-eval68.6%
Applied egg-rr68.6%
Applied egg-rr57.5%
fma-undefine57.5%
*-lft-identity57.5%
unsub-neg57.5%
distribute-lft-out--57.5%
sub-neg57.5%
mul-1-neg57.5%
mul-1-neg57.5%
sub-neg57.5%
Simplified57.5%
if -1e9 < (-.f64 lambda1 lambda2) < 1.99999999999999988e-11Initial program 74.2%
div-sub74.2%
sin-diff74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr74.9%
Taylor expanded in lambda2 around 0 74.9%
Taylor expanded in lambda1 around 0 74.9%
*-commutative74.9%
Simplified74.9%
div-sub74.2%
sin-diff74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
div-inv74.9%
metadata-eval74.9%
Applied egg-rr99.0%
if 1.99999999999999988e-11 < (-.f64 lambda1 lambda2) Initial program 51.7%
div-sub51.7%
sin-diff53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
unpow253.1%
sin-mult53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
div-inv53.1%
metadata-eval53.1%
Applied egg-rr53.1%
div-sub53.1%
+-inverses53.1%
cos-053.1%
metadata-eval53.1%
distribute-lft-out53.1%
metadata-eval53.1%
*-rgt-identity53.1%
Simplified53.1%
Final simplification65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(fabs
(+
(fma
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(cos phi1)
(pow (sin (* -0.5 (- phi2 phi1))) 2.0))
-1.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(fabs((fma((cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)), cos(phi1), pow(sin((-0.5 * (phi2 - phi1))), 2.0)) + -1.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(abs(Float64(fma(Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)), cos(phi1), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)) + -1.0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|\mathsf{fma}\left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right) + -1\right|}}\right)
\end{array}
\end{array}
Initial program 58.7%
add-sqr-sqrt58.7%
sqrt-unprod59.2%
pow259.2%
Applied egg-rr59.2%
Simplified59.2%
Final simplification59.2%
(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))))
(if (or (<= t_0 -0.14) (not (<= t_0 5e-12)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(expm1 (log1p (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double tmp;
if ((t_0 <= -0.14) || !(t_0 <= 5e-12)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(expm1(log1p((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((t_0 <= -0.14) || !(t_0 <= 5e-12)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.expm1(Math.log1p((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
return tmp;
}
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) tmp = 0 if (t_0 <= -0.14) or not (t_0 <= 5e-12): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.expm1(math.log1p((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) tmp = 0.0 if ((t_0 <= -0.14) || !(t_0 <= 5e-12)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(expm1(log1p(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.14], N[Not[LessEqual[t$95$0, 5e-12]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\mathbf{if}\;t\_0 \leq -0.14 \lor \neg \left(t\_0 \leq 5 \cdot 10^{-12}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.14000000000000001 or 4.9999999999999997e-12 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 53.6%
Taylor expanded in phi1 around 0 41.1%
+-commutative41.1%
associate--r+41.1%
unpow241.1%
1-sub-sin41.1%
unpow241.1%
sub-neg41.1%
mul-1-neg41.1%
+-commutative41.1%
distribute-lft-in41.1%
associate-*r*41.1%
metadata-eval41.1%
metadata-eval41.1%
associate-*r*41.1%
distribute-lft-in41.1%
Simplified41.1%
unpow254.6%
sin-mult54.7%
div-inv54.7%
metadata-eval54.7%
div-inv54.7%
metadata-eval54.7%
div-inv54.7%
metadata-eval54.7%
div-inv54.7%
metadata-eval54.7%
Applied egg-rr41.2%
div-sub54.7%
+-inverses54.7%
cos-054.7%
metadata-eval54.7%
distribute-lft-out54.7%
metadata-eval54.7%
*-rgt-identity54.7%
Simplified41.2%
if -0.14000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 4.9999999999999997e-12Initial program 72.9%
div-sub72.9%
sin-diff73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
div-inv73.6%
metadata-eval73.6%
Applied egg-rr73.6%
Taylor expanded in lambda2 around 0 71.7%
Taylor expanded in lambda1 around 0 70.8%
*-commutative70.8%
Simplified70.8%
expm1-log1p-u70.8%
*-commutative70.8%
*-commutative70.8%
*-commutative70.8%
*-commutative70.8%
sin-diff70.1%
*-commutative70.1%
*-commutative70.1%
*-commutative70.1%
Applied egg-rr70.1%
distribute-lft-out--70.1%
sub-neg70.1%
mul-1-neg70.1%
mul-1-neg70.1%
sub-neg70.1%
Simplified70.1%
Final simplification48.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= t_0 -0.3) (not (<= t_0 0.14)))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(cbrt
(pow
(- 1.0 (pow (sin (- (* phi1 0.5) (* 0.5 phi2))) 2.0))
3.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.14)) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(cbrt(pow((1.0 - pow(sin(((phi1 * 0.5) - (0.5 * phi2))), 2.0)), 3.0)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.14)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.cbrt(Math.pow((1.0 - Math.pow(Math.sin(((phi1 * 0.5) - (0.5 * phi2))), 2.0)), 3.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((t_0 <= -0.3) || !(t_0 <= 0.14)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(cbrt((Float64(1.0 - (sin(Float64(Float64(phi1 * 0.5) - Float64(0.5 * phi2))) ^ 2.0)) ^ 3.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.3], N[Not[LessEqual[t$95$0, 0.14]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Power[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 * 0.5), $MachinePrecision] - N[(0.5 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;t\_0 \leq -0.3 \lor \neg \left(t\_0 \leq 0.14\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{\sqrt[3]{{\left(1 - {\sin \left(\phi_1 \cdot 0.5 - 0.5 \cdot \phi_2\right)}^{2}\right)}^{3}}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.299999999999999989 or 0.14000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 53.0%
Taylor expanded in phi1 around 0 39.9%
+-commutative39.9%
associate--r+39.9%
unpow239.9%
1-sub-sin39.9%
unpow239.9%
sub-neg39.9%
mul-1-neg39.9%
+-commutative39.9%
distribute-lft-in39.9%
associate-*r*39.9%
metadata-eval39.9%
metadata-eval39.9%
associate-*r*39.9%
distribute-lft-in39.9%
Simplified39.9%
Taylor expanded in phi2 around 0 32.5%
if -0.299999999999999989 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.14000000000000001Initial program 69.7%
div-sub69.7%
sin-diff70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
Applied egg-rr70.4%
Taylor expanded in lambda2 around 0 65.0%
Taylor expanded in lambda1 around 0 61.3%
*-commutative61.3%
Simplified61.3%
add-cbrt-cube61.3%
pow361.3%
Applied egg-rr60.6%
Final simplification42.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= t_0 -0.3) (not (<= t_0 0.14)))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(expm1 (log1p (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.14)) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(expm1(log1p((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.14)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.expm1(Math.log1p((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (t_0 <= -0.3) or not (t_0 <= 0.14): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.expm1(math.log1p((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((t_0 <= -0.3) || !(t_0 <= 0.14)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(expm1(log1p(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.3], N[Not[LessEqual[t$95$0, 0.14]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 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 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;t\_0 \leq -0.3 \lor \neg \left(t\_0 \leq 0.14\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.299999999999999989 or 0.14000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 53.0%
Taylor expanded in phi1 around 0 39.9%
+-commutative39.9%
associate--r+39.9%
unpow239.9%
1-sub-sin39.9%
unpow239.9%
sub-neg39.9%
mul-1-neg39.9%
+-commutative39.9%
distribute-lft-in39.9%
associate-*r*39.9%
metadata-eval39.9%
metadata-eval39.9%
associate-*r*39.9%
distribute-lft-in39.9%
Simplified39.9%
Taylor expanded in phi2 around 0 32.5%
if -0.299999999999999989 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.14000000000000001Initial program 69.7%
div-sub69.7%
sin-diff70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
Applied egg-rr70.4%
Taylor expanded in lambda2 around 0 65.0%
Taylor expanded in lambda1 around 0 61.3%
*-commutative61.3%
Simplified61.3%
expm1-log1p-u61.3%
*-commutative61.3%
*-commutative61.3%
*-commutative61.3%
*-commutative61.3%
sin-diff60.6%
*-commutative60.6%
*-commutative60.6%
*-commutative60.6%
Applied egg-rr60.6%
distribute-lft-out--60.6%
sub-neg60.6%
mul-1-neg60.6%
mul-1-neg60.6%
sub-neg60.6%
Simplified60.6%
Final simplification42.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_2
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(t_3 (sqrt t_2)))
(if (<= phi2 -1.1e-19)
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1))))))
(if (<= phi2 3.8e+34)
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = sqrt(t_2);
double tmp;
if (phi2 <= -1.1e-19) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
} else if (phi2 <= 3.8e+34) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_2 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)
t_3 = sqrt(t_2)
if (phi2 <= (-1.1d-19)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))))
else if (phi2 <= 3.8d+34) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = Math.sqrt(t_2);
double tmp;
if (phi2 <= -1.1e-19) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
} else if (phi2 <= 3.8e+34) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_2 = (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_3 = math.sqrt(t_2) tmp = 0 if phi2 <= -1.1e-19: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) elif phi2 <= 3.8e+34: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_2 = Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) t_3 = sqrt(t_2) tmp = 0.0 if (phi2 <= -1.1e-19) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); elseif (phi2 <= 3.8e+34) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_2 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0); t_3 = sqrt(t_2); tmp = 0.0; if (phi2 <= -1.1e-19) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); elseif (phi2 <= 3.8e+34) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); else tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[t$95$2], $MachinePrecision]}, If[LessEqual[phi2, -1.1e-19], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3.8e+34], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_2 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_3 := \sqrt{t\_2}\\
\mathbf{if}\;\phi_2 \leq -1.1 \cdot 10^{-19}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_1}}\right)\\
\mathbf{elif}\;\phi_2 \leq 3.8 \cdot 10^{+34}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -1.0999999999999999e-19Initial program 45.7%
Taylor expanded in phi1 around 0 46.9%
+-commutative46.9%
associate--r+46.9%
unpow246.9%
1-sub-sin47.1%
unpow247.1%
sub-neg47.1%
mul-1-neg47.1%
+-commutative47.1%
distribute-lft-in47.1%
associate-*r*47.1%
metadata-eval47.1%
metadata-eval47.1%
associate-*r*47.1%
distribute-lft-in47.1%
Simplified47.1%
if -1.0999999999999999e-19 < phi2 < 3.8000000000000001e34Initial program 71.0%
Taylor expanded in phi2 around 0 71.4%
+-commutative71.4%
associate--r+71.4%
unpow271.4%
1-sub-sin71.5%
unpow271.5%
sub-neg71.5%
mul-1-neg71.5%
+-commutative71.5%
distribute-lft-in71.5%
associate-*r*71.5%
metadata-eval71.5%
metadata-eval71.5%
associate-*r*71.5%
distribute-lft-in71.5%
Simplified71.5%
if 3.8000000000000001e34 < phi2 Initial program 45.0%
Taylor expanded in phi1 around 0 46.0%
Taylor expanded in phi1 around 0 46.6%
Final simplification59.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 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(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((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), 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((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), 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((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), 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((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), 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(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), 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((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), 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[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[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{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\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 58.7%
unpow259.6%
sin-mult58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
Applied egg-rr58.8%
div-sub58.1%
+-inverses58.1%
cos-058.1%
metadata-eval58.1%
distribute-lft-out58.1%
metadata-eval58.1%
*-rgt-identity58.1%
Simplified58.8%
Final simplification58.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (t_1 + pow(sin(((phi1 - phi2) / 2.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
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (t_1 + (sin(((phi1 - phi2) / 2.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 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - (t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 58.7%
unpow259.6%
sin-mult58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
Applied egg-rr57.2%
div-sub58.1%
+-inverses58.1%
cos-058.1%
metadata-eval58.1%
distribute-lft-out58.1%
metadata-eval58.1%
*-rgt-identity58.1%
Simplified57.2%
Final simplification57.2%
(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 (+ (- 0.5 (/ (cos (- phi1 phi2)) 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(((0.5 - (cos((phi1 - phi2)) / 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(((0.5d0 - (cos((phi1 - phi2)) / 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(((0.5 - (Math.cos((phi1 - phi2)) / 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(((0.5 - (math.cos((phi1 - phi2)) / 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(0.5 - Float64(cos(Float64(phi1 - phi2)) / 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(((0.5 - (cos((phi1 - phi2)) / 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[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $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(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + 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 58.7%
associate-*l*58.7%
Simplified58.7%
unpow259.6%
sin-mult58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
Applied egg-rr57.1%
div-sub58.1%
+-inverses58.1%
cos-058.1%
metadata-eval58.1%
distribute-lft-out58.1%
metadata-eval58.1%
*-rgt-identity58.1%
Simplified57.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= phi1 -4.1e-10) (not (<= phi1 0.0066)))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 lambda1)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((phi1 <= -4.1e-10) || !(phi1 <= 0.0066)) {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((0.5 * lambda1)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if ((phi1 <= (-4.1d-10)) .or. (.not. (phi1 <= 0.0066d0))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((phi1 <= -4.1e-10) || !(phi1 <= 0.0066)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (phi1 <= -4.1e-10) or not (phi1 <= 0.0066): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((phi1 <= -4.1e-10) || !(phi1 <= 0.0066)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if ((phi1 <= -4.1e-10) || ~((phi1 <= 0.0066))) tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((0.5 * lambda1)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -4.1e-10], N[Not[LessEqual[phi1, 0.0066]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\phi_1 \leq -4.1 \cdot 10^{-10} \lor \neg \left(\phi_1 \leq 0.0066\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -4.0999999999999998e-10 or 0.0066 < phi1 Initial program 45.8%
div-sub45.8%
sin-diff47.4%
div-inv47.4%
metadata-eval47.4%
div-inv47.4%
metadata-eval47.4%
div-inv47.4%
metadata-eval47.4%
div-inv47.4%
metadata-eval47.4%
Applied egg-rr47.4%
Taylor expanded in lambda2 around 0 36.6%
Taylor expanded in phi2 around 0 36.0%
+-commutative36.0%
associate--r+36.0%
unpow236.0%
*-commutative36.0%
*-commutative36.0%
1-sub-sin36.1%
*-commutative36.1%
*-commutative36.1%
unpow236.1%
Simplified36.1%
if -4.0999999999999998e-10 < phi1 < 0.0066Initial program 75.5%
Taylor expanded in phi1 around 0 75.5%
+-commutative75.5%
associate--r+75.5%
unpow275.5%
1-sub-sin75.7%
unpow275.7%
sub-neg75.7%
mul-1-neg75.7%
+-commutative75.7%
distribute-lft-in75.7%
associate-*r*75.7%
metadata-eval75.7%
metadata-eval75.7%
associate-*r*75.7%
distribute-lft-in75.7%
Simplified75.7%
Final simplification53.2%
(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)))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_3 (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(t_4 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2)))))
(if (<= phi2 -1.1e-19)
(* R (* 2.0 (atan2 t_3 t_4)))
(if (<= phi2 3.8e+34)
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2))))))
(*
R
(* 2.0 (atan2 (sqrt (+ t_1 (pow (sin (* phi2 -0.5)) 2.0))) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_4 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)));
double tmp;
if (phi2 <= -1.1e-19) {
tmp = R * (2.0 * atan2(t_3, t_4));
} else if (phi2 <= 3.8e+34) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi2 * -0.5)), 2.0))), t_4));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_3 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
t_4 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))
if (phi2 <= (-1.1d-19)) then
tmp = r * (2.0d0 * atan2(t_3, t_4))
else if (phi2 <= 3.8d+34) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_2)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double t_4 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)));
double tmp;
if (phi2 <= -1.1e-19) {
tmp = R * (2.0 * Math.atan2(t_3, t_4));
} else if (phi2 <= 3.8e+34) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), t_4));
}
return tmp;
}
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) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_3 = math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) t_4 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))) tmp = 0 if phi2 <= -1.1e-19: tmp = R * (2.0 * math.atan2(t_3, t_4)) elif phi2 <= 3.8e+34: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_2))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi2 * -0.5)), 2.0))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_3 = sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) t_4 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2))) tmp = 0.0 if (phi2 <= -1.1e-19) tmp = Float64(R * Float64(2.0 * atan(t_3, t_4))); elseif (phi2 <= 3.8e+34) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_3 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); t_4 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))); tmp = 0.0; if (phi2 <= -1.1e-19) tmp = R * (2.0 * atan2(t_3, t_4)); elseif (phi2 <= 3.8e+34) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_2))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi2 * -0.5)) ^ 2.0))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.1e-19], N[(R * N[(2.0 * N[ArcTan[t$95$3 / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3.8e+34], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $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)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_3 := \sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
t_4 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_2}\\
\mathbf{if}\;\phi_2 \leq -1.1 \cdot 10^{-19}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{t\_4}\right)\\
\mathbf{elif}\;\phi_2 \leq 3.8 \cdot 10^{+34}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{t\_4}\right)\\
\end{array}
\end{array}
if phi2 < -1.0999999999999999e-19Initial program 45.7%
Taylor expanded in phi1 around 0 46.9%
+-commutative46.9%
associate--r+46.9%
unpow246.9%
1-sub-sin47.1%
unpow247.1%
sub-neg47.1%
mul-1-neg47.1%
+-commutative47.1%
distribute-lft-in47.1%
associate-*r*47.1%
metadata-eval47.1%
metadata-eval47.1%
associate-*r*47.1%
distribute-lft-in47.1%
Simplified47.1%
if -1.0999999999999999e-19 < phi2 < 3.8000000000000001e34Initial program 71.0%
Taylor expanded in phi2 around 0 71.4%
+-commutative71.4%
associate--r+71.4%
unpow271.4%
1-sub-sin71.5%
unpow271.5%
sub-neg71.5%
mul-1-neg71.5%
+-commutative71.5%
distribute-lft-in71.5%
associate-*r*71.5%
metadata-eval71.5%
metadata-eval71.5%
associate-*r*71.5%
distribute-lft-in71.5%
Simplified71.5%
if 3.8000000000000001e34 < phi2 Initial program 45.0%
Taylor expanded in phi1 around 0 45.1%
+-commutative45.1%
associate--r+45.1%
unpow245.1%
1-sub-sin45.2%
unpow245.2%
sub-neg45.2%
mul-1-neg45.2%
+-commutative45.2%
distribute-lft-in45.2%
associate-*r*45.2%
metadata-eval45.2%
metadata-eval45.2%
associate-*r*45.2%
distribute-lft-in45.2%
Simplified45.2%
Taylor expanded in phi1 around 0 45.5%
Final simplification59.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(if (or (<= phi1 -1.4e-14) (not (<= phi1 4.3e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 lambda1)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double tmp;
if ((phi1 <= -1.4e-14) || !(phi1 <= 4.3e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((0.5 * lambda1)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
if ((phi1 <= (-1.4d-14)) .or. (.not. (phi1 <= 4.3d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((phi1 <= -1.4e-14) || !(phi1 <= 4.3e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
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) tmp = 0 if (phi1 <= -1.4e-14) or not (phi1 <= 4.3e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
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)) tmp = 0.0 if ((phi1 <= -1.4e-14) || !(phi1 <= 4.3e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = 0.0; if ((phi1 <= -1.4e-14) || ~((phi1 <= 4.3e-5))) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((0.5 * lambda1)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -1.4e-14], N[Not[LessEqual[phi1, 4.3e-5]], $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[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\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)\\
\mathbf{if}\;\phi_1 \leq -1.4 \cdot 10^{-14} \lor \neg \left(\phi_1 \leq 4.3 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -1.4e-14 or 4.3000000000000002e-5 < phi1 Initial program 46.2%
div-sub46.2%
sin-diff47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
Applied egg-rr47.7%
Taylor expanded in lambda2 around 0 37.1%
Taylor expanded in phi2 around 0 36.5%
+-commutative36.5%
associate--r+36.5%
unpow236.5%
*-commutative36.5%
*-commutative36.5%
1-sub-sin36.5%
*-commutative36.5%
*-commutative36.5%
unpow236.5%
Simplified36.5%
if -1.4e-14 < phi1 < 4.3000000000000002e-5Initial program 75.3%
Taylor expanded in phi1 around 0 75.3%
+-commutative75.3%
associate--r+75.3%
unpow275.3%
1-sub-sin75.5%
unpow275.5%
sub-neg75.5%
mul-1-neg75.5%
+-commutative75.5%
distribute-lft-in75.5%
associate-*r*75.5%
metadata-eval75.5%
metadata-eval75.5%
associate-*r*75.5%
distribute-lft-in75.5%
Simplified75.5%
Taylor expanded in phi1 around 0 74.3%
Final simplification52.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= t_0 -0.3) (not (<= t_0 0.14)))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt (+ -1.0 (- 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));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.14)) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((-1.0 + (2.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if ((t_0 <= (-0.3d0)) .or. (.not. (t_0 <= 0.14d0))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((-1.0d0) + (2.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.14)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((-1.0 + (2.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (t_0 <= -0.3) or not (t_0 <= 0.14): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((-1.0 + (2.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((t_0 <= -0.3) || !(t_0 <= 0.14)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(-1.0 + Float64(2.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if ((t_0 <= -0.3) || ~((t_0 <= 0.14))) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_1, sqrt((-1.0 + (2.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.3], N[Not[LessEqual[t$95$0, 0.14]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(-1.0 + N[(2.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;t\_0 \leq -0.3 \lor \neg \left(t\_0 \leq 0.14\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{-1 + \left(2 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.299999999999999989 or 0.14000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 53.0%
Taylor expanded in phi1 around 0 39.9%
+-commutative39.9%
associate--r+39.9%
unpow239.9%
1-sub-sin39.9%
unpow239.9%
sub-neg39.9%
mul-1-neg39.9%
+-commutative39.9%
distribute-lft-in39.9%
associate-*r*39.9%
metadata-eval39.9%
metadata-eval39.9%
associate-*r*39.9%
distribute-lft-in39.9%
Simplified39.9%
Taylor expanded in phi2 around 0 32.5%
if -0.299999999999999989 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.14000000000000001Initial program 69.7%
div-sub69.7%
sin-diff70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
div-inv70.4%
metadata-eval70.4%
Applied egg-rr70.4%
Taylor expanded in lambda2 around 0 65.0%
Taylor expanded in lambda1 around 0 61.3%
*-commutative61.3%
Simplified61.3%
expm1-log1p-u61.3%
*-commutative61.3%
*-commutative61.3%
*-commutative61.3%
*-commutative61.3%
sin-diff60.6%
*-commutative60.6%
*-commutative60.6%
*-commutative60.6%
Applied egg-rr60.6%
expm1-undefine60.6%
sub-neg60.6%
log1p-undefine60.5%
rem-exp-log60.5%
associate-+r-60.5%
metadata-eval60.5%
distribute-lft-out--60.5%
sub-neg60.5%
mul-1-neg60.5%
mul-1-neg60.5%
sub-neg60.5%
metadata-eval60.5%
Simplified60.5%
Final simplification42.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= t_0 -0.3) (not (<= t_0 0.01)))
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* 0.5 phi2)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.01)) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((0.5 * phi2)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if ((t_0 <= (-0.3d0)) .or. (.not. (t_0 <= 0.01d0))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((0.5d0 * phi2)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((t_0 <= -0.3) || !(t_0 <= 0.01)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((0.5 * phi2)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (t_0 <= -0.3) or not (t_0 <= 0.01): tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((0.5 * phi2)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((t_0 <= -0.3) || !(t_0 <= 0.01)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(0.5 * phi2)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if ((t_0 <= -0.3) || ~((t_0 <= 0.01))) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((0.5 * phi2)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.3], N[Not[LessEqual[t$95$0, 0.01]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;t\_0 \leq -0.3 \lor \neg \left(t\_0 \leq 0.01\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(0.5 \cdot \phi_2\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.299999999999999989 or 0.0100000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 53.4%
Taylor expanded in phi1 around 0 40.3%
+-commutative40.3%
associate--r+40.3%
unpow240.3%
1-sub-sin40.3%
unpow240.3%
sub-neg40.3%
mul-1-neg40.3%
+-commutative40.3%
distribute-lft-in40.3%
associate-*r*40.3%
metadata-eval40.3%
metadata-eval40.3%
associate-*r*40.3%
distribute-lft-in40.3%
Simplified40.3%
Taylor expanded in phi2 around 0 32.0%
if -0.299999999999999989 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.0100000000000000002Initial program 71.5%
div-sub71.5%
sin-diff72.1%
div-inv72.1%
metadata-eval72.1%
div-inv72.1%
metadata-eval72.1%
div-inv72.1%
metadata-eval72.1%
div-inv72.1%
metadata-eval72.1%
Applied egg-rr72.1%
Taylor expanded in lambda2 around 0 67.6%
Taylor expanded in lambda1 around 0 66.7%
*-commutative66.7%
Simplified66.7%
Taylor expanded in phi1 around 0 51.3%
unpow251.3%
1-sub-sin51.4%
unpow251.4%
Simplified51.4%
Final simplification37.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= phi1 -0.045) (not (<= phi1 1.14e-5)))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* phi1 0.5)) 2.0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* 0.5 phi2)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((phi1 <= -0.045) || !(phi1 <= 1.14e-5)) {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((0.5 * phi2)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if ((phi1 <= (-0.045d0)) .or. (.not. (phi1 <= 1.14d-5))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((0.5d0 * phi2)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((phi1 <= -0.045) || !(phi1 <= 1.14e-5)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((0.5 * phi2)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (phi1 <= -0.045) or not (phi1 <= 1.14e-5): tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((0.5 * phi2)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((phi1 <= -0.045) || !(phi1 <= 1.14e-5)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(0.5 * phi2)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if ((phi1 <= -0.045) || ~((phi1 <= 1.14e-5))) tmp = R * (2.0 * atan2(t_1, sqrt((cos((phi1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((0.5 * phi2)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.045], N[Not[LessEqual[phi1, 1.14e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\phi_1 \leq -0.045 \lor \neg \left(\phi_1 \leq 1.14 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(0.5 \cdot \phi_2\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -0.044999999999999998 or 1.1399999999999999e-5 < phi1 Initial program 45.9%
div-sub45.9%
sin-diff47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
div-inv47.5%
metadata-eval47.5%
Applied egg-rr47.5%
Taylor expanded in lambda2 around 0 36.5%
Taylor expanded in lambda1 around 0 28.6%
*-commutative28.6%
Simplified28.6%
Taylor expanded in phi2 around 0 27.9%
unpow227.9%
1-sub-sin27.9%
unpow227.9%
Simplified27.9%
if -0.044999999999999998 < phi1 < 1.1399999999999999e-5Initial program 74.3%
div-sub74.3%
sin-diff74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
div-inv74.4%
metadata-eval74.4%
Applied egg-rr74.4%
Taylor expanded in lambda2 around 0 57.1%
Taylor expanded in lambda1 around 0 41.5%
*-commutative41.5%
Simplified41.5%
Taylor expanded in phi1 around 0 41.5%
unpow241.5%
1-sub-sin41.6%
unpow241.6%
Simplified41.6%
Final simplification34.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (pow (cos (* phi1 0.5)) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(pow(cos((phi1 * 0.5)), 2.0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos((phi1 * 0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 58.7%
div-sub58.7%
sin-diff59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
div-inv59.6%
metadata-eval59.6%
Applied egg-rr59.6%
Taylor expanded in lambda2 around 0 45.7%
Taylor expanded in lambda1 around 0 34.4%
*-commutative34.4%
Simplified34.4%
Taylor expanded in phi2 around 0 28.0%
unpow228.0%
1-sub-sin28.0%
unpow228.0%
Simplified28.0%
Final simplification28.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5))) (t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi1 -1.2e-14)
(*
R
(*
2.0
(atan2
(* (* phi1 -0.5) t_0)
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
(* phi1 (+ (* 0.5 t_0) (/ (sin (* phi2 -0.5)) phi1)))
(sqrt
(-
1.0
(+
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -1.2e-14) {
tmp = R * (2.0 * atan2(((phi1 * -0.5) * t_0), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2((phi1 * ((0.5 * t_0) + (sin((phi2 * -0.5)) / phi1))), sqrt((1.0 - ((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0)))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi1 <= (-1.2d-14)) then
tmp = r * (2.0d0 * atan2(((phi1 * (-0.5d0)) * t_0), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2((phi1 * ((0.5d0 * t_0) + (sin((phi2 * (-0.5d0))) / phi1))), sqrt((1.0d0 - ((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 * -0.5));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -1.2e-14) {
tmp = R * (2.0 * Math.atan2(((phi1 * -0.5) * t_0), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2((phi1 * ((0.5 * t_0) + (Math.sin((phi2 * -0.5)) / phi1))), Math.sqrt((1.0 - ((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi1 <= -1.2e-14: tmp = R * (2.0 * math.atan2(((phi1 * -0.5) * t_0), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2((phi1 * ((0.5 * t_0) + (math.sin((phi2 * -0.5)) / phi1))), math.sqrt((1.0 - ((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi1 <= -1.2e-14) tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(phi1 * -0.5) * t_0), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(Float64(0.5 * t_0) + Float64(sin(Float64(phi2 * -0.5)) / phi1))), sqrt(Float64(1.0 - Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi1 <= -1.2e-14) tmp = R * (2.0 * atan2(((phi1 * -0.5) * t_0), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2((phi1 * ((0.5 * t_0) + (sin((phi2 * -0.5)) / phi1))), sqrt((1.0 - ((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.2e-14], N[(R * N[(2.0 * N[ArcTan[N[(N[(phi1 * -0.5), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(N[(0.5 * t$95$0), $MachinePrecision] + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1.2 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\left(\phi_1 \cdot -0.5\right) \cdot t\_0}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(0.5 \cdot t\_0 + \frac{\sin \left(\phi_2 \cdot -0.5\right)}{\phi_1}\right)}{\sqrt{1 - \left(t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.2e-14Initial program 48.0%
Taylor expanded in phi1 around 0 19.9%
Taylor expanded in phi1 around -inf 14.6%
associate-*r*14.6%
*-commutative14.6%
Simplified14.6%
Taylor expanded in phi1 around 0 14.9%
+-commutative21.6%
associate--r+21.6%
unpow221.6%
1-sub-sin21.6%
unpow221.6%
sub-neg21.6%
mul-1-neg21.6%
+-commutative21.6%
distribute-lft-in21.6%
associate-*r*21.6%
metadata-eval21.6%
metadata-eval21.6%
associate-*r*21.6%
distribute-lft-in21.6%
Simplified14.9%
Taylor expanded in phi2 around 0 14.9%
if -1.2e-14 < phi1 Initial program 63.3%
Taylor expanded in phi1 around 0 53.2%
Taylor expanded in phi1 around inf 15.5%
Final simplification15.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(* phi1 (- (/ (sin (* phi2 -0.5)) (- phi1)) (* 0.5 (cos (* phi2 -0.5)))))
(sqrt
(-
1.0
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2((phi1 * ((sin((phi2 * -0.5)) / -phi1) - (0.5 * cos((phi2 * -0.5))))), sqrt((1.0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2((phi1 * ((sin((phi2 * (-0.5d0))) / -phi1) - (0.5d0 * cos((phi2 * (-0.5d0)))))), sqrt((1.0d0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.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));
return R * (2.0 * Math.atan2((phi1 * ((Math.sin((phi2 * -0.5)) / -phi1) - (0.5 * Math.cos((phi2 * -0.5))))), Math.sqrt((1.0 - ((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2((phi1 * ((math.sin((phi2 * -0.5)) / -phi1) - (0.5 * math.cos((phi2 * -0.5))))), math.sqrt((1.0 - ((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 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(Float64(phi1 * Float64(Float64(sin(Float64(phi2 * -0.5)) / Float64(-phi1)) - Float64(0.5 * cos(Float64(phi2 * -0.5))))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2((phi1 * ((sin((phi2 * -0.5)) / -phi1) - (0.5 * cos((phi2 * -0.5))))), sqrt((1.0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] / (-phi1)), $MachinePrecision] - N[(0.5 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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{\phi_1 \cdot \left(\frac{\sin \left(\phi_2 \cdot -0.5\right)}{-\phi_1} - 0.5 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{1 - \left(t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 58.7%
Taylor expanded in phi1 around 0 43.2%
Taylor expanded in phi1 around -inf 14.1%
Final simplification14.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5))) (t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi1 -1.8e-249)
(*
R
(*
2.0
(atan2
(* (* phi1 -0.5) t_0)
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
(* (* phi1 0.5) t_0)
(sqrt
(-
1.0
(+
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -1.8e-249) {
tmp = R * (2.0 * atan2(((phi1 * -0.5) * t_0), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(((phi1 * 0.5) * t_0), sqrt((1.0 - ((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0)))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi1 <= (-1.8d-249)) then
tmp = r * (2.0d0 * atan2(((phi1 * (-0.5d0)) * t_0), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(((phi1 * 0.5d0) * t_0), sqrt((1.0d0 - ((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 * -0.5));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -1.8e-249) {
tmp = R * (2.0 * Math.atan2(((phi1 * -0.5) * t_0), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(((phi1 * 0.5) * t_0), Math.sqrt((1.0 - ((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi1 <= -1.8e-249: tmp = R * (2.0 * math.atan2(((phi1 * -0.5) * t_0), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(((phi1 * 0.5) * t_0), math.sqrt((1.0 - ((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi1 <= -1.8e-249) tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(phi1 * -0.5) * t_0), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(phi1 * 0.5) * t_0), sqrt(Float64(1.0 - Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi1 <= -1.8e-249) tmp = R * (2.0 * atan2(((phi1 * -0.5) * t_0), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(((phi1 * 0.5) * t_0), sqrt((1.0 - ((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.8e-249], N[(R * N[(2.0 * N[ArcTan[N[(N[(phi1 * -0.5), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(phi1 * 0.5), $MachinePrecision] * t$95$0), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1.8 \cdot 10^{-249}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\left(\phi_1 \cdot -0.5\right) \cdot t\_0}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\left(\phi_1 \cdot 0.5\right) \cdot t\_0}{\sqrt{1 - \left(t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.79999999999999997e-249Initial program 59.7%
Taylor expanded in phi1 around 0 42.0%
Taylor expanded in phi1 around -inf 13.0%
associate-*r*13.0%
*-commutative13.0%
Simplified13.0%
Taylor expanded in phi1 around 0 13.1%
+-commutative43.1%
associate--r+43.1%
unpow243.1%
1-sub-sin43.2%
unpow243.2%
sub-neg43.2%
mul-1-neg43.2%
+-commutative43.2%
distribute-lft-in43.2%
associate-*r*43.2%
metadata-eval43.2%
metadata-eval43.2%
associate-*r*43.2%
distribute-lft-in43.2%
Simplified13.1%
Taylor expanded in phi2 around 0 13.1%
if -1.79999999999999997e-249 < phi1 Initial program 57.8%
Taylor expanded in phi1 around 0 44.2%
Taylor expanded in phi1 around inf 9.3%
associate-*r*9.3%
*-commutative9.3%
Simplified9.3%
Final simplification11.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* (* phi1 -0.5) (cos (* phi2 -0.5)))
(sqrt
(- 1.0 (* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(((phi1 * -0.5) * cos((phi2 * -0.5))), sqrt((1.0 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 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(((phi1 * (-0.5d0)) * cos((phi2 * (-0.5d0)))), sqrt((1.0d0 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(((phi1 * -0.5) * Math.cos((phi2 * -0.5))), Math.sqrt((1.0 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(((phi1 * -0.5) * math.cos((phi2 * -0.5))), math.sqrt((1.0 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(Float64(phi1 * -0.5) * cos(Float64(phi2 * -0.5))), sqrt(Float64(1.0 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(((phi1 * -0.5) * cos((phi2 * -0.5))), sqrt((1.0 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(N[(phi1 * -0.5), $MachinePrecision] * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\left(\phi_1 \cdot -0.5\right) \cdot \cos \left(\phi_2 \cdot -0.5\right)}{\sqrt{1 - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 58.7%
Taylor expanded in phi1 around 0 43.2%
Taylor expanded in phi1 around -inf 8.7%
associate-*r*8.7%
*-commutative8.7%
Simplified8.7%
Taylor expanded in phi1 around 0 9.0%
+-commutative44.4%
associate--r+44.3%
unpow244.3%
1-sub-sin44.4%
unpow244.4%
sub-neg44.4%
mul-1-neg44.4%
+-commutative44.4%
distribute-lft-in44.4%
associate-*r*44.4%
metadata-eval44.4%
metadata-eval44.4%
associate-*r*44.4%
distribute-lft-in44.4%
Simplified9.0%
Taylor expanded in phi2 around 0 9.0%
Final simplification9.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* (* phi1 -0.5) (cos (* phi2 -0.5)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(((phi1 * -0.5) * cos((phi2 * -0.5))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 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(((phi1 * (-0.5d0)) * cos((phi2 * (-0.5d0)))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(((phi1 * -0.5) * Math.cos((phi2 * -0.5))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(((phi1 * -0.5) * math.cos((phi2 * -0.5))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(Float64(phi1 * -0.5) * cos(Float64(phi2 * -0.5))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(((phi1 * -0.5) * cos((phi2 * -0.5))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(N[(phi1 * -0.5), $MachinePrecision] * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\left(\phi_1 \cdot -0.5\right) \cdot \cos \left(\phi_2 \cdot -0.5\right)}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 58.7%
Taylor expanded in phi1 around 0 43.2%
Taylor expanded in phi1 around -inf 8.7%
associate-*r*8.7%
*-commutative8.7%
Simplified8.7%
Taylor expanded in phi1 around 0 9.0%
+-commutative44.4%
associate--r+44.3%
unpow244.3%
1-sub-sin44.4%
unpow244.4%
sub-neg44.4%
mul-1-neg44.4%
+-commutative44.4%
distribute-lft-in44.4%
associate-*r*44.4%
metadata-eval44.4%
metadata-eval44.4%
associate-*r*44.4%
distribute-lft-in44.4%
Simplified9.0%
Taylor expanded in phi2 around 0 9.0%
Final simplification9.0%
herbie shell --seed 2024108
(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))))))))))