
(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 27 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))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt
(-
1.0
(fma
(cos phi2)
(*
(cos phi1)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0 - fma(cos(phi2), (cos(phi1) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)), pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(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(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - fma(cos(phi2), Float64(cos(phi1) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)), (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\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} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2, \cos \phi_1 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}, {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}\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%
Simplified77.3%
*-commutative77.3%
metadata-eval77.3%
div-inv77.3%
div-sub77.3%
sin-diff78.0%
Applied egg-rr78.0%
Final simplification78.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt
(-
1.0
(fma
(cos phi2)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0 - fma(cos(phi2), (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(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(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - fma(cos(phi2), Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)), (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
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} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2, \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}\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%
Simplified77.3%
Final simplification77.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))))))
(if (or (<= lambda1 -1e-10) (not (<= lambda1 1.92e-20)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))
t_2)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1))));
double tmp;
if ((lambda1 <= -1e-10) || !(lambda1 <= 1.92e-20)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1))))
if ((lambda1 <= (-1d-10)) .or. (.not. (lambda1 <= 1.92d-20))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = 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)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1))));
double tmp;
if ((lambda1 <= -1e-10) || !(lambda1 <= 1.92e-20)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = 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)) - ((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)))) tmp = 0 if (lambda1 <= -1e-10) or not (lambda1 <= 1.92e-20): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = 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)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)))) tmp = 0.0 if ((lambda1 <= -1e-10) || !(lambda1 <= 1.92e-20)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))); tmp = 0.0; if ((lambda1 <= -1e-10) || ~((lambda1 <= 1.92e-20))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))))), t_2)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(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] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -1e-10], N[Not[LessEqual[lambda1, 1.92e-20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_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) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)}\\
\mathbf{if}\;\lambda_1 \leq -1 \cdot 10^{-10} \lor \neg \left(\lambda_1 \leq 1.92 \cdot 10^{-20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{t\_2}\right)\\
\end{array}
\end{array}
if lambda1 < -1.00000000000000004e-10 or 1.9199999999999999e-20 < lambda1 Initial program 47.9%
associate-*l*47.9%
Simplified47.9%
div-sub47.9%
sin-diff49.1%
Applied egg-rr49.1%
div-sub47.9%
sin-diff49.1%
Applied egg-rr57.8%
Taylor expanded in lambda2 around 0 57.6%
if -1.00000000000000004e-10 < lambda1 < 1.9199999999999999e-20Initial program 79.5%
associate-*l*79.6%
Simplified79.6%
div-sub79.6%
sin-diff80.8%
Applied egg-rr80.8%
div-sub79.6%
sin-diff80.8%
Applied egg-rr98.8%
Taylor expanded in lambda1 around 0 98.8%
Final simplification77.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1)))
(t_3
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(if (or (<= lambda1 -5.2e-6) (not (<= lambda1 1.92e-20)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))
(sqrt (- (- 1.0 t_3) t_2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_2))
(sqrt
(-
1.0
(+
t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double t_3 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double tmp;
if ((lambda1 <= -5.2e-6) || !(lambda1 <= 1.92e-20)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))), sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = ((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
t_3 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
if ((lambda1 <= (-5.2d-6)) .or. (.not. (lambda1 <= 1.92d-20))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))), sqrt(((1.0d0 - t_3) - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_2)), sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double t_3 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double tmp;
if ((lambda1 <= -5.2e-6) || !(lambda1 <= 1.92e-20)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))), Math.sqrt(((1.0 - t_3) - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_2)), Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) t_3 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) tmp = 0 if (lambda1 <= -5.2e-6) or not (lambda1 <= 1.92e-20): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))), math.sqrt(((1.0 - t_3) - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_2)), math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) t_3 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 tmp = 0.0 if ((lambda1 <= -5.2e-6) || !(lambda1 <= 1.92e-20)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 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 + t_2)), sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); t_3 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; tmp = 0.0; if ((lambda1 <= -5.2e-6) || ~((lambda1 <= 1.92e-20))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))))), sqrt(((1.0 - t_3) - t_2)))); else tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[lambda1, -5.2e-6], N[Not[LessEqual[lambda1, 1.92e-20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
t_3 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -5.2 \cdot 10^{-6} \lor \neg \left(\lambda_1 \leq 1.92 \cdot 10^{-20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{\sqrt{\left(1 - t\_3\right) - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_2}}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -5.20000000000000019e-6 or 1.9199999999999999e-20 < lambda1 Initial program 47.5%
associate-*l*47.5%
Simplified47.6%
div-sub47.6%
sin-diff48.7%
Applied egg-rr48.7%
div-sub47.6%
sin-diff48.7%
Applied egg-rr57.5%
Taylor expanded in lambda2 around 0 57.3%
if -5.20000000000000019e-6 < lambda1 < 1.9199999999999999e-20Initial program 79.7%
associate-*l*79.7%
Simplified79.7%
div-sub79.7%
sin-diff81.0%
Applied egg-rr81.0%
div-sub79.7%
sin-diff81.0%
Applied egg-rr98.8%
Taylor expanded in lambda1 around 0 98.8%
Final simplification77.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_0 (* t_2 t_2)))
(t_4 (sqrt (- (- 1.0 t_1) t_3)))
(t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_6 (* t_2 (* t_0 t_2))))
(if (<= lambda1 -7.5e-11)
(* R (* 2.0 (atan2 (sqrt (+ t_3 t_5)) t_4)))
(if (<= lambda1 7e-7)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_4)))
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_6)) (sqrt (- 1.0 (+ t_5 t_6))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = sqrt(((1.0 - t_1) - t_3));
double t_5 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_6 = t_2 * (t_0 * t_2);
double tmp;
if (lambda1 <= -7.5e-11) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_5)), t_4));
} else if (lambda1 <= 7e-7) {
tmp = R * (2.0 * atan2(sqrt((pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0) + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), t_4));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_6)), sqrt((1.0 - (t_5 + t_6)))));
}
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 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_0 * (t_2 * t_2)
t_4 = sqrt(((1.0d0 - t_1) - t_3))
t_5 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_6 = t_2 * (t_0 * t_2)
if (lambda1 <= (-7.5d-11)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_5)), t_4))
else if (lambda1 <= 7d-7) then
tmp = r * (2.0d0 * atan2(sqrt(((((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_4))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_6)), sqrt((1.0d0 - (t_5 + t_6)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = Math.sqrt(((1.0 - t_1) - t_3));
double t_5 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_6 = t_2 * (t_0 * t_2);
double tmp;
if (lambda1 <= -7.5e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_5)), t_4));
} else if (lambda1 <= 7e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), t_4));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_6)), Math.sqrt((1.0 - (t_5 + t_6)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_0 * (t_2 * t_2) t_4 = math.sqrt(((1.0 - t_1) - t_3)) t_5 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_6 = t_2 * (t_0 * t_2) tmp = 0 if lambda1 <= -7.5e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_5)), t_4)) elif lambda1 <= 7e-7: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), t_4)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_6)), math.sqrt((1.0 - (t_5 + t_6))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_0 * Float64(t_2 * t_2)) t_4 = sqrt(Float64(Float64(1.0 - t_1) - t_3)) t_5 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_6 = Float64(t_2 * Float64(t_0 * t_2)) tmp = 0.0 if (lambda1 <= -7.5e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_5)), t_4))); elseif (lambda1 <= 7e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), t_4))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_6)), sqrt(Float64(1.0 - Float64(t_5 + t_6)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_0 * (t_2 * t_2); t_4 = sqrt(((1.0 - t_1) - t_3)); t_5 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_6 = t_2 * (t_0 * t_2); tmp = 0.0; if (lambda1 <= -7.5e-11) tmp = R * (2.0 * atan2(sqrt((t_3 + t_5)), t_4)); elseif (lambda1 <= 7e-7) tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0) + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_4)); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_6)), sqrt((1.0 - (t_5 + t_6))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -7.5e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$5), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 7e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$6), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + t$95$6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_0 \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := \sqrt{\left(1 - t\_1\right) - t\_3}\\
t_5 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_6 := t\_2 \cdot \left(t\_0 \cdot t\_2\right)\\
\mathbf{if}\;\lambda_1 \leq -7.5 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_5}}{t\_4}\right)\\
\mathbf{elif}\;\lambda_1 \leq 7 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{t\_4}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_6}}{\sqrt{1 - \left(t\_5 + t\_6\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -7.5e-11Initial program 44.8%
associate-*l*44.9%
Simplified44.9%
div-sub44.9%
sin-diff46.5%
Applied egg-rr46.5%
if -7.5e-11 < lambda1 < 6.99999999999999968e-7Initial program 79.4%
associate-*l*79.4%
Simplified79.4%
div-sub79.4%
sin-diff80.7%
Applied egg-rr80.7%
div-sub79.4%
sin-diff80.7%
Applied egg-rr98.8%
Taylor expanded in lambda1 around 0 98.8%
if 6.99999999999999968e-7 < lambda1 Initial program 51.5%
div-sub51.6%
sin-diff52.1%
Applied egg-rr53.5%
Final simplification73.3%
(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
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0))
(t_3
(+
t_2
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
(t_4 (* (* (cos phi1) (cos phi2)) (* t_1 t_1)))
(t_5 (sqrt (+ t_0 t_4))))
(if (<= lambda2 -2.7e-15)
(* R (* 2.0 (atan2 t_5 (sqrt (- 1.0 t_3)))))
(if (<= lambda2 3e-6)
(*
R
(*
2.0
(atan2
t_5
(sqrt
(-
1.0
(+
t_2
(*
(cos phi1)
(* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(* R (* 2.0 (atan2 (sqrt t_3) (sqrt (- (- 1.0 t_0) t_4)))))))))
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 = pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0);
double t_3 = t_2 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0)));
double t_4 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double t_5 = sqrt((t_0 + t_4));
double tmp;
if (lambda2 <= -2.7e-15) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - t_3))));
} else if (lambda2 <= 3e-6) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_2 + (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt(((1.0 - t_0) - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = ((sin((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 = ((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_3 = t_2 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))
t_4 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
t_5 = sqrt((t_0 + t_4))
if (lambda2 <= (-2.7d-15)) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - t_3))))
else if (lambda2 <= 3d-6) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - (t_2 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt(((1.0d0 - t_0) - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 / 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.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_3 = t_2 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)));
double t_4 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double t_5 = Math.sqrt((t_0 + t_4));
double tmp;
if (lambda2 <= -2.7e-15) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - t_3))));
} else if (lambda2 <= 3e-6) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - (t_2 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt(((1.0 - t_0) - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0) t_3 = t_2 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) t_4 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) t_5 = math.sqrt((t_0 + t_4)) tmp = 0 if lambda2 <= -2.7e-15: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - t_3)))) elif lambda2 <= 3e-6: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - (t_2 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt(((1.0 - t_0) - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_3 = Float64(t_2 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))) t_4 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) t_5 = sqrt(Float64(t_0 + t_4)) tmp = 0.0 if (lambda2 <= -2.7e-15) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - t_3))))); elseif (lambda2 <= 3e-6) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - Float64(t_2 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(Float64(1.0 - t_0) - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = ((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0; t_3 = t_2 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))); t_4 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); t_5 = sqrt((t_0 + t_4)); tmp = 0.0; if (lambda2 <= -2.7e-15) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - t_3)))); elseif (lambda2 <= 3e-6) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_2 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt(((1.0 - t_0) - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(t$95$0 + t$95$4), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -2.7e-15], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 3e-6], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$4), $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(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_3 := t\_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\\
t_4 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
t_5 := \sqrt{t\_0 + t\_4}\\
\mathbf{if}\;\lambda_2 \leq -2.7 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - t\_3}}\right)\\
\mathbf{elif}\;\lambda_2 \leq 3 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - \left(t\_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{\left(1 - t\_0\right) - t\_4}}\right)\\
\end{array}
\end{array}
if lambda2 < -2.70000000000000009e-15Initial program 44.0%
associate-*l*44.0%
Simplified44.0%
div-sub44.0%
sin-diff45.2%
Applied egg-rr45.2%
div-sub44.0%
sin-diff45.2%
Applied egg-rr58.6%
Taylor expanded in lambda1 around 0 58.8%
if -2.70000000000000009e-15 < lambda2 < 3.0000000000000001e-6Initial program 81.4%
associate-*l*81.5%
Simplified81.5%
div-sub81.5%
sin-diff82.4%
Applied egg-rr82.4%
div-sub81.5%
sin-diff82.4%
Applied egg-rr99.3%
Taylor expanded in lambda2 around 0 99.3%
if 3.0000000000000001e-6 < lambda2 Initial program 45.8%
associate-*l*45.8%
Simplified45.9%
div-sub45.9%
sin-diff47.7%
Applied egg-rr47.7%
div-sub45.9%
sin-diff47.7%
Applied egg-rr52.2%
Taylor expanded in lambda1 around 0 52.3%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(pow
(-
(* (sin (* phi1 0.5)) (cos (* phi2 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))) + pow(((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))) + (((sin((phi1 * 0.5d0)) * cos((phi2 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) + Math.pow(((Math.sin((phi1 * 0.5)) * Math.cos((phi2 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))), math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) + math.pow(((math.sin((phi1 * 0.5)) * math.cos((phi2 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(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(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) + (Float64(Float64(sin(Float64(phi1 * 0.5)) * cos(Float64(phi2 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))) + (((sin((phi1 * 0.5)) * cos((phi2 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
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} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right) + {\left(\sin \left(\phi_1 \cdot 0.5\right) \cdot \cos \left(\phi_2 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}\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%
Final simplification77.3%
(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
(+
(fma
(cos phi2)
(* (cos phi1) (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))
(pow (sin (* -0.5 (- phi2 phi1))) 2.0))
-1.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(fabs((fma(cos(phi2), (cos(phi1) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))), pow(sin((-0.5 * (phi2 - phi1))), 2.0)) + -1.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(abs(Float64(fma(cos(phi2), Float64(cos(phi1) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2))))), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)) + -1.0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[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[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\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|\mathsf{fma}\left(\cos \phi_2, \cos \phi_1 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right) + -1\right|}}\right)
\end{array}
\end{array}
Initial program 63.0%
Applied egg-rr63.7%
Simplified63.7%
Final simplification63.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= t_0 -0.002) (not (<= t_0 0.2695)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((t_0 <= -0.002) || !(t_0 <= 0.2695)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if ((t_0 <= (-0.002d0)) .or. (.not. (t_0 <= 0.2695d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((t_0 <= -0.002) || !(t_0 <= 0.2695)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (t_0 <= -0.002) or not (t_0 <= 0.2695): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((t_0 <= -0.002) || !(t_0 <= 0.2695)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = 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(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((t_0 <= -0.002) || ~((t_0 <= 0.2695))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -0.002], N[Not[LessEqual[t$95$0, 0.2695]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(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[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t\_0 \leq -0.002 \lor \neg \left(t\_0 \leq 0.2695\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -2e-3 or 0.269500000000000017 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 58.2%
Taylor expanded in phi1 around 0 49.9%
+-commutative49.9%
associate--r+49.9%
unpow249.9%
1-sub-sin50.0%
unpow250.0%
Simplified50.0%
Taylor expanded in phi1 around 0 50.9%
if -2e-3 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.269500000000000017Initial program 73.0%
Taylor expanded in lambda1 around 0 71.0%
Taylor expanded in lambda2 around 0 70.9%
Final simplification57.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (* phi2 -0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= t_3 -0.008)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_3 t_3)) (pow (+ t_2 (* 0.5 (* phi1 t_0))) 2.0)))
(sqrt (- 1.0 t_4)))))
(if (<= t_3 0.2695)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_3 (* t_1 t_3))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_4) (pow t_2 2.0)))
(sqrt
(-
(pow t_0 2.0)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin((phi2 * -0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_3 <= -0.008) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_3 * t_3)) + pow((t_2 + (0.5 * (phi1 * t_0))), 2.0))), sqrt((1.0 - t_4))));
} else if (t_3 <= 0.2695) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_3 * (t_1 * t_3)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_4) + pow(t_2, 2.0))), sqrt((pow(t_0, 2.0) - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0)))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin((phi2 * (-0.5d0)))
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (t_3 <= (-0.008d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_3 * t_3)) + ((t_2 + (0.5d0 * (phi1 * t_0))) ** 2.0d0))), sqrt((1.0d0 - t_4))))
else if (t_3 <= 0.2695d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_3 * (t_1 * t_3)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_4) + (t_2 ** 2.0d0))), sqrt(((t_0 ** 2.0d0) - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 * -0.5));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin((phi2 * -0.5));
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_3 <= -0.008) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_3 * t_3)) + Math.pow((t_2 + (0.5 * (phi1 * t_0))), 2.0))), Math.sqrt((1.0 - t_4))));
} else if (t_3 <= 0.2695) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_3 * (t_1 * t_3)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_4) + Math.pow(t_2, 2.0))), Math.sqrt((Math.pow(t_0, 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin((phi2 * -0.5)) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if t_3 <= -0.008: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_3 * t_3)) + math.pow((t_2 + (0.5 * (phi1 * t_0))), 2.0))), math.sqrt((1.0 - t_4)))) elif t_3 <= 0.2695: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_3 * (t_1 * t_3)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_4) + math.pow(t_2, 2.0))), math.sqrt((math.pow(t_0, 2.0) - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(phi2 * -0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (t_3 <= -0.008) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_3 * t_3)) + (Float64(t_2 + Float64(0.5 * Float64(phi1 * t_0))) ^ 2.0))), sqrt(Float64(1.0 - t_4))))); elseif (t_3 <= 0.2695) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_3 * Float64(t_1 * t_3)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_4) + (t_2 ^ 2.0))), sqrt(Float64((t_0 ^ 2.0) - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); t_1 = cos(phi1) * cos(phi2); t_2 = sin((phi2 * -0.5)); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if (t_3 <= -0.008) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_3 * t_3)) + ((t_2 + (0.5 * (phi1 * t_0))) ^ 2.0))), sqrt((1.0 - t_4)))); elseif (t_3 <= 0.2695) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_3 * (t_1 * t_3)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_4) + (t_2 ^ 2.0))), sqrt(((t_0 ^ 2.0) - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$3, -0.008], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$2 + N[(0.5 * N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.2695], 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$3 * N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision] + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\phi_2 \cdot -0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;t\_3 \leq -0.008:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_3 \cdot t\_3\right) + {\left(t\_2 + 0.5 \cdot \left(\phi_1 \cdot t\_0\right)\right)}^{2}}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{elif}\;t\_3 \leq 0.2695:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_3 \cdot \left(t\_1 \cdot t\_3\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_4 + {t\_2}^{2}}}{\sqrt{{t\_0}^{2} - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0080000000000000002Initial program 56.7%
associate-*l*56.7%
Simplified56.7%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 38.3%
Taylor expanded in phi1 around 0 39.1%
if -0.0080000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.269500000000000017Initial program 72.7%
Taylor expanded in lambda1 around 0 70.2%
Taylor expanded in lambda2 around 0 70.1%
if 0.269500000000000017 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 59.5%
Taylor expanded in phi1 around 0 49.4%
+-commutative49.4%
associate--r+49.4%
unpow249.4%
1-sub-sin49.4%
unpow249.4%
Simplified49.4%
Taylor expanded in lambda1 around 0 34.8%
*-commutative34.8%
Simplified34.8%
Taylor expanded in phi1 around 0 35.7%
Final simplification48.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (cos (* phi2 -0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= t_1 -0.008)
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))
(sqrt
(-
t_0
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(if (<= t_1 0.2695)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_2) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(cos((phi2 * -0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_1 <= -0.008) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))), sqrt((t_0 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else if (t_1 <= 0.2695) {
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 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_2) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((t_0 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (t_1 <= (-0.008d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((t_0 - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else if (t_1 <= 0.2695d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_2) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((t_0 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_1 <= -0.008) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((t_0 - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else if (t_1 <= 0.2695) {
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.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((t_0 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.cos((phi2 * -0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if t_1 <= -0.008: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((t_0 - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) elif t_1 <= 0.2695: 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.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((t_0 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (t_1 <= -0.008) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(t_0 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); elseif (t_1 <= 0.2695) 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 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(t_0 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if (t_1 <= -0.008) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((t_0 - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); elseif (t_1 <= 0.2695) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_2) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((t_0 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$1, -0.008], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.2695], 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[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;t\_1 \leq -0.008:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{t\_0 - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{elif}\;t\_1 \leq 0.2695:\\
\;\;\;\;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 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{t\_0 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0080000000000000002Initial program 56.7%
Taylor expanded in phi1 around 0 50.3%
+-commutative50.3%
associate--r+50.3%
unpow250.3%
1-sub-sin50.3%
unpow250.3%
Simplified50.3%
Taylor expanded in phi2 around 0 39.3%
if -0.0080000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.269500000000000017Initial program 72.7%
Taylor expanded in lambda1 around 0 70.2%
Taylor expanded in lambda2 around 0 70.1%
if 0.269500000000000017 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 59.5%
Taylor expanded in phi1 around 0 49.4%
+-commutative49.4%
associate--r+49.4%
unpow249.4%
1-sub-sin49.4%
unpow249.4%
Simplified49.4%
Taylor expanded in lambda1 around 0 34.8%
*-commutative34.8%
Simplified34.8%
Taylor expanded in phi1 around 0 35.7%
Final simplification48.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_0))))
(sqrt
(-
1.0
(fma
t_1
(+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), sqrt((1.0 - fma(t_1, (0.5 + (-0.5 * cos((lambda1 - lambda2)))), pow(sin((0.5 * (phi1 - phi2))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_0)))), sqrt(Float64(1.0 - fma(t_1, Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))), (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]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_0\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_1, 0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.0%
sub-neg63.0%
associate-*r*63.0%
+-commutative63.0%
fma-undefine63.0%
Applied egg-rr63.0%
sub-neg63.0%
*-commutative63.0%
cancel-sign-sub-inv63.0%
metadata-eval63.0%
*-commutative63.0%
Simplified63.0%
Final simplification63.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_0 (* t_1 t_1)))
(t_3 (sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))
(if (<= t_1 -0.008)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_2
(pow
(+ (sin (* phi2 -0.5)) (* 0.5 (* phi1 (cos (* phi2 -0.5)))))
2.0)))
t_3)))
(if (<= t_1 0.43)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_1 (* t_0 t_1))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_2
(pow
(+ (sin (* phi1 0.5)) (* -0.5 (* phi2 (cos (* phi1 0.5)))))
2.0)))
t_3)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double tmp;
if (t_1 <= -0.008) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))), 2.0))), t_3));
} else if (t_1 <= 0.43) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_1)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow((sin((phi1 * 0.5)) + (-0.5 * (phi2 * 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 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 * (t_1 * t_1)
t_3 = sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))
if (t_1 <= (-0.008d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + ((sin((phi2 * (-0.5d0))) + (0.5d0 * (phi1 * cos((phi2 * (-0.5d0)))))) ** 2.0d0))), t_3))
else if (t_1 <= 0.43d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (t_0 * t_1)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + ((sin((phi1 * 0.5d0)) + ((-0.5d0) * (phi2 * 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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double tmp;
if (t_1 <= -0.008) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((Math.sin((phi2 * -0.5)) + (0.5 * (phi1 * Math.cos((phi2 * -0.5))))), 2.0))), t_3));
} else if (t_1 <= 0.43) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_1)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow((Math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * Math.cos((phi1 * 0.5))))), 2.0))), t_3));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 * (t_1 * t_1) t_3 = math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) tmp = 0 if t_1 <= -0.008: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((math.sin((phi2 * -0.5)) + (0.5 * (phi1 * math.cos((phi2 * -0.5))))), 2.0))), t_3)) elif t_1 <= 0.43: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_0 * t_1)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow((math.sin((phi1 * 0.5)) + (-0.5 * (phi2 * math.cos((phi1 * 0.5))))), 2.0))), t_3)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 * Float64(t_1 * t_1)) t_3 = sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) tmp = 0.0 if (t_1 <= -0.008) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(sin(Float64(phi2 * -0.5)) + Float64(0.5 * Float64(phi1 * cos(Float64(phi2 * -0.5))))) ^ 2.0))), t_3))); elseif (t_1 <= 0.43) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_0 * t_1)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (Float64(sin(Float64(phi1 * 0.5)) + Float64(-0.5 * Float64(phi2 * cos(Float64(phi1 * 0.5))))) ^ 2.0))), t_3))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 * (t_1 * t_1); t_3 = sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))); tmp = 0.0; if (t_1 <= -0.008) tmp = R * (2.0 * atan2(sqrt((t_2 + ((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))) ^ 2.0))), t_3)); elseif (t_1 <= 0.43) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (t_0 * t_1)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + ((sin((phi1 * 0.5)) + (-0.5 * (phi2 * cos((phi1 * 0.5))))) ^ 2.0))), t_3)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$1, -0.008], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 0.43], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(-0.5 * N[(phi2 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_0 \cdot \left(t\_1 \cdot t\_1\right)\\
t_3 := \sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}\\
\mathbf{if}\;t\_1 \leq -0.008:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}}}{t\_3}\right)\\
\mathbf{elif}\;t\_1 \leq 0.43:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1 \cdot \left(t\_0 \cdot t\_1\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\left(\sin \left(\phi_1 \cdot 0.5\right) + -0.5 \cdot \left(\phi_2 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}}}{t\_3}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0080000000000000002Initial program 56.7%
associate-*l*56.7%
Simplified56.7%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 38.3%
Taylor expanded in phi1 around 0 39.1%
if -0.0080000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.429999999999999993Initial program 68.5%
Taylor expanded in lambda1 around 0 64.7%
Taylor expanded in lambda2 around 0 64.7%
if 0.429999999999999993 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 63.0%
associate-*l*63.1%
Simplified63.1%
Taylor expanded in phi1 around 0 50.4%
unpow250.4%
1-sub-sin50.5%
unpow250.5%
Simplified50.5%
Taylor expanded in phi2 around 0 34.1%
Taylor expanded in phi1 around 0 34.7%
Taylor expanded in phi2 around 0 35.0%
Final simplification47.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= t_2 -0.008)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_2)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
t_0)))
(if (<= t_2 0.42)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (* t_2 (* t_1 t_2))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_3
(* t_1 (* t_2 (sqrt (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))))))
t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (t_2 <= -0.008) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_0));
} else if (t_2 <= 0.42) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (t_1 * (t_2 * sqrt((0.5 - (0.5 * cos((lambda1 - lambda2))))))))), t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (t_2 <= (-0.008d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), t_0))
else if (t_2 <= 0.42d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (t_2 * (t_1 * t_2)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (t_1 * (t_2 * sqrt((0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))))))), t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (t_2 <= -0.008) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_0));
} else if (t_2 <= 0.42) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (t_2 * (t_1 * t_2)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (t_1 * (t_2 * Math.sqrt((0.5 - (0.5 * Math.cos((lambda1 - lambda2))))))))), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if t_2 <= -0.008: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_0)) elif t_2 <= 0.42: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (t_2 * (t_1 * t_2)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (t_1 * (t_2 * math.sqrt((0.5 - (0.5 * math.cos((lambda1 - lambda2))))))))), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (t_2 <= -0.008) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_2)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_0))); elseif (t_2 <= 0.42) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_2 * Float64(t_1 * t_2)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_1 * Float64(t_2 * sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))))))), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (t_2 <= -0.008) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_0)); elseif (t_2 <= 0.42) tmp = R * (2.0 * atan2(sqrt((t_3 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (t_1 * (t_2 * sqrt((0.5 - (0.5 * cos((lambda1 - lambda2))))))))), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$2, -0.008], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.42], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$1 * N[(t$95$2 * N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;t\_2 \leq -0.008:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_0}\right)\\
\mathbf{elif}\;t\_2 \leq 0.42:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_2 \cdot \left(t\_1 \cdot t\_2\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_1 \cdot \left(t\_2 \cdot \sqrt{0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)}}{t\_0}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0080000000000000002Initial program 56.7%
associate-*l*56.7%
Simplified56.7%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 38.3%
unpow238.3%
sin-mult38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
Applied egg-rr38.3%
div-sub38.3%
+-inverses38.3%
cos-038.3%
metadata-eval38.3%
distribute-lft-out38.3%
metadata-eval38.3%
*-rgt-identity38.3%
Simplified38.3%
if -0.0080000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.419999999999999984Initial program 69.2%
Taylor expanded in lambda1 around 0 65.4%
Taylor expanded in lambda2 around 0 65.2%
if 0.419999999999999984 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 62.2%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in phi1 around 0 50.1%
unpow250.1%
1-sub-sin50.1%
unpow250.1%
Simplified50.1%
Taylor expanded in phi2 around 0 34.0%
Taylor expanded in phi1 around 0 34.6%
add-sqr-sqrt34.6%
sqrt-prod34.6%
sqr-sin-a34.6%
cos-234.6%
cos-sum34.6%
add-log-exp0.0%
add-log-exp0.0%
sum-log0.0%
exp-sqrt0.0%
exp-sqrt0.0%
add-sqr-sqrt0.0%
add-log-exp34.6%
Applied egg-rr34.6%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_3 -0.008)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_2 (* t_3 t_3))
(pow
(+ (sin (* phi2 -0.5)) (* 0.5 (* phi1 (cos (* phi2 -0.5)))))
2.0)))
t_1)))
(if (<= t_3 0.42)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_3 (* t_2 t_3))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* t_2 (* t_3 (sqrt (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))))))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_3 <= -0.008) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_3 * t_3)) + pow((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))), 2.0))), t_1));
} else if (t_3 <= 0.42) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_2 * t_3)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sqrt((0.5 - (0.5 * cos((lambda1 - lambda2))))))))), 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(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_3 <= (-0.008d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_3 * t_3)) + ((sin((phi2 * (-0.5d0))) + (0.5d0 * (phi1 * cos((phi2 * (-0.5d0)))))) ** 2.0d0))), t_1))
else if (t_3 <= 0.42d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_3 * (t_2 * t_3)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sqrt((0.5d0 - (0.5d0 * cos((lambda1 - lambda2))))))))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_3 <= -0.008) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_3 * t_3)) + Math.pow((Math.sin((phi2 * -0.5)) + (0.5 * (phi1 * Math.cos((phi2 * -0.5))))), 2.0))), t_1));
} else if (t_3 <= 0.42) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * (t_2 * t_3)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * Math.sqrt((0.5 - (0.5 * Math.cos((lambda1 - lambda2))))))))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_3 <= -0.008: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_3 * t_3)) + math.pow((math.sin((phi2 * -0.5)) + (0.5 * (phi1 * math.cos((phi2 * -0.5))))), 2.0))), t_1)) elif t_3 <= 0.42: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_3 * (t_2 * t_3)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * math.sqrt((0.5 - (0.5 * math.cos((lambda1 - lambda2))))))))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_3 <= -0.008) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_3 * t_3)) + (Float64(sin(Float64(phi2 * -0.5)) + Float64(0.5 * Float64(phi1 * cos(Float64(phi2 * -0.5))))) ^ 2.0))), t_1))); elseif (t_3 <= 0.42) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * Float64(t_2 * t_3)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * sqrt(Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))))))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))); t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_3 <= -0.008) tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_3 * t_3)) + ((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))) ^ 2.0))), t_1)); elseif (t_3 <= 0.42) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_2 * t_3)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sqrt((0.5 - (0.5 * cos((lambda1 - lambda2))))))))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$3, -0.008], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.42], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * N[Sqrt[N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t\_3 \leq -0.008:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_3 \cdot t\_3\right) + {\left(\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}}}{t\_1}\right)\\
\mathbf{elif}\;t\_3 \leq 0.42:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3 \cdot \left(t\_2 \cdot t\_3\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_3 \cdot \sqrt{0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)}\right)}}{t\_1}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0080000000000000002Initial program 56.7%
associate-*l*56.7%
Simplified56.7%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 38.3%
Taylor expanded in phi1 around 0 39.1%
if -0.0080000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.419999999999999984Initial program 69.2%
Taylor expanded in lambda1 around 0 65.4%
Taylor expanded in lambda2 around 0 65.2%
if 0.419999999999999984 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 62.2%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in phi1 around 0 50.1%
unpow250.1%
1-sub-sin50.1%
unpow250.1%
Simplified50.1%
Taylor expanded in phi2 around 0 34.0%
Taylor expanded in phi1 around 0 34.6%
add-sqr-sqrt34.6%
sqrt-prod34.6%
sqr-sin-a34.6%
cos-234.6%
cos-sum34.6%
add-log-exp0.0%
add-log-exp0.0%
sum-log0.0%
exp-sqrt0.0%
exp-sqrt0.0%
add-sqr-sqrt0.0%
add-log-exp34.6%
Applied egg-rr34.6%
Final simplification47.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi2 -2.25e-5) (not (<= phi2 2.2e-40)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) 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((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -2.25e-5) || !(phi2 <= 2.2e-40)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * 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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi2 <= (-2.25d-5)) .or. (.not. (phi2 <= 2.2d-40))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * 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((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -2.25e-5) || !(phi2 <= 2.2e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.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)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * 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((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi2 <= -2.25e-5) or not (phi2 <= 2.2e-40): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.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))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi2 <= -2.25e-5) || !(phi2 <= 2.2e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * 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((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi2 <= -2.25e-5) || ~((phi2 <= 2.2e-40))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * 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[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -2.25e-5], N[Not[LessEqual[phi2, 2.2e-40]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(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[(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] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -2.25 \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 {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_1}}\right)\\
\end{array}
\end{array}
if phi2 < -2.25000000000000014e-5 or 2.20000000000000009e-40 < phi2 Initial program 45.6%
Taylor expanded in phi1 around 0 47.0%
+-commutative47.0%
associate--r+47.0%
unpow247.0%
1-sub-sin47.1%
unpow247.1%
Simplified47.1%
Taylor expanded in phi1 around 0 48.6%
if -2.25000000000000014e-5 < phi2 < 2.20000000000000009e-40Initial program 82.0%
Taylor expanded in phi2 around 0 82.1%
+-commutative82.1%
associate--r+82.1%
unpow282.1%
1-sub-sin82.1%
unpow282.1%
*-commutative82.1%
Simplified82.1%
Final simplification64.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(t_1 (sin (* lambda2 -0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2))
(t_4
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0))))
(if (<= phi1 -7.2e-6)
(* R (* 2.0 (atan2 (sqrt t_4) (sqrt (- 1.0 (+ t_0 (* t_1 t_3)))))))
(if (<= phi1 1.9e-11)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_2 t_3)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) (* (cos phi2) (pow t_1 2.0))) t_0))
(sqrt (- 1.0 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = sin((lambda2 * -0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double t_4 = (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -7.2e-6) {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - (t_0 + (t_1 * t_3))))));
} else if (phi1 <= 1.9e-11) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * t_3))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(t_1, 2.0))) + t_0)), sqrt((1.0 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin((0.5d0 * (phi1 - phi2))) ** 2.0d0
t_1 = sin((lambda2 * (-0.5d0)))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
t_4 = (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0)
if (phi1 <= (-7.2d-6)) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - (t_0 + (t_1 * t_3))))))
else if (phi1 <= 1.9d-11) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_2 * t_3))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (t_1 ** 2.0d0))) + t_0)), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = Math.sin((lambda2 * -0.5));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double t_4 = (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -7.2e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt((1.0 - (t_0 + (t_1 * t_3))))));
} else if (phi1 <= 1.9e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * t_3))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(t_1, 2.0))) + t_0)), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_1 = math.sin((lambda2 * -0.5)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 t_4 = (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0) tmp = 0 if phi1 <= -7.2e-6: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt((1.0 - (t_0 + (t_1 * t_3)))))) elif phi1 <= 1.9e-11: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * t_3))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(t_1, 2.0))) + t_0)), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0 t_1 = sin(Float64(lambda2 * -0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) t_4 = Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0)) tmp = 0.0 if (phi1 <= -7.2e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_1 * t_3))))))); elseif (phi1 <= 1.9e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * t_3))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (t_1 ^ 2.0))) + t_0)), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))) ^ 2.0; t_1 = sin((lambda2 * -0.5)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; t_4 = (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0); tmp = 0.0; if (phi1 <= -7.2e-6) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - (t_0 + (t_1 * t_3)))))); elseif (phi1 <= 1.9e-11) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_2 * t_3))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (t_1 ^ 2.0))) + t_0)), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -7.2e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.9e-11], 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$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_1 := \sin \left(\lambda_2 \cdot -0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\\
t_4 := \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -7.2 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{1 - \left(t\_0 + t\_1 \cdot t\_3\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.9 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2 \cdot t\_3}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {t\_1}^{2}\right) + t\_0}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if phi1 < -7.19999999999999967e-6Initial program 47.5%
add-cbrt-cube47.4%
pow347.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
Taylor expanded in phi2 around 0 48.8%
Taylor expanded in lambda1 around 0 41.5%
rem-cbrt-cube41.6%
Applied egg-rr41.6%
if -7.19999999999999967e-6 < phi1 < 1.8999999999999999e-11Initial program 76.7%
Taylor expanded in phi1 around 0 76.7%
+-commutative76.7%
associate--r+76.7%
unpow276.7%
1-sub-sin76.8%
unpow276.8%
Simplified76.8%
if 1.8999999999999999e-11 < phi1 Initial program 48.2%
associate-*l*48.3%
Simplified48.3%
div-sub48.3%
sin-diff50.6%
Applied egg-rr50.6%
Taylor expanded in lambda1 around 0 45.1%
Taylor expanded in phi2 around 0 44.1%
Final simplification60.6%
(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
(+
1.0
(-
(*
(cos phi1)
(* (cos phi2) (- -0.5 (* -0.5 (cos (- lambda1 lambda2))))))
(pow (sin (* -0.5 (- phi2 phi1))) 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((1.0 + ((cos(phi1) * (cos(phi2) * (-0.5 - (-0.5 * cos((lambda1 - lambda2)))))) - pow(sin((-0.5 * (phi2 - phi1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 + ((cos(phi1) * (cos(phi2) * ((-0.5d0) - ((-0.5d0) * cos((lambda1 - lambda2)))))) - (sin(((-0.5d0) * (phi2 - phi1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 + ((Math.cos(phi1) * (Math.cos(phi2) * (-0.5 - (-0.5 * Math.cos((lambda1 - lambda2)))))) - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 + ((math.cos(phi1) * (math.cos(phi2) * (-0.5 - (-0.5 * math.cos((lambda1 - lambda2)))))) - math.pow(math.sin((-0.5 * (phi2 - phi1))), 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(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(-0.5 - Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))) - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 + ((cos(phi1) * (cos(phi2) * (-0.5 - (-0.5 * cos((lambda1 - lambda2)))))) - (sin((-0.5 * (phi2 - phi1))) ^ 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[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 - N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
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{1 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(-0.5 - -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right) - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate--r+63.0%
*-un-lft-identity63.0%
associate-*r*63.0%
fmm-def63.0%
associate-*r*63.0%
div-inv63.0%
metadata-eval63.0%
Applied egg-rr63.0%
Simplified63.0%
Final simplification63.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi1 -3.5e-6) (not (<= phi1 3e-38)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
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) (pow (sin (* -0.5 (- lambda2 lambda1))) 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 tmp;
if ((phi1 <= -3.5e-6) || !(phi1 <= 3e-38)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if ((phi1 <= (-3.5d-6)) .or. (.not. (phi1 <= 3d-38))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
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) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -3.5e-6) || !(phi1 <= 3e-38)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((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) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi1 <= -3.5e-6) or not (phi1 <= 3e-38): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((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) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi1 <= -3.5e-6) || !(phi1 <= 3e-38)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if ((phi1 <= -3.5e-6) || ~((phi1 <= 3e-38))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); else 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) * (sin((-0.5 * (lambda2 - lambda1))) ^ 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]}, If[Or[LessEqual[phi1, -3.5e-6], N[Not[LessEqual[phi1, 3e-38]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(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[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -3.5 \cdot 10^{-6} \lor \neg \left(\phi_1 \leq 3 \cdot 10^{-38}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\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 {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -3.49999999999999995e-6 or 2.99999999999999989e-38 < phi1 Initial program 49.8%
associate-*l*49.9%
Simplified49.9%
div-sub49.9%
sin-diff52.3%
Applied egg-rr52.3%
Taylor expanded in lambda1 around 0 44.6%
Taylor expanded in phi2 around 0 43.7%
if -3.49999999999999995e-6 < phi1 < 2.99999999999999989e-38Initial program 75.9%
Taylor expanded in phi1 around 0 75.9%
+-commutative75.9%
associate--r+75.9%
unpow275.9%
1-sub-sin76.0%
unpow276.0%
Simplified76.0%
Taylor expanded in phi1 around 0 74.6%
Final simplification59.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (sin (* lambda2 -0.5)))
(t_3 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0))))
(if (<= phi1 -5.5e-6)
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt
(-
1.0
(+
t_0
(*
t_2
(*
(* (cos phi1) (cos phi2))
(sin (/ (- lambda1 lambda2) 2.0))))))))))
(if (<= phi1 3e-38)
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) (* (cos phi2) (pow t_2 2.0))) t_0))
(sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sin((lambda2 * -0.5));
double t_3 = (cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -5.5e-6) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_0 + (t_2 * ((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0)))))))));
} else if (phi1 <= 3e-38) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(t_2, 2.0))) + t_0)), sqrt((1.0 - t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin((0.5d0 * (phi1 - phi2))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = sin((lambda2 * (-0.5d0)))
t_3 = (cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0)
if (phi1 <= (-5.5d-6)) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_0 + (t_2 * ((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0d0)))))))))
else if (phi1 <= 3d-38) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (t_2 ** 2.0d0))) + t_0)), sqrt((1.0d0 - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.sin((lambda2 * -0.5));
double t_3 = (Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi1 <= -5.5e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_0 + (t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0)))))))));
} else if (phi1 <= 3e-38) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(t_2, 2.0))) + t_0)), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.sin((lambda2 * -0.5)) t_3 = (math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0) tmp = 0 if phi1 <= -5.5e-6: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_0 + (t_2 * ((math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0))))))))) elif phi1 <= 3e-38: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(t_2, 2.0))) + t_0)), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = sin(Float64(lambda2 * -0.5)) t_3 = Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0)) tmp = 0.0 if (phi1 <= -5.5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0)))))))))); elseif (phi1 <= 3e-38) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (t_2 ^ 2.0))) + t_0)), sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = sin((lambda2 * -0.5)); t_3 = (cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0); tmp = 0.0; if (phi1 <= -5.5e-6) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_0 + (t_2 * ((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))))))))); elseif (phi1 <= 3e-38) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (t_2 ^ 2.0))) + t_0)), sqrt((1.0 - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -5.5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3e-38], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\lambda_2 \cdot -0.5\right)\\
t_3 := \cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -5.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \left(t\_0 + t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 3 \cdot 10^{-38}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {t\_2}^{2}\right) + t\_0}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if phi1 < -5.4999999999999999e-6Initial program 47.5%
add-cbrt-cube47.4%
pow347.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
Taylor expanded in phi2 around 0 48.8%
Taylor expanded in lambda1 around 0 41.5%
rem-cbrt-cube41.6%
Applied egg-rr41.6%
if -5.4999999999999999e-6 < phi1 < 2.99999999999999989e-38Initial program 75.9%
Taylor expanded in phi1 around 0 75.9%
+-commutative75.9%
associate--r+75.9%
unpow275.9%
1-sub-sin76.0%
unpow276.0%
Simplified76.0%
Taylor expanded in phi1 around 0 74.6%
if 2.99999999999999989e-38 < phi1 Initial program 52.0%
associate-*l*52.1%
Simplified52.1%
div-sub52.1%
sin-diff54.3%
Applied egg-rr54.3%
Taylor expanded in lambda1 around 0 46.9%
Taylor expanded in phi2 around 0 46.0%
Final simplification59.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_1 (* t_2 t_2)))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= t_2 -0.008)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 t_0)))))
(if (<= t_2 0.42)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (* t_2 (* t_1 t_2))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(* R (* 2.0 (atan2 (sqrt (+ t_3 t_4)) (sqrt (+ (- 2.0 t_0) -1.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 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (t_2 <= -0.008) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_0))));
} else if (t_2 <= 0.42) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), sqrt(((2.0 - t_0) + -1.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_1 * (t_2 * t_2)
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (t_2 <= (-0.008d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - t_0))))
else if (t_2 <= 0.42d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (t_2 * (t_1 * t_2)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_4)), sqrt(((2.0d0 - t_0) + (-1.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.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (t_2 <= -0.008) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - t_0))));
} else if (t_2 <= 0.42) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (t_2 * (t_1 * t_2)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_4)), Math.sqrt(((2.0 - t_0) + -1.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.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_1 * (t_2 * t_2) t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if t_2 <= -0.008: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - t_0)))) elif t_2 <= 0.42: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (t_2 * (t_1 * t_2)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_4)), math.sqrt(((2.0 - t_0) + -1.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_1 * Float64(t_2 * t_2)) t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (t_2 <= -0.008) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - t_0))))); elseif (t_2 <= 0.42) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(t_2 * Float64(t_1 * t_2)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_4)), sqrt(Float64(Float64(2.0 - t_0) + -1.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 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_1 * (t_2 * t_2); t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (t_2 <= -0.008) tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - t_0)))); elseif (t_2 <= 0.42) tmp = R * (2.0 * atan2(sqrt((t_4 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), sqrt(((2.0 - t_0) + -1.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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$2, -0.008], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.42], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(2.0 - t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_1 \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;t\_2 \leq -0.008:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{elif}\;t\_2 \leq 0.42:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + t\_2 \cdot \left(t\_1 \cdot t\_2\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_4}}{\sqrt{\left(2 - t\_0\right) + -1}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0080000000000000002Initial program 56.7%
associate-*l*56.7%
Simplified56.7%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 38.3%
unpow238.3%
sin-mult38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
Applied egg-rr38.3%
div-sub38.3%
+-inverses38.3%
cos-038.3%
metadata-eval38.3%
distribute-lft-out38.3%
metadata-eval38.3%
*-rgt-identity38.3%
Simplified38.3%
if -0.0080000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.419999999999999984Initial program 69.2%
Taylor expanded in lambda1 around 0 65.4%
Taylor expanded in lambda2 around 0 65.2%
if 0.419999999999999984 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 62.2%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in phi1 around 0 50.1%
unpow250.1%
1-sub-sin50.1%
unpow250.1%
Simplified50.1%
Taylor expanded in phi2 around 0 34.0%
Taylor expanded in phi1 around 0 34.6%
expm1-log1p-u34.6%
Applied egg-rr34.6%
expm1-undefine34.6%
sub-neg34.6%
log1p-undefine34.6%
rem-exp-log34.6%
associate-+r-34.6%
metadata-eval34.6%
metadata-eval34.6%
Simplified34.6%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_1 (* t_2 t_2)))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= t_2 -0.008)
(*
R
(* 2.0 (atan2 (sqrt (+ t_3 (- 0.5 (/ (cos (- phi1 phi2)) 2.0)))) t_0)))
(if (<= t_2 0.42)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (* t_2 (* t_1 t_2))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(* R (* 2.0 (atan2 (sqrt (+ t_3 t_4)) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (t_2 <= -0.008) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_0));
} else if (t_2 <= 0.42) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), 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) :: tmp
t_0 = sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_1 * (t_2 * t_2)
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (t_2 <= (-0.008d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), t_0))
else if (t_2 <= 0.42d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (t_2 * (t_1 * t_2)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_4)), t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * (t_2 * t_2);
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (t_2 <= -0.008) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_0));
} else if (t_2 <= 0.42) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (t_2 * (t_1 * t_2)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_4)), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_1 * (t_2 * t_2) t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if t_2 <= -0.008: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_0)) elif t_2 <= 0.42: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (t_2 * (t_1 * t_2)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_4)), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_1 * Float64(t_2 * t_2)) t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (t_2 <= -0.008) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_0))); elseif (t_2 <= 0.42) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(t_2 * Float64(t_1 * t_2)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_4)), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_1 * (t_2 * t_2); t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (t_2 <= -0.008) tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_0)); elseif (t_2 <= 0.42) tmp = R * (2.0 * atan2(sqrt((t_4 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$2, -0.008], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.42], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$4), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_1 \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;t\_2 \leq -0.008:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_0}\right)\\
\mathbf{elif}\;t\_2 \leq 0.42:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + t\_2 \cdot \left(t\_1 \cdot t\_2\right)}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_4}}{t\_0}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.0080000000000000002Initial program 56.7%
associate-*l*56.7%
Simplified56.7%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.8%
unpow249.8%
Simplified49.8%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 38.3%
unpow238.3%
sin-mult38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
div-inv38.3%
metadata-eval38.3%
Applied egg-rr38.3%
div-sub38.3%
+-inverses38.3%
cos-038.3%
metadata-eval38.3%
distribute-lft-out38.3%
metadata-eval38.3%
*-rgt-identity38.3%
Simplified38.3%
if -0.0080000000000000002 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.419999999999999984Initial program 69.2%
Taylor expanded in lambda1 around 0 65.4%
Taylor expanded in lambda2 around 0 65.2%
if 0.419999999999999984 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 62.2%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in phi1 around 0 50.1%
unpow250.1%
1-sub-sin50.1%
unpow250.1%
Simplified50.1%
Taylor expanded in phi2 around 0 34.0%
Taylor expanded in phi1 around 0 34.6%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(if (or (<= lambda2 -4e-120) (not (<= lambda2 4800000.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (pow (cos (* lambda1 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double tmp;
if ((lambda2 <= -4e-120) || !(lambda2 <= 4800000.0)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(pow(cos((lambda1 * 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) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
if ((lambda2 <= (-4d-120)) .or. (.not. (lambda2 <= 4800000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double tmp;
if ((lambda2 <= -4e-120) || !(lambda2 <= 4800000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) tmp = 0 if (lambda2 <= -4e-120) or not (lambda2 <= 4800000.0): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) tmp = 0.0 if ((lambda2 <= -4e-120) || !(lambda2 <= 4800000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = 0.0; if ((lambda2 <= -4e-120) || ~((lambda2 <= 4800000.0))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -4e-120], N[Not[LessEqual[lambda2, 4800000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
\mathbf{if}\;\lambda_2 \leq -4 \cdot 10^{-120} \lor \neg \left(\lambda_2 \leq 4800000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < -3.99999999999999991e-120 or 4.8e6 < lambda2 Initial program 49.7%
associate-*l*49.8%
Simplified49.8%
Taylor expanded in phi1 around 0 40.2%
unpow240.2%
1-sub-sin40.3%
unpow240.3%
Simplified40.3%
Taylor expanded in phi2 around 0 30.6%
Taylor expanded in phi1 around 0 31.0%
unpow231.0%
sin-mult31.0%
div-inv31.0%
metadata-eval31.0%
div-inv31.0%
metadata-eval31.0%
div-inv31.0%
metadata-eval31.0%
div-inv31.0%
metadata-eval31.0%
Applied egg-rr31.0%
div-sub31.0%
+-inverses31.0%
cos-031.0%
metadata-eval31.0%
distribute-lft-out31.0%
metadata-eval31.0%
*-rgt-identity31.0%
Simplified31.0%
if -3.99999999999999991e-120 < lambda2 < 4.8e6Initial program 80.8%
associate-*l*80.9%
Simplified80.9%
Taylor expanded in phi1 around 0 62.4%
unpow262.4%
1-sub-sin62.4%
unpow262.4%
Simplified62.4%
Taylor expanded in phi2 around 0 45.1%
Taylor expanded in phi1 around 0 45.1%
Taylor expanded in lambda2 around 0 45.1%
unpow245.1%
1-sub-sin45.2%
unpow245.2%
Simplified45.2%
Final simplification37.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= lambda2 -0.0072) (not (<= lambda2 1.4e+16)))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda2 -0.5)) 2.0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda1 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((lambda2 <= -0.0072) || !(lambda2 <= 1.4e+16)) {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda1 * 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) / 2.0d0))
t_1 = sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if ((lambda2 <= (-0.0072d0)) .or. (.not. (lambda2 <= 1.4d+16))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((lambda2 <= -0.0072) || !(lambda2 <= 1.4e+16)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (lambda2 <= -0.0072) or not (lambda2 <= 1.4e+16): tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((lambda2 <= -0.0072) || !(lambda2 <= 1.4e+16)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if ((lambda2 <= -0.0072) || ~((lambda2 <= 1.4e+16))) tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.0072], N[Not[LessEqual[lambda2, 1.4e+16]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq -0.0072 \lor \neg \left(\lambda_2 \leq 1.4 \cdot 10^{+16}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < -0.0071999999999999998 or 1.4e16 < lambda2 Initial program 45.0%
associate-*l*45.0%
Simplified45.0%
Taylor expanded in phi1 around 0 38.2%
unpow238.2%
1-sub-sin38.2%
unpow238.2%
Simplified38.2%
Taylor expanded in phi2 around 0 29.1%
Taylor expanded in phi1 around 0 29.4%
Taylor expanded in lambda1 around 0 29.6%
unpow229.6%
1-sub-sin29.7%
unpow229.7%
*-commutative29.7%
Simplified29.7%
if -0.0071999999999999998 < lambda2 < 1.4e16Initial program 80.1%
associate-*l*80.2%
Simplified80.2%
Taylor expanded in phi1 around 0 60.6%
unpow260.6%
1-sub-sin60.7%
unpow260.7%
Simplified60.7%
Taylor expanded in phi2 around 0 44.1%
Taylor expanded in phi1 around 0 44.2%
Taylor expanded in lambda2 around 0 44.2%
unpow244.2%
1-sub-sin44.3%
unpow244.3%
Simplified44.3%
Final simplification37.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.7%
unpow249.7%
Simplified49.7%
Taylor expanded in phi2 around 0 36.8%
Taylor expanded in phi1 around 0 37.0%
Final simplification37.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
Taylor expanded in phi1 around 0 49.7%
unpow249.7%
1-sub-sin49.7%
unpow249.7%
Simplified49.7%
Taylor expanded in phi2 around 0 36.8%
Taylor expanded in phi1 around 0 37.0%
unpow237.0%
sin-mult33.3%
div-inv33.3%
metadata-eval33.3%
div-inv33.3%
metadata-eval33.3%
div-inv33.3%
metadata-eval33.3%
div-inv33.3%
metadata-eval33.3%
Applied egg-rr33.3%
div-sub33.3%
+-inverses33.3%
cos-033.3%
metadata-eval33.3%
distribute-lft-out33.3%
metadata-eval33.3%
*-rgt-identity33.3%
Simplified33.3%
Final simplification33.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))))))))))