
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 28 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (* lambda2 -0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2))
(t_4 (+ t_0 (* t_2 t_3)))
(t_5 (sqrt t_4)))
(if (<= lambda2 -1.45e-5)
(* R (* 2.0 (atan2 t_5 (sqrt (- 1.0 (+ t_0 (* t_3 t_1)))))))
(if (<= lambda2 0.00045)
(*
R
(*
2.0
(atan2
t_5
(sqrt
(-
1.0
(+
t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi1) (* (cos phi2) (pow t_1 2.0)))))
(sqrt (- 1.0 t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin((lambda2 * -0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double t_4 = t_0 + (t_2 * t_3);
double t_5 = sqrt(t_4);
double tmp;
if (lambda2 <= -1.45e-5) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_0 + (t_3 * t_1))))));
} else if (lambda2 <= 0.00045) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(t_1, 2.0))))), sqrt((1.0 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin((lambda2 * (-0.5d0)))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
t_4 = t_0 + (t_2 * t_3)
t_5 = sqrt(t_4)
if (lambda2 <= (-1.45d-5)) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - (t_0 + (t_3 * t_1))))))
else if (lambda2 <= 0.00045d0) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (t_1 ** 2.0d0))))), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin((lambda2 * -0.5));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double t_4 = t_0 + (t_2 * t_3);
double t_5 = Math.sqrt(t_4);
double tmp;
if (lambda2 <= -1.45e-5) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - (t_0 + (t_3 * t_1))))));
} else if (lambda2 <= 0.00045) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(t_1, 2.0))))), Math.sqrt((1.0 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin((lambda2 * -0.5)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 t_4 = t_0 + (t_2 * t_3) t_5 = math.sqrt(t_4) tmp = 0 if lambda2 <= -1.45e-5: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - (t_0 + (t_3 * t_1)))))) elif lambda2 <= 0.00045: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(t_1, 2.0))))), math.sqrt((1.0 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(lambda2 * -0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) t_4 = Float64(t_0 + Float64(t_2 * t_3)) t_5 = sqrt(t_4) tmp = 0.0 if (lambda2 <= -1.45e-5) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - Float64(t_0 + Float64(t_3 * t_1))))))); elseif (lambda2 <= 0.00045) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (t_1 ^ 2.0))))), sqrt(Float64(1.0 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin((lambda2 * -0.5)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; t_4 = t_0 + (t_2 * t_3); t_5 = sqrt(t_4); tmp = 0.0; if (lambda2 <= -1.45e-5) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_0 + (t_3 * t_1)))))); elseif (lambda2 <= 0.00045) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (t_1 ^ 2.0))))), sqrt((1.0 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[t$95$4], $MachinePrecision]}, If[LessEqual[lambda2, -1.45e-5], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$3 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 0.00045], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\lambda_2 \cdot -0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\\
t_4 := t\_0 + t\_2 \cdot t\_3\\
t_5 := \sqrt{t\_4}\\
\mathbf{if}\;\lambda_2 \leq -1.45 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - \left(t\_0 + t\_3 \cdot t\_1\right)}}\right)\\
\mathbf{elif}\;\lambda_2 \leq 0.00045:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {t\_1}^{2}\right)}}{\sqrt{1 - t\_4}}\right)\\
\end{array}
\end{array}
if lambda2 < -1.45e-5Initial program 47.2%
div-sub47.2%
sin-diff48.0%
div-inv48.0%
metadata-eval48.0%
div-inv48.0%
metadata-eval48.0%
div-inv48.0%
metadata-eval48.0%
div-inv48.0%
metadata-eval48.0%
Applied egg-rr48.0%
div-sub47.2%
sin-diff48.0%
div-inv48.0%
metadata-eval48.0%
div-inv48.0%
metadata-eval48.0%
div-inv48.0%
metadata-eval48.0%
div-inv48.0%
metadata-eval48.0%
Applied egg-rr57.8%
Taylor expanded in lambda1 around 0 57.7%
if -1.45e-5 < lambda2 < 4.4999999999999999e-4Initial program 75.9%
div-sub75.9%
sin-diff77.4%
div-inv77.4%
metadata-eval77.4%
div-inv77.4%
metadata-eval77.4%
div-inv77.4%
metadata-eval77.4%
div-inv77.4%
metadata-eval77.4%
Applied egg-rr77.4%
div-sub75.9%
sin-diff77.4%
div-inv77.4%
metadata-eval77.4%
div-inv77.4%
metadata-eval77.4%
div-inv77.4%
metadata-eval77.4%
div-inv77.4%
metadata-eval77.4%
Applied egg-rr97.0%
Taylor expanded in lambda2 around 0 97.0%
if 4.4999999999999999e-4 < lambda2 Initial program 44.4%
div-sub44.4%
sin-diff44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
Applied egg-rr44.9%
div-sub44.4%
sin-diff44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
Applied egg-rr55.6%
Taylor expanded in lambda1 around 0 55.9%
Final simplification76.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (sin (* 0.5 phi2)))
(t_2 (cos (* phi1 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (cos (* 0.5 phi2))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (- (* t_4 t_0) (* t_1 t_2)) 2.0)
(* t_3 (* (* (cos phi1) (cos phi2)) t_3))))
(sqrt
(-
1.0
(+
(pow (fma t_0 t_4 (* (- t_2) t_1)) 2.0)
(log1p
(expm1
(*
(cos phi1)
(*
(cos phi2)
(pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = sin((0.5 * phi2));
double t_2 = cos((phi1 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = cos((0.5 * phi2));
return R * (2.0 * atan2(sqrt((pow(((t_4 * t_0) - (t_1 * t_2)), 2.0) + (t_3 * ((cos(phi1) * cos(phi2)) * t_3)))), sqrt((1.0 - (pow(fma(t_0, t_4, (-t_2 * t_1)), 2.0) + log1p(expm1((cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0))))))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(0.5 * phi2)) t_2 = cos(Float64(phi1 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = cos(Float64(0.5 * phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_4 * t_0) - Float64(t_1 * t_2)) ^ 2.0) + Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)))), sqrt(Float64(1.0 - Float64((fma(t_0, t_4, Float64(Float64(-t_2) * t_1)) ^ 2.0) + log1p(expm1(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$4 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$0 * t$95$4 + N[((-t$95$2) * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[Log[1 + N[(Exp[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(0.5 \cdot \phi_2\right)\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_4 \cdot t\_0 - t\_1 \cdot t\_2\right)}^{2} + t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_0, t\_4, \left(-t\_2\right) \cdot t\_1\right)\right)}^{2} + \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
cancel-sign-sub-inv76.5%
fma-define76.5%
*-commutative76.5%
*-commutative76.5%
Applied egg-rr76.5%
log1p-expm1-u76.5%
associate-*r*76.6%
associate-*l*76.6%
pow276.6%
div-inv76.6%
metadata-eval76.6%
Applied egg-rr76.6%
Final simplification76.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (sin (* 0.5 phi2)))
(t_2 (cos (* phi1 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3)))
(t_5 (cos (* 0.5 phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* t_5 t_0) (* t_1 t_2)) 2.0) t_4))
(sqrt (- 1.0 (+ t_4 (pow (fma t_0 t_5 (* (- t_2) t_1)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = sin((0.5 * phi2));
double t_2 = cos((phi1 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
double t_5 = cos((0.5 * phi2));
return R * (2.0 * atan2(sqrt((pow(((t_5 * t_0) - (t_1 * t_2)), 2.0) + t_4)), sqrt((1.0 - (t_4 + pow(fma(t_0, t_5, (-t_2 * t_1)), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(0.5 * phi2)) t_2 = cos(Float64(phi1 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) t_5 = cos(Float64(0.5 * phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_5 * t_0) - Float64(t_1 * t_2)) ^ 2.0) + t_4)), sqrt(Float64(1.0 - Float64(t_4 + (fma(t_0, t_5, Float64(Float64(-t_2) * t_1)) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$5 * t$95$0), $MachinePrecision] - N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[(t$95$0 * t$95$5 + N[((-t$95$2) * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(0.5 \cdot \phi_2\right)\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
t_5 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_5 \cdot t\_0 - t\_1 \cdot t\_2\right)}^{2} + t\_4}}{\sqrt{1 - \left(t\_4 + {\left(\mathsf{fma}\left(t\_0, t\_5, \left(-t\_2\right) \cdot t\_1\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
cancel-sign-sub-inv76.5%
fma-define76.5%
*-commutative76.5%
*-commutative76.5%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sqrt (+ t_0 (* t_1 (* (* (cos phi1) (cos phi2)) t_1))))))
(if (or (<= lambda1 -4e-5) (not (<= lambda1 1e-5)))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
t_0
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
1.0
(+
t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))));
double tmp;
if ((lambda1 <= -4e-5) || !(lambda1 <= 1e-5)) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))))
if ((lambda1 <= (-4d-5)) .or. (.not. (lambda1 <= 1d-5))) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((t_0 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1))));
double tmp;
if ((lambda1 <= -4e-5) || !(lambda1 <= 1e-5)) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((t_0 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)))) tmp = 0 if (lambda1 <= -4e-5) or not (lambda1 <= 1e-5): tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(t_0 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))) tmp = 0.0 if ((lambda1 <= -4e-5) || !(lambda1 <= 1e-5)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt((t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))); tmp = 0.0; if ((lambda1 <= -4e-5) || ~((lambda1 <= 1e-5))) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -4e-5], N[Not[LessEqual[lambda1, 1e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{t\_0 + t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)}\\
\mathbf{if}\;\lambda_1 \leq -4 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{1 - \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -4.00000000000000033e-5 or 1.00000000000000008e-5 < lambda1 Initial program 45.6%
div-sub45.6%
sin-diff47.0%
div-inv47.0%
metadata-eval47.0%
div-inv47.0%
metadata-eval47.0%
div-inv47.0%
metadata-eval47.0%
div-inv47.0%
metadata-eval47.0%
Applied egg-rr47.0%
div-sub45.6%
sin-diff47.0%
div-inv47.0%
metadata-eval47.0%
div-inv47.0%
metadata-eval47.0%
div-inv47.0%
metadata-eval47.0%
div-inv47.0%
metadata-eval47.0%
Applied egg-rr57.1%
Taylor expanded in lambda2 around 0 57.2%
if -4.00000000000000033e-5 < lambda1 < 1.00000000000000008e-5Initial program 76.8%
div-sub76.8%
sin-diff77.5%
div-inv77.5%
metadata-eval77.5%
div-inv77.5%
metadata-eval77.5%
div-inv77.5%
metadata-eval77.5%
div-inv77.5%
metadata-eval77.5%
Applied egg-rr77.5%
div-sub76.8%
sin-diff77.5%
div-inv77.5%
metadata-eval77.5%
div-inv77.5%
metadata-eval77.5%
div-inv77.5%
metadata-eval77.5%
div-inv77.5%
metadata-eval77.5%
Applied egg-rr97.6%
Taylor expanded in lambda1 around 0 97.6%
Final simplification76.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_2 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_3 (+ t_1 t_2))
(t_4 (sqrt (- 1.0 t_3))))
(if (<= lambda1 -8500.0)
(*
R
(* 2.0 (atan2 (sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0)))) t_4)))
(if (<= lambda1 1.4e-5)
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt
(-
1.0
(+
t_1
(*
(cos phi1)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_3 = t_1 + t_2;
double t_4 = sqrt((1.0 - t_3));
double tmp;
if (lambda1 <= -8500.0) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4));
} else if (lambda1 <= 1.4e-5) {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0))), t_4));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_3 = t_1 + t_2
t_4 = sqrt((1.0d0 - t_3))
if (lambda1 <= (-8500.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), t_4))
else if (lambda1 <= 1.4d-5) then
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_1 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_2 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_3 = t_1 + t_2;
double t_4 = Math.sqrt((1.0 - t_3));
double tmp;
if (lambda1 <= -8500.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_4));
} else if (lambda1 <= 1.4e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_2 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_3 = t_1 + t_2 t_4 = math.sqrt((1.0 - t_3)) tmp = 0 if lambda1 <= -8500.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_4)) elif lambda1 <= 1.4e-5: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_2 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_3 = Float64(t_1 + t_2) t_4 = sqrt(Float64(1.0 - t_3)) tmp = 0.0 if (lambda1 <= -8500.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_4))); elseif (lambda1 <= 1.4e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_3 = t_1 + t_2; t_4 = sqrt((1.0 - t_3)); tmp = 0.0; if (lambda1 <= -8500.0) tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_4)); elseif (lambda1 <= 1.4e-5) tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_1 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 + t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -8500.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 1.4e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + 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[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_2 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_3 := t\_1 + t\_2\\
t_4 := \sqrt{1 - t\_3}\\
\mathbf{if}\;\lambda_1 \leq -8500:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_4}\right)\\
\mathbf{elif}\;\lambda_1 \leq 1.4 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - \left(t\_1 + \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{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{t\_4}\right)\\
\end{array}
\end{array}
if lambda1 < -8500Initial program 47.7%
div-sub47.7%
sin-diff49.4%
div-inv49.4%
metadata-eval49.4%
div-inv49.4%
metadata-eval49.4%
div-inv49.4%
metadata-eval49.4%
div-inv49.4%
metadata-eval49.4%
Applied egg-rr49.4%
unpow249.4%
sin-mult49.6%
div-inv49.6%
metadata-eval49.6%
div-inv49.6%
metadata-eval49.6%
div-inv49.6%
metadata-eval49.6%
div-inv49.6%
metadata-eval49.6%
Applied egg-rr49.6%
div-sub49.6%
+-inverses49.6%
cos-049.6%
metadata-eval49.6%
distribute-lft-out49.6%
metadata-eval49.6%
*-rgt-identity49.6%
Simplified49.6%
if -8500 < lambda1 < 1.39999999999999998e-5Initial program 76.2%
div-sub76.2%
sin-diff76.8%
div-inv76.8%
metadata-eval76.8%
div-inv76.8%
metadata-eval76.8%
div-inv76.8%
metadata-eval76.8%
div-inv76.8%
metadata-eval76.8%
Applied egg-rr76.8%
div-sub76.2%
sin-diff76.8%
div-inv76.8%
metadata-eval76.8%
div-inv76.8%
metadata-eval76.8%
div-inv76.8%
metadata-eval76.8%
div-inv76.8%
metadata-eval76.8%
Applied egg-rr97.6%
Taylor expanded in lambda1 around 0 97.0%
if 1.39999999999999998e-5 < lambda1 Initial program 44.0%
div-sub44.0%
sin-diff45.2%
div-inv45.2%
metadata-eval45.2%
div-inv45.2%
metadata-eval45.2%
div-inv45.2%
metadata-eval45.2%
div-inv45.2%
metadata-eval45.2%
Applied egg-rr45.2%
Taylor expanded in lambda2 around 0 45.5%
Final simplification71.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0))
(t_2 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_3 (sqrt (- 1.0 (+ t_1 t_2)))))
(if (<= lambda1 -8500.0)
(*
R
(* 2.0 (atan2 (sqrt (+ t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0)))) t_3)))
(if (<= lambda1 3.7e-26)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_3)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
t_3)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0);
double t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_3 = sqrt((1.0 - (t_1 + t_2)));
double tmp;
if (lambda1 <= -8500.0) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_3));
} else if (lambda1 <= 3.7e-26) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), t_3));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0))), t_3));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_3 = sqrt((1.0d0 - (t_1 + t_2)))
if (lambda1 <= (-8500.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), t_3))
else if (lambda1 <= 3.7d-26) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_3))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), t_3))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_2 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_3 = Math.sqrt((1.0 - (t_1 + t_2)));
double tmp;
if (lambda1 <= -8500.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_3));
} else if (lambda1 <= 3.7e-26) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), t_3));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), t_3));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) t_2 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_3 = math.sqrt((1.0 - (t_1 + t_2))) tmp = 0 if lambda1 <= -8500.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_3)) elif lambda1 <= 3.7e-26: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), t_3)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), t_3)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_2 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_3 = sqrt(Float64(1.0 - Float64(t_1 + t_2))) tmp = 0.0 if (lambda1 <= -8500.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), t_3))); elseif (lambda1 <= 3.7e-26) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), t_3))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), t_3))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0; t_2 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_3 = sqrt((1.0 - (t_1 + t_2))); tmp = 0.0; if (lambda1 <= -8500.0) tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), t_3)); elseif (lambda1 <= 3.7e-26) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_3)); else tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), t_3)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(t$95$1 + t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -8500.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 3.7e-26], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_2 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_3 := \sqrt{1 - \left(t\_1 + t\_2\right)}\\
\mathbf{if}\;\lambda_1 \leq -8500:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_3}\right)\\
\mathbf{elif}\;\lambda_1 \leq 3.7 \cdot 10^{-26}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{t\_3}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{t\_3}\right)\\
\end{array}
\end{array}
if lambda1 < -8500Initial program 47.7%
div-sub47.7%
sin-diff49.4%
div-inv49.4%
metadata-eval49.4%
div-inv49.4%
metadata-eval49.4%
div-inv49.4%
metadata-eval49.4%
div-inv49.4%
metadata-eval49.4%
Applied egg-rr49.4%
unpow249.4%
sin-mult49.6%
div-inv49.6%
metadata-eval49.6%
div-inv49.6%
metadata-eval49.6%
div-inv49.6%
metadata-eval49.6%
div-inv49.6%
metadata-eval49.6%
Applied egg-rr49.6%
div-sub49.6%
+-inverses49.6%
cos-049.6%
metadata-eval49.6%
distribute-lft-out49.6%
metadata-eval49.6%
*-rgt-identity49.6%
Simplified49.6%
if -8500 < lambda1 < 3.6999999999999999e-26Initial program 76.3%
div-sub76.3%
sin-diff76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
Applied egg-rr76.9%
div-sub76.3%
sin-diff76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
Applied egg-rr97.6%
Taylor expanded in lambda1 around 0 93.5%
if 3.6999999999999999e-26 < lambda1 Initial program 45.3%
div-sub45.3%
sin-diff46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
div-inv46.4%
metadata-eval46.4%
Applied egg-rr46.4%
Taylor expanded in lambda2 around 0 46.7%
Final simplification69.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (cos (* 0.5 phi2)))
(t_3 (sin (* phi1 0.5)))
(t_4 (sin (* 0.5 phi2)))
(t_5 (cos (* phi1 0.5))))
(if (or (<= phi1 -5.4e-12) (not (<= phi1 2.8e-11)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* t_2 t_3) (* t_4 t_5)) 2.0) t_1))
(sqrt
(-
1.0
(+
(pow (fma t_3 t_2 (* (- t_5) t_4)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(+ 1.0 (* phi1 (* t_2 t_4)))
(+
(*
(cos phi2)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow t_4 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = cos((0.5 * phi2));
double t_3 = sin((phi1 * 0.5));
double t_4 = sin((0.5 * phi2));
double t_5 = cos((phi1 * 0.5));
double tmp;
if ((phi1 <= -5.4e-12) || !(phi1 <= 2.8e-11)) {
tmp = R * (2.0 * atan2(sqrt((pow(((t_2 * t_3) - (t_4 * t_5)), 2.0) + t_1)), sqrt((1.0 - (pow(fma(t_3, t_2, (-t_5 * t_4)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 + (phi1 * (t_2 * t_4))) - ((cos(phi2) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(t_4, 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(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = cos(Float64(0.5 * phi2)) t_3 = sin(Float64(phi1 * 0.5)) t_4 = sin(Float64(0.5 * phi2)) t_5 = cos(Float64(phi1 * 0.5)) tmp = 0.0 if ((phi1 <= -5.4e-12) || !(phi1 <= 2.8e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_2 * t_3) - Float64(t_4 * t_5)) ^ 2.0) + t_1)), sqrt(Float64(1.0 - Float64((fma(t_3, t_2, Float64(Float64(-t_5) * t_4)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(phi1 * Float64(t_2 * t_4))) - Float64(Float64(cos(phi2) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)) + (t_4 ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -5.4e-12], N[Not[LessEqual[phi1, 2.8e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$2 * t$95$3), $MachinePrecision] - N[(t$95$4 * t$95$5), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(t$95$3 * t$95$2 + N[((-t$95$5) * t$95$4), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(phi1 * N[(t$95$2 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$4, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := \cos \left(0.5 \cdot \phi_2\right)\\
t_3 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_4 := \sin \left(0.5 \cdot \phi_2\right)\\
t_5 := \cos \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\phi_1 \leq -5.4 \cdot 10^{-12} \lor \neg \left(\phi_1 \leq 2.8 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t\_2 \cdot t\_3 - t\_4 \cdot t\_5\right)}^{2} + t\_1}}{\sqrt{1 - \left({\left(\mathsf{fma}\left(t\_3, t\_2, \left(-t\_5\right) \cdot t\_4\right)\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 + \phi_1 \cdot \left(t\_2 \cdot t\_4\right)\right) - \left(\cos \phi_2 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2} + {t\_4}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -5.39999999999999961e-12 or 2.8e-11 < phi1 Initial program 47.3%
div-sub47.3%
sin-diff49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
Applied egg-rr49.2%
div-sub47.3%
sin-diff49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
Applied egg-rr76.8%
cancel-sign-sub-inv76.8%
fma-define76.8%
*-commutative76.8%
*-commutative76.8%
Applied egg-rr76.8%
Taylor expanded in phi2 around 0 58.0%
*-commutative58.0%
Simplified58.0%
if -5.39999999999999961e-12 < phi1 < 2.8e-11Initial program 76.2%
div-sub76.2%
sin-diff76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in phi1 around 0 76.2%
*-commutative76.2%
metadata-eval76.2%
div-inv76.2%
div-sub76.2%
sin-diff76.9%
Applied egg-rr76.9%
Final simplification66.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* 0.5 phi2)))
(t_1 (sin (* phi1 0.5)))
(t_2 (cos (* phi1 0.5)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3)))
(t_5 (* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(t_6 (sin (* 0.5 phi2)))
(t_7 (pow (- (* t_0 t_1) (* t_6 t_2)) 2.0))
(t_8 (pow (fma t_1 t_0 (* (- t_2) t_6)) 2.0)))
(if (<= phi1 -5.4e-12)
(* R (* 2.0 (atan2 (sqrt (+ t_7 t_4)) (sqrt (- 1.0 (+ t_8 t_5))))))
(if (<= phi1 2.4e-11)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(+ 1.0 (* phi1 (* t_0 t_6)))
(+
(*
(cos phi2)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow t_6 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_7 t_5)) (sqrt (- 1.0 (+ t_4 t_8))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((0.5 * phi2));
double t_1 = sin((phi1 * 0.5));
double t_2 = cos((phi1 * 0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
double t_5 = cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_6 = sin((0.5 * phi2));
double t_7 = pow(((t_0 * t_1) - (t_6 * t_2)), 2.0);
double t_8 = pow(fma(t_1, t_0, (-t_2 * t_6)), 2.0);
double tmp;
if (phi1 <= -5.4e-12) {
tmp = R * (2.0 * atan2(sqrt((t_7 + t_4)), sqrt((1.0 - (t_8 + t_5)))));
} else if (phi1 <= 2.4e-11) {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 + (phi1 * (t_0 * t_6))) - ((cos(phi2) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(t_6, 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_7 + t_5)), sqrt((1.0 - (t_4 + t_8)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(0.5 * phi2)) t_1 = sin(Float64(phi1 * 0.5)) t_2 = cos(Float64(phi1 * 0.5)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) t_5 = Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) t_6 = sin(Float64(0.5 * phi2)) t_7 = Float64(Float64(t_0 * t_1) - Float64(t_6 * t_2)) ^ 2.0 t_8 = fma(t_1, t_0, Float64(Float64(-t_2) * t_6)) ^ 2.0 tmp = 0.0 if (phi1 <= -5.4e-12) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_7 + t_4)), sqrt(Float64(1.0 - Float64(t_8 + t_5)))))); elseif (phi1 <= 2.4e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(phi1 * Float64(t_0 * t_6))) - Float64(Float64(cos(phi2) * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 2.0)) + (t_6 ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_7 + t_5)), sqrt(Float64(1.0 - Float64(t_4 + t_8)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Power[N[(N[(t$95$0 * t$95$1), $MachinePrecision] - N[(t$95$6 * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$8 = N[Power[N[(t$95$1 * t$95$0 + N[((-t$95$2) * t$95$6), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -5.4e-12], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$7 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$8 + t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.4e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(phi1 * N[(t$95$0 * t$95$6), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$6, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$7 + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + t$95$8), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(0.5 \cdot \phi_2\right)\\
t_1 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
t_5 := \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_6 := \sin \left(0.5 \cdot \phi_2\right)\\
t_7 := {\left(t\_0 \cdot t\_1 - t\_6 \cdot t\_2\right)}^{2}\\
t_8 := {\left(\mathsf{fma}\left(t\_1, t\_0, \left(-t\_2\right) \cdot t\_6\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -5.4 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7 + t\_4}}{\sqrt{1 - \left(t\_8 + t\_5\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.4 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 + \phi_1 \cdot \left(t\_0 \cdot t\_6\right)\right) - \left(\cos \phi_2 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2} + {t\_6}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7 + t\_5}}{\sqrt{1 - \left(t\_4 + t\_8\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -5.39999999999999961e-12Initial program 45.0%
div-sub45.0%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
div-sub45.0%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr77.3%
cancel-sign-sub-inv77.3%
fma-define77.3%
*-commutative77.3%
*-commutative77.3%
Applied egg-rr77.3%
Taylor expanded in phi2 around 0 57.8%
*-commutative57.8%
Simplified57.8%
if -5.39999999999999961e-12 < phi1 < 2.4000000000000001e-11Initial program 76.2%
div-sub76.2%
sin-diff76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in phi1 around 0 76.2%
*-commutative76.2%
metadata-eval76.2%
div-inv76.2%
div-sub76.2%
sin-diff76.9%
Applied egg-rr76.9%
if 2.4000000000000001e-11 < phi1 Initial program 50.2%
div-sub50.2%
sin-diff51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
Applied egg-rr51.7%
div-sub50.2%
sin-diff51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
Applied egg-rr76.2%
cancel-sign-sub-inv76.2%
fma-define76.3%
*-commutative76.3%
*-commutative76.3%
Applied egg-rr76.3%
Taylor expanded in phi2 around 0 59.3%
*-commutative58.2%
Simplified59.3%
Final simplification67.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (sin (* 0.5 phi2)) (cos (* phi1 0.5))))
2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) 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(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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 = (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (sin((0.5d0 * phi2)) * cos((phi1 * 0.5d0)))) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.sin((0.5 * phi2)) * Math.cos((phi1 * 0.5)))), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * 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.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.sin((0.5 * phi2)) * math.cos((phi1 * 0.5)))), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * 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((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(0.5 * phi2)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * 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 = (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (sin((0.5 * phi2)) * cos((phi1 * 0.5)))) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, 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 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(0.5 \cdot \phi_2\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2
(pow (- (* (cos (* 0.5 phi2)) t_0) (* (sin (* 0.5 phi2)) t_1)) 2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3)))
(t_5 (+ t_2 t_4))
(t_6 (sqrt t_5))
(t_7 (+ t_2 (* t_3 (* (cos phi2) t_3)))))
(if (<= phi2 -0.0014)
(* R (* 2.0 (atan2 (sqrt t_7) (sqrt (- 1.0 t_5)))))
(if (<= phi2 0.005)
(*
R
(*
2.0
(atan2
t_6
(sqrt
(-
1.0
(+
t_4
(pow
(+ t_0 (* phi2 (- (* -0.125 (* phi2 t_0)) (* 0.5 t_1))))
2.0)))))))
(* R (* 2.0 (atan2 t_6 (sqrt (- 1.0 t_7)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = pow(((cos((0.5 * phi2)) * t_0) - (sin((0.5 * phi2)) * t_1)), 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
double t_5 = t_2 + t_4;
double t_6 = sqrt(t_5);
double t_7 = t_2 + (t_3 * (cos(phi2) * t_3));
double tmp;
if (phi2 <= -0.0014) {
tmp = R * (2.0 * atan2(sqrt(t_7), sqrt((1.0 - t_5))));
} else if (phi2 <= 0.005) {
tmp = R * (2.0 * atan2(t_6, sqrt((1.0 - (t_4 + pow((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) - (0.5 * t_1)))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_6, sqrt((1.0 - t_7))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = cos((phi1 * 0.5d0))
t_2 = ((cos((0.5d0 * phi2)) * t_0) - (sin((0.5d0 * phi2)) * t_1)) ** 2.0d0
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3)
t_5 = t_2 + t_4
t_6 = sqrt(t_5)
t_7 = t_2 + (t_3 * (cos(phi2) * t_3))
if (phi2 <= (-0.0014d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_7), sqrt((1.0d0 - t_5))))
else if (phi2 <= 0.005d0) then
tmp = r * (2.0d0 * atan2(t_6, sqrt((1.0d0 - (t_4 + ((t_0 + (phi2 * (((-0.125d0) * (phi2 * t_0)) - (0.5d0 * t_1)))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_6, sqrt((1.0d0 - t_7))))
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.cos((phi1 * 0.5));
double t_2 = Math.pow(((Math.cos((0.5 * phi2)) * t_0) - (Math.sin((0.5 * phi2)) * t_1)), 2.0);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((Math.cos(phi1) * Math.cos(phi2)) * t_3);
double t_5 = t_2 + t_4;
double t_6 = Math.sqrt(t_5);
double t_7 = t_2 + (t_3 * (Math.cos(phi2) * t_3));
double tmp;
if (phi2 <= -0.0014) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_7), Math.sqrt((1.0 - t_5))));
} else if (phi2 <= 0.005) {
tmp = R * (2.0 * Math.atan2(t_6, Math.sqrt((1.0 - (t_4 + Math.pow((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) - (0.5 * t_1)))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_6, Math.sqrt((1.0 - t_7))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.cos((phi1 * 0.5)) t_2 = math.pow(((math.cos((0.5 * phi2)) * t_0) - (math.sin((0.5 * phi2)) * t_1)), 2.0) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_3 * ((math.cos(phi1) * math.cos(phi2)) * t_3) t_5 = t_2 + t_4 t_6 = math.sqrt(t_5) t_7 = t_2 + (t_3 * (math.cos(phi2) * t_3)) tmp = 0 if phi2 <= -0.0014: tmp = R * (2.0 * math.atan2(math.sqrt(t_7), math.sqrt((1.0 - t_5)))) elif phi2 <= 0.005: tmp = R * (2.0 * math.atan2(t_6, math.sqrt((1.0 - (t_4 + math.pow((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) - (0.5 * t_1)))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_6, math.sqrt((1.0 - t_7)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = Float64(Float64(cos(Float64(0.5 * phi2)) * t_0) - Float64(sin(Float64(0.5 * phi2)) * t_1)) ^ 2.0 t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) t_5 = Float64(t_2 + t_4) t_6 = sqrt(t_5) t_7 = Float64(t_2 + Float64(t_3 * Float64(cos(phi2) * t_3))) tmp = 0.0 if (phi2 <= -0.0014) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_7), sqrt(Float64(1.0 - t_5))))); elseif (phi2 <= 0.005) tmp = Float64(R * Float64(2.0 * atan(t_6, sqrt(Float64(1.0 - Float64(t_4 + (Float64(t_0 + Float64(phi2 * Float64(Float64(-0.125 * Float64(phi2 * t_0)) - Float64(0.5 * t_1)))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_6, sqrt(Float64(1.0 - t_7))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = cos((phi1 * 0.5)); t_2 = ((cos((0.5 * phi2)) * t_0) - (sin((0.5 * phi2)) * t_1)) ^ 2.0; t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3); t_5 = t_2 + t_4; t_6 = sqrt(t_5); t_7 = t_2 + (t_3 * (cos(phi2) * t_3)); tmp = 0.0; if (phi2 <= -0.0014) tmp = R * (2.0 * atan2(sqrt(t_7), sqrt((1.0 - t_5)))); elseif (phi2 <= 0.005) tmp = R * (2.0 * atan2(t_6, sqrt((1.0 - (t_4 + ((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) - (0.5 * t_1)))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_6, sqrt((1.0 - t_7)))); 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[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 + t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[t$95$5], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$2 + N[(t$95$3 * N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.0014], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$7], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.005], N[(R * N[(2.0 * N[ArcTan[t$95$6 / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[(t$95$0 + N[(phi2 * N[(N[(-0.125 * N[(phi2 * t$95$0), $MachinePrecision]), $MachinePrecision] - N[(0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$6 / N[Sqrt[N[(1.0 - t$95$7), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot t\_0 - \sin \left(0.5 \cdot \phi_2\right) \cdot t\_1\right)}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
t_5 := t\_2 + t\_4\\
t_6 := \sqrt{t\_5}\\
t_7 := t\_2 + t\_3 \cdot \left(\cos \phi_2 \cdot t\_3\right)\\
\mathbf{if}\;\phi_2 \leq -0.0014:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.005:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_6}{\sqrt{1 - \left(t\_4 + {\left(t\_0 + \phi_2 \cdot \left(-0.125 \cdot \left(\phi_2 \cdot t\_0\right) - 0.5 \cdot t\_1\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_6}{\sqrt{1 - t\_7}}\right)\\
\end{array}
\end{array}
if phi2 < -0.00139999999999999999Initial program 45.7%
div-sub45.7%
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.8%
div-sub45.7%
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-rr76.7%
Taylor expanded in phi1 around 0 55.0%
if -0.00139999999999999999 < phi2 < 0.0050000000000000001Initial program 75.0%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr75.1%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr76.4%
Taylor expanded in phi2 around 0 76.2%
if 0.0050000000000000001 < phi2 Initial program 45.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr76.6%
Taylor expanded in phi1 around 0 58.5%
Final simplification66.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2
(pow (- (* (cos (* 0.5 phi2)) t_0) (* (sin (* 0.5 phi2)) t_1)) 2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3)))
(t_5 (+ t_2 t_4))
(t_6 (sqrt (- 1.0 t_5)))
(t_7 (+ t_2 (* t_3 (* (cos phi2) t_3)))))
(if (<= phi2 -0.0015)
(* R (* 2.0 (atan2 (sqrt t_7) t_6)))
(if (<= phi2 0.0072)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_4
(pow
(+ t_0 (* phi2 (+ (* -0.125 (* phi2 t_0)) (* -0.5 t_1))))
2.0)))
t_6)))
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_7)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = pow(((cos((0.5 * phi2)) * t_0) - (sin((0.5 * phi2)) * t_1)), 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
double t_5 = t_2 + t_4;
double t_6 = sqrt((1.0 - t_5));
double t_7 = t_2 + (t_3 * (cos(phi2) * t_3));
double tmp;
if (phi2 <= -0.0015) {
tmp = R * (2.0 * atan2(sqrt(t_7), t_6));
} else if (phi2 <= 0.0072) {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) + (-0.5 * t_1)))), 2.0))), t_6));
} else {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_7))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: t_7
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = cos((phi1 * 0.5d0))
t_2 = ((cos((0.5d0 * phi2)) * t_0) - (sin((0.5d0 * phi2)) * t_1)) ** 2.0d0
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3)
t_5 = t_2 + t_4
t_6 = sqrt((1.0d0 - t_5))
t_7 = t_2 + (t_3 * (cos(phi2) * t_3))
if (phi2 <= (-0.0015d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_7), t_6))
else if (phi2 <= 0.0072d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + ((t_0 + (phi2 * (((-0.125d0) * (phi2 * t_0)) + ((-0.5d0) * t_1)))) ** 2.0d0))), t_6))
else
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_7))))
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.cos((phi1 * 0.5));
double t_2 = Math.pow(((Math.cos((0.5 * phi2)) * t_0) - (Math.sin((0.5 * phi2)) * t_1)), 2.0);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((Math.cos(phi1) * Math.cos(phi2)) * t_3);
double t_5 = t_2 + t_4;
double t_6 = Math.sqrt((1.0 - t_5));
double t_7 = t_2 + (t_3 * (Math.cos(phi2) * t_3));
double tmp;
if (phi2 <= -0.0015) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_7), t_6));
} else if (phi2 <= 0.0072) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) + (-0.5 * t_1)))), 2.0))), t_6));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_7))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.cos((phi1 * 0.5)) t_2 = math.pow(((math.cos((0.5 * phi2)) * t_0) - (math.sin((0.5 * phi2)) * t_1)), 2.0) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_3 * ((math.cos(phi1) * math.cos(phi2)) * t_3) t_5 = t_2 + t_4 t_6 = math.sqrt((1.0 - t_5)) t_7 = t_2 + (t_3 * (math.cos(phi2) * t_3)) tmp = 0 if phi2 <= -0.0015: tmp = R * (2.0 * math.atan2(math.sqrt(t_7), t_6)) elif phi2 <= 0.0072: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) + (-0.5 * t_1)))), 2.0))), t_6)) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_7)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = Float64(Float64(cos(Float64(0.5 * phi2)) * t_0) - Float64(sin(Float64(0.5 * phi2)) * t_1)) ^ 2.0 t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) t_5 = Float64(t_2 + t_4) t_6 = sqrt(Float64(1.0 - t_5)) t_7 = Float64(t_2 + Float64(t_3 * Float64(cos(phi2) * t_3))) tmp = 0.0 if (phi2 <= -0.0015) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_7), t_6))); elseif (phi2 <= 0.0072) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (Float64(t_0 + Float64(phi2 * Float64(Float64(-0.125 * Float64(phi2 * t_0)) + Float64(-0.5 * t_1)))) ^ 2.0))), t_6))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_7))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = cos((phi1 * 0.5)); t_2 = ((cos((0.5 * phi2)) * t_0) - (sin((0.5 * phi2)) * t_1)) ^ 2.0; t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3); t_5 = t_2 + t_4; t_6 = sqrt((1.0 - t_5)); t_7 = t_2 + (t_3 * (cos(phi2) * t_3)); tmp = 0.0; if (phi2 <= -0.0015) tmp = R * (2.0 * atan2(sqrt(t_7), t_6)); elseif (phi2 <= 0.0072) tmp = R * (2.0 * atan2(sqrt((t_4 + ((t_0 + (phi2 * ((-0.125 * (phi2 * t_0)) + (-0.5 * t_1)))) ^ 2.0))), t_6)); else tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_7)))); 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[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 + t$95$4), $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$2 + N[(t$95$3 * N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.0015], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$7], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.0072], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[(t$95$0 + N[(phi2 * N[(N[(-0.125 * N[(phi2 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$7), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot t\_0 - \sin \left(0.5 \cdot \phi_2\right) \cdot t\_1\right)}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
t_5 := t\_2 + t\_4\\
t_6 := \sqrt{1 - t\_5}\\
t_7 := t\_2 + t\_3 \cdot \left(\cos \phi_2 \cdot t\_3\right)\\
\mathbf{if}\;\phi_2 \leq -0.0015:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7}}{t\_6}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.0072:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\left(t\_0 + \phi_2 \cdot \left(-0.125 \cdot \left(\phi_2 \cdot t\_0\right) + -0.5 \cdot t\_1\right)\right)}^{2}}}{t\_6}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_7}}\right)\\
\end{array}
\end{array}
if phi2 < -0.0015Initial program 45.7%
div-sub45.7%
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.8%
div-sub45.7%
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-rr76.7%
Taylor expanded in phi1 around 0 55.0%
if -0.0015 < phi2 < 0.0071999999999999998Initial program 75.0%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr75.1%
Taylor expanded in phi2 around 0 76.2%
if 0.0071999999999999998 < phi2 Initial program 45.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr76.6%
Taylor expanded in phi1 around 0 58.5%
Final simplification66.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (sin (* phi1 0.5)))
(t_2 (cos (* phi1 0.5)))
(t_3
(pow (- (* (cos (* 0.5 phi2)) t_1) (* (sin (* 0.5 phi2)) t_2)) 2.0))
(t_4 (+ t_3 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))))
(if (or (<= phi2 -0.001) (not (<= phi2 5.6e-5)))
(*
R
(*
2.0
(atan2 (sqrt (+ t_3 (* t_0 (* (cos phi2) t_0)))) (sqrt (- 1.0 t_4)))))
(*
R
(*
2.0
(atan2
(sqrt t_4)
(sqrt
(-
(+ 1.0 (* phi2 (* t_1 t_2)))
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow t_1 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 = sin((phi1 * 0.5));
double t_2 = cos((phi1 * 0.5));
double t_3 = pow(((cos((0.5 * phi2)) * t_1) - (sin((0.5 * phi2)) * t_2)), 2.0);
double t_4 = t_3 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0));
double tmp;
if ((phi2 <= -0.001) || !(phi2 <= 5.6e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (t_0 * (cos(phi2) * t_0)))), sqrt((1.0 - t_4))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(((1.0 + (phi2 * (t_1 * t_2))) - ((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(t_1, 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((phi1 * 0.5d0))
t_2 = cos((phi1 * 0.5d0))
t_3 = ((cos((0.5d0 * phi2)) * t_1) - (sin((0.5d0 * phi2)) * t_2)) ** 2.0d0
t_4 = t_3 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))
if ((phi2 <= (-0.001d0)) .or. (.not. (phi2 <= 5.6d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (t_0 * (cos(phi2) * t_0)))), sqrt((1.0d0 - t_4))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt(((1.0d0 + (phi2 * (t_1 * t_2))) - ((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (t_1 ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sin((phi1 * 0.5));
double t_2 = Math.cos((phi1 * 0.5));
double t_3 = Math.pow(((Math.cos((0.5 * phi2)) * t_1) - (Math.sin((0.5 * phi2)) * t_2)), 2.0);
double t_4 = t_3 + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0));
double tmp;
if ((phi2 <= -0.001) || !(phi2 <= 5.6e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (t_0 * (Math.cos(phi2) * t_0)))), Math.sqrt((1.0 - t_4))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), Math.sqrt(((1.0 + (phi2 * (t_1 * t_2))) - ((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(t_1, 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sin((phi1 * 0.5)) t_2 = math.cos((phi1 * 0.5)) t_3 = math.pow(((math.cos((0.5 * phi2)) * t_1) - (math.sin((0.5 * phi2)) * t_2)), 2.0) t_4 = t_3 + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) tmp = 0 if (phi2 <= -0.001) or not (phi2 <= 5.6e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (t_0 * (math.cos(phi2) * t_0)))), math.sqrt((1.0 - t_4)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_4), math.sqrt(((1.0 + (phi2 * (t_1 * t_2))) - ((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(t_1, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(phi1 * 0.5)) t_2 = cos(Float64(phi1 * 0.5)) t_3 = Float64(Float64(cos(Float64(0.5 * phi2)) * t_1) - Float64(sin(Float64(0.5 * phi2)) * t_2)) ^ 2.0 t_4 = Float64(t_3 + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) tmp = 0.0 if ((phi2 <= -0.001) || !(phi2 <= 5.6e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_0 * Float64(cos(phi2) * t_0)))), sqrt(Float64(1.0 - t_4))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), sqrt(Float64(Float64(1.0 + Float64(phi2 * Float64(t_1 * t_2))) - Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (t_1 ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((phi1 * 0.5)); t_2 = cos((phi1 * 0.5)); t_3 = ((cos((0.5 * phi2)) * t_1) - (sin((0.5 * phi2)) * t_2)) ^ 2.0; t_4 = t_3 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)); tmp = 0.0; if ((phi2 <= -0.001) || ~((phi2 <= 5.6e-5))) tmp = R * (2.0 * atan2(sqrt((t_3 + (t_0 * (cos(phi2) * t_0)))), sqrt((1.0 - t_4)))); else tmp = R * (2.0 * atan2(sqrt(t_4), sqrt(((1.0 + (phi2 * (t_1 * t_2))) - ((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (t_1 ^ 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[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.001], N[Not[LessEqual[phi2, 5.6e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(phi2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$1, 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 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_3 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot t\_1 - \sin \left(0.5 \cdot \phi_2\right) \cdot t\_2\right)}^{2}\\
t_4 := t\_3 + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\mathbf{if}\;\phi_2 \leq -0.001 \lor \neg \left(\phi_2 \leq 5.6 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_0 \cdot \left(\cos \phi_2 \cdot t\_0\right)}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4}}{\sqrt{\left(1 + \phi_2 \cdot \left(t\_1 \cdot t\_2\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {t\_1}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1e-3 or 5.59999999999999992e-5 < phi2 Initial program 45.5%
div-sub45.5%
sin-diff47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr47.6%
div-sub45.5%
sin-diff47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr76.7%
Taylor expanded in phi1 around 0 56.5%
if -1e-3 < phi2 < 5.59999999999999992e-5Initial program 75.0%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr75.1%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr76.4%
Taylor expanded in phi2 around 0 75.9%
Final simplification66.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2
(pow (- (* (cos (* 0.5 phi2)) t_0) (* (sin (* 0.5 phi2)) t_1)) 2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (+ t_2 (* t_3 (* (* (cos phi1) (cos phi2)) t_3))))
(t_5 (sqrt t_4))
(t_6 (+ t_2 (* t_3 (* (cos phi2) t_3)))))
(if (<= phi2 -0.001)
(* R (* 2.0 (atan2 (sqrt t_6) (sqrt (- 1.0 t_4)))))
(if (<= phi2 0.000145)
(*
R
(*
2.0
(atan2
t_5
(sqrt
(-
(+ 1.0 (* phi2 (* t_0 t_1)))
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow t_0 2.0)))))))
(* R (* 2.0 (atan2 t_5 (sqrt (- 1.0 t_6)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = pow(((cos((0.5 * phi2)) * t_0) - (sin((0.5 * phi2)) * t_1)), 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 + (t_3 * ((cos(phi1) * cos(phi2)) * t_3));
double t_5 = sqrt(t_4);
double t_6 = t_2 + (t_3 * (cos(phi2) * t_3));
double tmp;
if (phi2 <= -0.001) {
tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - t_4))));
} else if (phi2 <= 0.000145) {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - t_6))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = cos((phi1 * 0.5d0))
t_2 = ((cos((0.5d0 * phi2)) * t_0) - (sin((0.5d0 * phi2)) * t_1)) ** 2.0d0
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_2 + (t_3 * ((cos(phi1) * cos(phi2)) * t_3))
t_5 = sqrt(t_4)
t_6 = t_2 + (t_3 * (cos(phi2) * t_3))
if (phi2 <= (-0.001d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_6), sqrt((1.0d0 - t_4))))
else if (phi2 <= 0.000145d0) then
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 + (phi2 * (t_0 * t_1))) - ((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (t_0 ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - t_6))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((phi1 * 0.5));
double t_1 = Math.cos((phi1 * 0.5));
double t_2 = Math.pow(((Math.cos((0.5 * phi2)) * t_0) - (Math.sin((0.5 * phi2)) * t_1)), 2.0);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 + (t_3 * ((Math.cos(phi1) * Math.cos(phi2)) * t_3));
double t_5 = Math.sqrt(t_4);
double t_6 = t_2 + (t_3 * (Math.cos(phi2) * t_3));
double tmp;
if (phi2 <= -0.001) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_6), Math.sqrt((1.0 - t_4))));
} else if (phi2 <= 0.000145) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - t_6))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.cos((phi1 * 0.5)) t_2 = math.pow(((math.cos((0.5 * phi2)) * t_0) - (math.sin((0.5 * phi2)) * t_1)), 2.0) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_2 + (t_3 * ((math.cos(phi1) * math.cos(phi2)) * t_3)) t_5 = math.sqrt(t_4) t_6 = t_2 + (t_3 * (math.cos(phi2) * t_3)) tmp = 0 if phi2 <= -0.001: tmp = R * (2.0 * math.atan2(math.sqrt(t_6), math.sqrt((1.0 - t_4)))) elif phi2 <= 0.000145: tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(t_0, 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - t_6)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = Float64(Float64(cos(Float64(0.5 * phi2)) * t_0) - Float64(sin(Float64(0.5 * phi2)) * t_1)) ^ 2.0 t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_2 + Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3))) t_5 = sqrt(t_4) t_6 = Float64(t_2 + Float64(t_3 * Float64(cos(phi2) * t_3))) tmp = 0.0 if (phi2 <= -0.001) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_6), sqrt(Float64(1.0 - t_4))))); elseif (phi2 <= 0.000145) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 + Float64(phi2 * Float64(t_0 * t_1))) - Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (t_0 ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - t_6))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = cos((phi1 * 0.5)); t_2 = ((cos((0.5 * phi2)) * t_0) - (sin((0.5 * phi2)) * t_1)) ^ 2.0; t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_2 + (t_3 * ((cos(phi1) * cos(phi2)) * t_3)); t_5 = sqrt(t_4); t_6 = t_2 + (t_3 * (cos(phi2) * t_3)); tmp = 0.0; if (phi2 <= -0.001) tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - t_4)))); elseif (phi2 <= 0.000145) tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 + (phi2 * (t_0 * t_1))) - ((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (t_0 ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - t_6)))); 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[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 + N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[t$95$4], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$2 + N[(t$95$3 * N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.001], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$6], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.000145], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 + N[(phi2 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - t$95$6), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot t\_0 - \sin \left(0.5 \cdot \phi_2\right) \cdot t\_1\right)}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_2 + t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
t_5 := \sqrt{t\_4}\\
t_6 := t\_2 + t\_3 \cdot \left(\cos \phi_2 \cdot t\_3\right)\\
\mathbf{if}\;\phi_2 \leq -0.001:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.000145:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{\left(1 + \phi_2 \cdot \left(t\_0 \cdot t\_1\right)\right) - \left(\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {t\_0}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - t\_6}}\right)\\
\end{array}
\end{array}
if phi2 < -1e-3Initial program 45.7%
div-sub45.7%
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.8%
div-sub45.7%
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-rr76.7%
Taylor expanded in phi1 around 0 55.0%
if -1e-3 < phi2 < 1.45e-4Initial program 75.0%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr75.1%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr76.4%
Taylor expanded in phi2 around 0 75.9%
if 1.45e-4 < phi2 Initial program 45.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr76.6%
Taylor expanded in phi1 around 0 58.5%
Final simplification66.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_0 (* t_1 t_1))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))
(sqrt
(- (+ 1.0 (- (/ (+ t_0 (* (sin phi1) (sin phi2))) 2.0) 0.5)) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)), sqrt(((1.0 + (((t_0 + (sin(phi1) * sin(phi2))) / 2.0) - 0.5)) - t_2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 * (t_1 * t_1)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2)), sqrt(((1.0d0 + (((t_0 + (sin(phi1) * sin(phi2))) / 2.0d0) - 0.5d0)) - t_2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)), Math.sqrt(((1.0 + (((t_0 + (Math.sin(phi1) * Math.sin(phi2))) / 2.0) - 0.5)) - t_2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 * (t_1 * t_1) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)), math.sqrt(((1.0 + (((t_0 + (math.sin(phi1) * math.sin(phi2))) / 2.0) - 0.5)) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 * Float64(t_1 * t_1)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)), sqrt(Float64(Float64(1.0 + Float64(Float64(Float64(t_0 + Float64(sin(phi1) * sin(phi2))) / 2.0) - 0.5)) - t_2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 * (t_1 * t_1); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2)), sqrt(((1.0 + (((t_0 + (sin(phi1) * sin(phi2))) / 2.0) - 0.5)) - t_2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, 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$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[(t$95$0 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$2), $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 := t\_0 \cdot \left(t\_1 \cdot t\_1\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2}}{\sqrt{\left(1 + \left(\frac{t\_0 + \sin \phi_1 \cdot \sin \phi_2}{2} - 0.5\right)\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
unpow261.6%
sin-mult59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
Applied egg-rr60.6%
div-sub59.0%
+-inverses59.0%
cos-059.0%
metadata-eval59.0%
distribute-lft-out59.0%
metadata-eval59.0%
*-rgt-identity59.0%
Simplified60.6%
cos-diff61.7%
Applied egg-rr61.7%
Final simplification61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_1))))
(sqrt
(fabs
(-
1.0
(fma
t_0
(+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))
(pow (sin (* -0.5 (- phi2 phi1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(fabs((1.0 - fma(t_0, (0.5 + (-0.5 * cos((lambda1 - lambda2)))), pow(sin((-0.5 * (phi2 - phi1))), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(abs(Float64(1.0 - fma(t_0, Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))))) 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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $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)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left|1 - \mathsf{fma}\left(t\_0, 0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right), {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
Applied egg-rr61.1%
unpow1/261.1%
unpow261.1%
rem-sqrt-square61.1%
*-commutative61.1%
Simplified61.1%
Final simplification61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -0.0019) (not (<= phi2 0.000106)))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi2) t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 (+ (pow (sin (* 0.5 phi2)) 2.0) (* (cos phi2) t_0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(sqrt
(-
0.5
(-
(* (cos phi1) t_0)
(* 0.5 (+ (cos phi1) (* phi2 (sin phi1)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.0019) || !(phi2 <= 0.000106)) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), t_0, pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - (pow(sin((0.5 * phi2)), 2.0) + (cos(phi2) * t_0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))), sqrt((0.5 - ((cos(phi1) * t_0) - (0.5 * (cos(phi1) + (phi2 * sin(phi1)))))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -0.0019) || !(phi2 <= 0.000106)) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), t_0, (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - Float64((sin(Float64(0.5 * phi2)) ^ 2.0) + Float64(cos(phi2) * t_0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)))), sqrt(Float64(0.5 - Float64(Float64(cos(phi1) * t_0) - Float64(0.5 * Float64(cos(phi1) + Float64(phi2 * sin(phi1)))))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0019], N[Not[LessEqual[phi2, 0.000106]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(0.5 * N[(N[Cos[phi1], $MachinePrecision] + N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.0019 \lor \neg \left(\phi_2 \leq 0.000106\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \phi_2\right)}^{2} + \cos \phi_2 \cdot t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{0.5 - \left(\cos \phi_1 \cdot t\_0 - 0.5 \cdot \left(\cos \phi_1 + \phi_2 \cdot \sin \phi_1\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -0.0019 or 1.06e-4 < phi2 Initial program 45.6%
div-sub45.6%
sin-diff47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
Applied egg-rr47.7%
Taylor expanded in phi1 around 0 47.9%
fma-define47.9%
*-commutative47.9%
Simplified47.9%
Taylor expanded in phi1 around 0 47.0%
if -0.0019 < phi2 < 1.06e-4Initial program 74.7%
associate-*l*74.7%
Simplified74.6%
unpow274.7%
sin-mult69.7%
div-inv69.7%
metadata-eval69.7%
div-inv69.7%
metadata-eval69.7%
div-inv69.7%
metadata-eval69.7%
div-inv69.7%
metadata-eval69.7%
Applied egg-rr74.7%
div-sub69.7%
+-inverses69.7%
cos-069.7%
metadata-eval69.7%
distribute-lft-out69.7%
metadata-eval69.7%
*-rgt-identity69.7%
Simplified74.7%
Taylor expanded in phi2 around 0 74.7%
associate--l+74.8%
distribute-lft-out74.8%
*-commutative74.8%
Simplified74.8%
Final simplification61.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(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[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
unpow261.6%
sin-mult59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
Applied egg-rr60.6%
div-sub59.0%
+-inverses59.0%
cos-059.0%
metadata-eval59.0%
distribute-lft-out59.0%
metadata-eval59.0%
*-rgt-identity59.0%
Simplified60.6%
Final simplification60.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))
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));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (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
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - (t_0 * (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.cos(phi1) * Math.cos(phi2);
double t_1 = 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_1 * t_1)))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = 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_1 * t_1)))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64(t_0 * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2))))))))); 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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - t\_0 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
*-commutative60.6%
cancel-sign-sub-inv60.6%
div-inv60.6%
metadata-eval60.6%
Applied egg-rr60.6%
Final simplification60.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -0.0022) (not (<= phi2 0.00011)))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi2) t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 (+ (pow (sin (* 0.5 phi2)) 2.0) (* (cos phi2) t_0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(sqrt (+ 0.5 (- (* 0.5 (cos phi1)) (* (cos phi1) t_0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 0.00011)) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), t_0, pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - (pow(sin((0.5 * phi2)), 2.0) + (cos(phi2) * t_0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))), sqrt((0.5 + ((0.5 * cos(phi1)) - (cos(phi1) * t_0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -0.0022) || !(phi2 <= 0.00011)) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), t_0, (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - Float64((sin(Float64(0.5 * phi2)) ^ 2.0) + Float64(cos(phi2) * t_0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)))), sqrt(Float64(0.5 + Float64(Float64(0.5 * cos(phi1)) - Float64(cos(phi1) * t_0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0022], N[Not[LessEqual[phi2, 0.00011]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.0022 \lor \neg \left(\phi_2 \leq 0.00011\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{1 - \left({\sin \left(0.5 \cdot \phi_2\right)}^{2} + \cos \phi_2 \cdot t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{0.5 + \left(0.5 \cdot \cos \phi_1 - \cos \phi_1 \cdot t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -0.00220000000000000013 or 1.10000000000000004e-4 < phi2 Initial program 45.6%
div-sub45.6%
sin-diff47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
div-inv47.7%
metadata-eval47.7%
Applied egg-rr47.7%
Taylor expanded in phi1 around 0 47.9%
fma-define47.9%
*-commutative47.9%
Simplified47.9%
Taylor expanded in phi1 around 0 47.0%
if -0.00220000000000000013 < phi2 < 1.10000000000000004e-4Initial program 74.7%
associate-*l*74.7%
Simplified74.6%
unpow274.7%
sin-mult69.7%
div-inv69.7%
metadata-eval69.7%
div-inv69.7%
metadata-eval69.7%
div-inv69.7%
metadata-eval69.7%
div-inv69.7%
metadata-eval69.7%
Applied egg-rr74.7%
div-sub69.7%
+-inverses69.7%
cos-069.7%
metadata-eval69.7%
distribute-lft-out69.7%
metadata-eval69.7%
*-rgt-identity69.7%
Simplified74.7%
Taylor expanded in phi2 around 0 74.7%
associate--l+74.7%
*-commutative74.7%
Simplified74.7%
Final simplification61.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1)))
(t_3 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_4 (* (cos phi1) t_3)))
(if (<= phi1 -3000000000000.0)
(* R (* 2.0 (atan2 t_2 (sqrt (+ 0.5 (- (* 0.5 (cos phi1)) t_4))))))
(if (<= phi1 1.2e-23)
(*
R
(*
2.0
(atan2 t_2 (sqrt (- (+ 0.5 (* 0.5 (cos phi2))) (* (cos phi2) t_3))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1));
double t_3 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_4 = cos(phi1) * t_3;
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * atan2(t_2, sqrt((0.5 + ((0.5 * cos(phi1)) - t_4)))));
} else if (phi1 <= 1.2e-23) {
tmp = R * (2.0 * atan2(t_2, sqrt(((0.5 + (0.5 * cos(phi2))) - (cos(phi2) * t_3)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1))
t_3 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_4 = cos(phi1) * t_3
if (phi1 <= (-3000000000000.0d0)) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((0.5d0 + ((0.5d0 * cos(phi1)) - t_4)))))
else if (phi1 <= 1.2d-23) then
tmp = r * (2.0d0 * atan2(t_2, sqrt(((0.5d0 + (0.5d0 * cos(phi2))) - (cos(phi2) * t_3)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - t_1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_2 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1));
double t_3 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_4 = Math.cos(phi1) * t_3;
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((0.5 + ((0.5 * Math.cos(phi1)) - t_4)))));
} else if (phi1 <= 1.2e-23) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt(((0.5 + (0.5 * Math.cos(phi2))) - (Math.cos(phi2) * t_3)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_2 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)) t_3 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_4 = math.cos(phi1) * t_3 tmp = 0 if phi1 <= -3000000000000.0: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((0.5 + ((0.5 * math.cos(phi1)) - t_4))))) elif phi1 <= 1.2e-23: tmp = R * (2.0 * math.atan2(t_2, math.sqrt(((0.5 + (0.5 * math.cos(phi2))) - (math.cos(phi2) * t_3))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_2 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)) t_3 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_4 = Float64(cos(phi1) * t_3) tmp = 0.0 if (phi1 <= -3000000000000.0) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(0.5 + Float64(Float64(0.5 * cos(phi1)) - t_4)))))); elseif (phi1 <= 1.2e-23) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(Float64(0.5 + Float64(0.5 * cos(phi2))) - Float64(cos(phi2) * t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) - t_1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)); t_3 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_4 = cos(phi1) * t_3; tmp = 0.0; if (phi1 <= -3000000000000.0) tmp = R * (2.0 * atan2(t_2, sqrt((0.5 + ((0.5 * cos(phi1)) - t_4))))); elseif (phi1 <= 1.2e-23) tmp = R * (2.0 * atan2(t_2, sqrt(((0.5 + (0.5 * cos(phi2))) - (cos(phi2) * t_3))))); else tmp = R * (2.0 * atan2(sqrt((t_4 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]}, If[LessEqual[phi1, -3000000000000.0], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(0.5 + N[(N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.2e-23], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[(0.5 + N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
t_2 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}\\
t_3 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_4 := \cos \phi_1 \cdot t\_3\\
\mathbf{if}\;\phi_1 \leq -3000000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{0.5 + \left(0.5 \cdot \cos \phi_1 - t\_4\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.2 \cdot 10^{-23}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{\left(0.5 + 0.5 \cdot \cos \phi_2\right) - \cos \phi_2 \cdot t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12Initial program 44.9%
associate-*l*44.9%
Simplified44.8%
unpow247.1%
sin-mult47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
Applied egg-rr44.9%
div-sub47.1%
+-inverses47.1%
cos-047.1%
metadata-eval47.1%
distribute-lft-out47.1%
metadata-eval47.1%
*-rgt-identity47.1%
Simplified44.9%
Taylor expanded in phi2 around 0 46.2%
associate--l+46.2%
*-commutative46.2%
Simplified46.2%
if -3e12 < phi1 < 1.19999999999999998e-23Initial program 76.6%
associate-*l*76.6%
Simplified76.6%
unpow276.7%
sin-mult71.0%
div-inv71.0%
metadata-eval71.0%
div-inv71.0%
metadata-eval71.0%
div-inv71.0%
metadata-eval71.0%
div-inv71.0%
metadata-eval71.0%
Applied egg-rr76.7%
div-sub71.0%
+-inverses71.0%
cos-071.0%
metadata-eval71.0%
distribute-lft-out71.0%
metadata-eval71.0%
*-rgt-identity71.0%
Simplified76.7%
Taylor expanded in phi1 around 0 76.7%
cos-neg76.7%
*-commutative76.7%
Simplified76.7%
if 1.19999999999999998e-23 < phi1 Initial program 49.4%
associate-*l*49.4%
Simplified49.4%
unpow250.8%
sin-mult50.8%
div-inv50.8%
metadata-eval50.8%
div-inv50.8%
metadata-eval50.8%
div-inv50.8%
metadata-eval50.8%
div-inv50.8%
metadata-eval50.8%
Applied egg-rr49.4%
div-sub50.8%
+-inverses50.8%
cos-050.8%
metadata-eval50.8%
distribute-lft-out50.8%
metadata-eval50.8%
*-rgt-identity50.8%
Simplified49.4%
Taylor expanded in phi2 around 0 50.0%
Final simplification61.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))))))
(if (or (<= phi1 -3000000000000.0) (not (<= phi1 6e-20)))
(*
R
(*
2.0
(atan2 t_2 (sqrt (+ 0.5 (- (* 0.5 (cos phi1)) (* (cos phi1) t_0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- (+ 0.5 (* 0.5 (cos phi2))) (* (cos phi2) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1))));
double tmp;
if ((phi1 <= -3000000000000.0) || !(phi1 <= 6e-20)) {
tmp = R * (2.0 * atan2(t_2, sqrt((0.5 + ((0.5 * cos(phi1)) - (cos(phi1) * t_0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt(((0.5 + (0.5 * cos(phi2))) - (cos(phi2) * t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1))))
if ((phi1 <= (-3000000000000.0d0)) .or. (.not. (phi1 <= 6d-20))) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((0.5d0 + ((0.5d0 * cos(phi1)) - (cos(phi1) * t_0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt(((0.5d0 + (0.5d0 * cos(phi2))) - (cos(phi2) * t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1))));
double tmp;
if ((phi1 <= -3000000000000.0) || !(phi1 <= 6e-20)) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((0.5 + ((0.5 * Math.cos(phi1)) - (Math.cos(phi1) * t_0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt(((0.5 + (0.5 * Math.cos(phi2))) - (Math.cos(phi2) * t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)))) tmp = 0 if (phi1 <= -3000000000000.0) or not (phi1 <= 6e-20): tmp = R * (2.0 * math.atan2(t_2, math.sqrt((0.5 + ((0.5 * math.cos(phi1)) - (math.cos(phi1) * t_0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt(((0.5 + (0.5 * math.cos(phi2))) - (math.cos(phi2) * t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)))) tmp = 0.0 if ((phi1 <= -3000000000000.0) || !(phi1 <= 6e-20)) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(0.5 + Float64(Float64(0.5 * cos(phi1)) - Float64(cos(phi1) * t_0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(Float64(0.5 + Float64(0.5 * cos(phi2))) - Float64(cos(phi2) * t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))); tmp = 0.0; if ((phi1 <= -3000000000000.0) || ~((phi1 <= 6e-20))) tmp = R * (2.0 * atan2(t_2, sqrt((0.5 + ((0.5 * cos(phi1)) - (cos(phi1) * t_0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt(((0.5 + (0.5 * cos(phi2))) - (cos(phi2) * t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -3000000000000.0], N[Not[LessEqual[phi1, 6e-20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(0.5 + N[(N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(N[(0.5 + N[(0.5 * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)}\\
\mathbf{if}\;\phi_1 \leq -3000000000000 \lor \neg \left(\phi_1 \leq 6 \cdot 10^{-20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{0.5 + \left(0.5 \cdot \cos \phi_1 - \cos \phi_1 \cdot t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_2}{\sqrt{\left(0.5 + 0.5 \cdot \cos \phi_2\right) - \cos \phi_2 \cdot t\_0}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12 or 6.00000000000000057e-20 < phi1 Initial program 47.1%
associate-*l*47.1%
Simplified47.0%
unpow249.0%
sin-mult49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
div-inv49.0%
metadata-eval49.0%
Applied egg-rr47.1%
div-sub49.0%
+-inverses49.0%
cos-049.0%
metadata-eval49.0%
distribute-lft-out49.0%
metadata-eval49.0%
*-rgt-identity49.0%
Simplified47.1%
Taylor expanded in phi2 around 0 48.1%
associate--l+48.1%
*-commutative48.1%
Simplified48.1%
if -3e12 < phi1 < 6.00000000000000057e-20Initial program 76.2%
associate-*l*76.1%
Simplified76.2%
unpow276.2%
sin-mult70.6%
div-inv70.6%
metadata-eval70.6%
div-inv70.6%
metadata-eval70.6%
div-inv70.6%
metadata-eval70.6%
div-inv70.6%
metadata-eval70.6%
Applied egg-rr76.2%
div-sub70.6%
+-inverses70.6%
cos-070.6%
metadata-eval70.6%
distribute-lft-out70.6%
metadata-eval70.6%
*-rgt-identity70.6%
Simplified76.2%
Taylor expanded in phi1 around 0 76.2%
cos-neg76.2%
*-commutative76.2%
Simplified76.2%
Final simplification61.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt
(+
0.5
(-
(* 0.5 (cos phi1))
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((0.5 + ((0.5 * cos(phi1)) - (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((0.5d0 + ((0.5d0 * cos(phi1)) - (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)))), Math.sqrt((0.5 + ((0.5 * Math.cos(phi1)) - (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))), math.sqrt((0.5 + ((0.5 * math.cos(phi1)) - (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt(Float64(0.5 + Float64(Float64(0.5 * cos(phi1)) - Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((0.5 + ((0.5 * cos(phi1)) - (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(0.5 + N[(N[(0.5 * N[Cos[phi1], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{0.5 + \left(0.5 \cdot \cos \phi_1 - \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
unpow261.6%
sin-mult59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
Applied egg-rr60.6%
div-sub59.0%
+-inverses59.0%
cos-059.0%
metadata-eval59.0%
distribute-lft-out59.0%
metadata-eval59.0%
*-rgt-identity59.0%
Simplified60.6%
Taylor expanded in phi2 around 0 48.5%
associate--l+48.5%
*-commutative48.5%
Simplified48.5%
Final simplification48.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
Taylor expanded in phi1 around 0 39.6%
Taylor expanded in phi2 around 0 34.2%
Final simplification34.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
(atan2
(+ t_0 (/ (* -0.25 (* phi1 phi2)) t_0))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
(* t_1 t_1)
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(* R 2.0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return atan2((t_0 + ((-0.25 * (phi1 * phi2)) / t_0)), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), (t_1 * t_1), (0.5 - (cos((phi1 - phi2)) / 2.0)))))) * (R * 2.0);
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(atan(Float64(t_0 + Float64(Float64(-0.25 * Float64(phi1 * phi2)) / t_0)), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), Float64(t_1 * t_1), Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))))) * Float64(R * 2.0)) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[ArcTan[N[(t$95$0 + N[(N[(-0.25 * N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\tan^{-1}_* \frac{t\_0 + \frac{-0.25 \cdot \left(\phi_1 \cdot \phi_2\right)}{t\_0}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_1 \cdot t\_1, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*r*60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 15.9%
associate-*r/15.9%
*-commutative15.9%
Simplified15.9%
unpow261.6%
sin-mult59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
div-inv59.0%
metadata-eval59.0%
Applied egg-rr15.9%
div-sub59.0%
+-inverses59.0%
cos-059.0%
metadata-eval59.0%
distribute-lft-out59.0%
metadata-eval59.0%
*-rgt-identity59.0%
Simplified15.9%
Final simplification15.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
(* R 2.0)
(atan2
(+ t_0 (/ (* -0.25 (* phi1 phi2)) t_0))
(sqrt
(-
1.0
(fma (cos phi2) (* t_1 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((0.5 * (lambda1 - lambda2)));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return (R * 2.0) * atan2((t_0 + ((-0.25 * (phi1 * phi2)) / t_0)), sqrt((1.0 - fma(cos(phi2), (t_1 * t_1), pow(sin(((phi1 - phi2) / 2.0)), 2.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(Float64(R * 2.0) * atan(Float64(t_0 + Float64(Float64(-0.25 * Float64(phi1 * phi2)) / t_0)), sqrt(Float64(1.0 - fma(cos(phi2), Float64(t_1 * 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[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[(t$95$0 + N[(N[(-0.25 * N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{t\_0 + \frac{-0.25 \cdot \left(\phi_1 \cdot \phi_2\right)}{t\_0}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2, t\_1 \cdot t\_1, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}
\end{array}
\end{array}
Initial program 60.6%
associate-*r*60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 15.9%
associate-*r/15.9%
*-commutative15.9%
Simplified15.9%
Taylor expanded in phi1 around 0 14.9%
Final simplification14.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- lambda1 lambda2)))
(sqrt
(-
1.0
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (lambda1 - lambda2))), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 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(sin((0.5d0 * (lambda1 - lambda2))), sqrt((1.0d0 - ((cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 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.sin((0.5 * (lambda1 - lambda2))), Math.sqrt((1.0 - ((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (lambda1 - lambda2))), math.sqrt((1.0 - ((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(lambda1 - lambda2))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (lambda1 - lambda2))), sqrt((1.0 - ((cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}{\sqrt{1 - \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right)
\end{array}
Initial program 60.6%
Taylor expanded in lambda2 around 0 39.2%
associate-*r*39.2%
Simplified39.2%
Taylor expanded in phi2 around 0 28.6%
Taylor expanded in phi1 around 0 9.3%
Taylor expanded in lambda2 around 0 14.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- lambda1 lambda2)))
(sqrt
(-
1.0
(+
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)
(*
-0.5
(*
lambda2
(* (cos phi1) (* (cos phi2) (sin (* lambda2 -0.5)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (lambda1 - lambda2))), sqrt((1.0 - (pow(sin((0.5 * (phi1 - phi2))), 2.0) + (-0.5 * (lambda2 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5)))))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin((0.5d0 * (lambda1 - lambda2))), sqrt((1.0d0 - ((sin((0.5d0 * (phi1 - phi2))) ** 2.0d0) + ((-0.5d0) * (lambda2 * (cos(phi1) * (cos(phi2) * sin((lambda2 * (-0.5d0))))))))))))
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 * (lambda1 - lambda2))), Math.sqrt((1.0 - (Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0) + (-0.5 * (lambda2 * (Math.cos(phi1) * (Math.cos(phi2) * Math.sin((lambda2 * -0.5)))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (lambda1 - lambda2))), math.sqrt((1.0 - (math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) + (-0.5 * (lambda2 * (math.cos(phi1) * (math.cos(phi2) * math.sin((lambda2 * -0.5)))))))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(lambda1 - lambda2))), sqrt(Float64(1.0 - Float64((sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0) + Float64(-0.5 * Float64(lambda2 * Float64(cos(phi1) * Float64(cos(phi2) * sin(Float64(lambda2 * -0.5)))))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (lambda1 - lambda2))), sqrt((1.0 - ((sin((0.5 * (phi1 - phi2))) ^ 2.0) + (-0.5 * (lambda2 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5))))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $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[(-0.5 * N[(lambda2 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $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(\lambda_1 - \lambda_2\right)\right)}{\sqrt{1 - \left({\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2} + -0.5 \cdot \left(\lambda_2 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)\right)\right)}}\right)
\end{array}
Initial program 60.6%
Taylor expanded in lambda2 around 0 39.2%
associate-*r*39.2%
Simplified39.2%
Taylor expanded in phi2 around 0 28.6%
Taylor expanded in phi1 around 0 9.3%
Taylor expanded in lambda1 around 0 7.4%
Final simplification7.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2)))))
(*
R
(*
2.0
(atan2
t_0
(sqrt
(*
0.5
(*
(* (cos phi1) lambda2)
(* t_0 (* (cos phi2) (cos (* 0.5 lambda1))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
return R * (2.0 * atan2(t_0, sqrt((0.5 * ((cos(phi1) * lambda2) * (t_0 * (cos(phi2) * cos((0.5 * lambda1)))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin((0.5d0 * (lambda1 - lambda2)))
code = r * (2.0d0 * atan2(t_0, sqrt((0.5d0 * ((cos(phi1) * lambda2) * (t_0 * (cos(phi2) * cos((0.5d0 * lambda1)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * (lambda1 - lambda2)));
return R * (2.0 * Math.atan2(t_0, Math.sqrt((0.5 * ((Math.cos(phi1) * lambda2) * (t_0 * (Math.cos(phi2) * Math.cos((0.5 * lambda1)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (lambda1 - lambda2))) return R * (2.0 * math.atan2(t_0, math.sqrt((0.5 * ((math.cos(phi1) * lambda2) * (t_0 * (math.cos(phi2) * math.cos((0.5 * lambda1)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(0.5 * Float64(Float64(cos(phi1) * lambda2) * Float64(t_0 * Float64(cos(phi2) * cos(Float64(0.5 * lambda1)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))); tmp = R * (2.0 * atan2(t_0, sqrt((0.5 * ((cos(phi1) * lambda2) * (t_0 * (cos(phi2) * cos((0.5 * lambda1))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(0.5 * N[(N[(N[Cos[phi1], $MachinePrecision] * lambda2), $MachinePrecision] * N[(t$95$0 * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{0.5 \cdot \left(\left(\cos \phi_1 \cdot \lambda_2\right) \cdot \left(t\_0 \cdot \left(\cos \phi_2 \cdot \cos \left(0.5 \cdot \lambda_1\right)\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
Taylor expanded in lambda2 around 0 39.2%
associate-*r*39.2%
Simplified39.2%
Taylor expanded in phi2 around 0 28.6%
Taylor expanded in phi1 around 0 9.3%
Taylor expanded in lambda2 around inf 4.4%
*-commutative4.4%
sub-neg4.4%
neg-mul-14.4%
*-commutative4.4%
associate-*r*4.4%
associate-*r*4.4%
*-commutative4.4%
Simplified4.4%
Final simplification4.4%
herbie shell --seed 2024137
(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))))))))))