
(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 23 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)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(+
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))
(pow
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))))
(if (or (<= lambda2 -2.5e-6) (not (<= lambda2 1.75e-7)))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
t_0))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)));
double tmp;
if ((lambda2 <= -2.5e-6) || !(lambda2 <= 1.75e-7)) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + t_0)))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)))
if ((lambda2 <= (-2.5d-6)) .or. (.not. (lambda2 <= 1.75d-7))) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))) + t_0)))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt(((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + Math.pow(((Math.cos((phi2 / 2.0)) * Math.sin((phi1 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)));
double tmp;
if ((lambda2 <= -2.5e-6) || !(lambda2 <= 1.75e-7)) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))) + t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt(((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + math.pow(((math.cos((phi2 / 2.0)) * math.sin((phi1 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0))) tmp = 0 if (lambda2 <= -2.5e-6) or not (lambda2 <= 1.75e-7): tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) + t_0))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + (Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0))) tmp = 0.0 if ((lambda2 <= -2.5e-6) || !(lambda2 <= 1.75e-7)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0))); tmp = 0.0; if ((lambda2 <= -2.5e-6) || ~((lambda2 <= 1.75e-7))) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))) + t_0))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -2.5e-6], N[Not[LessEqual[lambda2, 1.75e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + {\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq -2.5 \cdot 10^{-6} \lor \neg \left(\lambda_2 \leq 1.75 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -2.5000000000000002e-6 or 1.74999999999999992e-7 < lambda2 Initial program 51.0%
div-sub51.0%
sin-diff51.9%
Applied egg-rr51.9%
div-sub51.0%
sin-diff51.9%
Applied egg-rr59.8%
fma-neg59.8%
distribute-rgt-neg-in59.8%
Simplified59.8%
Taylor expanded in lambda1 around 0 59.9%
if -2.5000000000000002e-6 < lambda2 < 1.74999999999999992e-7Initial program 72.5%
div-sub72.5%
sin-diff73.7%
Applied egg-rr73.7%
div-sub72.5%
sin-diff73.7%
Applied egg-rr98.3%
fma-neg98.3%
distribute-rgt-neg-in98.3%
Simplified98.3%
Taylor expanded in lambda2 around 0 98.3%
Final simplification79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (/ phi2 2.0)))
(t_1 (cos (/ phi1 2.0)))
(t_2 (sin (/ phi2 2.0)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (- (* (log1p (expm1 (sin (* phi1 0.5)))) t_0) (* t_1 t_2)) 2.0)
t_4))
(sqrt
(-
1.0
(+ t_4 (pow (fma (sin (/ phi1 2.0)) t_0 (* t_1 (- t_2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 / 2.0));
double t_1 = cos((phi1 / 2.0));
double t_2 = sin((phi2 / 2.0));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
return R * (2.0 * atan2(sqrt((pow(((log1p(expm1(sin((phi1 * 0.5)))) * t_0) - (t_1 * t_2)), 2.0) + t_4)), sqrt((1.0 - (t_4 + pow(fma(sin((phi1 / 2.0)), t_0, (t_1 * -t_2)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 / 2.0)) t_1 = cos(Float64(phi1 / 2.0)) t_2 = sin(Float64(phi2 / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(log1p(expm1(sin(Float64(phi1 * 0.5)))) * t_0) - Float64(t_1 * t_2)) ^ 2.0) + t_4)), sqrt(Float64(1.0 - Float64(t_4 + (fma(sin(Float64(phi1 / 2.0)), t_0, Float64(t_1 * Float64(-t_2))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Log[1 + N[(Exp[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * t$95$0 + N[(t$95$1 * (-t$95$2)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\frac{\phi_2}{2}\right)\\
t_1 := \cos \left(\frac{\phi_1}{2}\right)\\
t_2 := \sin \left(\frac{\phi_2}{2}\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(\phi_1 \cdot 0.5\right)\right)\right) \cdot t\_0 - t\_1 \cdot t\_2\right)}^{2} + t\_4}}{\sqrt{1 - \left(t\_4 + {\left(\mathsf{fma}\left(\sin \left(\frac{\phi_1}{2}\right), t\_0, t\_1 \cdot \left(-t\_2\right)\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr79.7%
fma-neg79.7%
distribute-rgt-neg-in79.7%
Simplified79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
log1p-expm1-u79.7%
*-commutative79.7%
Applied egg-rr79.7%
Final simplification79.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)))
(t_2 (sin (/ phi1 2.0)))
(t_3 (cos (/ phi2 2.0)))
(t_4 (cos (/ phi1 2.0)))
(t_5 (/ (cos (- phi1 phi2)) 2.0))
(t_6 (sin (/ phi2 2.0)))
(t_7 (sqrt (+ t_1 (pow (- (* t_3 t_2) (* t_4 t_6)) 2.0)))))
(if (<= lambda1 -0.92)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 t_5)))
(sqrt (- 1.0 (+ t_1 (pow (fma t_2 t_3 (* t_4 (- t_6))) 2.0)))))))
(if (<= lambda1 3800.0)
(*
R
(*
2.0
(atan2
t_7
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)))))))
(* R (* 2.0 (atan2 t_7 (sqrt (+ 1.0 (- (- t_5 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);
double t_2 = sin((phi1 / 2.0));
double t_3 = cos((phi2 / 2.0));
double t_4 = cos((phi1 / 2.0));
double t_5 = cos((phi1 - phi2)) / 2.0;
double t_6 = sin((phi2 / 2.0));
double t_7 = sqrt((t_1 + pow(((t_3 * t_2) - (t_4 * t_6)), 2.0)));
double tmp;
if (lambda1 <= -0.92) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - t_5))), sqrt((1.0 - (t_1 + pow(fma(t_2, t_3, (t_4 * -t_6)), 2.0))))));
} else if (lambda1 <= 3800.0) {
tmp = R * (2.0 * atan2(t_7, sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_7, sqrt((1.0 + ((t_5 - 0.5) - t_1)))));
}
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(phi1 / 2.0)) t_3 = cos(Float64(phi2 / 2.0)) t_4 = cos(Float64(phi1 / 2.0)) t_5 = Float64(cos(Float64(phi1 - phi2)) / 2.0) t_6 = sin(Float64(phi2 / 2.0)) t_7 = sqrt(Float64(t_1 + (Float64(Float64(t_3 * t_2) - Float64(t_4 * t_6)) ^ 2.0))) tmp = 0.0 if (lambda1 <= -0.92) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - t_5))), sqrt(Float64(1.0 - Float64(t_1 + (fma(t_2, t_3, Float64(t_4 * Float64(-t_6))) ^ 2.0))))))); elseif (lambda1 <= 3800.0) tmp = Float64(R * Float64(2.0 * atan(t_7, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_7, sqrt(Float64(1.0 + Float64(Float64(t_5 - 0.5) - t_1)))))); 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]}, Block[{t$95$2 = N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$6 = N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Sqrt[N[(t$95$1 + N[Power[N[(N[(t$95$3 * t$95$2), $MachinePrecision] - N[(t$95$4 * t$95$6), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -0.92], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[(t$95$2 * t$95$3 + N[(t$95$4 * (-t$95$6)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 3800.0], N[(R * N[(2.0 * N[ArcTan[t$95$7 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$7 / N[Sqrt[N[(1.0 + N[(N[(t$95$5 - 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)\\
t_2 := \sin \left(\frac{\phi_1}{2}\right)\\
t_3 := \cos \left(\frac{\phi_2}{2}\right)\\
t_4 := \cos \left(\frac{\phi_1}{2}\right)\\
t_5 := \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\\
t_6 := \sin \left(\frac{\phi_2}{2}\right)\\
t_7 := \sqrt{t\_1 + {\left(t\_3 \cdot t\_2 - t\_4 \cdot t\_6\right)}^{2}}\\
\mathbf{if}\;\lambda_1 \leq -0.92:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - t\_5\right)}}{\sqrt{1 - \left(t\_1 + {\left(\mathsf{fma}\left(t\_2, t\_3, t\_4 \cdot \left(-t\_6\right)\right)\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 3800:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_7}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_7}{\sqrt{1 + \left(\left(t\_5 - 0.5\right) - t\_1\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -0.92000000000000004Initial program 52.0%
div-sub52.0%
sin-diff52.2%
Applied egg-rr52.2%
div-sub52.0%
sin-diff52.2%
Applied egg-rr59.9%
fma-neg59.9%
distribute-rgt-neg-in59.9%
Simplified59.9%
sin-diff53.0%
div-sub53.0%
div-inv53.0%
metadata-eval53.0%
expm1-log1p-u28.4%
unpow228.4%
sin-mult28.4%
Applied egg-rr53.0%
div-sub53.0%
+-inverses53.0%
+-inverses47.8%
+-inverses53.0%
cos-053.0%
metadata-eval53.0%
distribute-lft-out53.0%
metadata-eval53.0%
*-rgt-identity53.0%
Simplified53.0%
if -0.92000000000000004 < lambda1 < 3800Initial program 76.0%
div-sub76.0%
sin-diff76.9%
Applied egg-rr76.9%
div-sub76.0%
sin-diff76.9%
Applied egg-rr97.6%
fma-neg97.6%
distribute-rgt-neg-in97.6%
Simplified97.6%
Taylor expanded in lambda1 around 0 96.9%
if 3800 < lambda1 Initial program 44.1%
div-sub44.1%
sin-diff45.8%
Applied egg-rr45.8%
unpow245.8%
sin-mult45.9%
div-inv45.9%
metadata-eval45.9%
div-inv45.9%
metadata-eval45.9%
div-inv45.9%
metadata-eval45.9%
div-inv45.9%
metadata-eval45.9%
Applied egg-rr45.9%
div-sub45.9%
+-inverses45.9%
cos-045.9%
metadata-eval45.9%
distribute-lft-out45.9%
metadata-eval45.9%
*-rgt-identity45.9%
Simplified45.9%
Final simplification73.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_2)) (sqrt (- (- 1.0 t_0) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
return R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
code = r * (2.0d0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0d0 - t_0) - t_2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((phi2 / 2.0)) * Math.sin((phi1 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt(((1.0 - t_0) - t_2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((phi2 / 2.0)) * math.sin((phi1 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) return R * (2.0 * math.atan2(math.sqrt((t_0 + t_2)), math.sqrt(((1.0 - t_0) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(Float64(1.0 - t_0) - t_2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{\left(1 - t\_0\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.0%
div-sub62.1%
sin-diff63.1%
Applied egg-rr79.7%
Final simplification79.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
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ 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(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((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 + (((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((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.cos((phi2 / 2.0)) * Math.sin((phi1 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((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.cos((phi2 / 2.0)) * math.sin((phi1 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((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 + (Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(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 + (((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((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[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(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 + {\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\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 62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.1%
unpow263.1%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified63.2%
Final simplification63.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(if (or (<= t_0 -0.09) (not (<= t_0 4e-6)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_0 t_0))
(- 0.5 (/ (+ t_1 (* (sin phi1) (sin phi2))) 2.0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_1 t_0)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if ((t_0 <= -0.09) || !(t_0 <= 4e-6)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (0.5 - ((t_1 + (sin(phi1) * sin(phi2))) / 2.0)))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
if ((t_0 <= (-0.09d0)) .or. (.not. (t_0 <= 4d-6))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (0.5d0 - ((t_1 + (sin(phi1) * sin(phi2))) / 2.0d0)))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((t_0 <= -0.09) || !(t_0 <= 4e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_0)) + (0.5 - ((t_1 + (Math.sin(phi1) * Math.sin(phi2))) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (t_0 <= -0.09) or not (t_0 <= 4e-6): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_0)) + (0.5 - ((t_1 + (math.sin(phi1) * math.sin(phi2))) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((t_0 <= -0.09) || !(t_0 <= 4e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_0)) + Float64(0.5 - Float64(Float64(t_1 + Float64(sin(phi1) * sin(phi2))) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); tmp = 0.0; if ((t_0 <= -0.09) || ~((t_0 <= 4e-6))) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (0.5 - ((t_1 + (sin(phi1) * sin(phi2))) / 2.0)))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.09], N[Not[LessEqual[t$95$0, 4e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[(t$95$1 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;t\_0 \leq -0.09 \lor \neg \left(t\_0 \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_0\right) + \left(0.5 - \frac{t\_1 + \sin \phi_1 \cdot \sin \phi_2}{2}\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_1 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.089999999999999997 or 3.99999999999999982e-6 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 58.4%
associate-*l*58.4%
Simplified58.4%
Taylor expanded in phi2 around 0 44.8%
Taylor expanded in phi1 around 0 35.5%
unpow259.4%
sin-mult59.5%
div-inv59.5%
metadata-eval59.5%
div-inv59.5%
metadata-eval59.5%
div-inv59.5%
metadata-eval59.5%
div-inv59.5%
metadata-eval59.5%
Applied egg-rr35.5%
div-sub59.5%
+-inverses59.5%
cos-059.5%
metadata-eval59.5%
distribute-lft-out59.5%
metadata-eval59.5%
*-rgt-identity59.5%
Simplified35.5%
cos-diff36.6%
*-commutative36.6%
Applied egg-rr36.6%
if -0.089999999999999997 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 3.99999999999999982e-6Initial program 70.8%
Taylor expanded in lambda2 around 0 68.4%
Taylor expanded in lambda1 around 0 68.4%
Final simplification46.1%
(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 (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(if (or (<= phi1 -0.00074) (not (<= phi1 6.4e-5)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* t_1 t_1))
(pow
(sin (* phi1 (+ 0.5 (* -0.16666666666666666 (/ phi2 phi1)))))
2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_0 t_1))
(pow (sin (/ (* phi2 (+ -1.0 (/ phi1 phi2))) 2.0)) 2.0)))
(sqrt
(- 1.0 (+ (* (cos phi2) t_2) (pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -0.00074) || !(phi1 <= 6.4e-5)) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + pow(sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))), 2.0))), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(sin(((phi2 * (-1.0 + (phi1 / phi2))) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi2) * t_2) + pow(sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
if ((phi1 <= (-0.00074d0)) .or. (.not. (phi1 <= 6.4d-5))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + (sin((phi1 * (0.5d0 + ((-0.16666666666666666d0) * (phi2 / phi1))))) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin(((phi2 * ((-1.0d0) + (phi1 / phi2))) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi2) * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -0.00074) || !(phi1 <= 6.4e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_1)) + Math.pow(Math.sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_1)) + Math.pow(Math.sin(((phi2 * (-1.0 + (phi1 / phi2))) / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi1 <= -0.00074) or not (phi1 <= 6.4e-5): tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_1)) + math.pow(math.sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_1)) + math.pow(math.sin(((phi2 * (-1.0 + (phi1 / phi2))) / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
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 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 tmp = 0.0 if ((phi1 <= -0.00074) || !(phi1 <= 6.4e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_1)) + (sin(Float64(phi1 * Float64(0.5 + Float64(-0.16666666666666666 * Float64(phi2 / phi1))))) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(Float64(phi2 * Float64(-1.0 + Float64(phi1 / phi2))) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = 0.0; if ((phi1 <= -0.00074) || ~((phi1 <= 6.4e-5))) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + (sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin(((phi2 * (-1.0 + (phi1 / phi2))) / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi2) * t_2) + (sin((phi2 * -0.5)) ^ 2.0)))))); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.00074], N[Not[LessEqual[phi1, 6.4e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * N[(0.5 + N[(-0.16666666666666666 * N[(phi2 / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi2 * N[(-1.0 + N[(phi1 / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -0.00074 \lor \neg \left(\phi_1 \leq 6.4 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_1 \cdot t\_1\right) + {\sin \left(\phi_1 \cdot \left(0.5 + -0.16666666666666666 \cdot \frac{\phi_2}{\phi_1}\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_1\right) + {\sin \left(\frac{\phi_2 \cdot \left(-1 + \frac{\phi_1}{\phi_2}\right)}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -7.3999999999999999e-4 or 6.39999999999999971e-5 < phi1 Initial program 46.5%
associate-*l*46.6%
Simplified46.6%
Taylor expanded in phi2 around 0 47.1%
add-cube-cbrt26.1%
pow226.1%
Applied egg-rr26.1%
Taylor expanded in phi1 around inf 26.0%
Taylor expanded in phi1 around inf 47.8%
if -7.3999999999999999e-4 < phi1 < 6.39999999999999971e-5Initial program 76.5%
Taylor expanded in phi2 around inf 76.5%
Taylor expanded in phi1 around 0 76.5%
Final simplification62.7%
(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)))
(t_2 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(if (or (<= phi1 -6.8e-5) (not (<= phi1 0.0014)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(pow
(sin (* phi1 (+ 0.5 (* -0.16666666666666666 (/ phi2 phi1)))))
2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(- 1.0 (+ (* (cos phi2) t_2) (pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -6.8e-5) || !(phi1 <= 0.0014)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))), 2.0))), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi2) * t_2) + pow(sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
if ((phi1 <= (-6.8d-5)) .or. (.not. (phi1 <= 0.0014d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi1 * (0.5d0 + ((-0.16666666666666666d0) * (phi2 / phi1))))) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi2) * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_2 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -6.8e-5) || !(phi1 <= 0.0014)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_2 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi1 <= -6.8e-5) or not (phi1 <= 0.0014): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 tmp = 0.0 if ((phi1 <= -6.8e-5) || !(phi1 <= 0.0014)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi1 * Float64(0.5 + Float64(-0.16666666666666666 * Float64(phi2 / phi1))))) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = 0.0; if ((phi1 <= -6.8e-5) || ~((phi1 <= 0.0014))) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi1 * (0.5 + (-0.16666666666666666 * (phi2 / phi1))))) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi2) * t_2) + (sin((phi2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -6.8e-5], N[Not[LessEqual[phi1, 0.0014]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi1 * N[(0.5 + N[(-0.16666666666666666 * N[(phi2 / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
t_2 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -6.8 \cdot 10^{-5} \lor \neg \left(\phi_1 \leq 0.0014\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\phi_1 \cdot \left(0.5 + -0.16666666666666666 \cdot \frac{\phi_2}{\phi_1}\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -6.7999999999999999e-5 or 0.00139999999999999999 < phi1 Initial program 46.5%
associate-*l*46.6%
Simplified46.6%
Taylor expanded in phi2 around 0 47.1%
add-cube-cbrt26.1%
pow226.1%
Applied egg-rr26.1%
Taylor expanded in phi1 around inf 26.0%
Taylor expanded in phi1 around inf 47.8%
if -6.7999999999999999e-5 < phi1 < 0.00139999999999999999Initial program 76.5%
associate-*l*76.5%
Simplified76.5%
Taylor expanded in phi1 around 0 76.5%
Final simplification62.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(sqrt (+ (* t_1 (* t_2 t_2)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(if (<= t_2 -0.09)
(* R (* 2.0 (atan2 t_3 t_0)))
(if (<= t_2 4e-6)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_2)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(* R (* 2.0 (atan2 t_3 (log (exp t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0))));
double tmp;
if (t_2 <= -0.09) {
tmp = R * (2.0 * atan2(t_3, t_0));
} else if (t_2 <= 4e-6) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_3, log(exp(t_0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt(((t_1 * (t_2 * t_2)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0))))
if (t_2 <= (-0.09d0)) then
tmp = r * (2.0d0 * atan2(t_3, t_0))
else if (t_2 <= 4d-6) then
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_3, log(exp(t_0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0))));
double tmp;
if (t_2 <= -0.09) {
tmp = R * (2.0 * Math.atan2(t_3, t_0));
} else if (t_2 <= 4e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_1 * t_2)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.log(Math.exp(t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))) tmp = 0 if t_2 <= -0.09: tmp = R * (2.0 * math.atan2(t_3, t_0)) elif t_2 <= 4e-6: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_1 * t_2)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_3, math.log(math.exp(t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64(Float64(t_1 * Float64(t_2 * t_2)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))) tmp = 0.0 if (t_2 <= -0.09) tmp = Float64(R * Float64(2.0 * atan(t_3, t_0))); elseif (t_2 <= 4e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, log(exp(t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))); tmp = 0.0; if (t_2 <= -0.09) tmp = R * (2.0 * atan2(t_3, t_0)); elseif (t_2 <= 4e-6) tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_3, log(exp(t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$2, -0.09], N[(R * N[(2.0 * N[ArcTan[t$95$3 / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 4e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Log[N[Exp[t$95$0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}\\
\mathbf{if}\;t\_2 \leq -0.09:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{t\_0}\right)\\
\mathbf{elif}\;t\_2 \leq 4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\log \left(e^{t\_0}\right)}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.089999999999999997Initial program 50.6%
associate-*l*50.7%
Simplified50.6%
Taylor expanded in phi2 around 0 41.6%
Taylor expanded in phi1 around 0 30.4%
unpow251.9%
sin-mult52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
Applied egg-rr30.4%
div-sub52.0%
+-inverses52.0%
cos-052.0%
metadata-eval52.0%
distribute-lft-out52.0%
metadata-eval52.0%
*-rgt-identity52.0%
Simplified30.4%
if -0.089999999999999997 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 3.99999999999999982e-6Initial program 70.8%
Taylor expanded in lambda2 around 0 68.4%
Taylor expanded in lambda1 around 0 68.4%
if 3.99999999999999982e-6 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 64.5%
associate-*l*64.5%
Simplified64.5%
Taylor expanded in phi2 around 0 47.4%
Taylor expanded in phi1 around 0 39.6%
unpow265.4%
sin-mult65.5%
div-inv65.5%
metadata-eval65.5%
div-inv65.5%
metadata-eval65.5%
div-inv65.5%
metadata-eval65.5%
div-inv65.5%
metadata-eval65.5%
Applied egg-rr39.6%
div-sub65.5%
+-inverses65.5%
cos-065.5%
metadata-eval65.5%
distribute-lft-out65.5%
metadata-eval65.5%
*-rgt-identity65.5%
Simplified39.6%
add-log-exp39.7%
*-commutative39.7%
Applied egg-rr39.7%
Final simplification45.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (* t_3 (* t_2 t_2)))
(t_5 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0))))
(if (<= phi1 -4.4e-7)
(*
R
(*
2.0
(atan2 (sqrt (+ t_4 (pow (sin (/ phi1 2.0)) 2.0))) (sqrt (- 1.0 t_5)))))
(if (<= phi1 4.7e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 t_0))
(sqrt
(- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2 (sqrt t_5) (sqrt (- 1.0 (+ (* t_2 (* t_3 t_2)) t_0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos(phi1) * cos(phi2);
double t_4 = t_3 * (t_2 * t_2);
double t_5 = (cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -4.4e-7) {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - t_5))));
} else if (phi1 <= 4.7e-5) {
tmp = R * (2.0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - ((t_2 * (t_3 * t_2)) + t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos(phi1) * cos(phi2)
t_4 = t_3 * (t_2 * t_2)
t_5 = (cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0)
if (phi1 <= (-4.4d-7)) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - t_5))))
else if (phi1 <= 4.7d-5) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - ((t_2 * (t_3 * t_2)) + t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = t_3 * (t_2 * t_2);
double t_5 = (Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -4.4e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - t_5))));
} else if (phi1 <= 4.7e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + t_0)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - ((t_2 * (t_3 * t_2)) + t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos(phi1) * math.cos(phi2) t_4 = t_3 * (t_2 * t_2) t_5 = (math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0) tmp = 0 if phi1 <= -4.4e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - t_5)))) elif phi1 <= 4.7e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + t_0)), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - ((t_2 * (t_3 * t_2)) + t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = Float64(t_3 * Float64(t_2 * t_2)) t_5 = Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0)) tmp = 0.0 if (phi1 <= -4.4e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - t_5))))); elseif (phi1 <= 4.7e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + t_0)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - Float64(Float64(t_2 * Float64(t_3 * t_2)) + t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos(phi1) * cos(phi2); t_4 = t_3 * (t_2 * t_2); t_5 = (cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0); tmp = 0.0; if (phi1 <= -4.4e-7) tmp = R * (2.0 * atan2(sqrt((t_4 + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - t_5)))); elseif (phi1 <= 4.7e-5) tmp = R * (2.0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - ((t_2 * (t_3 * t_2)) + t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.4e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4.7e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := t\_3 \cdot \left(t\_2 \cdot t\_2\right)\\
t_5 := \cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -4.4 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{elif}\;\phi_1 \leq 4.7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + t\_0}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - \left(t\_2 \cdot \left(t\_3 \cdot t\_2\right) + t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -4.4000000000000002e-7Initial program 42.6%
associate-*l*42.6%
Simplified42.6%
Taylor expanded in phi2 around 0 43.0%
Taylor expanded in phi1 around inf 43.2%
if -4.4000000000000002e-7 < phi1 < 4.69999999999999972e-5Initial program 76.9%
associate-*l*77.0%
Simplified77.0%
Taylor expanded in phi1 around 0 77.0%
if 4.69999999999999972e-5 < phi1 Initial program 49.5%
expm1-log1p-u20.0%
div-inv20.0%
metadata-eval20.0%
Applied egg-rr20.0%
Taylor expanded in phi2 around 0 50.6%
Final simplification62.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_3 (+ (* (cos phi2) t_2) (pow (sin (* phi2 -0.5)) 2.0)))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (* t_0 (* t_4 t_4))))
(if (<= phi2 -7100000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_3)))))
(if (<= phi2 0.0175)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 t_1))
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2 (sqrt t_3) (sqrt (- 1.0 (+ (* t_4 (* t_0 t_4)) t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_3 = (cos(phi2) * t_2) + pow(sin((phi2 * -0.5)), 2.0);
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_0 * (t_4 * t_4);
double tmp;
if (phi2 <= -7100000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_5 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3))));
} else if (phi2 <= 0.0175) {
tmp = R * (2.0 * atan2(sqrt((t_5 + t_1)), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - ((t_4 * (t_0 * t_4)) + t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_3 = (cos(phi2) * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0)
t_4 = sin(((lambda1 - lambda2) / 2.0d0))
t_5 = t_0 * (t_4 * t_4)
if (phi2 <= (-7100000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - t_3))))
else if (phi2 <= 0.0175d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + t_1)), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - ((t_4 * (t_0 * t_4)) + t_1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_3 = (Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_4 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_0 * (t_4 * t_4);
double tmp;
if (phi2 <= -7100000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_3))));
} else if (phi2 <= 0.0175) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + t_1)), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - ((t_4 * (t_0 * t_4)) + t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_3 = (math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0) t_4 = math.sin(((lambda1 - lambda2) / 2.0)) t_5 = t_0 * (t_4 * t_4) tmp = 0 if phi2 <= -7100000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_3)))) elif phi2 <= 0.0175: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + t_1)), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - ((t_4 * (t_0 * t_4)) + t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_3 = Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0)) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = Float64(t_0 * Float64(t_4 * t_4)) tmp = 0.0 if (phi2 <= -7100000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_3))))); elseif (phi2 <= 0.0175) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + t_1)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(Float64(t_4 * Float64(t_0 * t_4)) + t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_3 = (cos(phi2) * t_2) + (sin((phi2 * -0.5)) ^ 2.0); t_4 = sin(((lambda1 - lambda2) / 2.0)); t_5 = t_0 * (t_4 * t_4); tmp = 0.0; if (phi2 <= -7100000000.0) tmp = R * (2.0 * atan2(sqrt((t_5 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_3)))); elseif (phi2 <= 0.0175) tmp = R * (2.0 * atan2(sqrt((t_5 + t_1)), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - ((t_4 * (t_0 * t_4)) + t_1))))); 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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$0 * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -7100000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + 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], If[LessEqual[phi2, 0.0175], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$4 * N[(t$95$0 * t$95$4), $MachinePrecision]), $MachinePrecision] + t$95$1), $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{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_3 := \cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := t\_0 \cdot \left(t\_4 \cdot t\_4\right)\\
\mathbf{if}\;\phi_2 \leq -7100000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.0175:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + t\_1}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \left(t\_4 \cdot \left(t\_0 \cdot t\_4\right) + t\_1\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -7.1e9Initial program 47.2%
associate-*l*47.2%
Simplified47.3%
Taylor expanded in phi1 around 0 48.1%
unpow249.0%
sin-mult49.1%
div-inv49.1%
metadata-eval49.1%
div-inv49.1%
metadata-eval49.1%
div-inv49.1%
metadata-eval49.1%
div-inv49.1%
metadata-eval49.1%
Applied egg-rr48.1%
div-sub49.1%
+-inverses49.1%
cos-049.1%
metadata-eval49.1%
distribute-lft-out49.1%
metadata-eval49.1%
*-rgt-identity49.1%
Simplified48.1%
if -7.1e9 < phi2 < 0.017500000000000002Initial program 77.2%
associate-*l*77.2%
Simplified77.2%
Taylor expanded in phi2 around 0 76.9%
if 0.017500000000000002 < phi2 Initial program 50.1%
expm1-log1p-u0.6%
div-inv0.6%
metadata-eval0.6%
Applied egg-rr0.6%
Taylor expanded in phi1 around 0 51.3%
Final simplification62.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi2 -0.5)) 2.0))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (* t_3 (* t_2 t_2)))
(t_5 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0))))
(if (<= phi1 -1.95e-7)
(*
R
(*
2.0
(atan2 (sqrt (+ t_4 (pow (sin (/ phi1 2.0)) 2.0))) (sqrt (- 1.0 t_5)))))
(if (<= phi1 6.4e-7)
(*
R
(*
2.0
(atan2 (sqrt (+ t_4 t_0)) (sqrt (- 1.0 (+ (* (cos phi2) t_1) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt t_5)
(sqrt
(-
1.0
(+
(* t_2 (* t_3 t_2))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos(phi1) * cos(phi2);
double t_4 = t_3 * (t_2 * t_2);
double t_5 = (cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -1.95e-7) {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - t_5))));
} else if (phi1 <= 6.4e-7) {
tmp = R * (2.0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0 - ((cos(phi2) * t_1) + t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - ((t_2 * (t_3 * t_2)) + 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) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos(phi1) * cos(phi2)
t_4 = t_3 * (t_2 * t_2)
t_5 = (cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0)
if (phi1 <= (-1.95d-7)) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - t_5))))
else if (phi1 <= 6.4d-7) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0d0 - ((cos(phi2) * t_1) + t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - ((t_2 * (t_3 * t_2)) + (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.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = t_3 * (t_2 * t_2);
double t_5 = (Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -1.95e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - t_5))));
} else if (phi1 <= 6.4e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + t_0)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - ((t_2 * (t_3 * t_2)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos(phi1) * math.cos(phi2) t_4 = t_3 * (t_2 * t_2) t_5 = (math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0) tmp = 0 if phi1 <= -1.95e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - t_5)))) elif phi1 <= 6.4e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + t_0)), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - ((t_2 * (t_3 * t_2)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = Float64(t_3 * Float64(t_2 * t_2)) t_5 = Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0)) tmp = 0.0 if (phi1 <= -1.95e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - t_5))))); elseif (phi1 <= 6.4e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + t_0)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - Float64(Float64(t_2 * Float64(t_3 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi2 * -0.5)) ^ 2.0; t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos(phi1) * cos(phi2); t_4 = t_3 * (t_2 * t_2); t_5 = (cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0); tmp = 0.0; if (phi1 <= -1.95e-7) tmp = R * (2.0 * atan2(sqrt((t_4 + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - t_5)))); elseif (phi1 <= 6.4e-7) tmp = R * (2.0 * atan2(sqrt((t_4 + t_0)), sqrt((1.0 - ((cos(phi2) * t_1) + t_0))))); else tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - ((t_2 * (t_3 * t_2)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -1.95e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 6.4e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[(t$95$3 * t$95$2), $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(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := t\_3 \cdot \left(t\_2 \cdot t\_2\right)\\
t_5 := \cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -1.95 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{elif}\;\phi_1 \leq 6.4 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + t\_0}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - \left(t\_2 \cdot \left(t\_3 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.95000000000000012e-7Initial program 42.6%
associate-*l*42.6%
Simplified42.6%
Taylor expanded in phi2 around 0 43.0%
Taylor expanded in phi1 around inf 43.2%
if -1.95000000000000012e-7 < phi1 < 6.4000000000000001e-7Initial program 76.9%
associate-*l*77.0%
Simplified77.0%
Taylor expanded in phi1 around 0 77.0%
Taylor expanded in phi1 around 0 75.5%
if 6.4000000000000001e-7 < phi1 Initial program 49.5%
expm1-log1p-u20.0%
div-inv20.0%
metadata-eval20.0%
Applied egg-rr20.0%
Taylor expanded in phi2 around 0 50.6%
Final simplification61.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (+ 1.0 (- (/ (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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 + ((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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 + ((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 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 + ((Math.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 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 + ((math.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(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(Float64(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 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 + ((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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
div-sub62.1%
sin-diff63.1%
Applied egg-rr63.0%
sin-diff63.0%
div-sub63.0%
div-inv63.0%
metadata-eval63.0%
expm1-log1p-u27.2%
unpow227.2%
sin-mult25.3%
Applied egg-rr62.2%
div-sub61.1%
+-inverses61.1%
+-inverses52.2%
+-inverses61.1%
cos-061.1%
metadata-eval61.1%
distribute-lft-out61.1%
metadata-eval61.1%
*-rgt-identity61.1%
Simplified62.2%
Final simplification62.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 (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(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((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), 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((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), 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((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), 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((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), 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(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), 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((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), 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[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
unpow263.1%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr60.2%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified60.2%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi2 -0.5)) 2.0))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) (* t_2 t_2))))
(if (or (<= phi1 -9.4e-8) (not (<= phi1 0.00035)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_0))
(sqrt (- 1.0 (+ (* (cos phi2) t_1) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * (t_2 * t_2);
double tmp;
if ((phi1 <= -9.4e-8) || !(phi1 <= 0.00035)) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_0)), sqrt((1.0 - ((cos(phi2) * t_1) + t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * (t_2 * t_2)
if ((phi1 <= (-9.4d-8)) .or. (.not. (phi1 <= 0.00035d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_0)), sqrt((1.0d0 - ((cos(phi2) * t_1) + t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * (t_2 * t_2);
double tmp;
if ((phi1 <= -9.4e-8) || !(phi1 <= 0.00035)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_0)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * (t_2 * t_2) tmp = 0 if (phi1 <= -9.4e-8) or not (phi1 <= 0.00035): tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_0)), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_2 * t_2)) tmp = 0.0 if ((phi1 <= -9.4e-8) || !(phi1 <= 0.00035)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_0)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi2 * -0.5)) ^ 2.0; t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * (t_2 * t_2); tmp = 0.0; if ((phi1 <= -9.4e-8) || ~((phi1 <= 0.00035))) tmp = R * (2.0 * atan2(sqrt((t_3 + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + t_0)), sqrt((1.0 - ((cos(phi2) * t_1) + t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -9.4e-8], N[Not[LessEqual[phi1, 0.00035]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_2 \cdot t\_2\right)\\
\mathbf{if}\;\phi_1 \leq -9.4 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 0.00035\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_0}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -9.3999999999999995e-8 or 3.49999999999999996e-4 < phi1 Initial program 46.3%
associate-*l*46.3%
Simplified46.3%
Taylor expanded in phi2 around 0 46.9%
Taylor expanded in phi1 around inf 47.2%
if -9.3999999999999995e-8 < phi1 < 3.49999999999999996e-4Initial program 76.9%
associate-*l*77.0%
Simplified77.0%
Taylor expanded in phi1 around 0 77.0%
Taylor expanded in phi1 around 0 75.5%
Final simplification61.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1)))
(t_3 (pow (sin (* phi2 -0.5)) 2.0)))
(if (or (<= phi1 -1.85e-5) (not (<= phi1 1.2e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 t_3))
(sqrt (- 1.0 (+ (* (cos phi2) t_0) t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double t_3 = pow(sin((phi2 * -0.5)), 2.0);
double tmp;
if ((phi1 <= -1.85e-5) || !(phi1 <= 1.2e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0 - ((cos(phi2) * t_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((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
t_3 = sin((phi2 * (-0.5d0))) ** 2.0d0
if ((phi1 <= (-1.85d-5)) .or. (.not. (phi1 <= 1.2d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0d0 - ((cos(phi2) * t_0) + t_3)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double t_3 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double tmp;
if ((phi1 <= -1.85e-5) || !(phi1 <= 1.2e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_3)), Math.sqrt((1.0 - ((Math.cos(phi2) * t_0) + t_3)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) t_3 = math.pow(math.sin((phi2 * -0.5)), 2.0) tmp = 0 if (phi1 <= -1.85e-5) or not (phi1 <= 1.2e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_3)), math.sqrt((1.0 - ((math.cos(phi2) * t_0) + t_3))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) t_3 = sin(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if ((phi1 <= -1.85e-5) || !(phi1 <= 1.2e-5)) 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 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_3)), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_0) + t_3)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); t_3 = sin((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if ((phi1 <= -1.85e-5) || ~((phi1 <= 1.2e-5))) tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((1.0 - ((cos(phi2) * t_0) + t_3))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -1.85e-5], N[Not[LessEqual[phi1, 1.2e-5]], $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 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
t_3 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -1.85 \cdot 10^{-5} \lor \neg \left(\phi_1 \leq 1.2 \cdot 10^{-5}\right):\\
\;\;\;\;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 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_3}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_0 + t\_3\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.84999999999999991e-5 or 1.2e-5 < phi1 Initial program 46.5%
associate-*l*46.6%
Simplified46.6%
Taylor expanded in phi2 around 0 47.1%
unpow248.6%
sin-mult48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
Applied egg-rr47.2%
div-sub48.7%
+-inverses48.7%
cos-048.7%
metadata-eval48.7%
distribute-lft-out48.7%
metadata-eval48.7%
*-rgt-identity48.7%
Simplified47.2%
if -1.84999999999999991e-5 < phi1 < 1.2e-5Initial program 76.5%
associate-*l*76.5%
Simplified76.5%
Taylor expanded in phi1 around 0 76.5%
Taylor expanded in phi1 around 0 75.1%
Final simplification61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= (- lambda1 lambda2) -2e-6) (not (<= (- lambda1 lambda2) 1e-12)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_1 t_1)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))
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 tmp;
if (((lambda1 - lambda2) <= -2e-6) || !((lambda1 - lambda2) <= 1e-12)) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
}
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(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if (((lambda1 - lambda2) <= (-2d-6)) .or. (.not. ((lambda1 - lambda2) <= 1d-12))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
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.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (((lambda1 - lambda2) <= -2e-6) || !((lambda1 - lambda2) <= 1e-12)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_1)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if ((lambda1 - lambda2) <= -2e-6) or not ((lambda1 - lambda2) <= 1e-12): tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_1)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -2e-6) || !(Float64(lambda1 - lambda2) <= 1e-12)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_1)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (((lambda1 - lambda2) <= -2e-6) || ~(((lambda1 - lambda2) <= 1e-12))) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_1)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -2e-6], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 1e-12]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -2 \cdot 10^{-6} \lor \neg \left(\lambda_1 - \lambda_2 \leq 10^{-12}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_1 \cdot t\_1\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.99999999999999991e-6 or 9.9999999999999998e-13 < (-.f64 lambda1 lambda2) Initial program 58.0%
associate-*l*58.0%
Simplified58.0%
Taylor expanded in phi2 around 0 44.7%
unpow259.0%
sin-mult59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
Applied egg-rr44.8%
div-sub59.1%
+-inverses59.1%
cos-059.1%
metadata-eval59.1%
distribute-lft-out59.1%
metadata-eval59.1%
*-rgt-identity59.1%
Simplified44.8%
if -1.99999999999999991e-6 < (-.f64 lambda1 lambda2) < 9.9999999999999998e-13Initial program 73.4%
Taylor expanded in lambda2 around 0 72.9%
Taylor expanded in lambda1 around 0 72.9%
Final simplification52.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(if (or (<= phi1 -8.5e-6) (not (<= phi1 8.5e-5)))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(- 1.0 (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((((cos(phi1) * cos(phi2)) * (t_1 * t_1)) + (0.5 - (cos((phi1 - phi2)) / 2.0))));
double tmp;
if ((phi1 <= -8.5e-6) || !(phi1 <= 8.5e-5)) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt((((cos(phi1) * cos(phi2)) * (t_1 * t_1)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0))))
if ((phi1 <= (-8.5d-6)) .or. (.not. (phi1 <= 8.5d-5))) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - ((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0))));
double tmp;
if ((phi1 <= -8.5e-6) || !(phi1 <= 8.5e-5)) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - ((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))) tmp = 0 if (phi1 <= -8.5e-6) or not (phi1 <= 8.5e-5): tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - ((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))) tmp = 0.0 if ((phi1 <= -8.5e-6) || !(phi1 <= 8.5e-5)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt((((cos(phi1) * cos(phi2)) * (t_1 * t_1)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))); tmp = 0.0; if ((phi1 <= -8.5e-6) || ~((phi1 <= 8.5e-5))) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - ((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $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[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -8.5e-6], N[Not[LessEqual[phi1, 8.5e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}\\
\mathbf{if}\;\phi_1 \leq -8.5 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 8.5 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -8.4999999999999999e-6 or 8.500000000000001e-5 < phi1 Initial program 46.5%
associate-*l*46.6%
Simplified46.6%
Taylor expanded in phi2 around 0 47.1%
unpow248.6%
sin-mult48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
Applied egg-rr47.2%
div-sub48.7%
+-inverses48.7%
cos-048.7%
metadata-eval48.7%
distribute-lft-out48.7%
metadata-eval48.7%
*-rgt-identity48.7%
Simplified47.2%
if -8.4999999999999999e-6 < phi1 < 8.500000000000001e-5Initial program 76.5%
associate-*l*76.5%
Simplified76.5%
Taylor expanded in phi1 around 0 76.5%
unpow276.5%
sin-mult76.6%
div-inv76.6%
metadata-eval76.6%
div-inv76.6%
metadata-eval76.6%
div-inv76.6%
metadata-eval76.6%
div-inv76.6%
metadata-eval76.6%
Applied egg-rr72.9%
div-sub76.6%
+-inverses76.6%
cos-076.6%
metadata-eval76.6%
distribute-lft-out76.6%
metadata-eval76.6%
*-rgt-identity76.6%
Simplified72.9%
Final simplification60.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(if (or (<= t_0 -0.09) (not (<= t_0 4e-6)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_0)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_1 t_0)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double tmp;
if ((t_0 <= -0.09) || !(t_0 <= 4e-6)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
if ((t_0 <= (-0.09d0)) .or. (.not. (t_0 <= 4d-6))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((t_0 <= -0.09) || !(t_0 <= 4e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (t_0 <= -0.09) or not (t_0 <= 4e-6): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((t_0 <= -0.09) || !(t_0 <= 4e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); tmp = 0.0; if ((t_0 <= -0.09) || ~((t_0 <= 4e-6))) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.09], N[Not[LessEqual[t$95$0, 4e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;t\_0 \leq -0.09 \lor \neg \left(t\_0 \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_1 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.089999999999999997 or 3.99999999999999982e-6 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 58.4%
associate-*l*58.4%
Simplified58.4%
Taylor expanded in phi2 around 0 44.8%
Taylor expanded in phi1 around 0 35.5%
unpow259.4%
sin-mult59.5%
div-inv59.5%
metadata-eval59.5%
div-inv59.5%
metadata-eval59.5%
div-inv59.5%
metadata-eval59.5%
div-inv59.5%
metadata-eval59.5%
Applied egg-rr35.5%
div-sub59.5%
+-inverses59.5%
cos-059.5%
metadata-eval59.5%
distribute-lft-out59.5%
metadata-eval59.5%
*-rgt-identity59.5%
Simplified35.5%
if -0.089999999999999997 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 3.99999999999999982e-6Initial program 70.8%
Taylor expanded in lambda2 around 0 68.4%
Taylor expanded in lambda1 around 0 68.4%
Final simplification45.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)
(* (cos phi1) (* (cos phi2) t_0))))
(sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * atan2(sqrt((pow(sin((0.5 * (phi1 - phi2))), 2.0) + (cos(phi1) * (cos(phi2) * t_0)))), sqrt((1.0 - t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((sin((0.5d0 * (phi1 - phi2))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * t_0)))), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * t_0)))), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * t_0)))), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * t_0)))), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((sin((0.5 * (phi1 - phi2))) ^ 2.0) + (cos(phi1) * (cos(phi2) * t_0)))), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in phi2 around 0 47.3%
Taylor expanded in phi1 around 0 34.1%
Taylor expanded in phi1 around 0 34.1%
Final simplification34.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in phi2 around 0 47.3%
Taylor expanded in phi1 around 0 34.1%
unpow263.1%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr32.2%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified32.2%
Final simplification32.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(*
(* R 2.0)
(atan2
(sqrt
(+
0.5
(- (* (cos phi1) (* (cos phi2) t_0)) (* 0.5 (cos (- phi1 phi2))))))
(sqrt (- 1.0 t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return (R * 2.0) * atan2(sqrt((0.5 + ((cos(phi1) * (cos(phi2) * t_0)) - (0.5 * cos((phi1 - phi2)))))), sqrt((1.0 - t_0)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
code = (r * 2.0d0) * atan2(sqrt((0.5d0 + ((cos(phi1) * (cos(phi2) * t_0)) - (0.5d0 * cos((phi1 - phi2)))))), sqrt((1.0d0 - t_0)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return (R * 2.0) * Math.atan2(Math.sqrt((0.5 + ((Math.cos(phi1) * (Math.cos(phi2) * t_0)) - (0.5 * Math.cos((phi1 - phi2)))))), Math.sqrt((1.0 - t_0)));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return (R * 2.0) * math.atan2(math.sqrt((0.5 + ((math.cos(phi1) * (math.cos(phi2) * t_0)) - (0.5 * math.cos((phi1 - phi2)))))), math.sqrt((1.0 - t_0)))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 return Float64(Float64(R * 2.0) * atan(sqrt(Float64(0.5 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * t_0)) - Float64(0.5 * cos(Float64(phi1 - phi2)))))), sqrt(Float64(1.0 - t_0)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = (R * 2.0) * atan2(sqrt((0.5 + ((cos(phi1) * (cos(phi2) * t_0)) - (0.5 * cos((phi1 - phi2)))))), sqrt((1.0 - t_0))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sqrt[N[(0.5 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right) - 0.5 \cdot \cos \left(\phi_1 - \phi_2\right)\right)}}{\sqrt{1 - t\_0}}
\end{array}
\end{array}
Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in phi2 around 0 47.3%
Taylor expanded in phi1 around 0 34.1%
unpow263.1%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr32.2%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified32.2%
Taylor expanded in R around 0 29.9%
Simplified30.0%
Final simplification30.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt
(-
(+ 0.5 (* (cos phi1) (* (cos phi2) t_0)))
(* 0.5 (cos (- phi1 phi2)))))
(sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * atan2(sqrt(((0.5 + (cos(phi1) * (cos(phi2) * t_0))) - (0.5 * cos((phi1 - phi2))))), sqrt((1.0 - t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((0.5d0 + (cos(phi1) * (cos(phi2) * t_0))) - (0.5d0 * cos((phi1 - phi2))))), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(((0.5 + (Math.cos(phi1) * (Math.cos(phi2) * t_0))) - (0.5 * Math.cos((phi1 - phi2))))), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return R * (2.0 * math.atan2(math.sqrt(((0.5 + (math.cos(phi1) * (math.cos(phi2) * t_0))) - (0.5 * math.cos((phi1 - phi2))))), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 + Float64(cos(phi1) * Float64(cos(phi2) * t_0))) - Float64(0.5 * cos(Float64(phi1 - phi2))))), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((0.5 + (cos(phi1) * (cos(phi2) * t_0))) - (0.5 * cos((phi1 - phi2))))), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right) - 0.5 \cdot \cos \left(\phi_1 - \phi_2\right)}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in phi2 around 0 47.3%
Taylor expanded in phi1 around 0 34.1%
unpow263.1%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr32.2%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified32.2%
Taylor expanded in phi1 around 0 29.9%
herbie shell --seed 2024113
(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))))))))))