
(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 17 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_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt
(-
(-
1.0
(pow
(fma
(cos (* phi2 0.5))
(sin (* phi1 0.5))
(* (cos (* phi1 0.5)) (sin (* phi2 -0.5))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt(((1.0 - pow(fma(cos((phi2 * 0.5)), sin((phi1 * 0.5)), (cos((phi1 * 0.5)) * sin((phi2 * -0.5)))), 2.0)) - t_1))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (fma(cos(Float64(phi2 * 0.5)), sin(Float64(phi1 * 0.5)), Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * -0.5)))) ^ 2.0)) - t_1))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(\cos \left(\phi_2 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
div-sub63.0%
sin-diff64.2%
Applied egg-rr64.2%
div-sub63.0%
sin-diff64.2%
Applied egg-rr77.3%
Taylor expanded in phi1 around inf 77.3%
fma-neg77.3%
distribute-rgt-neg-in77.3%
*-commutative77.3%
sin-neg77.3%
*-commutative77.3%
distribute-lft-neg-in77.3%
metadata-eval77.3%
*-commutative77.3%
Simplified77.3%
Final simplification77.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (* phi1 0.5)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_2 t_0))))
(t_4 (sqrt t_3))
(t_5 (* (- lambda1 lambda2) 0.5)))
(if (<= (atan2 t_4 (sqrt (- 1.0 t_3))) 0.01)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- 1.0 (+ (* (cos phi1) (pow (sin t_5) 2.0)) (pow t_1 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_2 (- 0.5 (/ (cos (* 2.0 t_5)) 2.0)))))
(sqrt
(-
(-
1.0
(pow
(fma
(cos (* phi2 0.5))
t_1
(* (cos (* phi1 0.5)) (sin (* phi2 -0.5))))
2.0))
(* t_2 (* 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 = sin((phi1 * 0.5));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_0));
double t_4 = sqrt(t_3);
double t_5 = (lambda1 - lambda2) * 0.5;
double tmp;
if (atan2(t_4, sqrt((1.0 - t_3))) <= 0.01) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * pow(sin(t_5), 2.0)) + pow(t_1, 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_2 * (0.5 - (cos((2.0 * t_5)) / 2.0))))), sqrt(((1.0 - pow(fma(cos((phi2 * 0.5)), t_1, (cos((phi1 * 0.5)) * sin((phi2 * -0.5)))), 2.0)) - (t_2 * (t_0 * t_0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(phi1 * 0.5)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_2 * t_0))) t_4 = sqrt(t_3) t_5 = Float64(Float64(lambda1 - lambda2) * 0.5) tmp = 0.0 if (atan(t_4, sqrt(Float64(1.0 - t_3))) <= 0.01) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(t_5) ^ 2.0)) + (t_1 ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_2 * Float64(0.5 - Float64(cos(Float64(2.0 * t_5)) / 2.0))))), sqrt(Float64(Float64(1.0 - (fma(cos(Float64(phi2 * 0.5)), t_1, Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * -0.5)))) ^ 2.0)) - Float64(t_2 * Float64(t_0 * t_0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = 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$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[t$95$3], $MachinePrecision]}, Block[{t$95$5 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 0.01], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[t$95$5], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[(0.5 - N[(N[Cos[N[(2.0 * t$95$5), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$1 + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * 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 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_2 \cdot t\_0\right)\\
t_4 := \sqrt{t\_3}\\
t_5 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
\mathbf{if}\;\tan^{-1}_* \frac{t\_4}{\sqrt{1 - t\_3}} \leq 0.01:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin t\_5}^{2} + {t\_1}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_2 \cdot \left(0.5 - \frac{\cos \left(2 \cdot t\_5\right)}{2}\right)}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(\cos \left(\phi_2 \cdot 0.5\right), t\_1, \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}\right) - t\_2 \cdot \left(t\_0 \cdot t\_0\right)}}\right)\\
\end{array}
\end{array}
if (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) < 0.0100000000000000002Initial program 100.0%
Taylor expanded in phi2 around 0 100.0%
if 0.0100000000000000002 < (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) Initial program 59.5%
associate-*l*59.5%
Simplified59.5%
div-sub59.5%
sin-diff60.8%
Applied egg-rr60.8%
div-sub59.5%
sin-diff60.8%
Applied egg-rr75.2%
Taylor expanded in phi1 around inf 75.2%
fma-neg75.2%
distribute-rgt-neg-in75.2%
*-commutative75.2%
sin-neg75.2%
*-commutative75.2%
distribute-lft-neg-in75.2%
metadata-eval75.2%
*-commutative75.2%
Simplified75.2%
sin-mult75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
cos-sum75.1%
cos-275.2%
div-inv75.2%
metadata-eval75.2%
Applied egg-rr75.2%
div-sub75.2%
+-inverses75.2%
cos-075.2%
metadata-eval75.2%
*-commutative75.2%
Simplified75.2%
Final simplification77.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_2 t_0))))
(t_4 (sqrt t_3))
(t_5 (* (- lambda1 lambda2) 0.5)))
(if (<= (atan2 t_4 (sqrt (- 1.0 t_3))) 0.01)
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin t_5) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_2 (- 0.5 (/ (cos (* 2.0 t_5)) 2.0)))))
(sqrt (- (- 1.0 t_1) (* t_2 (* 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 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_0));
double t_4 = sqrt(t_3);
double t_5 = (lambda1 - lambda2) * 0.5;
double tmp;
if (atan2(t_4, sqrt((1.0 - t_3))) <= 0.01) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * pow(sin(t_5), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (0.5 - (cos((2.0 * t_5)) / 2.0))))), sqrt(((1.0 - t_1) - (t_2 * (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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_2 * t_0))
t_4 = sqrt(t_3)
t_5 = (lambda1 - lambda2) * 0.5d0
if (atan2(t_4, sqrt((1.0d0 - t_3))) <= 0.01d0) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi1) * (sin(t_5) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * (0.5d0 - (cos((2.0d0 * t_5)) / 2.0d0))))), sqrt(((1.0d0 - t_1) - (t_2 * (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.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_0));
double t_4 = Math.sqrt(t_3);
double t_5 = (lambda1 - lambda2) * 0.5;
double tmp;
if (Math.atan2(t_4, Math.sqrt((1.0 - t_3))) <= 0.01) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(t_5), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * (0.5 - (Math.cos((2.0 * t_5)) / 2.0))))), Math.sqrt(((1.0 - t_1) - (t_2 * (t_0 * t_0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_0)) t_4 = math.sqrt(t_3) t_5 = (lambda1 - lambda2) * 0.5 tmp = 0 if math.atan2(t_4, math.sqrt((1.0 - t_3))) <= 0.01: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(t_5), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * (0.5 - (math.cos((2.0 * t_5)) / 2.0))))), math.sqrt(((1.0 - t_1) - (t_2 * (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(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_2 * t_0))) t_4 = sqrt(t_3) t_5 = Float64(Float64(lambda1 - lambda2) * 0.5) tmp = 0.0 if (atan(t_4, sqrt(Float64(1.0 - t_3))) <= 0.01) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(t_5) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * Float64(0.5 - Float64(cos(Float64(2.0 * t_5)) / 2.0))))), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_2 * 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 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_2 * t_0)); t_4 = sqrt(t_3); t_5 = (lambda1 - lambda2) * 0.5; tmp = 0.0; if (atan2(t_4, sqrt((1.0 - t_3))) <= 0.01) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi1) * (sin(t_5) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (0.5 - (cos((2.0 * t_5)) / 2.0))))), sqrt(((1.0 - t_1) - (t_2 * (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[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = 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$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[t$95$3], $MachinePrecision]}, Block[{t$95$5 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 0.01], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[t$95$5], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(0.5 - N[(N[Cos[N[(2.0 * t$95$5), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$2 * 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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_2 \cdot t\_0\right)\\
t_4 := \sqrt{t\_3}\\
t_5 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
\mathbf{if}\;\tan^{-1}_* \frac{t\_4}{\sqrt{1 - t\_3}} \leq 0.01:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin t\_5}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_2 \cdot \left(0.5 - \frac{\cos \left(2 \cdot t\_5\right)}{2}\right)}}{\sqrt{\left(1 - t\_1\right) - t\_2 \cdot \left(t\_0 \cdot t\_0\right)}}\right)\\
\end{array}
\end{array}
if (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) < 0.0100000000000000002Initial program 100.0%
Taylor expanded in phi2 around 0 100.0%
if 0.0100000000000000002 < (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) Initial program 59.5%
associate-*l*59.5%
Simplified59.5%
div-sub59.5%
sin-diff60.8%
Applied egg-rr60.8%
sin-mult75.2%
div-inv75.2%
metadata-eval75.2%
div-inv75.2%
metadata-eval75.2%
cos-sum75.1%
cos-275.2%
div-inv75.2%
metadata-eval75.2%
Applied egg-rr60.8%
div-sub75.2%
+-inverses75.2%
cos-075.2%
metadata-eval75.2%
*-commutative75.2%
Simplified60.8%
div-sub59.5%
sin-diff60.8%
Applied egg-rr75.2%
Final simplification77.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (- lambda1 lambda2) 0.5))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4 (* t_2 (* t_0 t_0))))
(if (<= (+ t_3 (* t_0 (* t_2 t_0))) 0.034)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (fabs (* t_2 (pow (sin t_1) 2.0)))))
(sqrt
(- (+ (- 2.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)) -1.0) t_4)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_2 (- 0.5 (/ (cos (* 2.0 t_1)) 2.0)))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
t_4))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (lambda1 - lambda2) * 0.5;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = t_2 * (t_0 * t_0);
double tmp;
if ((t_3 + (t_0 * (t_2 * t_0))) <= 0.034) {
tmp = R * (2.0 * atan2(sqrt((t_3 + fabs((t_2 * pow(sin(t_1), 2.0))))), sqrt((((2.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) + -1.0) - t_4))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (0.5 - (cos((2.0 * t_1)) / 2.0))) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - t_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 = (lambda1 - lambda2) * 0.5d0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_4 = t_2 * (t_0 * t_0)
if ((t_3 + (t_0 * (t_2 * t_0))) <= 0.034d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + abs((t_2 * (sin(t_1) ** 2.0d0))))), sqrt((((2.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) + (-1.0d0)) - t_4))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (0.5d0 - (cos((2.0d0 * t_1)) / 2.0d0))) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (lambda1 - lambda2) * 0.5;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = t_2 * (t_0 * t_0);
double tmp;
if ((t_3 + (t_0 * (t_2 * t_0))) <= 0.034) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.abs((t_2 * Math.pow(Math.sin(t_1), 2.0))))), Math.sqrt((((2.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) + -1.0) - t_4))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (0.5 - (Math.cos((2.0 * t_1)) / 2.0))) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (lambda1 - lambda2) * 0.5 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = t_2 * (t_0 * t_0) tmp = 0 if (t_3 + (t_0 * (t_2 * t_0))) <= 0.034: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.fabs((t_2 * math.pow(math.sin(t_1), 2.0))))), math.sqrt((((2.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) + -1.0) - t_4)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (0.5 - (math.cos((2.0 * t_1)) / 2.0))) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(lambda1 - lambda2) * 0.5) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = Float64(t_2 * Float64(t_0 * t_0)) tmp = 0.0 if (Float64(t_3 + Float64(t_0 * Float64(t_2 * t_0))) <= 0.034) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + abs(Float64(t_2 * (sin(t_1) ^ 2.0))))), sqrt(Float64(Float64(Float64(2.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) + -1.0) - t_4))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(0.5 - Float64(cos(Float64(2.0 * t_1)) / 2.0))) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (lambda1 - lambda2) * 0.5; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_4 = t_2 * (t_0 * t_0); tmp = 0.0; if ((t_3 + (t_0 * (t_2 * t_0))) <= 0.034) tmp = R * (2.0 * atan2(sqrt((t_3 + abs((t_2 * (sin(t_1) ^ 2.0))))), sqrt((((2.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) + -1.0) - t_4)))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (0.5 - (cos((2.0 * t_1)) / 2.0))) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$3 + N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 0.034], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Abs[N[(t$95$2 * N[Power[N[Sin[t$95$1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(2.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision] - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(0.5 - N[(N[Cos[N[(2.0 * t$95$1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$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 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := t\_2 \cdot \left(t\_0 \cdot t\_0\right)\\
\mathbf{if}\;t\_3 + t\_0 \cdot \left(t\_2 \cdot t\_0\right) \leq 0.034:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \left|t\_2 \cdot {\sin t\_1}^{2}\right|}}{\sqrt{\left(\left(2 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) + -1\right) - t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(0.5 - \frac{\cos \left(2 \cdot t\_1\right)}{2}\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_4}}\right)\\
\end{array}
\end{array}
if (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) < 0.034000000000000002Initial program 69.0%
associate-*l*69.0%
Simplified69.0%
expm1-log1p-u69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr69.0%
expm1-undefine69.0%
sub-neg69.0%
log1p-undefine69.0%
rem-exp-log69.0%
associate-+r-69.0%
metadata-eval69.0%
*-commutative69.0%
metadata-eval69.0%
Simplified69.0%
pow169.0%
metadata-eval69.0%
pow-prod-up67.8%
pow-prod-down71.7%
Applied egg-rr71.7%
unpow1/271.7%
unpow271.7%
rem-sqrt-square74.0%
associate-*r*74.0%
*-commutative74.0%
*-commutative74.0%
Simplified74.0%
if 0.034000000000000002 < (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))))) Initial program 61.8%
associate-*l*61.9%
Simplified61.9%
div-sub61.9%
sin-diff63.3%
Applied egg-rr63.3%
sin-mult75.5%
div-inv75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
cos-sum75.4%
cos-275.5%
div-inv75.5%
metadata-eval75.5%
Applied egg-rr63.3%
div-sub75.5%
+-inverses75.5%
cos-075.5%
metadata-eval75.5%
*-commutative75.5%
Simplified63.3%
unpow263.3%
sin-mult63.3%
div-inv63.3%
metadata-eval63.3%
div-inv63.3%
metadata-eval63.3%
div-inv63.3%
metadata-eval63.3%
div-inv63.3%
metadata-eval63.3%
Applied egg-rr63.3%
div-sub63.3%
+-inverses63.3%
cos-063.3%
metadata-eval63.3%
distribute-lft-out63.3%
metadata-eval63.3%
*-rgt-identity63.3%
Simplified63.3%
Final simplification65.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_2)) (sqrt (- (- 1.0 t_0) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
return R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
code = r * (2.0d0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0d0 - t_0) - t_2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt(((1.0 - t_0) - t_2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) return R * (2.0 * math.atan2(math.sqrt((t_0 + t_2)), math.sqrt(((1.0 - t_0) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(Float64(1.0 - t_0) - t_2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{\left(1 - t\_0\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
div-sub63.0%
sin-diff64.2%
Applied egg-rr64.2%
div-sub63.0%
sin-diff64.2%
Applied egg-rr77.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 t_0))
(t_2
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3 (* (* (cos phi1) (cos phi2)) t_1)))
(if (or (<= phi2 -2.3e-7) (not (<= phi2 8.5e-16)))
(*
R
(*
2.0
(atan2 (sqrt (+ t_2 (* (cos phi2) t_1))) (sqrt (- (- 1.0 t_2) t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_3))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * t_0;
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = (cos(phi1) * cos(phi2)) * t_1;
double tmp;
if ((phi2 <= -2.3e-7) || !(phi2 <= 8.5e-16)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * t_1))), sqrt(((1.0 - t_2) - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * t_0
t_2 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_3 = (cos(phi1) * cos(phi2)) * t_1
if ((phi2 <= (-2.3d-7)) .or. (.not. (phi2 <= 8.5d-16))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (cos(phi2) * t_1))), sqrt(((1.0d0 - t_2) - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * t_0;
double t_2 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_1;
double tmp;
if ((phi2 <= -2.3e-7) || !(phi2 <= 8.5e-16)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi2) * t_1))), Math.sqrt(((1.0 - t_2) - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * t_0 t_2 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_1 tmp = 0 if (phi2 <= -2.3e-7) or not (phi2 <= 8.5e-16): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (math.cos(phi2) * t_1))), math.sqrt(((1.0 - t_2) - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * t_0) t_2 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_1) tmp = 0.0 if ((phi2 <= -2.3e-7) || !(phi2 <= 8.5e-16)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi2) * t_1))), sqrt(Float64(Float64(1.0 - t_2) - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * t_0; t_2 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_3 = (cos(phi1) * cos(phi2)) * t_1; tmp = 0.0; if ((phi2 <= -2.3e-7) || ~((phi2 <= 8.5e-16))) tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * t_1))), sqrt(((1.0 - t_2) - t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi2, -2.3e-7], N[Not[LessEqual[phi2, 8.5e-16]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot t\_0\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\\
\mathbf{if}\;\phi_2 \leq -2.3 \cdot 10^{-7} \lor \neg \left(\phi_2 \leq 8.5 \cdot 10^{-16}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \cos \phi_2 \cdot t\_1}}{\sqrt{\left(1 - t\_2\right) - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t\_3}}\right)\\
\end{array}
\end{array}
if phi2 < -2.29999999999999995e-7 or 8.5000000000000001e-16 < phi2 Initial program 45.4%
associate-*l*45.5%
Simplified45.5%
div-sub45.5%
sin-diff47.8%
Applied egg-rr47.8%
div-sub45.5%
sin-diff47.8%
Applied egg-rr73.2%
Taylor expanded in phi1 around 0 58.3%
if -2.29999999999999995e-7 < phi2 < 8.5000000000000001e-16Initial program 81.7%
associate-*l*81.7%
Simplified81.7%
Taylor expanded in phi2 around 0 81.7%
unpow281.7%
1-sub-sin81.8%
unpow281.8%
Simplified81.8%
Final simplification69.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (/ phi1 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_3 (* (cos (/ phi1 2.0)) (sin (/ phi2 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (- t_1 t_3) 2.0)))
(sqrt (- (- 1.0 (pow (- (* t_1 (cos (/ phi2 2.0))) t_3) 2.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 = sin((phi1 / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_3 = cos((phi1 / 2.0)) * sin((phi2 / 2.0));
return R * (2.0 * atan2(sqrt((t_2 + pow((t_1 - t_3), 2.0))), sqrt(((1.0 - pow(((t_1 * cos((phi2 / 2.0))) - t_3), 2.0)) - t_2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((phi1 / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_3 = cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_2 + ((t_1 - t_3) ** 2.0d0))), sqrt(((1.0d0 - (((t_1 * cos((phi2 / 2.0d0))) - t_3) ** 2.0d0)) - t_2))))
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.sin((phi1 / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_3 = Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((t_1 - t_3), 2.0))), Math.sqrt(((1.0 - Math.pow(((t_1 * Math.cos((phi2 / 2.0))) - t_3), 2.0)) - t_2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sin((phi1 / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_3 = math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((t_1 - t_3), 2.0))), math.sqrt(((1.0 - math.pow(((t_1 * math.cos((phi2 / 2.0))) - t_3), 2.0)) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(phi1 / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_3 = Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(t_1 - t_3) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(t_1 * cos(Float64(phi2 / 2.0))) - t_3) ^ 2.0)) - t_2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((phi1 / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_3 = cos((phi1 / 2.0)) * sin((phi2 / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_2 + ((t_1 - t_3) ^ 2.0))), sqrt(((1.0 - (((t_1 * cos((phi2 / 2.0))) - t_3) ^ 2.0)) - t_2)))); 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[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * 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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(t$95$1 - t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(t$95$1 * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sin \left(\frac{\phi_1}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
t_3 := \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(t\_1 - t\_3\right)}^{2}}}{\sqrt{\left(1 - {\left(t\_1 \cdot \cos \left(\frac{\phi_2}{2}\right) - t\_3\right)}^{2}\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
div-sub63.0%
sin-diff64.2%
Applied egg-rr64.2%
div-sub63.0%
sin-diff64.2%
Applied egg-rr77.3%
Taylor expanded in phi2 around 0 64.9%
Final simplification64.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
div-sub63.0%
sin-diff64.2%
Applied egg-rr64.2%
Final simplification64.2%
(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)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(fabs
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(fabs((1.0 - fma(cos(phi1), (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(abs(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*r*63.0%
+-commutative63.0%
fma-undefine63.0%
pow163.0%
metadata-eval63.0%
pow-prod-up63.0%
Applied egg-rr63.7%
unpow1/263.7%
unpow263.7%
rem-sqrt-square63.7%
*-commutative63.7%
*-commutative63.7%
Simplified63.7%
Final simplification63.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -1.32e-5) (not (<= phi2 2.2e-40)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) (* t_1 t_1)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(sqrt
(- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -1.32e-5) || !(phi2 <= 2.2e-40)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.0 - ((cos(phi1) * t_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) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-1.32d-5)) .or. (.not. (phi2 <= 2.2d-40))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (t_1 * t_1))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -1.32e-5) || !(phi2 <= 2.2e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -1.32e-5) or not (phi2 <= 2.2e-40): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * (t_1 * t_1)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -1.32e-5) || !(phi2 <= 2.2e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * Float64(t_1 * t_1))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -1.32e-5) || ~((phi2 <= 2.2e-40))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (t_1 * t_1)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -1.32e-5], N[Not[LessEqual[phi2, 2.2e-40]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -1.32 \cdot 10^{-5} \lor \neg \left(\phi_2 \leq 2.2 \cdot 10^{-40}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(t\_1 \cdot 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\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1.32000000000000007e-5 or 2.20000000000000009e-40 < phi2 Initial program 45.6%
associate-*l*45.7%
Simplified45.7%
expm1-log1p-u45.6%
div-inv45.6%
metadata-eval45.6%
Applied egg-rr45.6%
expm1-undefine45.6%
sub-neg45.6%
log1p-undefine45.6%
rem-exp-log45.6%
associate-+r-45.6%
metadata-eval45.6%
*-commutative45.6%
metadata-eval45.6%
Simplified45.6%
Taylor expanded in phi1 around 0 46.3%
unpow246.3%
1-sub-sin46.4%
unpow246.4%
*-commutative46.4%
Simplified46.4%
Taylor expanded in phi1 around 0 47.1%
Taylor expanded in phi1 around 0 48.6%
if -1.32000000000000007e-5 < phi2 < 2.20000000000000009e-40Initial program 82.0%
Taylor expanded in phi2 around 0 82.1%
Final simplification64.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))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (- 1.0 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - (0.5 - (cos((phi1 - phi2)) / 2.0))) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (0.5d0 - (cos((phi1 - phi2)) / 2.0d0))) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - (0.5 - (Math.cos((phi1 - phi2)) / 2.0))) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - (0.5 - (math.cos((phi1 - phi2)) / 2.0))) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0))) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (0.5 - (cos((phi1 - phi2)) / 2.0))) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
unpow262.1%
sin-mult58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
div-inv58.3%
metadata-eval58.3%
Applied egg-rr63.1%
div-sub58.3%
+-inverses58.3%
cos-058.3%
metadata-eval58.3%
distribute-lft-out58.3%
metadata-eval58.3%
*-rgt-identity58.3%
Simplified63.1%
Final simplification63.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 t_1))
(t_3 (* (cos phi1) t_0))
(t_4 (sqrt (+ t_3 (pow (sin (* phi1 0.5)) 2.0))))
(t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= phi1 -1.05e-5)
(* R (* 2.0 (atan2 t_4 (sqrt (- (- 1.0 t_5) t_3)))))
(if (<= phi1 1.9e-11)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (* (cos phi2) t_0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2))))))
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
(- 1.0 (pow (sin (/ phi1 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * t_1;
double t_3 = cos(phi1) * t_0;
double t_4 = sqrt((t_3 + pow(sin((phi1 * 0.5)), 2.0)));
double t_5 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -1.05e-5) {
tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - t_5) - t_3))));
} else if (phi1 <= 1.9e-11) {
tmp = R * (2.0 * atan2(sqrt((t_5 + (cos(phi2) * t_0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - pow(sin((phi1 / 2.0)), 2.0)) - ((cos(phi1) * cos(phi2)) * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_1 * t_1
t_3 = cos(phi1) * t_0
t_4 = sqrt((t_3 + (sin((phi1 * 0.5d0)) ** 2.0d0)))
t_5 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (phi1 <= (-1.05d-5)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt(((1.0d0 - t_5) - t_3))))
else if (phi1 <= 1.9d-11) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (cos(phi2) * t_0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt(((1.0d0 - (sin((phi1 / 2.0d0)) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * t_1;
double t_3 = Math.cos(phi1) * t_0;
double t_4 = Math.sqrt((t_3 + Math.pow(Math.sin((phi1 * 0.5)), 2.0)));
double t_5 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -1.05e-5) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt(((1.0 - t_5) - t_3))));
} else if (phi1 <= 1.9e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + (Math.cos(phi2) * t_0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt(((1.0 - Math.pow(Math.sin((phi1 / 2.0)), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_1 * t_1 t_3 = math.cos(phi1) * t_0 t_4 = math.sqrt((t_3 + math.pow(math.sin((phi1 * 0.5)), 2.0))) t_5 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if phi1 <= -1.05e-5: tmp = R * (2.0 * math.atan2(t_4, math.sqrt(((1.0 - t_5) - t_3)))) elif phi1 <= 1.9e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + (math.cos(phi2) * t_0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt(((1.0 - math.pow(math.sin((phi1 / 2.0)), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * t_1) t_3 = Float64(cos(phi1) * t_0) t_4 = sqrt(Float64(t_3 + (sin(Float64(phi1 * 0.5)) ^ 2.0))) t_5 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (phi1 <= -1.05e-5) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(1.0 - t_5) - t_3))))); elseif (phi1 <= 1.9e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + Float64(cos(phi2) * t_0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(1.0 - (sin(Float64(phi1 / 2.0)) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_1 * t_1; t_3 = cos(phi1) * t_0; t_4 = sqrt((t_3 + (sin((phi1 * 0.5)) ^ 2.0))); t_5 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (phi1 <= -1.05e-5) tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - t_5) - t_3)))); elseif (phi1 <= 1.9e-11) tmp = R * (2.0 * atan2(sqrt((t_5 + (cos(phi2) * t_0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); else tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - (sin((phi1 / 2.0)) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -1.05e-5], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[(1.0 - t$95$5), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot t\_1\\
t_3 := \cos \phi_1 \cdot t\_0\\
t_4 := \sqrt{t\_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}\\
t_5 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -1.05 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{\left(1 - t\_5\right) - t\_3}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + \cos \phi_2 \cdot t\_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1}{2}\right)}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2}}\right)\\
\end{array}
\end{array}
if phi1 < -1.04999999999999994e-5Initial program 47.5%
associate-*l*47.5%
Simplified47.5%
Taylor expanded in phi2 around 0 48.9%
Taylor expanded in phi2 around 0 49.9%
*-commutative49.9%
Simplified49.9%
if -1.04999999999999994e-5 < phi1 < 1.8999999999999999e-11Initial program 76.7%
associate-*l*76.8%
Simplified76.8%
expm1-log1p-u76.8%
div-inv76.8%
metadata-eval76.8%
Applied egg-rr76.8%
expm1-undefine76.8%
sub-neg76.8%
log1p-undefine76.7%
rem-exp-log76.7%
associate-+r-76.7%
metadata-eval76.7%
*-commutative76.7%
metadata-eval76.7%
Simplified76.7%
Taylor expanded in phi1 around 0 76.8%
unpow276.8%
1-sub-sin76.9%
unpow276.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in phi1 around 0 76.9%
Taylor expanded in phi1 around 0 76.9%
if 1.8999999999999999e-11 < phi1 Initial program 48.2%
associate-*l*48.3%
Simplified48.3%
Taylor expanded in phi2 around 0 50.2%
Taylor expanded in phi1 around inf 50.5%
Final simplification64.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (- lambda1 lambda2) 0.5))
(t_1 (pow (sin t_0) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (cos phi1) t_1))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_5 (sqrt (+ t_3 (pow (sin (* phi1 0.5)) 2.0))))
(t_6 (- 1.0 t_4)))
(if (<= phi1 -9e-6)
(* R (* 2.0 (atan2 t_5 (sqrt (- t_6 t_3)))))
(if (<= phi1 1.9e-11)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (* (cos phi2) t_1)))
(sqrt
(- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) (* t_2 t_2)))))))
(*
R
(*
2.0
(atan2
t_5
(sqrt
(+
t_6
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (* 2.0 t_0)) 2.0) 0.5)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * 0.5;
double t_1 = pow(sin(t_0), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos(phi1) * t_1;
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = sqrt((t_3 + pow(sin((phi1 * 0.5)), 2.0)));
double t_6 = 1.0 - t_4;
double tmp;
if (phi1 <= -9e-6) {
tmp = R * (2.0 * atan2(t_5, sqrt((t_6 - t_3))));
} else if (phi1 <= 1.9e-11) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi2) * t_1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * (t_2 * t_2))))));
} else {
tmp = R * (2.0 * atan2(t_5, sqrt((t_6 + ((cos(phi1) * cos(phi2)) * ((cos((2.0 * t_0)) / 2.0) - 0.5))))));
}
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 = (lambda1 - lambda2) * 0.5d0
t_1 = sin(t_0) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos(phi1) * t_1
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_5 = sqrt((t_3 + (sin((phi1 * 0.5d0)) ** 2.0d0)))
t_6 = 1.0d0 - t_4
if (phi1 <= (-9d-6)) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((t_6 - t_3))))
else if (phi1 <= 1.9d-11) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (cos(phi2) * t_1))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (t_2 * t_2))))))
else
tmp = r * (2.0d0 * atan2(t_5, sqrt((t_6 + ((cos(phi1) * cos(phi2)) * ((cos((2.0d0 * t_0)) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (lambda1 - lambda2) * 0.5;
double t_1 = Math.pow(Math.sin(t_0), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos(phi1) * t_1;
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = Math.sqrt((t_3 + Math.pow(Math.sin((phi1 * 0.5)), 2.0)));
double t_6 = 1.0 - t_4;
double tmp;
if (phi1 <= -9e-6) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((t_6 - t_3))));
} else if (phi1 <= 1.9e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (Math.cos(phi2) * t_1))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * (t_2 * t_2))))));
} else {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((t_6 + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((2.0 * t_0)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (lambda1 - lambda2) * 0.5 t_1 = math.pow(math.sin(t_0), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos(phi1) * t_1 t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_5 = math.sqrt((t_3 + math.pow(math.sin((phi1 * 0.5)), 2.0))) t_6 = 1.0 - t_4 tmp = 0 if phi1 <= -9e-6: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((t_6 - t_3)))) elif phi1 <= 1.9e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (math.cos(phi2) * t_1))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * (t_2 * t_2)))))) else: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((t_6 + ((math.cos(phi1) * math.cos(phi2)) * ((math.cos((2.0 * t_0)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(lambda1 - lambda2) * 0.5) t_1 = sin(t_0) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(cos(phi1) * t_1) t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_5 = sqrt(Float64(t_3 + (sin(Float64(phi1 * 0.5)) ^ 2.0))) t_6 = Float64(1.0 - t_4) tmp = 0.0 if (phi1 <= -9e-6) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(t_6 - t_3))))); elseif (phi1 <= 1.9e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(cos(phi2) * t_1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * Float64(t_2 * t_2))))))); else tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(t_6 + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(2.0 * t_0)) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (lambda1 - lambda2) * 0.5; t_1 = sin(t_0) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos(phi1) * t_1; t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_5 = sqrt((t_3 + (sin((phi1 * 0.5)) ^ 2.0))); t_6 = 1.0 - t_4; tmp = 0.0; if (phi1 <= -9e-6) tmp = R * (2.0 * atan2(t_5, sqrt((t_6 - t_3)))); elseif (phi1 <= 1.9e-11) tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi2) * t_1))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (t_2 * t_2)))))); else tmp = R * (2.0 * atan2(t_5, sqrt((t_6 + ((cos(phi1) * cos(phi2)) * ((cos((2.0 * t_0)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[t$95$0], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(1.0 - t$95$4), $MachinePrecision]}, If[LessEqual[phi1, -9e-6], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(t$95$6 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(t$95$6 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(2.0 * t$95$0), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
t_1 := {\sin t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \phi_1 \cdot t\_1\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_5 := \sqrt{t\_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}\\
t_6 := 1 - t\_4\\
\mathbf{if}\;\phi_1 \leq -9 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{t\_6 - t\_3}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + \cos \phi_2 \cdot t\_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{t\_6 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(2 \cdot t\_0\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -9.00000000000000023e-6Initial program 47.5%
associate-*l*47.5%
Simplified47.5%
Taylor expanded in phi2 around 0 48.9%
Taylor expanded in phi2 around 0 49.9%
*-commutative49.9%
Simplified49.9%
if -9.00000000000000023e-6 < phi1 < 1.8999999999999999e-11Initial program 76.7%
associate-*l*76.8%
Simplified76.8%
expm1-log1p-u76.8%
div-inv76.8%
metadata-eval76.8%
Applied egg-rr76.8%
expm1-undefine76.8%
sub-neg76.8%
log1p-undefine76.7%
rem-exp-log76.7%
associate-+r-76.7%
metadata-eval76.7%
*-commutative76.7%
metadata-eval76.7%
Simplified76.7%
Taylor expanded in phi1 around 0 76.8%
unpow276.8%
1-sub-sin76.9%
unpow276.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in phi1 around 0 76.9%
Taylor expanded in phi1 around 0 76.9%
if 1.8999999999999999e-11 < phi1 Initial program 48.2%
associate-*l*48.3%
Simplified48.3%
Taylor expanded in phi2 around 0 50.2%
sin-mult77.1%
div-inv77.1%
metadata-eval77.1%
div-inv77.1%
metadata-eval77.1%
cos-sum77.1%
cos-277.1%
div-inv77.1%
metadata-eval77.1%
Applied egg-rr50.2%
div-sub77.1%
+-inverses77.1%
cos-077.1%
metadata-eval77.1%
*-commutative77.1%
Simplified50.2%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) t_0))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (or (<= phi1 -7.2e-6) (not (<= phi1 1.9e-11)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (- 1.0 t_3) t_2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (* (cos phi2) t_0)))
(sqrt
(- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) (* t_1 t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * t_0;
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((phi1 <= -7.2e-6) || !(phi1 <= 1.9e-11)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (cos(phi2) * t_0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * (t_1 * t_1))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * t_0
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if ((phi1 <= (-7.2d-6)) .or. (.not. (phi1 <= 1.9d-11))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - t_3) - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (cos(phi2) * t_0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (t_1 * t_1))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * t_0;
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((phi1 <= -7.2e-6) || !(phi1 <= 1.9e-11)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (Math.cos(phi2) * t_0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * (t_1 * t_1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * t_0 t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if (phi1 <= -7.2e-6) or not (phi1 <= 1.9e-11): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - t_3) - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (math.cos(phi2) * t_0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * (t_1 * t_1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * t_0) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if ((phi1 <= -7.2e-6) || !(phi1 <= 1.9e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_3) - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(cos(phi2) * t_0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * Float64(t_1 * t_1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * t_0; t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if ((phi1 <= -7.2e-6) || ~((phi1 <= 1.9e-11))) tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - t_3) - t_2)))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (cos(phi2) * t_0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (t_1 * t_1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -7.2e-6], N[Not[LessEqual[phi1, 1.9e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot t\_0\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -7.2 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 1.9 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - t\_3\right) - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \cos \phi_2 \cdot t\_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(t\_1 \cdot t\_1\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -7.19999999999999967e-6 or 1.8999999999999999e-11 < phi1 Initial program 47.8%
associate-*l*47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi2 around 0 49.8%
*-commutative49.8%
Simplified49.8%
if -7.19999999999999967e-6 < phi1 < 1.8999999999999999e-11Initial program 76.7%
associate-*l*76.8%
Simplified76.8%
expm1-log1p-u76.8%
div-inv76.8%
metadata-eval76.8%
Applied egg-rr76.8%
expm1-undefine76.8%
sub-neg76.8%
log1p-undefine76.7%
rem-exp-log76.7%
associate-+r-76.7%
metadata-eval76.7%
*-commutative76.7%
metadata-eval76.7%
Simplified76.7%
Taylor expanded in phi1 around 0 76.8%
unpow276.8%
1-sub-sin76.9%
unpow276.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in phi1 around 0 76.9%
Taylor expanded in phi1 around 0 76.9%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) t_0)))
(if (or (<= phi2 -9.5e-60) (not (<= phi2 2.2e-40)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) (* t_1 t_1)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * t_0;
double tmp;
if ((phi2 <= -9.5e-60) || !(phi2 <= 2.2e-40)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * t_0
if ((phi2 <= (-9.5d-60)) .or. (.not. (phi2 <= 2.2d-40))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (t_1 * t_1))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * t_0;
double tmp;
if ((phi2 <= -9.5e-60) || !(phi2 <= 2.2e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * t_0 tmp = 0 if (phi2 <= -9.5e-60) or not (phi2 <= 2.2e-40): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * (t_1 * t_1)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * t_0) tmp = 0.0 if ((phi2 <= -9.5e-60) || !(phi2 <= 2.2e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * Float64(t_1 * t_1))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * t_0; tmp = 0.0; if ((phi2 <= -9.5e-60) || ~((phi2 <= 2.2e-40))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (t_1 * t_1)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[Or[LessEqual[phi2, -9.5e-60], N[Not[LessEqual[phi2, 2.2e-40]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot t\_0\\
\mathbf{if}\;\phi_2 \leq -9.5 \cdot 10^{-60} \lor \neg \left(\phi_2 \leq 2.2 \cdot 10^{-40}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot \left(t\_1 \cdot t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -9.49999999999999958e-60 or 2.20000000000000009e-40 < phi2 Initial program 47.3%
associate-*l*47.4%
Simplified47.4%
expm1-log1p-u47.4%
div-inv47.4%
metadata-eval47.4%
Applied egg-rr47.4%
expm1-undefine47.3%
sub-neg47.3%
log1p-undefine47.3%
rem-exp-log47.3%
associate-+r-47.3%
metadata-eval47.3%
*-commutative47.3%
metadata-eval47.3%
Simplified47.3%
Taylor expanded in phi1 around 0 47.4%
unpow247.4%
1-sub-sin47.5%
unpow247.5%
*-commutative47.5%
Simplified47.5%
Taylor expanded in phi1 around 0 48.2%
Taylor expanded in phi1 around 0 49.7%
if -9.49999999999999958e-60 < phi2 < 2.20000000000000009e-40Initial program 81.8%
associate-*l*81.8%
Simplified81.9%
Taylor expanded in phi2 around 0 80.2%
Taylor expanded in phi2 around 0 80.2%
*-commutative80.2%
Simplified80.2%
Final simplification63.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi1) t_1))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (or (<= phi1 -3.6e-6) (not (<= phi1 1.9e-11)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (- 1.0 t_3) t_2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (* (cos phi1) (cos phi2)) (* t_0 t_0)) t_3))
(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(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi1) * t_1;
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((phi1 <= -3.6e-6) || !(phi1 <= 1.9e-11)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + t_3)), sqrt((1.0 - t_1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = cos(phi1) * t_1
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if ((phi1 <= (-3.6d-6)) .or. (.not. (phi1 <= 1.9d-11))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - t_3) - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + t_3)), sqrt((1.0d0 - t_1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi1) * t_1;
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((phi1 <= -3.6e-6) || !(phi1 <= 1.9e-11)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + t_3)), Math.sqrt((1.0 - t_1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi1) * t_1 t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if (phi1 <= -3.6e-6) or not (phi1 <= 1.9e-11): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - t_3) - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + t_3)), math.sqrt((1.0 - t_1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi1) * t_1) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if ((phi1 <= -3.6e-6) || !(phi1 <= 1.9e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_3) - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + t_3)), sqrt(Float64(1.0 - t_1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = cos(phi1) * t_1; t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if ((phi1 <= -3.6e-6) || ~((phi1 <= 1.9e-11))) tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - t_3) - t_2)))); else tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + t_3)), sqrt((1.0 - 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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.6e-6], N[Not[LessEqual[phi1, 1.9e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]], $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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_1 \cdot t\_1\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -3.6 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 1.9 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - t\_3\right) - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + t\_3}}{\sqrt{1 - t\_1}}\right)\\
\end{array}
\end{array}
if phi1 < -3.59999999999999984e-6 or 1.8999999999999999e-11 < phi1 Initial program 47.8%
associate-*l*47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi2 around 0 49.8%
*-commutative49.8%
Simplified49.8%
if -3.59999999999999984e-6 < phi1 < 1.8999999999999999e-11Initial program 76.7%
associate-*l*76.8%
Simplified76.8%
expm1-log1p-u76.8%
div-inv76.8%
metadata-eval76.8%
Applied egg-rr76.8%
expm1-undefine76.8%
sub-neg76.8%
log1p-undefine76.7%
rem-exp-log76.7%
associate-+r-76.7%
metadata-eval76.7%
*-commutative76.7%
metadata-eval76.7%
Simplified76.7%
Taylor expanded in phi1 around 0 76.8%
unpow276.8%
1-sub-sin76.9%
unpow276.9%
*-commutative76.9%
Simplified76.9%
Taylor expanded in phi1 around 0 76.9%
Taylor expanded in phi2 around 0 51.4%
Final simplification50.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5))) (t_1 (sin (* (- lambda1 lambda2) 0.5))))
(*
R
(*
2.0
(atan2
(hypot t_0 t_1)
(sqrt (- 1.0 (+ (* (cos phi1) (pow t_1 2.0)) (pow t_0 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * atan2(hypot(t_0, t_1), sqrt((1.0 - ((cos(phi1) * pow(t_1, 2.0)) + pow(t_0, 2.0))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((phi1 * 0.5));
double t_1 = Math.sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * Math.atan2(Math.hypot(t_0, t_1), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(t_1, 2.0)) + Math.pow(t_0, 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.sin(((lambda1 - lambda2) * 0.5)) return R * (2.0 * math.atan2(math.hypot(t_0, t_1), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(t_1, 2.0)) + math.pow(t_0, 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) return Float64(R * Float64(2.0 * atan(hypot(t_0, t_1), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (t_1 ^ 2.0)) + (t_0 ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = sin(((lambda1 - lambda2) * 0.5)); tmp = R * (2.0 * atan2(hypot(t_0, t_1), sqrt((1.0 - ((cos(phi1) * (t_1 ^ 2.0)) + (t_0 ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0 ^ 2 + t$95$1 ^ 2], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_0, t\_1\right)}{\sqrt{1 - \left(\cos \phi_1 \cdot {t\_1}^{2} + {t\_0}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.0%
add-exp-log19.7%
div-inv19.7%
metadata-eval19.7%
Applied egg-rr19.7%
Taylor expanded in phi1 around 0 19.5%
Taylor expanded in phi2 around 0 41.2%
unpow241.2%
*-commutative41.2%
unpow241.2%
hypot-define41.2%
*-commutative41.2%
Simplified41.2%
Taylor expanded in phi2 around 0 41.3%
Final simplification41.3%
herbie shell --seed 2024112
(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))))))))))