
(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 30 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 (cos (* phi1 0.5)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (cos (* phi2 0.5)))
(t_3 (sin (* phi1 0.5)))
(t_4 (* (cos phi2) (* t_1 t_1))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
t_4
(pow (- (* t_2 t_3) (* (sin (* phi2 0.5)) t_0)) 2.0)))
(sqrt
(-
1.0
(fma
(cos phi1)
t_4
(pow (fma t_2 t_3 (* (sin (* phi2 -0.5)) t_0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos((phi2 * 0.5));
double t_3 = sin((phi1 * 0.5));
double t_4 = cos(phi2) * (t_1 * t_1);
return R * (2.0 * atan2(sqrt(fma(cos(phi1), t_4, pow(((t_2 * t_3) - (sin((phi2 * 0.5)) * t_0)), 2.0))), sqrt((1.0 - fma(cos(phi1), t_4, pow(fma(t_2, t_3, (sin((phi2 * -0.5)) * t_0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = cos(Float64(phi2 * 0.5)) t_3 = sin(Float64(phi1 * 0.5)) t_4 = Float64(cos(phi2) * Float64(t_1 * t_1)) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), t_4, (Float64(Float64(t_2 * t_3) - Float64(sin(Float64(phi2 * 0.5)) * t_0)) ^ 2.0))), sqrt(Float64(1.0 - fma(cos(phi1), t_4, (fma(t_2, t_3, Float64(sin(Float64(phi2 * -0.5)) * t_0)) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$4 + N[Power[N[(N[(t$95$2 * t$95$3), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * t$95$4 + N[Power[N[(t$95$2 * t$95$3 + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_3 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_4 := \cos \phi_2 \cdot \left(t\_1 \cdot t\_1\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_4, {\left(t\_2 \cdot t\_3 - \sin \left(\phi_2 \cdot 0.5\right) \cdot t\_0\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, t\_4, {\left(\mathsf{fma}\left(t\_2, t\_3, \sin \left(\phi_2 \cdot -0.5\right) \cdot t\_0\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.0%
Simplified64.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr65.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr80.7%
*-commutative80.7%
*-commutative80.7%
fma-neg80.7%
*-commutative80.7%
*-commutative80.7%
distribute-lft-neg-in80.7%
sin-neg80.7%
*-commutative80.7%
distribute-rgt-neg-out80.7%
mul-1-neg80.7%
associate-*r*80.7%
metadata-eval80.7%
Simplified80.7%
Final simplification80.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos (* phi2 0.5)) (sin (* phi1 0.5)))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (* t_1 t_1))
(pow (- t_2 (* (sin (* phi2 0.5)) t_0)) 2.0)))
(sqrt
(-
1.0
(fma
(pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)
(* (cos phi1) (cos phi2))
(pow (fma (sin (* phi2 -0.5)) t_0 t_2) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos((phi2 * 0.5)) * sin((phi1 * 0.5));
return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_1 * t_1)), pow((t_2 - (sin((phi2 * 0.5)) * t_0)), 2.0))), sqrt((1.0 - fma(pow(sin(((lambda1 - lambda2) * 0.5)), 2.0), (cos(phi1) * cos(phi2)), pow(fma(sin((phi2 * -0.5)), t_0, t_2), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_1 * t_1)), (Float64(t_2 - Float64(sin(Float64(phi2 * 0.5)) * t_0)) ^ 2.0))), sqrt(Float64(1.0 - fma((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0), Float64(cos(phi1) * cos(phi2)), (fma(sin(Float64(phi2 * -0.5)), t_0, t_2) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$2 - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$0 + t$95$2), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t\_1 \cdot t\_1\right), {\left(t\_2 - \sin \left(\phi_2 \cdot 0.5\right) \cdot t\_0\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left({\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, \cos \phi_1 \cdot \cos \phi_2, {\left(\mathsf{fma}\left(\sin \left(\phi_2 \cdot -0.5\right), t\_0, t\_2\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.0%
Simplified64.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr65.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr80.7%
*-commutative80.7%
*-commutative80.7%
fma-neg80.7%
*-commutative80.7%
*-commutative80.7%
distribute-lft-neg-in80.7%
sin-neg80.7%
*-commutative80.7%
distribute-rgt-neg-out80.7%
mul-1-neg80.7%
associate-*r*80.7%
metadata-eval80.7%
Simplified80.7%
Taylor expanded in phi1 around inf 80.7%
associate-*r*80.7%
*-commutative80.7%
*-commutative80.7%
*-commutative80.7%
fma-define80.7%
Simplified80.7%
Final simplification80.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(fma
(cos phi1)
(* (cos phi2) (* t_0 t_0))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = fma(cos(phi1), (cos(phi2) * (t_0 * t_0)), pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0));
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = fma(cos(phi1), Float64(cos(phi2) * Float64(t_0 * t_0)), (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(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[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 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]}, 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 := \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t\_0 \cdot t\_0\right), {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 64.0%
Simplified64.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr65.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr80.7%
Final simplification80.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos (* phi2 0.5)) (sin (* phi1 0.5))))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(sqrt
(fma
(cos phi1)
(* (cos phi2) (* t_2 t_2))
(pow (- t_0 (* (sin (* phi2 0.5)) t_1)) 2.0))))
(t_4 (pow (+ t_0 (* (sin (* phi2 -0.5)) t_1)) 2.0)))
(if (or (<= lambda1 -8.2e-37) (not (<= lambda1 2.95e-5)))
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(+
t_4
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(+
t_4
(*
(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 = cos((phi2 * 0.5)) * sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt(fma(cos(phi1), (cos(phi2) * (t_2 * t_2)), pow((t_0 - (sin((phi2 * 0.5)) * t_1)), 2.0)));
double t_4 = pow((t_0 + (sin((phi2 * -0.5)) * t_1)), 2.0);
double tmp;
if ((lambda1 <= -8.2e-37) || !(lambda1 <= 2.95e-5)) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_4 + (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_4 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_2 * t_2)), (Float64(t_0 - Float64(sin(Float64(phi2 * 0.5)) * t_1)) ^ 2.0))) t_4 = Float64(t_0 + Float64(sin(Float64(phi2 * -0.5)) * t_1)) ^ 2.0 tmp = 0.0 if ((lambda1 <= -8.2e-37) || !(lambda1 <= 2.95e-5)) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_4 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_4 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$0 - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(t$95$0 + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[lambda1, -8.2e-37], N[Not[LessEqual[lambda1, 2.95e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$4 + 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[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$4 + 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 := \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t\_2 \cdot t\_2\right), {\left(t\_0 - \sin \left(\phi_2 \cdot 0.5\right) \cdot t\_1\right)}^{2}\right)}\\
t_4 := {\left(t\_0 + \sin \left(\phi_2 \cdot -0.5\right) \cdot t\_1\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -8.2 \cdot 10^{-37} \lor \neg \left(\lambda_1 \leq 2.95 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_4 + \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{t\_3}{\sqrt{1 - \left(t\_4 + \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 < -8.1999999999999996e-37 or 2.9499999999999999e-5 < lambda1 Initial program 48.9%
Simplified48.9%
div-sub48.9%
sin-diff49.8%
div-inv49.8%
metadata-eval49.8%
div-inv49.8%
metadata-eval49.8%
div-inv49.8%
metadata-eval49.8%
div-inv49.8%
metadata-eval49.8%
Applied egg-rr49.8%
div-sub48.9%
sin-diff49.8%
div-inv49.8%
metadata-eval49.8%
div-inv49.8%
metadata-eval49.8%
div-inv49.8%
metadata-eval49.8%
div-inv49.8%
metadata-eval49.8%
Applied egg-rr61.3%
*-commutative61.3%
*-commutative61.3%
fma-neg61.3%
*-commutative61.3%
*-commutative61.3%
distribute-lft-neg-in61.3%
sin-neg61.3%
*-commutative61.3%
distribute-rgt-neg-out61.3%
mul-1-neg61.3%
associate-*r*61.3%
metadata-eval61.3%
Simplified61.3%
Taylor expanded in lambda2 around 0 60.0%
if -8.1999999999999996e-37 < lambda1 < 2.9499999999999999e-5Initial program 78.5%
Simplified78.5%
div-sub78.5%
sin-diff79.5%
div-inv79.5%
metadata-eval79.5%
div-inv79.5%
metadata-eval79.5%
div-inv79.5%
metadata-eval79.5%
div-inv79.5%
metadata-eval79.5%
Applied egg-rr79.5%
div-sub78.5%
sin-diff79.5%
div-inv79.5%
metadata-eval79.5%
div-inv79.5%
metadata-eval79.5%
div-inv79.5%
metadata-eval79.5%
div-inv79.5%
metadata-eval79.5%
Applied egg-rr99.2%
*-commutative99.2%
*-commutative99.2%
fma-neg99.2%
*-commutative99.2%
*-commutative99.2%
distribute-lft-neg-in99.2%
sin-neg99.2%
*-commutative99.2%
distribute-rgt-neg-out99.2%
mul-1-neg99.2%
associate-*r*99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in lambda1 around 0 99.2%
Final simplification80.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (cos (* phi1 0.5)))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (* t_4 t_4))
(t_6 (cos (* phi2 0.5)))
(t_7 (* t_6 t_0))
(t_8 (pow (- t_7 (* (sin (* phi2 0.5)) t_2)) 2.0))
(t_9 (* (sin (* phi2 -0.5)) t_2))
(t_10 (* t_4 (* t_4 t_3))))
(if (<= lambda1 -4.4e-14)
(*
(atan2 (sqrt (fma t_3 t_5 t_1)) (sqrt (- 1.0 (fma t_3 t_5 t_8))))
(* R 2.0))
(if (<= lambda1 3e-6)
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi1) (* (cos phi2) t_5) t_8))
(sqrt
(-
1.0
(+
(pow (+ t_7 t_9) 2.0)
(*
(cos phi1)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (fma t_6 t_0 t_9) 2.0) t_10))
(sqrt (- 1.0 (+ t_1 t_10))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos((phi1 * 0.5));
double t_3 = cos(phi1) * cos(phi2);
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_4 * t_4;
double t_6 = cos((phi2 * 0.5));
double t_7 = t_6 * t_0;
double t_8 = pow((t_7 - (sin((phi2 * 0.5)) * t_2)), 2.0);
double t_9 = sin((phi2 * -0.5)) * t_2;
double t_10 = t_4 * (t_4 * t_3);
double tmp;
if (lambda1 <= -4.4e-14) {
tmp = atan2(sqrt(fma(t_3, t_5, t_1)), sqrt((1.0 - fma(t_3, t_5, t_8)))) * (R * 2.0);
} else if (lambda1 <= 3e-6) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * t_5), t_8)), sqrt((1.0 - (pow((t_7 + t_9), 2.0) + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(fma(t_6, t_0, t_9), 2.0) + t_10)), sqrt((1.0 - (t_1 + t_10)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = cos(Float64(phi1 * 0.5)) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = Float64(t_4 * t_4) t_6 = cos(Float64(phi2 * 0.5)) t_7 = Float64(t_6 * t_0) t_8 = Float64(t_7 - Float64(sin(Float64(phi2 * 0.5)) * t_2)) ^ 2.0 t_9 = Float64(sin(Float64(phi2 * -0.5)) * t_2) t_10 = Float64(t_4 * Float64(t_4 * t_3)) tmp = 0.0 if (lambda1 <= -4.4e-14) tmp = Float64(atan(sqrt(fma(t_3, t_5, t_1)), sqrt(Float64(1.0 - fma(t_3, t_5, t_8)))) * Float64(R * 2.0)); elseif (lambda1 <= 3e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * t_5), t_8)), sqrt(Float64(1.0 - Float64((Float64(t_7 + t_9) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(t_6, t_0, t_9) ^ 2.0) + t_10)), sqrt(Float64(1.0 - Float64(t_1 + t_10)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$6 * t$95$0), $MachinePrecision]}, Block[{t$95$8 = N[Power[N[(t$95$7 - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$9 = N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$10 = N[(t$95$4 * N[(t$95$4 * t$95$3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -4.4e-14], N[(N[ArcTan[N[Sqrt[N[(t$95$3 * t$95$5 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 * t$95$5 + t$95$8), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 3e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$5), $MachinePrecision] + t$95$8), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$7 + t$95$9), $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]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(t$95$6 * t$95$0 + t$95$9), $MachinePrecision], 2.0], $MachinePrecision] + t$95$10), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + t$95$10), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := t\_4 \cdot t\_4\\
t_6 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_7 := t\_6 \cdot t\_0\\
t_8 := {\left(t\_7 - \sin \left(\phi_2 \cdot 0.5\right) \cdot t\_2\right)}^{2}\\
t_9 := \sin \left(\phi_2 \cdot -0.5\right) \cdot t\_2\\
t_10 := t\_4 \cdot \left(t\_4 \cdot t\_3\right)\\
\mathbf{if}\;\lambda_1 \leq -4.4 \cdot 10^{-14}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_3, t\_5, t\_1\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_3, t\_5, t\_8\right)}} \cdot \left(R \cdot 2\right)\\
\mathbf{elif}\;\lambda_1 \leq 3 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_5, t\_8\right)}}{\sqrt{1 - \left({\left(t\_7 + t\_9\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(t\_6, t\_0, t\_9\right)\right)}^{2} + t\_10}}{\sqrt{1 - \left(t\_1 + t\_10\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -4.4000000000000002e-14Initial program 47.3%
associate-*r*47.3%
*-commutative47.3%
Simplified47.4%
div-sub47.4%
sin-diff48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
div-inv48.1%
metadata-eval48.1%
Applied egg-rr48.5%
if -4.4000000000000002e-14 < lambda1 < 3.0000000000000001e-6Initial program 78.8%
Simplified78.8%
div-sub78.8%
sin-diff79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
Applied egg-rr79.8%
div-sub78.8%
sin-diff79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
div-inv79.8%
metadata-eval79.8%
Applied egg-rr99.2%
*-commutative99.2%
*-commutative99.2%
fma-neg99.2%
*-commutative99.2%
*-commutative99.2%
distribute-lft-neg-in99.2%
sin-neg99.2%
*-commutative99.2%
distribute-rgt-neg-out99.2%
mul-1-neg99.2%
associate-*r*99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in lambda1 around 0 99.2%
if 3.0000000000000001e-6 < lambda1 Initial program 46.6%
div-sub46.5%
sin-diff47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
Applied egg-rr47.9%
*-commutative56.4%
*-commutative56.4%
fma-neg56.4%
*-commutative56.4%
*-commutative56.4%
distribute-lft-neg-in56.4%
sin-neg56.4%
*-commutative56.4%
distribute-rgt-neg-out56.4%
mul-1-neg56.4%
associate-*r*56.4%
metadata-eval56.4%
Simplified47.9%
Final simplification75.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos (* phi2 0.5)) (sin (* phi1 0.5)))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
(* (cos phi2) (* t_1 t_1))
(pow (- t_2 (* (sin (* phi2 0.5)) t_0)) 2.0)))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(pow (+ t_2 (* (sin (* phi2 -0.5)) t_0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos((phi2 * 0.5)) * sin((phi1 * 0.5));
return R * (2.0 * atan2(sqrt(fma(cos(phi1), (cos(phi2) * (t_1 * t_1)), pow((t_2 - (sin((phi2 * 0.5)) * t_0)), 2.0))), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))) + pow((t_2 + (sin((phi2 * -0.5)) * t_0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), Float64(cos(phi2) * Float64(t_1 * t_1)), (Float64(t_2 - Float64(sin(Float64(phi2 * 0.5)) * t_0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))) + (Float64(t_2 + Float64(sin(Float64(phi2 * -0.5)) * t_0)) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[(t$95$2 - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $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[(t$95$2 + N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(t\_1 \cdot t\_1\right), {\left(t\_2 - \sin \left(\phi_2 \cdot 0.5\right) \cdot t\_0\right)}^{2}\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(t\_2 + \sin \left(\phi_2 \cdot -0.5\right) \cdot t\_0\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.0%
Simplified64.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr65.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr80.7%
*-commutative80.7%
*-commutative80.7%
fma-neg80.7%
*-commutative80.7%
*-commutative80.7%
distribute-lft-neg-in80.7%
sin-neg80.7%
*-commutative80.7%
distribute-rgt-neg-out80.7%
mul-1-neg80.7%
associate-*r*80.7%
metadata-eval80.7%
Simplified80.7%
Taylor expanded in phi1 around inf 80.7%
Final simplification80.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi2) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(fma
(cos phi1)
t_1
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))
(sqrt
(- 1.0 (fma (cos phi1) t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi2) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt(fma(cos(phi1), t_1, pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))), sqrt((1.0 - fma(cos(phi1), t_1, pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi2) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi1), t_1, (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))), sqrt(Float64(1.0 - fma(cos(phi1), t_1, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 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] / N[Sqrt[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_2 \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1, t\_1, {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, t\_1, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.0%
Simplified64.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr65.0%
Final simplification65.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)
t_1))
(sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
return R * (2.0 * atan2(sqrt((pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0) + t_1)), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
code = r * (2.0d0 * atan2(sqrt(((((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0) + t_1)), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0) + t_1)), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0) + t_1)), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + t_1)), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); tmp = R * (2.0 * atan2(sqrt(((((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0) + t_1)), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 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] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \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}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 64.0%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr65.0%
Final simplification65.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* t_0 t_0) (* (cos phi1) (cos phi2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt
(-
(-
1.0
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (t_0 * t_0) * (cos(phi1) * cos(phi2));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 - pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 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 = (t_0 * t_0) * (cos(phi1) * cos(phi2))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 - (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 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 = (t_0 * t_0) * (Math.cos(phi1) * Math.cos(phi2));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 - Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (t_0 * t_0) * (math.cos(phi1) * math.cos(phi2)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 - math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (t_0 * t_0) * (cos(phi1) * cos(phi2)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 - (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 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] - 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(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 64.0%
associate-*l*64.0%
Simplified64.1%
div-sub64.0%
sin-diff65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
div-inv65.0%
metadata-eval65.0%
Applied egg-rr64.9%
Final simplification64.9%
(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 t_0) (* (cos phi1) (cos phi2)))))
(sqrt
(fabs
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (fma -0.5 (cos (- lambda1 lambda2)) 0.5))
(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 * t_0) * (cos(phi1) * cos(phi2))))), sqrt(fabs((1.0 - fma(cos(phi1), (cos(phi2) * fma(-0.5, cos((lambda1 - lambda2)), 0.5)), pow(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(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))))), sqrt(abs(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * fma(-0.5, cos(Float64(lambda1 - lambda2)), 0.5)), (sin(Float64(-0.5 * Float64(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[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + 0.5), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \mathsf{fma}\left(-0.5, \cos \left(\lambda_1 - \lambda_2\right), 0.5\right), {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 64.0%
associate-*l*64.0%
Simplified64.1%
Applied egg-rr64.5%
Simplified64.5%
Final simplification64.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi1 0.5)) 2.0))
(t_1
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= t_2 -1e-6)
(* R (* 2.0 (atan2 (sqrt (+ (* (cos phi1) t_3) t_0)) t_1)))
(if (<= t_2 0.1)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_2 (* t_2 (* (cos phi1) (cos phi2))))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(* R (* 2.0 (atan2 (sqrt (fma t_3 (cos phi1) t_0)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi1 * 0.5)), 2.0);
double t_1 = sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_2 <= -1e-6) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_3) + t_0)), t_1));
} else if (t_2 <= 0.1) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * (t_2 * (cos(phi1) * cos(phi2)))))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_3, cos(phi1), t_0)), t_1));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_1 = sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (t_2 <= -1e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_3) + t_0)), t_1))); elseif (t_2 <= 0.1) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * Float64(t_2 * Float64(cos(phi1) * cos(phi2)))))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(t_3, cos(phi1), t_0)), t_1))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$2, -1e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.1], 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 * N[(t$95$2 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $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[Cos[phi1], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_1 := \sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;t\_2 \leq -1 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_3 + t\_0}}{t\_1}\right)\\
\mathbf{elif}\;t\_2 \leq 0.1:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2 \cdot \left(t\_2 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\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{\mathsf{fma}\left(t\_3, \cos \phi_1, t\_0\right)}}{t\_1}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -9.99999999999999955e-7Initial program 52.7%
associate-*l*52.7%
Simplified52.8%
Taylor expanded in phi2 around 0 41.8%
Simplified41.8%
Taylor expanded in phi2 around 0 42.1%
Taylor expanded in phi2 around 0 42.4%
if -9.99999999999999955e-7 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.10000000000000001Initial program 86.5%
add-sqr-sqrt42.6%
sqrt-prod86.5%
rem-sqrt-square86.5%
div-inv86.5%
metadata-eval86.5%
Applied egg-rr86.5%
Taylor expanded in lambda1 around 0 84.5%
Taylor expanded in lambda2 around 0 82.2%
if 0.10000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 51.7%
associate-*l*51.7%
Simplified51.8%
Taylor expanded in phi2 around 0 41.1%
Simplified41.1%
Taylor expanded in phi2 around 0 39.9%
Taylor expanded in phi2 around 0 41.0%
*-commutative41.0%
fma-define41.0%
Simplified41.0%
Final simplification55.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= t_0 -1e-6) (not (<= t_0 0.1)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(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 <= -1e-6) || !(t_0 <= 0.1)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * 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 * (t_0 * (cos(phi1) * cos(phi2)))))), 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 <= (-1d-6)) .or. (.not. (t_0 <= 0.1d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))))), 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 <= -1e-6) || !(t_0 <= 0.1)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * 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 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))))), 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 <= -1e-6) or not (t_0 <= 0.1): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * 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 * (t_0 * (math.cos(phi1) * math.cos(phi2)))))), 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 <= -1e-6) || !(t_0 <= 0.1)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (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(t_0 * Float64(cos(phi1) * cos(phi2)))))), 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 <= -1e-6) || ~((t_0 <= 0.1))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))))), 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, -1e-6], N[Not[LessEqual[t$95$0, 0.1]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[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]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * 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[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $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 -1 \cdot 10^{-6} \lor \neg \left(t\_0 \leq 0.1\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\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}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \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(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\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))) < -9.99999999999999955e-7 or 0.10000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 52.3%
associate-*l*52.3%
Simplified52.3%
Taylor expanded in phi2 around 0 41.5%
Simplified41.5%
Taylor expanded in phi2 around 0 41.1%
Taylor expanded in phi2 around 0 41.8%
if -9.99999999999999955e-7 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.10000000000000001Initial program 86.5%
add-sqr-sqrt42.6%
sqrt-prod86.5%
rem-sqrt-square86.5%
div-inv86.5%
metadata-eval86.5%
Applied egg-rr86.5%
Taylor expanded in lambda1 around 0 84.5%
Taylor expanded in lambda2 around 0 82.2%
Final simplification55.7%
(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 t_0) (* (cos phi1) (cos phi2)))))
(sqrt
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (+ 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));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), sqrt((1.0 - fma(cos(phi1), (cos(phi2) * (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)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))))), sqrt(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * 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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - 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] + 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)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 64.0%
associate-*l*64.0%
Simplified64.1%
Applied egg-rr64.1%
sub-neg64.1%
fma-undefine64.1%
fma-undefine64.1%
*-commutative64.1%
Simplified64.1%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -0.007) (not (<= phi2 3100.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_2 (* t_2 t_0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* (* t_2 t_2) t_0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.007) || !(phi2 <= 3100.0)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_2 * t_0)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + ((t_2 * t_2) * t_0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-0.007d0)) .or. (.not. (phi2 <= 3100.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * (t_2 * t_0)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + ((t_2 * t_2) * t_0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.007) || !(phi2 <= 3100.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * (t_2 * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + ((t_2 * t_2) * t_0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -0.007) or not (phi2 <= 3100.0): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * (t_2 * t_0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + ((t_2 * t_2) * t_0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -0.007) || !(phi2 <= 3100.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * Float64(t_2 * t_0)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(Float64(t_2 * t_2) * t_0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -0.007) || ~((phi2 <= 3100.0))) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_2 * t_0)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + ((t_2 * t_2) * t_0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.007], N[Not[LessEqual[phi2, 3100.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(t$95$2 * 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[(t$95$2 * t$95$2), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.007 \lor \neg \left(\phi_2 \leq 3100\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_2 \cdot \left(t\_2 \cdot t\_0\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\_1 + \left(t\_2 \cdot t\_2\right) \cdot t\_0}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -0.00700000000000000015 or 3100 < phi2 Initial program 49.1%
add-sqr-sqrt26.2%
sqrt-prod40.2%
rem-sqrt-square40.2%
div-inv40.2%
metadata-eval40.2%
Applied egg-rr40.2%
Taylor expanded in lambda1 around 0 35.0%
Taylor expanded in lambda2 around 0 33.0%
if -0.00700000000000000015 < phi2 < 3100Initial program 79.7%
associate-*l*79.7%
Simplified79.7%
Taylor expanded in phi2 around 0 79.5%
Simplified79.5%
Final simplification55.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* phi1 0.5)) 2.0))
(t_4 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0)))))
(if (<= phi1 -9.5e-5)
(* R (* 2.0 (atan2 (sqrt (+ (* (cos phi1) t_1) t_3)) t_4)))
(if (<= phi1 6.4e-6)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* t_2 t_2) (* (cos phi1) (cos phi2)))))
(sqrt (- (pow (cos (* phi2 0.5)) 2.0) (* (cos phi2) t_0))))))
(* R (* 2.0 (atan2 (sqrt (fma t_1 (cos phi1) t_3)) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin((phi1 * 0.5)), 2.0);
double t_4 = sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)));
double tmp;
if (phi1 <= -9.5e-5) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_1) + t_3)), t_4));
} else if (phi1 <= 6.4e-6) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_2 * t_2) * (cos(phi1) * cos(phi2))))), sqrt((pow(cos((phi2 * 0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_1, cos(phi1), t_3)), t_4));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_4 = sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0))) tmp = 0.0 if (phi1 <= -9.5e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_1) + t_3)), t_4))); elseif (phi1 <= 6.4e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_2 * t_2) * Float64(cos(phi1) * cos(phi2))))), sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(t_1, cos(phi1), t_3)), t_4))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $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[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -9.5e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 6.4e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$2 * t$95$2), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 * N[Cos[phi1], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_4 := \sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_0}\\
\mathbf{if}\;\phi_1 \leq -9.5 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_1 + t\_3}}{t\_4}\right)\\
\mathbf{elif}\;\phi_1 \leq 6.4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_2 \cdot t\_2\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}{\sqrt{{\cos \left(\phi_2 \cdot 0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_1, \cos \phi_1, t\_3\right)}}{t\_4}\right)\\
\end{array}
\end{array}
if phi1 < -9.5000000000000005e-5Initial program 54.1%
associate-*l*54.2%
Simplified54.2%
Taylor expanded in phi2 around 0 54.9%
Simplified54.9%
Taylor expanded in phi2 around 0 56.1%
Taylor expanded in phi2 around 0 56.7%
if -9.5000000000000005e-5 < phi1 < 6.3999999999999997e-6Initial program 78.4%
associate-*l*78.4%
Simplified78.4%
Taylor expanded in phi1 around 0 78.4%
Simplified78.5%
if 6.3999999999999997e-6 < phi1 Initial program 47.4%
associate-*l*47.4%
Simplified47.4%
Taylor expanded in phi2 around 0 47.7%
Simplified47.7%
Taylor expanded in phi2 around 0 47.6%
Taylor expanded in phi2 around 0 48.0%
*-commutative48.0%
fma-define48.0%
Simplified48.0%
Final simplification64.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* t_0 t_0) (* (cos phi1) (cos phi2)))))
(sqrt
(-
1.0
(+
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)
(*
(cos phi1)
(* (cos phi2) (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))))
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 * t_0) * (cos(phi1) * cos(phi2))))), sqrt((1.0 - (pow(sin((0.5 * (phi1 - phi2))), 2.0) + (cos(phi1) * (cos(phi2) * (0.5 + (-0.5 * cos((lambda1 - lambda2)))))))))));
}
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 * t_0) * (cos(phi1) * cos(phi2))))), sqrt((1.0d0 - ((sin((0.5d0 * (phi1 - phi2))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * (0.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))))))))))
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 * t_0) * (Math.cos(phi1) * Math.cos(phi2))))), Math.sqrt((1.0 - (Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * (0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))))));
}
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 * t_0) * (math.cos(phi1) * math.cos(phi2))))), math.sqrt((1.0 - (math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * (0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))))), sqrt(Float64(1.0 - Float64((sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))))) 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 * t_0) * (cos(phi1) * cos(phi2))))), sqrt((1.0 - ((sin((0.5 * (phi1 - phi2))) ^ 2.0) + (cos(phi1) * (cos(phi2) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 64.0%
associate-*l*64.0%
Simplified64.1%
sub-neg64.1%
associate--l+64.1%
div-inv64.1%
metadata-eval64.1%
associate-*l*64.1%
sqr-sin-a64.1%
cancel-sign-sub-inv64.1%
metadata-eval64.1%
Applied egg-rr64.1%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= t_2 -0.15)
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) t_3) (pow (sin (* phi1 0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0)))))))
(if (<= t_2 0.18)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_2 (* t_2 t_0))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2 (sqrt (+ t_1 (* (* t_2 t_2) t_0))) (sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_2 <= -0.15) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_3) + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))));
} else if (t_2 <= 0.18) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_2 * t_0)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + ((t_2 * t_2) * 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 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (t_2 <= (-0.15d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_3) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
else if (t_2 <= 0.18d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * (t_2 * t_0)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + ((t_2 * t_2) * 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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_2 <= -0.15) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_3) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
} else if (t_2 <= 0.18) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * (t_2 * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + ((t_2 * t_2) * t_0))), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if t_2 <= -0.15: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_3) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) elif t_2 <= 0.18: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * (t_2 * t_0)))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + ((t_2 * t_2) * t_0))), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (t_2 <= -0.15) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_3) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); elseif (t_2 <= 0.18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * Float64(t_2 * t_0)))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(Float64(t_2 * t_2) * t_0))), sqrt(Float64(1.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(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if (t_2 <= -0.15) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_3) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0)))))); elseif (t_2 <= 0.18) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_2 * t_0)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + ((t_2 * t_2) * t_0))), sqrt((1.0 - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$2, -0.15], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 0.18], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(t$95$2 * 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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[(t$95$2 * t$95$2), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;t\_2 \leq -0.15:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{elif}\;t\_2 \leq 0.18:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_2 \cdot \left(t\_2 \cdot t\_0\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\_1 + \left(t\_2 \cdot t\_2\right) \cdot t\_0}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.149999999999999994Initial program 50.0%
associate-*l*50.0%
Simplified50.0%
Taylor expanded in phi2 around 0 40.5%
Simplified40.5%
Taylor expanded in lambda1 around 0 31.3%
*-commutative31.3%
Simplified31.3%
Taylor expanded in phi2 around 0 32.1%
if -0.149999999999999994 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.17999999999999999Initial program 83.9%
add-sqr-sqrt40.0%
sqrt-prod79.7%
rem-sqrt-square79.7%
div-inv79.7%
metadata-eval79.7%
Applied egg-rr79.7%
Taylor expanded in lambda1 around 0 77.6%
Taylor expanded in lambda2 around 0 73.7%
if 0.17999999999999999 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 50.5%
associate-*l*50.5%
Simplified50.5%
Taylor expanded in phi1 around 0 37.4%
Taylor expanded in phi2 around 0 33.7%
Final simplification49.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (or (<= t_1 -0.05) (not (<= t_1 0.18)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* (* t_1 t_1) t_0)))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_1 (* t_1 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 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((t_1 <= -0.05) || !(t_1 <= 0.18)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + ((t_1 * t_1) * t_0))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (t_1 * (t_1 * 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) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if ((t_1 <= (-0.05d0)) .or. (.not. (t_1 <= 0.18d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + ((t_1 * t_1) * t_0))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (t_1 * (t_1 * 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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((t_1 <= -0.05) || !(t_1 <= 0.18)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + ((t_1 * t_1) * t_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_2 + (t_1 * (t_1 * 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.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if (t_1 <= -0.05) or not (t_1 <= 0.18): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + ((t_1 * t_1) * t_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_2 + (t_1 * (t_1 * 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 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if ((t_1 <= -0.05) || !(t_1 <= 0.18)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(Float64(t_1 * t_1) * t_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_2 + Float64(t_1 * Float64(t_1 * 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 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if ((t_1 <= -0.05) || ~((t_1 <= 0.18))) tmp = R * (2.0 * atan2(sqrt((t_2 + ((t_1 * t_1) * t_0))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (t_1 * (t_1 * 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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[t$95$1, -0.05], N[Not[LessEqual[t$95$1, 0.18]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[(t$95$1 * t$95$1), $MachinePrecision] * t$95$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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$1 * N[(t$95$1 * 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 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;t\_1 \leq -0.05 \lor \neg \left(t\_1 \leq 0.18\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(t\_1 \cdot t\_1\right) \cdot t\_0}}{\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\_2 + t\_1 \cdot \left(t\_1 \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))) < -0.050000000000000003 or 0.17999999999999999 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 51.1%
associate-*l*51.1%
Simplified51.1%
Taylor expanded in phi1 around 0 34.0%
Taylor expanded in phi2 around 0 30.0%
if -0.050000000000000003 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.17999999999999999Initial program 84.6%
add-sqr-sqrt42.4%
sqrt-prod82.9%
rem-sqrt-square82.9%
div-inv82.9%
metadata-eval82.9%
Applied egg-rr82.9%
Taylor expanded in lambda1 around 0 80.7%
Taylor expanded in lambda2 around 0 76.5%
Final simplification48.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (<= t_2 -0.05)
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_3) (* 0.25 (pow phi2 2.0))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(if (<= t_2 0.18)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_2 t_1))))
(sqrt (- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))
(*
R
(*
2.0
(atan2 (sqrt (+ t_0 (* (* t_2 t_2) t_1))) (sqrt (- 1.0 t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_2 <= -0.05) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_3) + (0.25 * pow(phi2, 2.0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else if (t_2 <= 0.18) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_2 * t_1)))), sqrt((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + ((t_2 * t_2) * t_1))), 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(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if (t_2 <= (-0.05d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_3) + (0.25d0 * (phi2 ** 2.0d0)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else if (t_2 <= 0.18d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_2 * t_1)))), sqrt((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + ((t_2 * t_2) * t_1))), 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(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if (t_2 <= -0.05) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_3) + (0.25 * Math.pow(phi2, 2.0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else if (t_2 <= 0.18) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_2 * 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_0 + ((t_2 * t_2) * t_1))), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if t_2 <= -0.05: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_3) + (0.25 * math.pow(phi2, 2.0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) elif t_2 <= 0.18: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_2 * 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_0 + ((t_2 * t_2) * t_1))), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if (t_2 <= -0.05) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_3) + Float64(0.25 * (phi2 ^ 2.0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); elseif (t_2 <= 0.18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_2 * 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_0 + Float64(Float64(t_2 * t_2) * t_1))), sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if (t_2 <= -0.05) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_3) + (0.25 * (phi2 ^ 2.0)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); elseif (t_2 <= 0.18) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_2 * t_1)))), sqrt((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + ((t_2 * t_2) * t_1))), 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[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[t$95$2, -0.05], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision] + N[(0.25 * N[Power[phi2, 2.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] * 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$2, 0.18], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$2 * 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$0 + N[(N[(t$95$2 * t$95$2), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;t\_2 \leq -0.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_3 + 0.25 \cdot {\phi_2}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{elif}\;t\_2 \leq 0.18:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_2 \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\_0 + \left(t\_2 \cdot t\_2\right) \cdot t\_1}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.050000000000000003Initial program 51.6%
associate-*l*51.6%
Simplified51.6%
Taylor expanded in phi2 around 0 41.0%
Simplified41.0%
Taylor expanded in phi2 around 0 41.3%
Taylor expanded in phi1 around 0 27.5%
if -0.050000000000000003 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 0.17999999999999999Initial program 84.6%
add-sqr-sqrt42.4%
sqrt-prod82.9%
rem-sqrt-square82.9%
div-inv82.9%
metadata-eval82.9%
Applied egg-rr82.9%
Taylor expanded in lambda1 around 0 80.7%
Taylor expanded in lambda2 around 0 76.5%
if 0.17999999999999999 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 50.5%
associate-*l*50.5%
Simplified50.5%
Taylor expanded in phi1 around 0 37.4%
Taylor expanded in phi2 around 0 33.7%
Final simplification48.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5))) (t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 1.45e-166)
(*
R
(*
2.0
(atan2
(log1p (expm1 (sin (* 0.5 (- phi1 phi2)))))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* t_1 (* (cos phi1) (cos phi2))))))))))
(*
R
(*
2.0
(atan2
(* phi2 (- (* 0.5 t_0) (/ (sin (* phi1 0.5)) phi2)))
(sqrt
(-
(pow t_0 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 1.45e-166) {
tmp = R * (2.0 * atan2(log1p(expm1(sin((0.5 * (phi1 - phi2))))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_1 * (cos(phi1) * cos(phi2)))))))));
} else {
tmp = R * (2.0 * atan2((phi2 * ((0.5 * t_0) - (sin((phi1 * 0.5)) / phi2))), sqrt((pow(t_0, 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi1 * 0.5));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 1.45e-166) {
tmp = R * (2.0 * Math.atan2(Math.log1p(Math.expm1(Math.sin((0.5 * (phi1 - phi2))))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)))))))));
} else {
tmp = R * (2.0 * Math.atan2((phi2 * ((0.5 * t_0) - (Math.sin((phi1 * 0.5)) / phi2))), Math.sqrt((Math.pow(t_0, 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi1 * 0.5)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 1.45e-166: tmp = R * (2.0 * math.atan2(math.log1p(math.expm1(math.sin((0.5 * (phi1 - phi2))))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2))))))))) else: tmp = R * (2.0 * math.atan2((phi2 * ((0.5 * t_0) - (math.sin((phi1 * 0.5)) / phi2))), math.sqrt((math.pow(t_0, 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 1.45e-166) tmp = Float64(R * Float64(2.0 * atan(log1p(expm1(sin(Float64(0.5 * Float64(phi1 - phi2))))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2)))))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi2 * Float64(Float64(0.5 * t_0) - Float64(sin(Float64(phi1 * 0.5)) / phi2))), sqrt(Float64((t_0 ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 1.45e-166], N[(R * N[(2.0 * N[ArcTan[N[Log[1 + N[(Exp[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi2 * N[(N[(0.5 * t$95$0), $MachinePrecision] - N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(N[Cos[phi1], $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 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 1.45 \cdot 10^{-166}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1 \cdot \left(t\_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_2 \cdot \left(0.5 \cdot t\_0 - \frac{\sin \left(\phi_1 \cdot 0.5\right)}{\phi_2}\right)}{\sqrt{{t\_0}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.45e-166Initial program 68.4%
Taylor expanded in lambda1 around 0 51.5%
Taylor expanded in lambda2 around 0 23.7%
log1p-expm1-u23.7%
Applied egg-rr23.7%
if 1.45e-166 < lambda2 Initial program 57.1%
associate-*l*57.1%
Simplified57.1%
Taylor expanded in phi2 around 0 45.6%
Simplified45.6%
Taylor expanded in phi2 around 0 44.5%
Taylor expanded in phi2 around inf 16.4%
Final simplification20.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* t_0 t_0) (* (cos phi1) (cos phi2)))))
(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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), 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(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), 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.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (Math.cos(phi1) * Math.cos(phi2))))), 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.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_0 * t_0) * (math.cos(phi1) * math.cos(phi2))))), 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_0 * t_0) * Float64(cos(phi1) * cos(phi2))))), 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(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((t_0 * t_0) * (cos(phi1) * cos(phi2))))), 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$0 * t$95$0), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t\_0 \cdot t\_0\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 64.0%
associate-*l*64.0%
Simplified64.1%
Taylor expanded in phi1 around 0 42.6%
Taylor expanded in phi2 around 0 33.6%
Final simplification33.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* t_0 (* (cos phi1) (cos phi2))))))
(if (or (<= phi1 -2.3e+21) (not (<= phi1 1.5e-10)))
(*
R
(*
2.0
(atan2
(sin (* phi1 0.5))
(sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))))))
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt (- 1.0 (+ t_1 (pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)));
double tmp;
if ((phi1 <= -2.3e+21) || !(phi1 <= 1.5e-10)) {
tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
} else {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (t_1 + pow(sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2)))
if ((phi1 <= (-2.3d+21)) .or. (.not. (phi1 <= 1.5d-10))) then
tmp = r * (2.0d0 * atan2(sin((phi1 * 0.5d0)), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)))))
else
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt((1.0d0 - (t_1 + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)));
double tmp;
if ((phi1 <= -2.3e+21) || !(phi1 <= 1.5e-10)) {
tmp = R * (2.0 * Math.atan2(Math.sin((phi1 * 0.5)), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))) tmp = 0 if (phi1 <= -2.3e+21) or not (phi1 <= 1.5e-10): tmp = R * (2.0 * math.atan2(math.sin((phi1 * 0.5)), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1))))) else: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - (t_1 + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))) tmp = 0.0 if ((phi1 <= -2.3e+21) || !(phi1 <= 1.5e-10)) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(phi1 * 0.5)), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * (t_0 * (cos(phi1) * cos(phi2))); tmp = 0.0; if ((phi1 <= -2.3e+21) || ~((phi1 <= 1.5e-10))) tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1))))); else tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (t_1 + (sin((phi2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -2.3e+21], N[Not[LessEqual[phi1, 1.5e-10]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
\mathbf{if}\;\phi_1 \leq -2.3 \cdot 10^{+21} \lor \neg \left(\phi_1 \leq 1.5 \cdot 10^{-10}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_1 \cdot 0.5\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left(t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -2.3e21 or 1.5e-10 < phi1 Initial program 50.5%
Taylor expanded in lambda1 around 0 42.5%
Taylor expanded in lambda2 around 0 19.6%
Taylor expanded in phi2 around 0 20.7%
if -2.3e21 < phi1 < 1.5e-10Initial program 77.5%
Taylor expanded in lambda1 around 0 58.3%
Taylor expanded in lambda2 around 0 18.5%
Taylor expanded in phi1 around 0 18.5%
Final simplification19.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* t_1 (* (cos phi1) (cos phi2)))))
(t_3 (sin (* 0.5 (- phi1 phi2)))))
(if (<= phi1 -3.2)
(* R (* 2.0 (atan2 t_3 (sqrt (- 1.0 (+ t_2 (pow t_0 2.0)))))))
(if (<= phi1 2.8e-11)
(*
R
(*
2.0
(atan2 t_3 (sqrt (- 1.0 (+ t_2 (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_0
(sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * (t_1 * (cos(phi1) * cos(phi2)));
double t_3 = sin((0.5 * (phi1 - phi2)));
double tmp;
if (phi1 <= -3.2) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + pow(t_0, 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_1 * (t_1 * (cos(phi1) * cos(phi2)))
t_3 = sin((0.5d0 * (phi1 - phi2)))
if (phi1 <= (-3.2d0)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_2 + (t_0 ** 2.0d0))))))
else if (phi1 <= 2.8d-11) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_2 + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((phi1 * 0.5));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)));
double t_3 = Math.sin((0.5 * (phi1 - phi2)));
double tmp;
if (phi1 <= -3.2) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_2 + Math.pow(t_0, 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_2 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2))) t_3 = math.sin((0.5 * (phi1 - phi2))) tmp = 0 if phi1 <= -3.2: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_2 + math.pow(t_0, 2.0)))))) elif phi1 <= 2.8e-11: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_2 + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2)))) t_3 = sin(Float64(0.5 * Float64(phi1 - phi2))) tmp = 0.0 if (phi1 <= -3.2) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_2 + (t_0 ^ 2.0))))))); elseif (phi1 <= 2.8e-11) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_2 + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_1 * (t_1 * (cos(phi1) * cos(phi2))); t_3 = sin((0.5 * (phi1 - phi2))); tmp = 0.0; if (phi1 <= -3.2) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + (t_0 ^ 2.0)))))); elseif (phi1 <= 2.8e-11) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_2 + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.2], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.8e-11], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot \left(t\_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
t_3 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
\mathbf{if}\;\phi_1 \leq -3.2:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_2 + {t\_0}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left(t\_2 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3.2000000000000002Initial program 54.1%
Taylor expanded in lambda1 around 0 47.9%
Taylor expanded in lambda2 around 0 19.5%
Taylor expanded in phi2 around 0 19.7%
if -3.2000000000000002 < phi1 < 2.8e-11Initial program 78.5%
Taylor expanded in lambda1 around 0 58.5%
Taylor expanded in lambda2 around 0 18.9%
Taylor expanded in phi1 around 0 18.9%
if 2.8e-11 < phi1 Initial program 47.7%
Taylor expanded in lambda1 around 0 38.9%
Taylor expanded in lambda2 around 0 18.8%
Taylor expanded in phi2 around 0 20.6%
Final simplification19.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (cos (* phi1 0.5)))
(t_2 (pow t_1 2.0)))
(if (<= phi2 -8.2e-8)
(*
R
(*
2.0
(atan2
(* t_1 (* phi2 -0.5))
(sqrt (- t_2 (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(if (<= phi2 1.5e-63)
(*
R
(*
2.0
(atan2
(sin (* phi1 0.5))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* t_0 (* (cos phi1) (cos phi2))))))))))
(*
R
(*
2.0
(atan2
(* (* phi2 0.5) t_1)
(sqrt
(-
t_2
(*
(cos phi1)
(pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos((phi1 * 0.5));
double t_2 = pow(t_1, 2.0);
double tmp;
if (phi2 <= -8.2e-8) {
tmp = R * (2.0 * atan2((t_1 * (phi2 * -0.5)), sqrt((t_2 - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else if (phi2 <= 1.5e-63) {
tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))))))));
} else {
tmp = R * (2.0 * atan2(((phi2 * 0.5) * t_1), sqrt((t_2 - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos((phi1 * 0.5d0))
t_2 = t_1 ** 2.0d0
if (phi2 <= (-8.2d-8)) then
tmp = r * (2.0d0 * atan2((t_1 * (phi2 * (-0.5d0))), sqrt((t_2 - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else if (phi2 <= 1.5d-63) then
tmp = r * (2.0d0 * atan2(sin((phi1 * 0.5d0)), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2)))))))))
else
tmp = r * (2.0d0 * atan2(((phi2 * 0.5d0) * t_1), sqrt((t_2 - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos((phi1 * 0.5));
double t_2 = Math.pow(t_1, 2.0);
double tmp;
if (phi2 <= -8.2e-8) {
tmp = R * (2.0 * Math.atan2((t_1 * (phi2 * -0.5)), Math.sqrt((t_2 - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else if (phi2 <= 1.5e-63) {
tmp = R * (2.0 * Math.atan2(Math.sin((phi1 * 0.5)), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_0 * (Math.cos(phi1) * Math.cos(phi2)))))))));
} else {
tmp = R * (2.0 * Math.atan2(((phi2 * 0.5) * t_1), Math.sqrt((t_2 - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos((phi1 * 0.5)) t_2 = math.pow(t_1, 2.0) tmp = 0 if phi2 <= -8.2e-8: tmp = R * (2.0 * math.atan2((t_1 * (phi2 * -0.5)), math.sqrt((t_2 - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) elif phi2 <= 1.5e-63: tmp = R * (2.0 * math.atan2(math.sin((phi1 * 0.5)), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_0 * (math.cos(phi1) * math.cos(phi2))))))))) else: tmp = R * (2.0 * math.atan2(((phi2 * 0.5) * t_1), math.sqrt((t_2 - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = t_1 ^ 2.0 tmp = 0.0 if (phi2 <= -8.2e-8) tmp = Float64(R * Float64(2.0 * atan(Float64(t_1 * Float64(phi2 * -0.5)), sqrt(Float64(t_2 - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); elseif (phi2 <= 1.5e-63) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(phi1 * 0.5)), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_0 * Float64(cos(phi1) * cos(phi2)))))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(phi2 * 0.5) * t_1), sqrt(Float64(t_2 - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos((phi1 * 0.5)); t_2 = t_1 ^ 2.0; tmp = 0.0; if (phi2 <= -8.2e-8) tmp = R * (2.0 * atan2((t_1 * (phi2 * -0.5)), sqrt((t_2 - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); elseif (phi2 <= 1.5e-63) tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_0 * (cos(phi1) * cos(phi2))))))))); else tmp = R * (2.0 * atan2(((phi2 * 0.5) * t_1), sqrt((t_2 - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[t$95$1, 2.0], $MachinePrecision]}, If[LessEqual[phi2, -8.2e-8], N[(R * N[(2.0 * N[ArcTan[N[(t$95$1 * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.5e-63], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(phi2 * 0.5), $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := {t\_1}^{2}\\
\mathbf{if}\;\phi_2 \leq -8.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1 \cdot \left(\phi_2 \cdot -0.5\right)}{\sqrt{t\_2 - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.5 \cdot 10^{-63}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_1 \cdot 0.5\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\left(\phi_2 \cdot 0.5\right) \cdot t\_1}{\sqrt{t\_2 - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -8.20000000000000063e-8Initial program 47.7%
associate-*l*47.7%
Simplified47.7%
Taylor expanded in phi2 around 0 20.6%
Simplified20.6%
Taylor expanded in phi2 around 0 19.1%
Taylor expanded in phi2 around -inf 16.0%
associate-*r*16.0%
*-commutative16.0%
Simplified16.0%
Taylor expanded in lambda2 around 0 16.0%
if -8.20000000000000063e-8 < phi2 < 1.4999999999999999e-63Initial program 81.3%
Taylor expanded in lambda1 around 0 61.7%
Taylor expanded in lambda2 around 0 21.1%
Taylor expanded in phi2 around 0 21.1%
if 1.4999999999999999e-63 < phi2 Initial program 52.6%
associate-*l*52.6%
Simplified52.6%
Taylor expanded in phi2 around 0 26.8%
Simplified26.8%
Taylor expanded in phi2 around 0 25.9%
Taylor expanded in phi2 around inf 13.8%
associate-*r*13.8%
*-commutative13.8%
Simplified13.8%
Final simplification17.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5))) (t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 1.2e-166)
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* t_1 (* (cos phi1) (cos phi2))))))))))
(*
R
(*
2.0
(atan2
(* phi2 (- (* 0.5 t_0) (/ (sin (* phi1 0.5)) phi2)))
(sqrt
(-
(pow t_0 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 1.2e-166) {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_1 * (cos(phi1) * cos(phi2)))))))));
} else {
tmp = R * (2.0 * atan2((phi2 * ((0.5 * t_0) - (sin((phi1 * 0.5)) / phi2))), sqrt((pow(t_0, 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((phi1 * 0.5d0))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 1.2d-166) then
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (t_1 * (cos(phi1) * cos(phi2)))))))))
else
tmp = r * (2.0d0 * atan2((phi2 * ((0.5d0 * t_0) - (sin((phi1 * 0.5d0)) / phi2))), sqrt(((t_0 ** 2.0d0) - (cos(phi1) * (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.cos((phi1 * 0.5));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 1.2e-166) {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_1 * (Math.cos(phi1) * Math.cos(phi2)))))))));
} else {
tmp = R * (2.0 * Math.atan2((phi2 * ((0.5 * t_0) - (Math.sin((phi1 * 0.5)) / phi2))), Math.sqrt((Math.pow(t_0, 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi1 * 0.5)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 1.2e-166: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_1 * (math.cos(phi1) * math.cos(phi2))))))))) else: tmp = R * (2.0 * math.atan2((phi2 * ((0.5 * t_0) - (math.sin((phi1 * 0.5)) / phi2))), math.sqrt((math.pow(t_0, 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 1.2e-166) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_1 * Float64(cos(phi1) * cos(phi2)))))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi2 * Float64(Float64(0.5 * t_0) - Float64(sin(Float64(phi1 * 0.5)) / phi2))), sqrt(Float64((t_0 ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi1 * 0.5)); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 1.2e-166) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (t_1 * (cos(phi1) * cos(phi2))))))))); else tmp = R * (2.0 * atan2((phi2 * ((0.5 * t_0) - (sin((phi1 * 0.5)) / phi2))), sqrt(((t_0 ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 1.2e-166], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi2 * N[(N[(0.5 * t$95$0), $MachinePrecision] - N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(N[Cos[phi1], $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 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 1.2 \cdot 10^{-166}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1 \cdot \left(t\_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_2 \cdot \left(0.5 \cdot t\_0 - \frac{\sin \left(\phi_1 \cdot 0.5\right)}{\phi_2}\right)}{\sqrt{{t\_0}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.1999999999999999e-166Initial program 68.4%
Taylor expanded in lambda1 around 0 51.5%
Taylor expanded in lambda2 around 0 23.7%
if 1.1999999999999999e-166 < lambda2 Initial program 57.1%
associate-*l*57.1%
Simplified57.1%
Taylor expanded in phi2 around 0 45.6%
Simplified45.6%
Taylor expanded in phi2 around 0 44.5%
Taylor expanded in phi2 around inf 16.4%
Final simplification20.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5))))
(if (<= lambda2 1.25e-166)
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(sin (* lambda1 0.5))
(*
(sin (/ (- lambda1 lambda2) 2.0))
(* (cos phi1) (cos phi2))))))))))
(*
R
(*
2.0
(atan2
(* phi2 (- (* 0.5 t_0) (/ (sin (* phi1 0.5)) phi2)))
(sqrt
(-
(pow t_0 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double tmp;
if (lambda2 <= 1.25e-166) {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (sin((lambda1 * 0.5)) * (sin(((lambda1 - lambda2) / 2.0)) * (cos(phi1) * cos(phi2)))))))));
} else {
tmp = R * (2.0 * atan2((phi2 * ((0.5 * t_0) - (sin((phi1 * 0.5)) / phi2))), sqrt((pow(t_0, 2.0) - (cos(phi1) * 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 = cos((phi1 * 0.5d0))
if (lambda2 <= 1.25d-166) then
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (sin((lambda1 * 0.5d0)) * (sin(((lambda1 - lambda2) / 2.0d0)) * (cos(phi1) * cos(phi2)))))))))
else
tmp = r * (2.0d0 * atan2((phi2 * ((0.5d0 * t_0) - (sin((phi1 * 0.5d0)) / phi2))), sqrt(((t_0 ** 2.0d0) - (cos(phi1) * (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.cos((phi1 * 0.5));
double tmp;
if (lambda2 <= 1.25e-166) {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.sin((lambda1 * 0.5)) * (Math.sin(((lambda1 - lambda2) / 2.0)) * (Math.cos(phi1) * Math.cos(phi2)))))))));
} else {
tmp = R * (2.0 * Math.atan2((phi2 * ((0.5 * t_0) - (Math.sin((phi1 * 0.5)) / phi2))), Math.sqrt((Math.pow(t_0, 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi1 * 0.5)) tmp = 0 if lambda2 <= 1.25e-166: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.sin((lambda1 * 0.5)) * (math.sin(((lambda1 - lambda2) / 2.0)) * (math.cos(phi1) * math.cos(phi2))))))))) else: tmp = R * (2.0 * math.atan2((phi2 * ((0.5 * t_0) - (math.sin((phi1 * 0.5)) / phi2))), math.sqrt((math.pow(t_0, 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) tmp = 0.0 if (lambda2 <= 1.25e-166) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(sin(Float64(lambda1 * 0.5)) * Float64(sin(Float64(Float64(lambda1 - lambda2) / 2.0)) * Float64(cos(phi1) * cos(phi2)))))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(phi2 * Float64(Float64(0.5 * t_0) - Float64(sin(Float64(phi1 * 0.5)) / phi2))), sqrt(Float64((t_0 ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi1 * 0.5)); tmp = 0.0; if (lambda2 <= 1.25e-166) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (sin((lambda1 * 0.5)) * (sin(((lambda1 - lambda2) / 2.0)) * (cos(phi1) * cos(phi2))))))))); else tmp = R * (2.0 * atan2((phi2 * ((0.5 * t_0) - (sin((phi1 * 0.5)) / phi2))), sqrt(((t_0 ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 1.25e-166], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(phi2 * N[(N[(0.5 * t$95$0), $MachinePrecision] - N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] / phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(N[Cos[phi1], $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 := \cos \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\lambda_2 \leq 1.25 \cdot 10^{-166}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\lambda_1 \cdot 0.5\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_2 \cdot \left(0.5 \cdot t\_0 - \frac{\sin \left(\phi_1 \cdot 0.5\right)}{\phi_2}\right)}{\sqrt{{t\_0}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.25e-166Initial program 68.4%
Taylor expanded in lambda1 around 0 51.5%
Taylor expanded in lambda2 around 0 23.7%
Taylor expanded in lambda2 around 0 23.6%
if 1.25e-166 < lambda2 Initial program 57.1%
associate-*l*57.1%
Simplified57.1%
Taylor expanded in phi2 around 0 45.6%
Simplified45.6%
Taylor expanded in phi2 around 0 44.5%
Taylor expanded in phi2 around inf 16.4%
Final simplification20.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(sin (* lambda2 -0.5))
(* (sin (/ (- lambda1 lambda2) 2.0)) (* (cos phi1) (cos phi2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (sin((lambda2 * -0.5)) * (sin(((lambda1 - lambda2) / 2.0)) * (cos(phi1) * cos(phi2)))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (sin((lambda2 * (-0.5d0))) * (sin(((lambda1 - lambda2) / 2.0d0)) * (cos(phi1) * cos(phi2)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.sin((lambda2 * -0.5)) * (Math.sin(((lambda1 - lambda2) / 2.0)) * (Math.cos(phi1) * Math.cos(phi2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.sin((lambda2 * -0.5)) * (math.sin(((lambda1 - lambda2) / 2.0)) * (math.cos(phi1) * math.cos(phi2)))))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(sin(Float64(lambda2 * -0.5)) * Float64(sin(Float64(Float64(lambda1 - lambda2) / 2.0)) * Float64(cos(phi1) * cos(phi2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (sin((lambda2 * -0.5)) * (sin(((lambda1 - lambda2) / 2.0)) * (cos(phi1) * cos(phi2))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\right)}}\right)
\end{array}
Initial program 64.0%
Taylor expanded in lambda1 around 0 50.4%
Taylor expanded in lambda2 around 0 19.0%
Taylor expanded in lambda1 around 0 18.7%
Final simplification18.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(t_1 (cos (* phi1 0.5))))
(if (<= phi2 -4.8e-279)
(*
R
(*
2.0
(atan2
(* t_1 (* phi2 -0.5))
(sqrt (- (/ (+ (cos phi1) 1.0) 2.0) t_0)))))
(* R (* 2.0 (atan2 (* (* phi2 0.5) t_1) (sqrt (- (pow t_1 2.0) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = cos((phi1 * 0.5));
double tmp;
if (phi2 <= -4.8e-279) {
tmp = R * (2.0 * atan2((t_1 * (phi2 * -0.5)), sqrt((((cos(phi1) + 1.0) / 2.0) - t_0))));
} else {
tmp = R * (2.0 * atan2(((phi2 * 0.5) * t_1), sqrt((pow(t_1, 2.0) - t_0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)
t_1 = cos((phi1 * 0.5d0))
if (phi2 <= (-4.8d-279)) then
tmp = r * (2.0d0 * atan2((t_1 * (phi2 * (-0.5d0))), sqrt((((cos(phi1) + 1.0d0) / 2.0d0) - t_0))))
else
tmp = r * (2.0d0 * atan2(((phi2 * 0.5d0) * t_1), sqrt(((t_1 ** 2.0d0) - t_0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = Math.cos((phi1 * 0.5));
double tmp;
if (phi2 <= -4.8e-279) {
tmp = R * (2.0 * Math.atan2((t_1 * (phi2 * -0.5)), Math.sqrt((((Math.cos(phi1) + 1.0) / 2.0) - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(((phi2 * 0.5) * t_1), Math.sqrt((Math.pow(t_1, 2.0) - t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_1 = math.cos((phi1 * 0.5)) tmp = 0 if phi2 <= -4.8e-279: tmp = R * (2.0 * math.atan2((t_1 * (phi2 * -0.5)), math.sqrt((((math.cos(phi1) + 1.0) / 2.0) - t_0)))) else: tmp = R * (2.0 * math.atan2(((phi2 * 0.5) * t_1), math.sqrt((math.pow(t_1, 2.0) - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)) t_1 = cos(Float64(phi1 * 0.5)) tmp = 0.0 if (phi2 <= -4.8e-279) tmp = Float64(R * Float64(2.0 * atan(Float64(t_1 * Float64(phi2 * -0.5)), sqrt(Float64(Float64(Float64(cos(phi1) + 1.0) / 2.0) - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(phi2 * 0.5) * t_1), sqrt(Float64((t_1 ^ 2.0) - t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0); t_1 = cos((phi1 * 0.5)); tmp = 0.0; if (phi2 <= -4.8e-279) tmp = R * (2.0 * atan2((t_1 * (phi2 * -0.5)), sqrt((((cos(phi1) + 1.0) / 2.0) - t_0)))); else tmp = R * (2.0 * atan2(((phi2 * 0.5) * t_1), sqrt(((t_1 ^ 2.0) - t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.8e-279], N[(R * N[(2.0 * N[ArcTan[N[(t$95$1 * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(phi2 * 0.5), $MachinePrecision] * t$95$1), $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$1, 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\phi_2 \leq -4.8 \cdot 10^{-279}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_1 \cdot \left(\phi_2 \cdot -0.5\right)}{\sqrt{\frac{\cos \phi_1 + 1}{2} - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\left(\phi_2 \cdot 0.5\right) \cdot t\_1}{\sqrt{{t\_1}^{2} - t\_0}}\right)\\
\end{array}
\end{array}
if phi2 < -4.7999999999999998e-279Initial program 62.3%
associate-*l*62.3%
Simplified62.3%
Taylor expanded in phi2 around 0 47.6%
Simplified47.6%
Taylor expanded in phi2 around 0 46.9%
Taylor expanded in phi2 around -inf 11.4%
associate-*r*11.4%
*-commutative11.4%
Simplified11.4%
unpow211.4%
cos-mult11.4%
*-commutative11.4%
*-commutative11.4%
*-commutative11.4%
*-commutative11.4%
Applied egg-rr11.4%
+-commutative11.4%
+-inverses11.4%
cos-011.4%
distribute-lft-out11.4%
metadata-eval11.4%
*-rgt-identity11.4%
Simplified11.4%
if -4.7999999999999998e-279 < phi2 Initial program 65.6%
associate-*l*65.6%
Simplified65.6%
Taylor expanded in phi2 around 0 50.6%
Simplified50.6%
Taylor expanded in phi2 around 0 50.1%
Taylor expanded in phi2 around inf 11.4%
associate-*r*11.4%
*-commutative11.4%
Simplified11.4%
Final simplification11.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* (cos (* phi1 0.5)) (* phi2 -0.5))
(sqrt
(-
(/ (+ (cos phi1) 1.0) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((cos((phi1 * 0.5)) * (phi2 * -0.5)), sqrt((((cos(phi1) + 1.0) / 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2((cos((phi1 * 0.5d0)) * (phi2 * (-0.5d0))), sqrt((((cos(phi1) + 1.0d0) / 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((Math.cos((phi1 * 0.5)) * (phi2 * -0.5)), Math.sqrt((((Math.cos(phi1) + 1.0) / 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((math.cos((phi1 * 0.5)) * (phi2 * -0.5)), math.sqrt((((math.cos(phi1) + 1.0) / 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(cos(Float64(phi1 * 0.5)) * Float64(phi2 * -0.5)), sqrt(Float64(Float64(Float64(cos(phi1) + 1.0) / 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((cos((phi1 * 0.5)) * (phi2 * -0.5)), sqrt((((cos(phi1) + 1.0) / 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] + 1.0), $MachinePrecision] / 2.0), $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\cos \left(\phi_1 \cdot 0.5\right) \cdot \left(\phi_2 \cdot -0.5\right)}{\sqrt{\frac{\cos \phi_1 + 1}{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 64.0%
associate-*l*64.0%
Simplified64.1%
Taylor expanded in phi2 around 0 49.2%
Simplified49.2%
Taylor expanded in phi2 around 0 48.5%
Taylor expanded in phi2 around -inf 9.1%
associate-*r*9.1%
*-commutative9.1%
Simplified9.1%
unpow29.1%
cos-mult9.1%
*-commutative9.1%
*-commutative9.1%
*-commutative9.1%
*-commutative9.1%
Applied egg-rr9.1%
+-commutative9.1%
+-inverses9.1%
cos-09.1%
distribute-lft-out9.1%
metadata-eval9.1%
*-rgt-identity9.1%
Simplified9.1%
Final simplification9.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* (cos (* phi1 0.5)) (* phi2 -0.5))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((cos((phi1 * 0.5)) * (phi2 * -0.5)), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2((cos((phi1 * 0.5d0)) * (phi2 * (-0.5d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((Math.cos((phi1 * 0.5)) * (phi2 * -0.5)), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((math.cos((phi1 * 0.5)) * (phi2 * -0.5)), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(cos(Float64(phi1 * 0.5)) * Float64(phi2 * -0.5)), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((cos((phi1 * 0.5)) * (phi2 * -0.5)), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\cos \left(\phi_1 \cdot 0.5\right) \cdot \left(\phi_2 \cdot -0.5\right)}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 64.0%
associate-*l*64.0%
Simplified64.1%
Taylor expanded in phi2 around 0 49.2%
Simplified49.2%
Taylor expanded in phi2 around 0 48.5%
Taylor expanded in phi2 around -inf 9.1%
associate-*r*9.1%
*-commutative9.1%
Simplified9.1%
Taylor expanded in phi1 around 0 9.1%
Final simplification9.1%
herbie shell --seed 2024103
(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))))))))))