
(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 28 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2
(pow
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3 (sqrt (+ (* t_0 (* t_1 t_0)) t_2))))
(if (or (<= lambda1 -0.0048) (not (<= lambda1 3.2e-20)))
(*
R
(*
2.0
(atan2
t_3
(sqrt (- 1.0 (+ t_2 (* t_1 (pow (sin (* 0.5 lambda1)) 2.0))))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt (- 1.0 (+ t_2 (* t_1 (pow (sin (* lambda2 -0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = sqrt(((t_0 * (t_1 * t_0)) + t_2));
double tmp;
if ((lambda1 <= -0.0048) || !(lambda1 <= 3.2e-20)) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + (t_1 * pow(sin((0.5 * lambda1)), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + (t_1 * pow(sin((lambda2 * -0.5)), 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_3 = sqrt(((t_0 * (t_1 * t_0)) + t_2))
if ((lambda1 <= (-0.0048d0)) .or. (.not. (lambda1 <= 3.2d-20))) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_2 + (t_1 * (sin((0.5d0 * lambda1)) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_2 + (t_1 * (sin((lambda2 * (-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);
double t_2 = 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_3 = Math.sqrt(((t_0 * (t_1 * t_0)) + t_2));
double tmp;
if ((lambda1 <= -0.0048) || !(lambda1 <= 3.2e-20)) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_2 + (t_1 * Math.pow(Math.sin((0.5 * lambda1)), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_2 + (t_1 * Math.pow(Math.sin((lambda2 * -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_2 = 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_3 = math.sqrt(((t_0 * (t_1 * t_0)) + t_2)) tmp = 0 if (lambda1 <= -0.0048) or not (lambda1 <= 3.2e-20): tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_2 + (t_1 * math.pow(math.sin((0.5 * lambda1)), 2.0))))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_2 + (t_1 * math.pow(math.sin((lambda2 * -0.5)), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = 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_3 = sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + t_2)) tmp = 0.0 if ((lambda1 <= -0.0048) || !(lambda1 <= 3.2e-20)) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_2 + Float64(t_1 * (sin(Float64(0.5 * lambda1)) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_2 + Float64(t_1 * (sin(Float64(lambda2 * -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_2 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_3 = sqrt(((t_0 * (t_1 * t_0)) + t_2)); tmp = 0.0; if ((lambda1 <= -0.0048) || ~((lambda1 <= 3.2e-20))) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + (t_1 * (sin((0.5 * lambda1)) ^ 2.0))))))); else tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + (t_1 * (sin((lambda2 * -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[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$3 = N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.0048], N[Not[LessEqual[lambda1, 3.2e-20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(t$95$1 * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(t$95$1 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := {\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_3 := \sqrt{t\_0 \cdot \left(t\_1 \cdot t\_0\right) + t\_2}\\
\mathbf{if}\;\lambda_1 \leq -0.0048 \lor \neg \left(\lambda_1 \leq 3.2 \cdot 10^{-20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_2 + t\_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_2 + t\_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -0.00479999999999999958 or 3.1999999999999997e-20 < lambda1 Initial program 49.7%
div-sub49.7%
sin-diff50.8%
Applied egg-rr50.8%
div-sub49.7%
sin-diff50.8%
Applied egg-rr61.2%
Taylor expanded in lambda2 around 0 61.2%
associate-*r*61.2%
*-commutative61.2%
Simplified61.2%
if -0.00479999999999999958 < lambda1 < 3.1999999999999997e-20Initial program 83.7%
div-sub83.7%
sin-diff84.2%
Applied egg-rr84.2%
div-sub83.7%
sin-diff84.2%
Applied egg-rr97.8%
Taylor expanded in lambda1 around 0 97.8%
associate-*r*97.8%
*-commutative97.8%
Simplified97.8%
Final simplification78.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(fma
(sin (* phi1 0.5))
(cos (* 0.5 phi2))
(* (cos (* phi1 0.5)) (- (sin (* 0.5 phi2)))))
2.0)
t_1))
(sqrt
(-
1.0
(+
t_1
(pow
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((pow(fma(sin((phi1 * 0.5)), cos((0.5 * phi2)), (cos((phi1 * 0.5)) * -sin((0.5 * phi2)))), 2.0) + t_1)), sqrt((1.0 - (t_1 + pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(sin(Float64(phi1 * 0.5)), cos(Float64(0.5 * phi2)), Float64(cos(Float64(phi1 * 0.5)) * Float64(-sin(Float64(0.5 * phi2))))) ^ 2.0) + t_1)), sqrt(Float64(1.0 - 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))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * (-N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - 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]], $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{{\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(0.5 \cdot \phi_2\right), \cos \left(\phi_1 \cdot 0.5\right) \cdot \left(-\sin \left(0.5 \cdot \phi_2\right)\right)\right)\right)}^{2} + t\_1}}{\sqrt{1 - \left(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}\right)}}\right)
\end{array}
\end{array}
Initial program 65.9%
div-sub65.9%
sin-diff66.7%
Applied egg-rr66.7%
div-sub65.9%
sin-diff66.7%
Applied egg-rr78.7%
expm1-log1p-u78.7%
div-inv78.7%
metadata-eval78.7%
div-inv78.7%
metadata-eval78.7%
Applied egg-rr78.7%
cancel-sign-sub-inv78.7%
expm1-log1p-u78.7%
fma-define78.7%
*-commutative78.7%
div-inv78.7%
metadata-eval78.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
Applied egg-rr78.7%
Final simplification78.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (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))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (+ (* t_2 (* t_0 t_2)) t_1)))
(if (or (<= lambda1 -0.0048) (not (<= lambda1 3.2e-20)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_1 (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
(sqrt (- 1.0 t_3)))))
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt (- 1.0 (+ t_1 (* t_0 (pow (sin (* lambda2 -0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (t_2 * (t_0 * t_2)) + t_1;
double tmp;
if ((lambda1 <= -0.0048) || !(lambda1 <= 3.2e-20)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_1 + (t_0 * pow(sin((lambda2 * -0.5)), 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (t_2 * (t_0 * t_2)) + t_1
if ((lambda1 <= (-0.0048d0)) .or. (.not. (lambda1 <= 3.2d-20))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), sqrt((1.0d0 - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_1 + (t_0 * (sin((lambda2 * (-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.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_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (t_2 * (t_0 * t_2)) + t_1;
double tmp;
if ((lambda1 <= -0.0048) || !(lambda1 <= 3.2e-20)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), Math.sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_1 + (t_0 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 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) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (t_2 * (t_0 * t_2)) + t_1 tmp = 0 if (lambda1 <= -0.0048) or not (lambda1 <= 3.2e-20): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), math.sqrt((1.0 - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_1 + (t_0 * math.pow(math.sin((lambda2 * -0.5)), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = 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 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(t_2 * Float64(t_0 * t_2)) + t_1) tmp = 0.0 if ((lambda1 <= -0.0048) || !(lambda1 <= 3.2e-20)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), sqrt(Float64(1.0 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_0 * (sin(Float64(lambda2 * -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 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (t_2 * (t_0 * t_2)) + t_1; tmp = 0.0; if ((lambda1 <= -0.0048) || ~((lambda1 <= 3.2e-20))) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), sqrt((1.0 - t_3)))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_1 + (t_0 * (sin((lambda2 * -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[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$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, If[Or[LessEqual[lambda1, -0.0048], N[Not[LessEqual[lambda1, 3.2e-20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$0 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\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_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(t\_0 \cdot t\_2\right) + t\_1\\
\mathbf{if}\;\lambda_1 \leq -0.0048 \lor \neg \left(\lambda_1 \leq 3.2 \cdot 10^{-20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \left(t\_1 + t\_0 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -0.00479999999999999958 or 3.1999999999999997e-20 < lambda1 Initial program 49.7%
div-sub49.7%
sin-diff50.8%
Applied egg-rr50.8%
div-sub49.7%
sin-diff50.8%
Applied egg-rr61.2%
Taylor expanded in lambda2 around 0 61.1%
if -0.00479999999999999958 < lambda1 < 3.1999999999999997e-20Initial program 83.7%
div-sub83.7%
sin-diff84.2%
Applied egg-rr84.2%
div-sub83.7%
sin-diff84.2%
Applied egg-rr97.8%
Taylor expanded in lambda1 around 0 97.8%
associate-*r*97.8%
*-commutative97.8%
Simplified97.8%
Final simplification78.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (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))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (sqrt (- 1.0 (+ (* t_2 (* t_0 t_2)) t_1)))))
(if (or (<= lambda2 -6.7e-9) (not (<= lambda2 1.8e-6)))
(*
R
(*
2.0
(atan2 (sqrt (+ t_1 (* t_0 (pow (sin (* lambda2 -0.5)) 2.0)))) t_3)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_1 (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
t_3))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1)));
double tmp;
if ((lambda2 <= -6.7e-9) || !(lambda2 <= 1.8e-6)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * pow(sin((lambda2 * -0.5)), 2.0)))), t_3));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), t_3));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt((1.0d0 - ((t_2 * (t_0 * t_2)) + t_1)))
if ((lambda2 <= (-6.7d-9)) .or. (.not. (lambda2 <= 1.8d-6))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), t_3))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), t_3))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double 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 t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1)));
double tmp;
if ((lambda2 <= -6.7e-9) || !(lambda2 <= 1.8e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), t_3));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), t_3));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = 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) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1))) tmp = 0 if (lambda2 <= -6.7e-9) or not (lambda2 <= 1.8e-6): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), t_3)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), t_3)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = 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 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64(1.0 - Float64(Float64(t_2 * Float64(t_0 * t_2)) + t_1))) tmp = 0.0 if ((lambda2 <= -6.7e-9) || !(lambda2 <= 1.8e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), t_3))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), t_3))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1))); tmp = 0.0; if ((lambda2 <= -6.7e-9) || ~((lambda2 <= 1.8e-6))) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (sin((lambda2 * -0.5)) ^ 2.0)))), t_3)); else tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), t_3)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(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$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -6.7e-9], N[Not[LessEqual[lambda2, 1.8e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
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}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{1 - \left(t\_2 \cdot \left(t\_0 \cdot t\_2\right) + t\_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -6.7 \cdot 10^{-9} \lor \neg \left(\lambda_2 \leq 1.8 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{t\_3}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{t\_3}\right)\\
\end{array}
\end{array}
if lambda2 < -6.69999999999999961e-9 or 1.79999999999999992e-6 < lambda2 Initial program 50.0%
div-sub50.0%
sin-diff50.6%
Applied egg-rr50.6%
div-sub50.0%
sin-diff50.6%
Applied egg-rr56.1%
Taylor expanded in lambda1 around 0 56.1%
associate-*r*56.1%
*-commutative56.1%
Simplified56.1%
if -6.69999999999999961e-9 < lambda2 < 1.79999999999999992e-6Initial program 79.6%
div-sub79.6%
sin-diff80.7%
Applied egg-rr80.7%
div-sub79.6%
sin-diff80.7%
Applied egg-rr98.2%
Taylor expanded in lambda2 around 0 98.2%
Final simplification78.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* t_0 (* t_1 t_0)))
(t_3 (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
(t_4 (pow (- (* (cos (/ phi2 2.0)) (sin (/ phi1 2.0))) t_3) 2.0))
(t_5 (sqrt (- 1.0 (+ t_2 t_4))))
(t_6 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= lambda2 -5.2e-9)
(*
R
(* 2.0 (atan2 (sqrt (+ t_2 (pow (- (sin (* phi1 0.5)) t_3) 2.0))) t_5)))
(if (<= lambda2 5.8e-33)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_4
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
t_5)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_6
(*
t_1
(-
0.5
(/
(+
(* (cos lambda1) (cos lambda2))
(* (sin lambda1) (sin lambda2)))
2.0)))))
(sqrt (- (- 1.0 t_6) (* t_1 (* t_0 t_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 t_2 = t_0 * (t_1 * t_0);
double t_3 = cos((phi1 / 2.0)) * sin((phi2 / 2.0));
double t_4 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - t_3), 2.0);
double t_5 = sqrt((1.0 - (t_2 + t_4)));
double t_6 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (lambda2 <= -5.2e-9) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow((sin((phi1 * 0.5)) - t_3), 2.0))), t_5));
} else if (lambda2 <= 5.8e-33) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), t_5));
} else {
tmp = R * (2.0 * atan2(sqrt((t_6 + (t_1 * (0.5 - (((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0))))), sqrt(((1.0 - t_6) - (t_1 * (t_0 * t_0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = t_0 * (t_1 * t_0)
t_3 = cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0))
t_4 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - t_3) ** 2.0d0
t_5 = sqrt((1.0d0 - (t_2 + t_4)))
t_6 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (lambda2 <= (-5.2d-9)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + ((sin((phi1 * 0.5d0)) - t_3) ** 2.0d0))), t_5))
else if (lambda2 <= 5.8d-33) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), t_5))
else
tmp = r * (2.0d0 * atan2(sqrt((t_6 + (t_1 * (0.5d0 - (((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0d0))))), sqrt(((1.0d0 - t_6) - (t_1 * (t_0 * 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.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = t_0 * (t_1 * t_0);
double t_3 = Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0));
double t_4 = Math.pow(((Math.cos((phi2 / 2.0)) * Math.sin((phi1 / 2.0))) - t_3), 2.0);
double t_5 = Math.sqrt((1.0 - (t_2 + t_4)));
double t_6 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (lambda2 <= -5.2e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((Math.sin((phi1 * 0.5)) - t_3), 2.0))), t_5));
} else if (lambda2 <= 5.8e-33) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), t_5));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_6 + (t_1 * (0.5 - (((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))) / 2.0))))), Math.sqrt(((1.0 - t_6) - (t_1 * (t_0 * t_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_2 = t_0 * (t_1 * t_0) t_3 = math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)) t_4 = math.pow(((math.cos((phi2 / 2.0)) * math.sin((phi1 / 2.0))) - t_3), 2.0) t_5 = math.sqrt((1.0 - (t_2 + t_4))) t_6 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if lambda2 <= -5.2e-9: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((math.sin((phi1 * 0.5)) - t_3), 2.0))), t_5)) elif lambda2 <= 5.8e-33: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), t_5)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_6 + (t_1 * (0.5 - (((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))) / 2.0))))), math.sqrt(((1.0 - t_6) - (t_1 * (t_0 * t_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)) t_2 = Float64(t_0 * Float64(t_1 * t_0)) t_3 = Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0))) t_4 = Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 / 2.0))) - t_3) ^ 2.0 t_5 = sqrt(Float64(1.0 - Float64(t_2 + t_4))) t_6 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (lambda2 <= -5.2e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(sin(Float64(phi1 * 0.5)) - t_3) ^ 2.0))), t_5))); elseif (lambda2 <= 5.8e-33) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), t_5))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + Float64(t_1 * Float64(0.5 - Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))) / 2.0))))), sqrt(Float64(Float64(1.0 - t_6) - Float64(t_1 * Float64(t_0 * t_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_2 = t_0 * (t_1 * t_0); t_3 = cos((phi1 / 2.0)) * sin((phi2 / 2.0)); t_4 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - t_3) ^ 2.0; t_5 = sqrt((1.0 - (t_2 + t_4))); t_6 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (lambda2 <= -5.2e-9) tmp = R * (2.0 * atan2(sqrt((t_2 + ((sin((phi1 * 0.5)) - t_3) ^ 2.0))), t_5)); elseif (lambda2 <= 5.8e-33) tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), t_5)); else tmp = R * (2.0 * atan2(sqrt((t_6 + (t_1 * (0.5 - (((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0))))), sqrt(((1.0 - t_6) - (t_1 * (t_0 * t_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]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(1.0 - N[(t$95$2 + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda2, -5.2e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] - t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 5.8e-33], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$6 + N[(t$95$1 * N[(0.5 - N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$6), $MachinePrecision] - N[(t$95$1 * N[(t$95$0 * t$95$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 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := t\_0 \cdot \left(t\_1 \cdot t\_0\right)\\
t_3 := \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\\
t_4 := {\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\frac{\phi_1}{2}\right) - t\_3\right)}^{2}\\
t_5 := \sqrt{1 - \left(t\_2 + t\_4\right)}\\
t_6 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\lambda_2 \leq -5.2 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(\sin \left(\phi_1 \cdot 0.5\right) - t\_3\right)}^{2}}}{t\_5}\right)\\
\mathbf{elif}\;\lambda_2 \leq 5.8 \cdot 10^{-33}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{t\_5}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6 + t\_1 \cdot \left(0.5 - \frac{\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2}{2}\right)}}{\sqrt{\left(1 - t\_6\right) - t\_1 \cdot \left(t\_0 \cdot t\_0\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -5.2000000000000002e-9Initial program 49.8%
div-sub49.8%
sin-diff50.3%
Applied egg-rr50.3%
div-sub49.8%
sin-diff50.3%
Applied egg-rr57.7%
expm1-log1p-u57.7%
div-inv57.7%
metadata-eval57.7%
div-inv57.7%
metadata-eval57.7%
Applied egg-rr57.7%
Taylor expanded in phi2 around 0 51.3%
if -5.2000000000000002e-9 < lambda2 < 5.80000000000000005e-33Initial program 78.9%
div-sub78.9%
sin-diff80.0%
Applied egg-rr80.0%
div-sub78.9%
sin-diff80.0%
Applied egg-rr98.2%
Taylor expanded in lambda2 around 0 98.1%
if 5.80000000000000005e-33 < lambda2 Initial program 54.8%
associate-*l*54.8%
Simplified54.8%
sin-mult54.8%
div-inv54.8%
metadata-eval54.8%
div-inv54.8%
metadata-eval54.8%
cos-sum54.7%
cos-254.8%
div-inv54.8%
metadata-eval54.8%
Applied egg-rr54.8%
div-sub54.8%
+-inverses54.8%
cos-054.8%
metadata-eval54.8%
*-commutative54.8%
Simplified54.8%
associate-*r*54.8%
metadata-eval54.8%
*-un-lft-identity54.8%
cos-diff55.6%
Applied egg-rr55.6%
Final simplification76.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(((Math.cos((phi2 / 2.0)) * Math.sin((phi1 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(((math.cos((phi2 / 2.0)) * math.sin((phi1 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\left(\cos \left(\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}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 65.9%
div-sub65.9%
sin-diff66.7%
Applied egg-rr66.7%
div-sub65.9%
sin-diff66.7%
Applied egg-rr78.7%
Final simplification78.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (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))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -3.5e-12) (not (<= phi2 1.2e-8)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_1 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (- 1.0 (+ (* t_2 (* t_0 t_2)) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_2 t_2))))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -3.5e-12) || !(phi2 <= 1.2e-8)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_2)))), sqrt((1.0 - ((cos(phi1) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-3.5d-12)) .or. (.not. (phi2 <= 1.2d-8))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt((1.0d0 - ((t_2 * (t_0 * t_2)) + t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_2 * t_2)))), sqrt((1.0d0 - ((cos(phi1) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double 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 t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -3.5e-12) || !(phi2 <= 1.2e-8)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_2)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.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) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -3.5e-12) or not (phi2 <= 1.2e-8): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_2)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(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 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -3.5e-12) || !(phi2 <= 1.2e-8)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64(1.0 - Float64(Float64(t_2 * Float64(t_0 * t_2)) + t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -3.5e-12) || ~((phi2 <= 1.2e-8))) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt((1.0 - ((t_2 * (t_0 * t_2)) + t_1))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_2 * t_2)))), sqrt((1.0 - ((cos(phi1) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{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]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -3.5e-12], N[Not[LessEqual[phi2, 1.2e-8]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
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}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -3.5 \cdot 10^{-12} \lor \neg \left(\phi_2 \leq 1.2 \cdot 10^{-8}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - \left(t\_2 \cdot \left(t\_0 \cdot t\_2\right) + t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -3.5e-12 or 1.19999999999999999e-8 < phi2 Initial program 52.7%
div-sub52.7%
sin-diff54.4%
Applied egg-rr54.4%
div-sub52.7%
sin-diff54.4%
Applied egg-rr78.3%
Taylor expanded in phi1 around 0 63.1%
if -3.5e-12 < phi2 < 1.19999999999999999e-8Initial program 79.1%
associate-*l*79.1%
Simplified79.0%
Taylor expanded in phi2 around 0 79.0%
*-commutative79.0%
metadata-eval79.0%
div-inv79.0%
div-sub79.0%
sin-diff79.7%
Applied egg-rr79.7%
Final simplification71.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (* phi2 -0.5)))
(t_2
(pow
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -0.23) (not (<= phi1 1.26e-12)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_2 (* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (- 1.0 (+ (* t_3 (* t_0 t_3)) t_2))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_3 t_3))))
(sqrt
(-
(- 1.0 (* phi1 (* t_1 (cos (* phi2 -0.5)))))
(+
(*
(cos phi2)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow t_1 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((phi2 * -0.5));
double t_2 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -0.23) || !(phi1 <= 1.26e-12)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((1.0 - ((t_3 * (t_0 * t_3)) + t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_3 * t_3)))), sqrt(((1.0 - (phi1 * (t_1 * cos((phi2 * -0.5))))) - ((cos(phi2) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(t_1, 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin((phi2 * (-0.5d0)))
t_2 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-0.23d0)) .or. (.not. (phi1 <= 1.26d-12))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt((1.0d0 - ((t_3 * (t_0 * t_3)) + t_2)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_3 * t_3)))), sqrt(((1.0d0 - (phi1 * (t_1 * cos((phi2 * (-0.5d0)))))) - ((cos(phi2) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)) + (t_1 ** 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((phi2 * -0.5));
double t_2 = 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_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -0.23) || !(phi1 <= 1.26e-12)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((1.0 - ((t_3 * (t_0 * t_3)) + t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_3 * t_3)))), Math.sqrt(((1.0 - (phi1 * (t_1 * Math.cos((phi2 * -0.5))))) - ((Math.cos(phi2) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)) + Math.pow(t_1, 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin((phi2 * -0.5)) t_2 = 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_3 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -0.23) or not (phi1 <= 1.26e-12): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((1.0 - ((t_3 * (t_0 * t_3)) + t_2))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_3 * t_3)))), math.sqrt(((1.0 - (phi1 * (t_1 * math.cos((phi2 * -0.5))))) - ((math.cos(phi2) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)) + math.pow(t_1, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(phi2 * -0.5)) t_2 = 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_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -0.23) || !(phi1 <= 1.26e-12)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64(1.0 - Float64(Float64(t_3 * Float64(t_0 * t_3)) + t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_3 * t_3)))), sqrt(Float64(Float64(1.0 - Float64(phi1 * Float64(t_1 * cos(Float64(phi2 * -0.5))))) - Float64(Float64(cos(phi2) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)) + (t_1 ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin((phi2 * -0.5)); t_2 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_3 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -0.23) || ~((phi1 <= 1.26e-12))) tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt((1.0 - ((t_3 * (t_0 * t_3)) + t_2))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_3 * t_3)))), sqrt(((1.0 - (phi1 * (t_1 * cos((phi2 * -0.5))))) - ((cos(phi2) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)) + (t_1 ^ 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[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = 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$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.23], N[Not[LessEqual[phi1, 1.26e-12]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$3 * N[(t$95$0 * t$95$3), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(phi1 * N[(t$95$1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$1, 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(\phi_2 \cdot -0.5\right)\\
t_2 := {\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_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -0.23 \lor \neg \left(\phi_1 \leq 1.26 \cdot 10^{-12}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - \left(t\_3 \cdot \left(t\_0 \cdot t\_3\right) + t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_3 \cdot t\_3\right)}}{\sqrt{\left(1 - \phi_1 \cdot \left(t\_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)\right) - \left(\cos \phi_2 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2} + {t\_1}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -0.23000000000000001 or 1.26000000000000008e-12 < phi1 Initial program 52.2%
div-sub52.2%
sin-diff53.9%
Applied egg-rr53.9%
div-sub52.2%
sin-diff53.9%
Applied egg-rr78.1%
Taylor expanded in phi2 around 0 62.3%
if -0.23000000000000001 < phi1 < 1.26000000000000008e-12Initial program 78.3%
associate-*l*78.2%
Simplified78.3%
Taylor expanded in phi1 around 0 78.3%
*-commutative49.2%
metadata-eval49.2%
div-inv49.2%
div-sub49.2%
sin-diff49.5%
Applied egg-rr78.8%
Final simplification70.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2
(pow
(-
(* (cos (/ phi2 2.0)) (sin (/ phi1 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3
(+ t_2 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(t_4 (+ (* t_0 (* t_1 t_0)) t_2)))
(if (<= phi2 -3.7e-12)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 t_3)))))
(if (<= phi2 7.5e-9)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_1 (* t_0 t_0))))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- 1.0 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = pow(((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = t_2 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0));
double t_4 = (t_0 * (t_1 * t_0)) + t_2;
double tmp;
if (phi2 <= -3.7e-12) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_3))));
} else if (phi2 <= 7.5e-9) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = ((cos((phi2 / 2.0d0)) * sin((phi1 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_3 = t_2 + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))
t_4 = (t_0 * (t_1 * t_0)) + t_2
if (phi2 <= (-3.7d-12)) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - t_3))))
else if (phi2 <= 7.5d-9) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (t_0 * t_0)))), sqrt((1.0d0 - ((cos(phi1) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = 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_3 = t_2 + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0));
double t_4 = (t_0 * (t_1 * t_0)) + t_2;
double tmp;
if (phi2 <= -3.7e-12) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - t_3))));
} else if (phi2 <= 7.5e-9) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = 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_3 = t_2 + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) t_4 = (t_0 * (t_1 * t_0)) + t_2 tmp = 0 if phi2 <= -3.7e-12: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - t_3)))) elif phi2 <= 7.5e-9: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_0)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = 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_3 = Float64(t_2 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) t_4 = Float64(Float64(t_0 * Float64(t_1 * t_0)) + t_2) tmp = 0.0 if (phi2 <= -3.7e-12) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - t_3))))); elseif (phi2 <= 7.5e-9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = ((cos((phi2 / 2.0)) * sin((phi1 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_3 = t_2 + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)); t_4 = (t_0 * (t_1 * t_0)) + t_2; tmp = 0.0; if (phi2 <= -3.7e-12) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - t_3)))); elseif (phi2 <= 7.5e-9) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = 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$3 = N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]}, If[LessEqual[phi2, -3.7e-12], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 7.5e-9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := {\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_3 := t\_2 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_4 := t\_0 \cdot \left(t\_1 \cdot t\_0\right) + t\_2\\
\mathbf{if}\;\phi_2 \leq -3.7 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - t\_3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 7.5 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1 \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if phi2 < -3.69999999999999999e-12Initial program 58.1%
div-sub58.1%
sin-diff59.8%
Applied egg-rr59.8%
div-sub58.1%
sin-diff59.8%
Applied egg-rr79.0%
Taylor expanded in phi1 around 0 66.3%
if -3.69999999999999999e-12 < phi2 < 7.49999999999999933e-9Initial program 79.1%
associate-*l*79.1%
Simplified79.0%
Taylor expanded in phi2 around 0 79.0%
*-commutative79.0%
metadata-eval79.0%
div-inv79.0%
div-sub79.0%
sin-diff79.7%
Applied egg-rr79.7%
if 7.49999999999999933e-9 < phi2 Initial program 46.3%
div-sub46.3%
sin-diff48.1%
Applied egg-rr48.1%
div-sub46.3%
sin-diff48.1%
Applied egg-rr77.4%
Taylor expanded in phi1 around 0 59.6%
Final simplification71.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
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 65.9%
div-sub65.9%
sin-diff66.7%
Applied egg-rr66.7%
unpow266.7%
sin-mult66.7%
div-inv66.7%
metadata-eval66.7%
div-inv66.7%
metadata-eval66.7%
div-inv66.7%
metadata-eval66.7%
div-inv66.7%
metadata-eval66.7%
Applied egg-rr66.7%
div-sub66.7%
+-inverses66.7%
+-inverses66.7%
+-inverses66.7%
cos-066.7%
metadata-eval66.7%
distribute-lft-out66.7%
metadata-eval66.7%
*-rgt-identity66.7%
Simplified66.7%
Final simplification66.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(pow
(- (sin (/ phi1 2.0)) (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(sqrt (- 1.0 (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow((sin((phi1 / 2.0)) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0))), sqrt((1.0 - (t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + ((sin((phi1 / 2.0d0)) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0))), sqrt((1.0d0 - (t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow((Math.sin((phi1 / 2.0)) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0))), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow((math.sin((phi1 / 2.0)) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0))), math.sqrt((1.0 - (t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (Float64(sin(Float64(phi1 / 2.0)) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + ((sin((phi1 / 2.0)) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0))), sqrt((1.0 - (t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[(N[Sin[N[(phi1 / 2.0), $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[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\left(\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(t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 65.9%
div-sub65.9%
sin-diff66.7%
Applied egg-rr66.7%
Taylor expanded in phi2 around 0 66.5%
Final simplification66.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (+ 1.0 (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 + (((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + (((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + (((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 + (((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 65.9%
unpow266.7%
sin-mult66.7%
div-inv66.7%
metadata-eval66.7%
div-inv66.7%
metadata-eval66.7%
div-inv66.7%
metadata-eval66.7%
div-inv66.7%
metadata-eval66.7%
Applied egg-rr65.9%
div-sub66.7%
+-inverses66.7%
+-inverses66.7%
+-inverses66.7%
cos-066.7%
metadata-eval66.7%
distribute-lft-out66.7%
metadata-eval66.7%
*-rgt-identity66.7%
Simplified65.9%
Final simplification65.9%
(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 (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(+
(- 1.0 t_2)
(*
t_0
(- (/ (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))) 2.0) 0.5)))))))))
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(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) + (t_0 * ((cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
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(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) + (t_0 * ((Math.cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
}
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(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) + (t_0 * ((math.cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0) - 0.5))))))
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(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_0 * Float64(Float64(cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); 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[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $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(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - t\_2\right) + t\_0 \cdot \left(\frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 65.9%
associate-*l*65.8%
Simplified65.8%
sin-mult65.3%
div-inv65.3%
metadata-eval65.3%
div-inv65.3%
metadata-eval65.3%
cos-sum65.3%
cos-265.3%
div-inv65.3%
metadata-eval65.3%
Applied egg-rr65.8%
div-sub65.3%
+-inverses65.3%
cos-065.3%
metadata-eval65.3%
*-commutative65.3%
Simplified65.8%
Final simplification65.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)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (or (<= phi1 -2.5e+33) (not (<= phi1 6.5e-6)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
1.0
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* (cos phi2) (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))))
(sqrt (- (- 1.0 t_2) 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);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((phi1 <= -2.5e+33) || !(phi1 <= 6.5e-6)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * (0.5 - (0.5 * cos((lambda1 - lambda2))))))), sqrt(((1.0 - t_2) - t_1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if ((phi1 <= (-2.5d+33)) .or. (.not. (phi1 <= 6.5d-6))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (cos(phi2) * (0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))))), sqrt(((1.0d0 - t_2) - 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.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(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((phi1 <= -2.5e+33) || !(phi1 <= 6.5e-6)) {
tmp = 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 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi2) * (0.5 - (0.5 * Math.cos((lambda1 - lambda2))))))), Math.sqrt(((1.0 - t_2) - t_1))));
}
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(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if (phi1 <= -2.5e+33) or not (phi1 <= 6.5e-6): tmp = 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 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (math.cos(phi2) * (0.5 - (0.5 * math.cos((lambda1 - lambda2))))))), math.sqrt(((1.0 - t_2) - t_1)))) 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(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if ((phi1 <= -2.5e+33) || !(phi1 <= 6.5e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))))), sqrt(Float64(Float64(1.0 - t_2) - t_1))))); 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(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if ((phi1 <= -2.5e+33) || ~((phi1 <= 6.5e-6))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * (0.5 - (0.5 * cos((lambda1 - lambda2))))))), sqrt(((1.0 - t_2) - t_1)))); 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[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -2.5e+33], N[Not[LessEqual[phi1, 6.5e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $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)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -2.5 \cdot 10^{+33} \lor \neg \left(\phi_1 \leq 6.5 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}{\sqrt{\left(1 - t\_2\right) - t\_1}}\right)\\
\end{array}
\end{array}
if phi1 < -2.49999999999999986e33 or 6.4999999999999996e-6 < phi1 Initial program 53.3%
associate-*l*53.3%
Simplified53.2%
Taylor expanded in phi2 around 0 53.8%
unpow254.9%
sin-mult54.9%
div-inv54.9%
metadata-eval54.9%
div-inv54.9%
metadata-eval54.9%
div-inv54.9%
metadata-eval54.9%
div-inv54.9%
metadata-eval54.9%
Applied egg-rr53.8%
div-sub54.9%
+-inverses54.9%
+-inverses54.9%
+-inverses54.9%
cos-054.9%
metadata-eval54.9%
distribute-lft-out54.9%
metadata-eval54.9%
*-rgt-identity54.9%
Simplified53.8%
if -2.49999999999999986e33 < phi1 < 6.4999999999999996e-6Initial program 76.0%
associate-*l*75.9%
Simplified75.9%
sin-mult75.0%
div-inv75.0%
metadata-eval75.0%
div-inv75.0%
metadata-eval75.0%
cos-sum75.0%
cos-275.0%
div-inv75.0%
metadata-eval75.0%
Applied egg-rr75.0%
div-sub75.0%
+-inverses75.0%
cos-075.0%
metadata-eval75.0%
*-commutative75.0%
Simplified75.0%
Taylor expanded in phi1 around 0 75.2%
Final simplification65.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* 0.5 (- lambda1 lambda2)))
(t_4 (pow (sin t_3) 2.0)))
(if (or (<= phi1 -3.1e+33) (not (<= phi1 6.5e-6)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_2)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) (* (cos phi1) t_4)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 (- 0.5 (/ (cos (* 2.0 t_3)) 2.0)))))
(sqrt (- (- 1.0 t_0) (* (cos phi2) t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = 0.5 * (lambda1 - lambda2);
double t_4 = pow(sin(t_3), 2.0);
double tmp;
if ((phi1 <= -3.1e+33) || !(phi1 <= 6.5e-6)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * t_4))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (0.5 - (cos((2.0 * t_3)) / 2.0))))), sqrt(((1.0 - t_0) - (cos(phi2) * t_4)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = 0.5d0 * (lambda1 - lambda2)
t_4 = sin(t_3) ** 2.0d0
if ((phi1 <= (-3.1d+33)) .or. (.not. (phi1 <= 6.5d-6))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * t_4))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * (0.5d0 - (cos((2.0d0 * t_3)) / 2.0d0))))), sqrt(((1.0d0 - t_0) - (cos(phi2) * t_4)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = 0.5 * (lambda1 - lambda2);
double t_4 = Math.pow(Math.sin(t_3), 2.0);
double tmp;
if ((phi1 <= -3.1e+33) || !(phi1 <= 6.5e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * t_4))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (0.5 - (Math.cos((2.0 * t_3)) / 2.0))))), Math.sqrt(((1.0 - t_0) - (Math.cos(phi2) * t_4)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = 0.5 * (lambda1 - lambda2) t_4 = math.pow(math.sin(t_3), 2.0) tmp = 0 if (phi1 <= -3.1e+33) or not (phi1 <= 6.5e-6): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * t_4)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (0.5 - (math.cos((2.0 * t_3)) / 2.0))))), math.sqrt(((1.0 - t_0) - (math.cos(phi2) * t_4))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(0.5 * Float64(lambda1 - lambda2)) t_4 = sin(t_3) ^ 2.0 tmp = 0.0 if ((phi1 <= -3.1e+33) || !(phi1 <= 6.5e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_2)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * t_4))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(0.5 - Float64(cos(Float64(2.0 * t_3)) / 2.0))))), sqrt(Float64(Float64(1.0 - t_0) - Float64(cos(phi2) * t_4)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = 0.5 * (lambda1 - lambda2); t_4 = sin(t_3) ^ 2.0; tmp = 0.0; if ((phi1 <= -3.1e+33) || ~((phi1 <= 6.5e-6))) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * t_4)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (0.5 - (cos((2.0 * t_3)) / 2.0))))), sqrt(((1.0 - t_0) - (cos(phi2) * t_4))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[t$95$3], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.1e+33], N[Not[LessEqual[phi1, 6.5e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[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] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(0.5 - N[(N[Cos[N[(2.0 * t$95$3), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := 0.5 \cdot \left(\lambda_1 - \lambda_2\right)\\
t_4 := {\sin t\_3}^{2}\\
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{+33} \lor \neg \left(\phi_1 \leq 6.5 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot t\_4\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_1 \cdot \left(0.5 - \frac{\cos \left(2 \cdot t\_3\right)}{2}\right)}}{\sqrt{\left(1 - t\_0\right) - \cos \phi_2 \cdot t\_4}}\right)\\
\end{array}
\end{array}
if phi1 < -3.1e33 or 6.4999999999999996e-6 < phi1 Initial program 53.3%
associate-*l*53.3%
Simplified53.2%
Taylor expanded in phi2 around 0 53.8%
unpow254.9%
sin-mult54.9%
div-inv54.9%
metadata-eval54.9%
div-inv54.9%
metadata-eval54.9%
div-inv54.9%
metadata-eval54.9%
div-inv54.9%
metadata-eval54.9%
Applied egg-rr53.8%
div-sub54.9%
+-inverses54.9%
+-inverses54.9%
+-inverses54.9%
cos-054.9%
metadata-eval54.9%
distribute-lft-out54.9%
metadata-eval54.9%
*-rgt-identity54.9%
Simplified53.8%
if -3.1e33 < phi1 < 6.4999999999999996e-6Initial program 76.0%
associate-*l*75.9%
Simplified75.9%
sin-mult75.0%
div-inv75.0%
metadata-eval75.0%
div-inv75.0%
metadata-eval75.0%
cos-sum75.0%
cos-275.0%
div-inv75.0%
metadata-eval75.0%
Applied egg-rr75.0%
div-sub75.0%
+-inverses75.0%
cos-075.0%
metadata-eval75.0%
*-commutative75.0%
Simplified75.0%
Taylor expanded in phi1 around 0 75.1%
Final simplification65.6%
(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 -2550.0) (not (<= phi1 3e-6)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (pow (sin (* phi1 0.5)) 2.0) (* (cos phi1) t_2)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -2550.0) || !(phi1 <= 3e-6)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * t_2))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((1.0 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: 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 <= (-2550.0d0)) .or. (.not. (phi1 <= 3d-6))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * t_2))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((1.0d0 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.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 <= -2550.0) || !(phi1 <= 3e-6)) {
tmp = 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 * 0.5)), 2.0) + (Math.cos(phi1) * t_2))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.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 <= -2550.0) or not (phi1 <= 3e-6): tmp = 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 * 0.5)), 2.0) + (math.cos(phi1) * t_2)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(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 <= -2550.0) || !(phi1 <= 3e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * t_2))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = 0.0; if ((phi1 <= -2550.0) || ~((phi1 <= 3e-6))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * t_2)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(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, -2550.0], N[Not[LessEqual[phi1, 3e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \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 -2550 \lor \neg \left(\phi_1 \leq 3 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if phi1 < -2550 or 3.0000000000000001e-6 < phi1 Initial program 52.4%
associate-*l*52.4%
Simplified52.4%
Taylor expanded in phi2 around 0 52.9%
unpow254.2%
sin-mult54.2%
div-inv54.2%
metadata-eval54.2%
div-inv54.2%
metadata-eval54.2%
div-inv54.2%
metadata-eval54.2%
div-inv54.2%
metadata-eval54.2%
Applied egg-rr52.9%
div-sub54.2%
+-inverses54.2%
+-inverses54.2%
+-inverses54.2%
cos-054.2%
metadata-eval54.2%
distribute-lft-out54.2%
metadata-eval54.2%
*-rgt-identity54.2%
Simplified52.9%
if -2550 < phi1 < 3.0000000000000001e-6Initial program 77.5%
associate-*l*77.5%
Simplified77.5%
Taylor expanded in phi2 around 0 48.7%
Taylor expanded in phi1 around 0 48.7%
Final simplification50.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (/ (cos (* 2.0 (* 0.5 (- lambda1 lambda2)))) 2.0))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (- 0.5 t_1))))
(sqrt (+ (- 1.0 t_2) (* t_0 (- t_1 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0;
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (0.5 - t_1)))), sqrt(((1.0 - t_2) + (t_0 * (t_1 - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = cos((2.0d0 * (0.5d0 * (lambda1 - lambda2)))) / 2.0d0
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (0.5d0 - t_1)))), sqrt(((1.0d0 - t_2) + (t_0 * (t_1 - 0.5d0))))))
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.cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0;
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (0.5 - t_1)))), Math.sqrt(((1.0 - t_2) + (t_0 * (t_1 - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0 t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (0.5 - t_1)))), math.sqrt(((1.0 - t_2) + (t_0 * (t_1 - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(cos(Float64(2.0 * Float64(0.5 * Float64(lambda1 - lambda2)))) / 2.0) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(0.5 - t_1)))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_0 * Float64(t_1 - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = cos((2.0 * (0.5 * (lambda1 - lambda2)))) / 2.0; t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (0.5 - t_1)))), sqrt(((1.0 - t_2) + (t_0 * (t_1 - 0.5)))))); 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[(N[Cos[N[(2.0 * N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$0 * N[(t$95$1 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \frac{\cos \left(2 \cdot \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_0 \cdot \left(0.5 - t\_1\right)}}{\sqrt{\left(1 - t\_2\right) + t\_0 \cdot \left(t\_1 - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 65.9%
associate-*l*65.8%
Simplified65.8%
sin-mult65.3%
div-inv65.3%
metadata-eval65.3%
div-inv65.3%
metadata-eval65.3%
cos-sum65.3%
cos-265.3%
div-inv65.3%
metadata-eval65.3%
Applied egg-rr65.3%
div-sub65.3%
+-inverses65.3%
cos-065.3%
metadata-eval65.3%
*-commutative65.3%
Simplified65.3%
sin-mult65.3%
div-inv65.3%
metadata-eval65.3%
div-inv65.3%
metadata-eval65.3%
cos-sum65.3%
cos-265.3%
div-inv65.3%
metadata-eval65.3%
Applied egg-rr65.4%
div-sub65.3%
+-inverses65.3%
cos-065.3%
metadata-eval65.3%
*-commutative65.3%
Simplified65.4%
Final simplification65.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_2 (sin (* phi2 -0.5))))
(if (<= phi2 -5200000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt
(- (- 1.0 (* phi1 (* t_2 (cos (* phi2 -0.5))))) (pow t_2 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
1.0
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (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));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = sin((phi2 * -0.5));
double tmp;
if (phi2 <= -5200000000.0) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 - (phi1 * (t_2 * cos((phi2 * -0.5))))) - pow(t_2, 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 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((phi2 * (-0.5d0)))
if (phi2 <= (-5200000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 - (phi1 * (t_2 * cos((phi2 * (-0.5d0)))))) - (t_2 ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 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.sin((phi2 * -0.5));
double tmp;
if (phi2 <= -5200000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 - (phi1 * (t_2 * Math.cos((phi2 * -0.5))))) - Math.pow(t_2, 2.0)))));
} else {
tmp = 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 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 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.sin((phi2 * -0.5)) tmp = 0 if phi2 <= -5200000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 - (phi1 * (t_2 * math.cos((phi2 * -0.5))))) - math.pow(t_2, 2.0))))) else: tmp = 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 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 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(phi2 * -0.5)) tmp = 0.0 if (phi2 <= -5200000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - Float64(phi1 * Float64(t_2 * cos(Float64(phi2 * -0.5))))) - (t_2 ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 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((phi2 * -0.5)); tmp = 0.0; if (phi2 <= -5200000000.0) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 - (phi1 * (t_2 * cos((phi2 * -0.5))))) - (t_2 ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 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[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -5200000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(phi1 * N[(t$95$2 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\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(\phi_2 \cdot -0.5\right)\\
\mathbf{if}\;\phi_2 \leq -5200000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 - \phi_1 \cdot \left(t\_2 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)\right) - {t\_2}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -5.2e9Initial program 57.8%
associate-*l*57.7%
Simplified57.8%
Taylor expanded in phi1 around 0 53.1%
Taylor expanded in lambda1 around 0 39.9%
*-commutative39.9%
Simplified39.9%
Taylor expanded in lambda2 around 0 33.8%
mul-1-neg33.8%
unsub-neg33.8%
*-commutative33.8%
*-commutative33.8%
*-commutative33.8%
*-commutative33.8%
Simplified33.8%
if -5.2e9 < phi2 Initial program 68.2%
associate-*l*68.2%
Simplified68.2%
Taylor expanded in phi2 around 0 59.6%
unpow268.8%
sin-mult68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
Applied egg-rr55.3%
div-sub68.9%
+-inverses68.9%
+-inverses68.9%
+-inverses68.9%
cos-068.9%
metadata-eval68.9%
distribute-lft-out68.9%
metadata-eval68.9%
*-rgt-identity68.9%
Simplified55.3%
Final simplification50.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (* 0.5 (- lambda1 lambda2))))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi1 1e-7)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_3))))
(sqrt (- 1.0 (pow t_1 2.0))))))
(*
R
(*
2.0
(atan2
(hypot (* t_1 (sqrt (cos phi1))) (sin (* phi1 0.5)))
(sqrt (- 1.0 (+ (* t_3 (* t_2 t_3)) 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 = sin((0.5 * (lambda1 - lambda2)));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= 1e-7) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((1.0 - pow(t_1, 2.0)))));
} else {
tmp = R * (2.0 * atan2(hypot((t_1 * sqrt(cos(phi1))), sin((phi1 * 0.5))), sqrt((1.0 - ((t_3 * (t_2 * t_3)) + t_0)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin((0.5 * (lambda1 - lambda2)));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= 1e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), Math.sqrt((1.0 - Math.pow(t_1, 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot((t_1 * Math.sqrt(Math.cos(phi1))), Math.sin((phi1 * 0.5))), Math.sqrt((1.0 - ((t_3 * (t_2 * t_3)) + 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.sin((0.5 * (lambda1 - lambda2))) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi1 <= 1e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), math.sqrt((1.0 - math.pow(t_1, 2.0))))) else: tmp = R * (2.0 * math.atan2(math.hypot((t_1 * math.sqrt(math.cos(phi1))), math.sin((phi1 * 0.5))), math.sqrt((1.0 - ((t_3 * (t_2 * t_3)) + 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))) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi1 <= 1e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(1.0 - (t_1 ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(Float64(t_1 * sqrt(cos(phi1))), sin(Float64(phi1 * 0.5))), sqrt(Float64(1.0 - Float64(Float64(t_3 * Float64(t_2 * t_3)) + 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))); t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi1 <= 1e-7) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((1.0 - (t_1 ^ 2.0))))); else tmp = R * (2.0 * atan2(hypot((t_1 * sqrt(cos(phi1))), sin((phi1 * 0.5))), sqrt((1.0 - ((t_3 * (t_2 * t_3)) + 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[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 1e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$3 * N[(t$95$2 * t$95$3), $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)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_3 \cdot t\_3\right)}}{\sqrt{1 - {t\_1}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_1 \cdot \sqrt{\cos \phi_1}, \sin \left(\phi_1 \cdot 0.5\right)\right)}{\sqrt{1 - \left(t\_3 \cdot \left(t\_2 \cdot t\_3\right) + t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < 9.9999999999999995e-8Initial program 68.5%
associate-*l*68.5%
Simplified68.5%
Taylor expanded in phi2 around 0 48.4%
Taylor expanded in phi1 around 0 39.9%
if 9.9999999999999995e-8 < phi1 Initial program 57.4%
Taylor expanded in phi1 around inf 58.0%
+-commutative58.0%
associate-*l*58.0%
pow258.0%
div-inv58.0%
metadata-eval58.0%
add-sqr-sqrt40.7%
unpow240.7%
hypot-define40.6%
div-inv40.6%
Applied egg-rr40.6%
Taylor expanded in phi2 around 0 38.1%
Final simplification39.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), 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.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_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.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_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(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 65.9%
associate-*l*65.8%
Simplified65.8%
Taylor expanded in phi2 around 0 50.6%
Taylor expanded in phi1 around 0 35.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt (pow (cos (* lambda2 -0.5)) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt(pow(cos((lambda2 * -0.5)), 2.0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)))), Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))), math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 65.9%
associate-*l*65.8%
Simplified65.8%
Taylor expanded in phi1 around 0 46.3%
Taylor expanded in lambda1 around 0 35.6%
*-commutative35.6%
Simplified35.6%
Taylor expanded in phi2 around 0 30.8%
unpow230.8%
1-sub-sin30.8%
unpow230.8%
*-commutative30.8%
Simplified30.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5)))
(t_1 (/ (sin (* phi2 -0.5)) phi1))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(sqrt
(-
1.0
(+
(* t_2 (* (* (cos phi1) (cos phi2)) t_2))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))
(if (<= phi1 -4.2e-279)
(* R (* 2.0 (atan2 (* phi1 (- (* 0.5 (- t_0)) t_1)) t_3)))
(* R (* 2.0 (atan2 (* phi1 (+ (* 0.5 t_0) t_1)) t_3))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double t_1 = sin((phi2 * -0.5)) / phi1;
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((1.0 - ((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))));
double tmp;
if (phi1 <= -4.2e-279) {
tmp = R * (2.0 * atan2((phi1 * ((0.5 * -t_0) - t_1)), t_3));
} else {
tmp = R * (2.0 * atan2((phi1 * ((0.5 * t_0) + t_1)), 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 = cos((phi2 * (-0.5d0)))
t_1 = sin((phi2 * (-0.5d0))) / phi1
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt((1.0d0 - ((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))
if (phi1 <= (-4.2d-279)) then
tmp = r * (2.0d0 * atan2((phi1 * ((0.5d0 * -t_0) - t_1)), t_3))
else
tmp = r * (2.0d0 * atan2((phi1 * ((0.5d0 * t_0) + t_1)), 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.cos((phi2 * -0.5));
double t_1 = Math.sin((phi2 * -0.5)) / phi1;
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt((1.0 - ((t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))));
double tmp;
if (phi1 <= -4.2e-279) {
tmp = R * (2.0 * Math.atan2((phi1 * ((0.5 * -t_0) - t_1)), t_3));
} else {
tmp = R * (2.0 * Math.atan2((phi1 * ((0.5 * t_0) + t_1)), t_3));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) t_1 = math.sin((phi2 * -0.5)) / phi1 t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((1.0 - ((t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))) tmp = 0 if phi1 <= -4.2e-279: tmp = R * (2.0 * math.atan2((phi1 * ((0.5 * -t_0) - t_1)), t_3)) else: tmp = R * (2.0 * math.atan2((phi1 * ((0.5 * t_0) + t_1)), t_3)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) t_1 = Float64(sin(Float64(phi2 * -0.5)) / phi1) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64(1.0 - Float64(Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))) tmp = 0.0 if (phi1 <= -4.2e-279) tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(Float64(0.5 * Float64(-t_0)) - t_1)), t_3))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(Float64(0.5 * t_0) + t_1)), t_3))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); t_1 = sin((phi2 * -0.5)) / phi1; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt((1.0 - ((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))); tmp = 0.0; if (phi1 <= -4.2e-279) tmp = R * (2.0 * atan2((phi1 * ((0.5 * -t_0) - t_1)), t_3)); else tmp = R * (2.0 * atan2((phi1 * ((0.5 * t_0) + t_1)), t_3)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] / phi1), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -4.2e-279], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(N[(0.5 * (-t$95$0)), $MachinePrecision] - t$95$1), $MachinePrecision]), $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(N[(0.5 * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \frac{\sin \left(\phi_2 \cdot -0.5\right)}{\phi_1}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{1 - \left(t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}\\
\mathbf{if}\;\phi_1 \leq -4.2 \cdot 10^{-279}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(0.5 \cdot \left(-t\_0\right) - t\_1\right)}{t\_3}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(0.5 \cdot t\_0 + t\_1\right)}{t\_3}\right)\\
\end{array}
\end{array}
if phi1 < -4.20000000000000011e-279Initial program 62.3%
Taylor expanded in phi1 around 0 48.7%
associate-*r*48.7%
Simplified48.7%
Taylor expanded in phi1 around -inf 20.7%
if -4.20000000000000011e-279 < phi1 Initial program 69.1%
Taylor expanded in phi1 around 0 52.2%
associate-*r*52.2%
Simplified52.2%
Taylor expanded in phi1 around inf 19.3%
Final simplification20.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi1 -1.05e-201)
(*
R
(*
2.0
(atan2
(*
-0.5
(*
phi1
(+
1.0
(*
(pow phi2 2.0)
(- (* (pow phi2 2.0) 0.0026041666666666665) 0.125)))))
(sqrt
(-
1.0
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(* phi1 (+ (* 0.5 (cos (* phi2 -0.5))) (/ (sin (* phi2 -0.5)) phi1)))
(sqrt
(-
1.0
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -1.05e-201) {
tmp = R * (2.0 * atan2((-0.5 * (phi1 * (1.0 + (pow(phi2, 2.0) * ((pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2((phi1 * ((0.5 * cos((phi2 * -0.5))) + (sin((phi2 * -0.5)) / phi1))), sqrt((1.0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + 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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi1 <= (-1.05d-201)) then
tmp = r * (2.0d0 * atan2(((-0.5d0) * (phi1 * (1.0d0 + ((phi2 ** 2.0d0) * (((phi2 ** 2.0d0) * 0.0026041666666666665d0) - 0.125d0))))), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2((phi1 * ((0.5d0 * cos((phi2 * (-0.5d0)))) + (sin((phi2 * (-0.5d0))) / phi1))), sqrt((1.0d0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (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.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -1.05e-201) {
tmp = R * (2.0 * Math.atan2((-0.5 * (phi1 * (1.0 + (Math.pow(phi2, 2.0) * ((Math.pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2((phi1 * ((0.5 * Math.cos((phi2 * -0.5))) + (Math.sin((phi2 * -0.5)) / phi1))), Math.sqrt((1.0 - ((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi1 <= -1.05e-201: tmp = R * (2.0 * math.atan2((-0.5 * (phi1 * (1.0 + (math.pow(phi2, 2.0) * ((math.pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))) else: tmp = R * (2.0 * math.atan2((phi1 * ((0.5 * math.cos((phi2 * -0.5))) + (math.sin((phi2 * -0.5)) / phi1))), math.sqrt((1.0 - ((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi1 <= -1.05e-201) tmp = Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi1 * Float64(1.0 + Float64((phi2 ^ 2.0) * Float64(Float64((phi2 ^ 2.0) * 0.0026041666666666665) - 0.125))))), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(Float64(0.5 * cos(Float64(phi2 * -0.5))) + Float64(sin(Float64(phi2 * -0.5)) / phi1))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi1 <= -1.05e-201) tmp = R * (2.0 * atan2((-0.5 * (phi1 * (1.0 + ((phi2 ^ 2.0) * (((phi2 ^ 2.0) * 0.0026041666666666665) - 0.125))))), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); else tmp = R * (2.0 * atan2((phi1 * ((0.5 * cos((phi2 * -0.5))) + (sin((phi2 * -0.5)) / phi1))), sqrt((1.0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1.05e-201], N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi1 * N[(1.0 + N[(N[Power[phi2, 2.0], $MachinePrecision] * N[(N[(N[Power[phi2, 2.0], $MachinePrecision] * 0.0026041666666666665), $MachinePrecision] - 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(N[(0.5 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1.05 \cdot 10^{-201}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot \left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot 0.0026041666666666665 - 0.125\right)\right)\right)}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(0.5 \cdot \cos \left(\phi_2 \cdot -0.5\right) + \frac{\sin \left(\phi_2 \cdot -0.5\right)}{\phi_1}\right)}{\sqrt{1 - \left(t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.05000000000000006e-201Initial program 59.7%
Taylor expanded in phi1 around 0 43.4%
associate-*r*43.4%
Simplified43.4%
Taylor expanded in phi1 around -inf 11.8%
*-commutative11.8%
Simplified11.8%
Taylor expanded in phi2 around 0 11.8%
Taylor expanded in phi2 around 0 17.3%
if -1.05000000000000006e-201 < phi1 Initial program 70.0%
Taylor expanded in phi1 around 0 55.3%
associate-*r*55.3%
Simplified55.3%
Taylor expanded in phi1 around inf 19.5%
Final simplification18.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi1 -5e-310)
(*
R
(*
2.0
(atan2
(*
-0.5
(*
phi1
(+
1.0
(*
(pow phi2 2.0)
(- (* (pow phi2 2.0) 0.0026041666666666665) 0.125)))))
(sqrt
(-
1.0
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(* 0.5 (* phi1 (cos (* phi2 -0.5))))
(sqrt
(-
1.0
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -5e-310) {
tmp = R * (2.0 * atan2((-0.5 * (phi1 * (1.0 + (pow(phi2, 2.0) * ((pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2((0.5 * (phi1 * cos((phi2 * -0.5)))), sqrt((1.0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + 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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi1 <= (-5d-310)) then
tmp = r * (2.0d0 * atan2(((-0.5d0) * (phi1 * (1.0d0 + ((phi2 ** 2.0d0) * (((phi2 ** 2.0d0) * 0.0026041666666666665d0) - 0.125d0))))), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2((0.5d0 * (phi1 * cos((phi2 * (-0.5d0))))), sqrt((1.0d0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (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.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -5e-310) {
tmp = R * (2.0 * Math.atan2((-0.5 * (phi1 * (1.0 + (Math.pow(phi2, 2.0) * ((Math.pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2((0.5 * (phi1 * Math.cos((phi2 * -0.5)))), Math.sqrt((1.0 - ((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi1 <= -5e-310: tmp = R * (2.0 * math.atan2((-0.5 * (phi1 * (1.0 + (math.pow(phi2, 2.0) * ((math.pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))) else: tmp = R * (2.0 * math.atan2((0.5 * (phi1 * math.cos((phi2 * -0.5)))), math.sqrt((1.0 - ((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi1 <= -5e-310) tmp = Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi1 * Float64(1.0 + Float64((phi2 ^ 2.0) * Float64(Float64((phi2 ^ 2.0) * 0.0026041666666666665) - 0.125))))), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(0.5 * Float64(phi1 * cos(Float64(phi2 * -0.5)))), sqrt(Float64(1.0 - Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi1 <= -5e-310) tmp = R * (2.0 * atan2((-0.5 * (phi1 * (1.0 + ((phi2 ^ 2.0) * (((phi2 ^ 2.0) * 0.0026041666666666665) - 0.125))))), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); else tmp = R * (2.0 * atan2((0.5 * (phi1 * cos((phi2 * -0.5)))), sqrt((1.0 - ((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e-310], N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi1 * N[(1.0 + N[(N[Power[phi2, 2.0], $MachinePrecision] * N[(N[(N[Power[phi2, 2.0], $MachinePrecision] * 0.0026041666666666665), $MachinePrecision] - 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(0.5 * N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot \left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot 0.0026041666666666665 - 0.125\right)\right)\right)}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{1 - \left(t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -4.999999999999985e-310Initial program 62.2%
Taylor expanded in phi1 around 0 49.4%
associate-*r*49.4%
Simplified49.4%
Taylor expanded in phi1 around -inf 11.5%
*-commutative11.5%
Simplified11.5%
Taylor expanded in phi2 around 0 11.6%
Taylor expanded in phi2 around 0 17.2%
if -4.999999999999985e-310 < phi1 Initial program 69.7%
Taylor expanded in phi1 around 0 51.6%
associate-*r*51.6%
Simplified51.6%
Taylor expanded in phi1 around inf 12.9%
*-commutative12.9%
Simplified12.9%
Final simplification15.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(-
1.0
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))
(if (<= phi1 -5e-310)
(*
R
(*
2.0
(atan2
(*
-0.5
(*
phi1
(+
1.0
(*
(pow phi2 2.0)
(- (* (pow phi2 2.0) 0.0026041666666666665) 0.125)))))
t_0)))
(*
R
(*
2.0
(atan2 (+ (* phi1 -0.5) (* 0.0625 (* phi1 (pow phi2 2.0)))) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
double tmp;
if (phi1 <= -5e-310) {
tmp = R * (2.0 * atan2((-0.5 * (phi1 * (1.0 + (pow(phi2, 2.0) * ((pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), t_0));
} else {
tmp = R * (2.0 * atan2(((phi1 * -0.5) + (0.0625 * (phi1 * pow(phi2, 2.0)))), t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
if (phi1 <= (-5d-310)) then
tmp = r * (2.0d0 * atan2(((-0.5d0) * (phi1 * (1.0d0 + ((phi2 ** 2.0d0) * (((phi2 ** 2.0d0) * 0.0026041666666666665d0) - 0.125d0))))), t_0))
else
tmp = r * (2.0d0 * atan2(((phi1 * (-0.5d0)) + (0.0625d0 * (phi1 * (phi2 ** 2.0d0)))), t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
double tmp;
if (phi1 <= -5e-310) {
tmp = R * (2.0 * Math.atan2((-0.5 * (phi1 * (1.0 + (Math.pow(phi2, 2.0) * ((Math.pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), t_0));
} else {
tmp = R * (2.0 * Math.atan2(((phi1 * -0.5) + (0.0625 * (phi1 * Math.pow(phi2, 2.0)))), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))) tmp = 0 if phi1 <= -5e-310: tmp = R * (2.0 * math.atan2((-0.5 * (phi1 * (1.0 + (math.pow(phi2, 2.0) * ((math.pow(phi2, 2.0) * 0.0026041666666666665) - 0.125))))), t_0)) else: tmp = R * (2.0 * math.atan2(((phi1 * -0.5) + (0.0625 * (phi1 * math.pow(phi2, 2.0)))), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))))) tmp = 0.0 if (phi1 <= -5e-310) tmp = Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi1 * Float64(1.0 + Float64((phi2 ^ 2.0) * Float64(Float64((phi2 ^ 2.0) * 0.0026041666666666665) - 0.125))))), t_0))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(phi1 * -0.5) + Float64(0.0625 * Float64(phi1 * (phi2 ^ 2.0)))), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); tmp = 0.0; if (phi1 <= -5e-310) tmp = R * (2.0 * atan2((-0.5 * (phi1 * (1.0 + ((phi2 ^ 2.0) * (((phi2 ^ 2.0) * 0.0026041666666666665) - 0.125))))), t_0)); else tmp = R * (2.0 * atan2(((phi1 * -0.5) + (0.0625 * (phi1 * (phi2 ^ 2.0)))), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e-310], N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi1 * N[(1.0 + N[(N[Power[phi2, 2.0], $MachinePrecision] * N[(N[(N[Power[phi2, 2.0], $MachinePrecision] * 0.0026041666666666665), $MachinePrecision] - 0.125), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(phi1 * -0.5), $MachinePrecision] + N[(0.0625 * N[(phi1 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot \left(1 + {\phi_2}^{2} \cdot \left({\phi_2}^{2} \cdot 0.0026041666666666665 - 0.125\right)\right)\right)}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot -0.5 + 0.0625 \cdot \left(\phi_1 \cdot {\phi_2}^{2}\right)}{t\_0}\right)\\
\end{array}
\end{array}
if phi1 < -4.999999999999985e-310Initial program 62.2%
Taylor expanded in phi1 around 0 49.4%
associate-*r*49.4%
Simplified49.4%
Taylor expanded in phi1 around -inf 11.5%
*-commutative11.5%
Simplified11.5%
Taylor expanded in phi2 around 0 11.6%
Taylor expanded in phi2 around 0 17.2%
if -4.999999999999985e-310 < phi1 Initial program 69.7%
Taylor expanded in phi1 around 0 51.6%
associate-*r*51.6%
Simplified51.6%
Taylor expanded in phi1 around -inf 5.1%
*-commutative5.1%
Simplified5.1%
Taylor expanded in phi2 around 0 5.3%
Taylor expanded in phi2 around 0 8.2%
Final simplification12.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(-
1.0
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))
(if (<= phi1 -5e-310)
(* R (* 2.0 (atan2 (* phi1 -0.5) t_0)))
(*
R
(*
2.0
(atan2 (+ (* phi1 -0.5) (* 0.0625 (* phi1 (pow phi2 2.0)))) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
double tmp;
if (phi1 <= -5e-310) {
tmp = R * (2.0 * atan2((phi1 * -0.5), t_0));
} else {
tmp = R * (2.0 * atan2(((phi1 * -0.5) + (0.0625 * (phi1 * pow(phi2, 2.0)))), t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
if (phi1 <= (-5d-310)) then
tmp = r * (2.0d0 * atan2((phi1 * (-0.5d0)), t_0))
else
tmp = r * (2.0d0 * atan2(((phi1 * (-0.5d0)) + (0.0625d0 * (phi1 * (phi2 ** 2.0d0)))), t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
double tmp;
if (phi1 <= -5e-310) {
tmp = R * (2.0 * Math.atan2((phi1 * -0.5), t_0));
} else {
tmp = R * (2.0 * Math.atan2(((phi1 * -0.5) + (0.0625 * (phi1 * Math.pow(phi2, 2.0)))), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))) tmp = 0 if phi1 <= -5e-310: tmp = R * (2.0 * math.atan2((phi1 * -0.5), t_0)) else: tmp = R * (2.0 * math.atan2(((phi1 * -0.5) + (0.0625 * (phi1 * math.pow(phi2, 2.0)))), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))))) tmp = 0.0 if (phi1 <= -5e-310) tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * -0.5), t_0))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(phi1 * -0.5) + Float64(0.0625 * Float64(phi1 * (phi2 ^ 2.0)))), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); tmp = 0.0; if (phi1 <= -5e-310) tmp = R * (2.0 * atan2((phi1 * -0.5), t_0)); else tmp = R * (2.0 * atan2(((phi1 * -0.5) + (0.0625 * (phi1 * (phi2 ^ 2.0)))), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e-310], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * -0.5), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(phi1 * -0.5), $MachinePrecision] + N[(0.0625 * N[(phi1 * N[Power[phi2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-310}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot -0.5}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot -0.5 + 0.0625 \cdot \left(\phi_1 \cdot {\phi_2}^{2}\right)}{t\_0}\right)\\
\end{array}
\end{array}
if phi1 < -4.999999999999985e-310Initial program 62.2%
Taylor expanded in phi1 around 0 49.4%
associate-*r*49.4%
Simplified49.4%
Taylor expanded in phi1 around -inf 11.5%
*-commutative11.5%
Simplified11.5%
Taylor expanded in phi2 around 0 11.6%
Taylor expanded in phi2 around 0 13.9%
*-commutative13.9%
Simplified13.9%
if -4.999999999999985e-310 < phi1 Initial program 69.7%
Taylor expanded in phi1 around 0 51.6%
associate-*r*51.6%
Simplified51.6%
Taylor expanded in phi1 around -inf 5.1%
*-commutative5.1%
Simplified5.1%
Taylor expanded in phi2 around 0 5.3%
Taylor expanded in phi2 around 0 8.2%
Final simplification11.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* phi1 -0.5)
(sqrt
(-
1.0
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((phi1 * -0.5), sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * 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
code = r * (2.0d0 * atan2((phi1 * (-0.5d0)), sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((phi1 * -0.5), Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((phi1 * -0.5), math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(phi1 * -0.5), sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((phi1 * -0.5), sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(phi1 * -0.5), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot -0.5}{\sqrt{1 - \left({\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)
\end{array}
Initial program 65.9%
Taylor expanded in phi1 around 0 50.5%
associate-*r*50.5%
Simplified50.5%
Taylor expanded in phi1 around -inf 8.4%
*-commutative8.4%
Simplified8.4%
Taylor expanded in phi2 around 0 8.5%
Taylor expanded in phi2 around 0 8.9%
*-commutative8.9%
Simplified8.9%
Final simplification8.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* -0.5 (* phi1 (cos (* phi2 -0.5))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((-0.5 * (phi1 * cos((phi2 * -0.5)))), 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
code = r * (2.0d0 * atan2(((-0.5d0) * (phi1 * cos((phi2 * (-0.5d0))))), 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) {
return R * (2.0 * Math.atan2((-0.5 * (phi1 * Math.cos((phi2 * -0.5)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((-0.5 * (phi1 * math.cos((phi2 * -0.5)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(-0.5 * Float64(phi1 * cos(Float64(phi2 * -0.5)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((-0.5 * (phi1 * cos((phi2 * -0.5)))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(-0.5 * N[(phi1 * N[Cos[N[(phi2 * -0.5), $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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
Initial program 65.9%
Taylor expanded in phi1 around 0 50.5%
associate-*r*50.5%
Simplified50.5%
Taylor expanded in phi1 around -inf 8.4%
*-commutative8.4%
Simplified8.4%
Taylor expanded in phi2 around 0 8.5%
Taylor expanded in phi1 around 0 8.5%
herbie shell --seed 2024119
(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))))))))))