
(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 26 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_0 (* t_1 t_1)))
(t_3
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_4 (- 1.0 t_3)))
(if (or (<= lambda2 -0.61) (not (<= lambda2 0.0032)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)))
(sqrt (- t_4 t_2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_2))
(sqrt (- t_4 (* t_0 (* t_1 (sin (* lambda1 0.5))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_4 = 1.0 - t_3;
double tmp;
if ((lambda2 <= -0.61) || !(lambda2 <= 0.0032)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0))), sqrt((t_4 - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((t_4 - (t_0 * (t_1 * sin((lambda1 * 0.5))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 * (t_1 * t_1)
t_3 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_4 = 1.0d0 - t_3
if ((lambda2 <= (-0.61d0)) .or. (.not. (lambda2 <= 0.0032d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))) + (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0))), sqrt((t_4 - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_2)), sqrt((t_4 - (t_0 * (t_1 * sin((lambda1 * 0.5d0))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_4 = 1.0 - t_3;
double tmp;
if ((lambda2 <= -0.61) || !(lambda2 <= 0.0032)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))) + Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0))), Math.sqrt((t_4 - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_2)), Math.sqrt((t_4 - (t_0 * (t_1 * Math.sin((lambda1 * 0.5))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 * (t_1 * t_1) t_3 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_4 = 1.0 - t_3 tmp = 0 if (lambda2 <= -0.61) or not (lambda2 <= 0.0032): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) + math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0))), math.sqrt((t_4 - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_2)), math.sqrt((t_4 - (t_0 * (t_1 * math.sin((lambda1 * 0.5)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 * Float64(t_1 * t_1)) t_3 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_4 = Float64(1.0 - t_3) tmp = 0.0 if ((lambda2 <= -0.61) || !(lambda2 <= 0.0032)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0))), sqrt(Float64(t_4 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_2)), sqrt(Float64(t_4 - Float64(t_0 * Float64(t_1 * sin(Float64(lambda1 * 0.5))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 * (t_1 * t_1); t_3 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_4 = 1.0 - t_3; tmp = 0.0; if ((lambda2 <= -0.61) || ~((lambda2 <= 0.0032))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))) + (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0))), sqrt((t_4 - t_2)))); else tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((t_4 - (t_0 * (t_1 * sin((lambda1 * 0.5)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$3), $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.61], N[Not[LessEqual[lambda2, 0.0032]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - N[(t$95$0 * N[(t$95$1 * N[Sin[N[(lambda1 * 0.5), $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)\\
t_2 := t\_0 \cdot \left(t\_1 \cdot t\_1\right)\\
t_3 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_4 := 1 - t\_3\\
\mathbf{if}\;\lambda_2 \leq -0.61 \lor \neg \left(\lambda_2 \leq 0.0032\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}}}{\sqrt{t\_4 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_2}}{\sqrt{t\_4 - t\_0 \cdot \left(t\_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -0.609999999999999987 or 0.00320000000000000015 < lambda2 Initial program 46.7%
associate-*l*46.7%
Simplified46.7%
div-sub46.7%
sin-diff47.7%
Applied egg-rr47.7%
div-sub46.7%
sin-diff47.7%
Applied egg-rr60.9%
Taylor expanded in lambda1 around 0 61.0%
if -0.609999999999999987 < lambda2 < 0.00320000000000000015Initial program 69.0%
associate-*l*69.0%
Simplified69.0%
div-sub69.0%
sin-diff70.0%
Applied egg-rr70.0%
div-sub69.0%
sin-diff70.0%
Applied egg-rr96.6%
Taylor expanded in lambda2 around 0 96.6%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt
(-
(-
1.0
(expm1
(log1p
(pow
(fma
(cos (* phi2 0.5))
(sin (* phi1 0.5))
(* (cos (* phi1 0.5)) (sin (* phi2 -0.5))))
2.0))))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt(((1.0 - expm1(log1p(pow(fma(cos((phi2 * 0.5)), sin((phi1 * 0.5)), (cos((phi1 * 0.5)) * sin((phi2 * -0.5)))), 2.0)))) - t_1))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - expm1(log1p((fma(cos(Float64(phi2 * 0.5)), sin(Float64(phi1 * 0.5)), Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * -0.5)))) ^ 2.0)))) - t_1))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(Exp[N[Log[1 + N[Power[N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{\left(1 - \mathsf{expm1}\left(\mathsf{log1p}\left({\left(\mathsf{fma}\left(\cos \left(\phi_2 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}\right)\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*l*57.0%
Simplified57.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr58.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr77.3%
Taylor expanded in phi1 around inf 77.3%
fma-neg77.4%
*-commutative77.4%
*-commutative77.4%
*-commutative77.4%
distribute-lft-neg-in77.4%
*-commutative77.4%
*-commutative77.4%
sin-neg77.4%
distribute-rgt-neg-in77.4%
metadata-eval77.4%
*-commutative77.4%
Simplified77.4%
expm1-log1p-u77.4%
*-commutative77.4%
*-commutative77.4%
Applied egg-rr77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt
(-
(-
1.0
(pow
(fma
(cos (* phi2 0.5))
(sin (* phi1 0.5))
(* (cos (* phi1 0.5)) (sin (* phi2 -0.5))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + t_1)), sqrt(((1.0 - pow(fma(cos((phi2 * 0.5)), sin((phi1 * 0.5)), (cos((phi1 * 0.5)) * sin((phi2 * -0.5)))), 2.0)) - t_1))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (fma(cos(Float64(phi2 * 0.5)), sin(Float64(phi1 * 0.5)), Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * -0.5)))) ^ 2.0)) - t_1))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(\cos \left(\phi_2 \cdot 0.5\right), \sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*l*57.0%
Simplified57.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr58.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr77.3%
Taylor expanded in phi1 around inf 77.3%
fma-neg77.4%
*-commutative77.4%
*-commutative77.4%
*-commutative77.4%
distribute-lft-neg-in77.4%
*-commutative77.4%
*-commutative77.4%
sin-neg77.4%
distribute-rgt-neg-in77.4%
metadata-eval77.4%
*-commutative77.4%
Simplified77.4%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_0 (* t_1 t_1)))
(t_3
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_4 (- 1.0 t_3)))
(if (or (<= lambda1 -1.38e-5) (not (<= lambda1 0.034)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))
(sqrt (- t_4 t_2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_2))
(sqrt (- t_4 (* t_0 (* t_1 (sin (* lambda2 -0.5))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_4 = 1.0 - t_3;
double tmp;
if ((lambda1 <= -1.38e-5) || !(lambda1 <= 0.034)) {
tmp = R * (2.0 * atan2(sqrt((pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0) + (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))), sqrt((t_4 - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((t_4 - (t_0 * (t_1 * sin((lambda2 * -0.5))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 * (t_1 * t_1)
t_3 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_4 = 1.0d0 - t_3
if ((lambda1 <= (-1.38d-5)) .or. (.not. (lambda1 <= 0.034d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))), sqrt((t_4 - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_2)), sqrt((t_4 - (t_0 * (t_1 * sin((lambda2 * (-0.5d0)))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_4 = 1.0 - t_3;
double tmp;
if ((lambda1 <= -1.38e-5) || !(lambda1 <= 0.034)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))), Math.sqrt((t_4 - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_2)), Math.sqrt((t_4 - (t_0 * (t_1 * Math.sin((lambda2 * -0.5))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 * (t_1 * t_1) t_3 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_4 = 1.0 - t_3 tmp = 0 if (lambda1 <= -1.38e-5) or not (lambda1 <= 0.034): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))), math.sqrt((t_4 - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_2)), math.sqrt((t_4 - (t_0 * (t_1 * math.sin((lambda2 * -0.5)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 * Float64(t_1 * t_1)) t_3 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_4 = Float64(1.0 - t_3) tmp = 0.0 if ((lambda1 <= -1.38e-5) || !(lambda1 <= 0.034)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))), sqrt(Float64(t_4 - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_2)), sqrt(Float64(t_4 - Float64(t_0 * Float64(t_1 * sin(Float64(lambda2 * -0.5))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 * (t_1 * t_1); t_3 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_4 = 1.0 - t_3; tmp = 0.0; if ((lambda1 <= -1.38e-5) || ~((lambda1 <= 0.034))) tmp = R * (2.0 * atan2(sqrt(((((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0) + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))))), sqrt((t_4 - t_2)))); else tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt((t_4 - (t_0 * (t_1 * sin((lambda2 * -0.5)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$3), $MachinePrecision]}, If[Or[LessEqual[lambda1, -1.38e-5], N[Not[LessEqual[lambda1, 0.034]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - N[(t$95$0 * N[(t$95$1 * N[Sin[N[(lambda2 * -0.5), $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)\\
t_2 := t\_0 \cdot \left(t\_1 \cdot t\_1\right)\\
t_3 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_4 := 1 - t\_3\\
\mathbf{if}\;\lambda_1 \leq -1.38 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 0.034\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{\sqrt{t\_4 - t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_2}}{\sqrt{t\_4 - t\_0 \cdot \left(t\_1 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.38e-5 or 0.034000000000000002 < lambda1 Initial program 43.0%
associate-*l*43.1%
Simplified43.1%
div-sub43.1%
sin-diff44.1%
Applied egg-rr44.1%
div-sub43.1%
sin-diff44.1%
Applied egg-rr56.7%
Taylor expanded in lambda2 around 0 56.8%
if -1.38e-5 < lambda1 < 0.034000000000000002Initial program 70.3%
associate-*l*70.3%
Simplified70.3%
div-sub70.3%
sin-diff71.2%
Applied egg-rr71.2%
div-sub70.3%
sin-diff71.2%
Applied egg-rr97.0%
Taylor expanded in lambda1 around 0 97.0%
Final simplification77.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(* (* (cos phi1) (cos phi2)) (* t_0 t_0)))))
(t_2
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)))
(if (or (<= lambda2 -0.61) (not (<= lambda2 0.0032)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
t_2))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_2 (* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double t_2 = pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0);
double tmp;
if ((lambda2 <= -0.61) || !(lambda2 <= 0.0032)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + t_2)), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
t_2 = ((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0
if ((lambda2 <= (-0.61d0)) .or. (.not. (lambda2 <= 0.0032d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))) + t_2)), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double t_2 = Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0);
double tmp;
if ((lambda2 <= -0.61) || !(lambda2 <= 0.0032)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))) + t_2)), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) t_2 = math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) tmp = 0 if (lambda2 <= -0.61) or not (lambda2 <= 0.0032): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))) + t_2)), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) t_2 = Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0 tmp = 0.0 if ((lambda2 <= -0.61) || !(lambda2 <= 0.0032)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + t_2)), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); t_2 = ((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0; tmp = 0.0; if ((lambda2 <= -0.61) || ~((lambda2 <= 0.0032))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))) + t_2)), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.61], N[Not[LessEqual[lambda2, 0.0032]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}\\
t_2 := {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
\mathbf{if}\;\lambda_2 \leq -0.61 \lor \neg \left(\lambda_2 \leq 0.0032\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + t\_2}}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{t\_1}\right)\\
\end{array}
\end{array}
if lambda2 < -0.609999999999999987 or 0.00320000000000000015 < lambda2 Initial program 46.7%
associate-*l*46.7%
Simplified46.7%
div-sub46.7%
sin-diff47.7%
Applied egg-rr47.7%
div-sub46.7%
sin-diff47.7%
Applied egg-rr60.9%
Taylor expanded in lambda1 around 0 61.0%
if -0.609999999999999987 < lambda2 < 0.00320000000000000015Initial program 69.0%
associate-*l*69.0%
Simplified69.0%
div-sub69.0%
sin-diff70.0%
Applied egg-rr70.0%
div-sub69.0%
sin-diff70.0%
Applied egg-rr96.6%
Taylor expanded in lambda2 around 0 95.8%
Final simplification77.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi2 0.5)))
(t_1 (sin (/ phi1 2.0)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) (* t_2 t_2)))
(t_4 (cos (* phi2 0.5)))
(t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_6 (cos (/ phi1 2.0)))
(t_7
(sqrt
(-
(-
1.0
(pow
(- (* t_1 (cos (/ phi2 2.0))) (* t_6 (sin (/ phi2 2.0))))
2.0))
t_3))))
(if (<= lambda1 -2.8e-10)
(* R (* 2.0 (atan2 (sqrt (+ t_3 t_5)) t_7)))
(if (<= lambda1 2.85e-21)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
(pow
(- (* t_4 (sin (* phi1 0.5))) (* (cos (* phi1 0.5)) t_0))
2.0)))
t_7)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (fma t_1 t_4 (* t_6 (- t_0))) 2.0)))
(sqrt (- (- 1.0 t_5) t_3)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi2 * 0.5));
double t_1 = sin((phi1 / 2.0));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * (t_2 * t_2);
double t_4 = cos((phi2 * 0.5));
double t_5 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_6 = cos((phi1 / 2.0));
double t_7 = sqrt(((1.0 - pow(((t_1 * cos((phi2 / 2.0))) - (t_6 * sin((phi2 / 2.0)))), 2.0)) - t_3));
double tmp;
if (lambda1 <= -2.8e-10) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_5)), t_7));
} else if (lambda1 <= 2.85e-21) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))) + pow(((t_4 * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * t_0)), 2.0))), t_7));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(fma(t_1, t_4, (t_6 * -t_0)), 2.0))), sqrt(((1.0 - t_5) - t_3))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * 0.5)) t_1 = sin(Float64(phi1 / 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_2 * t_2)) t_4 = cos(Float64(phi2 * 0.5)) t_5 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_6 = cos(Float64(phi1 / 2.0)) t_7 = sqrt(Float64(Float64(1.0 - (Float64(Float64(t_1 * cos(Float64(phi2 / 2.0))) - Float64(t_6 * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_3)) tmp = 0.0 if (lambda1 <= -2.8e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_5)), t_7))); elseif (lambda1 <= 2.85e-21) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))) + (Float64(Float64(t_4 * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * t_0)) ^ 2.0))), t_7))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (fma(t_1, t_4, Float64(t_6 * Float64(-t_0))) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_5) - t_3))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 / 2.0), $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] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$6 = N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$7 = N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(t$95$1 * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(t$95$6 * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -2.8e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$5), $MachinePrecision]], $MachinePrecision] / t$95$7], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 2.85e-21], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(t$95$4 * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$7], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[(t$95$1 * t$95$4 + N[(t$95$6 * (-t$95$0)), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$5), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_2 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\phi_1}{2}\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := \cos \left(\phi_2 \cdot 0.5\right)\\
t_5 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_6 := \cos \left(\frac{\phi_1}{2}\right)\\
t_7 := \sqrt{\left(1 - {\left(t\_1 \cdot \cos \left(\frac{\phi_2}{2}\right) - t\_6 \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_3}\\
\mathbf{if}\;\lambda_1 \leq -2.8 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_5}}{t\_7}\right)\\
\mathbf{elif}\;\lambda_1 \leq 2.85 \cdot 10^{-21}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right) + {\left(t\_4 \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot t\_0\right)}^{2}}}{t\_7}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\left(\mathsf{fma}\left(t\_1, t\_4, t\_6 \cdot \left(-t\_0\right)\right)\right)}^{2}}}{\sqrt{\left(1 - t\_5\right) - t\_3}}\right)\\
\end{array}
\end{array}
if lambda1 < -2.80000000000000015e-10Initial program 45.0%
associate-*l*45.0%
Simplified45.0%
div-sub45.0%
sin-diff46.5%
Applied egg-rr46.5%
if -2.80000000000000015e-10 < lambda1 < 2.8499999999999998e-21Initial program 69.3%
associate-*l*69.2%
Simplified69.3%
div-sub69.3%
sin-diff70.3%
Applied egg-rr70.3%
div-sub69.3%
sin-diff70.3%
Applied egg-rr98.2%
Taylor expanded in lambda1 around 0 96.1%
if 2.8499999999999998e-21 < lambda1 Initial program 47.2%
associate-*l*47.2%
Simplified47.2%
div-sub47.2%
sin-diff47.5%
Applied egg-rr48.1%
fma-neg48.1%
*-rgt-identity48.1%
associate-/l*48.1%
metadata-eval48.1%
*-commutative48.1%
distribute-rgt-neg-in48.1%
*-rgt-identity48.1%
associate-/l*48.1%
metadata-eval48.1%
Simplified48.1%
Final simplification70.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_2)) (sqrt (- (- 1.0 t_0) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
return R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
code = r * (2.0d0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0d0 - t_0) - t_2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt(((1.0 - t_0) - t_2))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) return R * (2.0 * math.atan2(math.sqrt((t_0 + t_2)), math.sqrt(((1.0 - t_0) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(Float64(1.0 - t_0) - t_2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt(((1.0 - t_0) - t_2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_1 \cdot t\_1\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2}}{\sqrt{\left(1 - t\_0\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*l*57.0%
Simplified57.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr58.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr77.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*l*57.0%
Simplified57.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr58.0%
Final simplification58.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
t_1))
(sqrt (- (+ 1.0 (- (/ (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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((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 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((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 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((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 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((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((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 + 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 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((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[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(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{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_1}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*l*57.0%
Simplified57.0%
div-sub57.0%
sin-diff58.0%
Applied egg-rr57.8%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr57.8%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified57.8%
Final simplification57.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_0))))
(sqrt
(fabs
(-
1.0
(fma
(pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)
t_1
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), sqrt(fabs((1.0 - fma(pow(sin(((lambda1 - lambda2) * 0.5)), 2.0), t_1, pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_0)))), sqrt(abs(Float64(1.0 - fma((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0), t_1, (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_0\right)}}{\sqrt{\left|1 - \mathsf{fma}\left({\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, t\_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*r*57.0%
+-commutative57.0%
fma-undefine57.0%
add-sqr-sqrt57.0%
pow1/257.0%
Applied egg-rr57.3%
unpow1/257.3%
unpow257.3%
rem-sqrt-square57.3%
*-commutative57.3%
*-commutative57.3%
Simplified57.3%
Final simplification57.3%
(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_1 t_1)))
(*
(atan2
(sqrt (fma t_0 t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (fma t_0 t_2 (- 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 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * t_1;
return atan2(sqrt(fma(t_0, t_2, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_0, t_2, (0.5 - (cos((phi1 - phi2)) / 2.0)))))) * (R * 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)) t_2 = Float64(t_1 * t_1) return Float64(atan(sqrt(fma(t_0, t_2, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, t_2, 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[(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$1 * t$95$1), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(t$95$0 * t$95$2 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 * t$95$2 + 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 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t\_1 \cdot t\_1\\
\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_0, t\_2, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t\_0, t\_2, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*r*57.0%
*-commutative57.0%
Simplified57.0%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr57.0%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified57.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= t_0 -2e-30) (not (<= t_0 5e-48)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) t_1) (- 0.5 (/ (cos phi1) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((t_0 <= -2e-30) || !(t_0 <= 5e-48)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_1) + (0.5 - (cos(phi1) / 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if ((t_0 <= (-2d-30)) .or. (.not. (t_0 <= 5d-48))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_1) + (0.5d0 - (cos(phi1) / 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))))
else
tmp = r * (2.0d0 * atan2(((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((t_0 <= -2e-30) || !(t_0 <= 5e-48)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_1) + (0.5 - (Math.cos(phi1) / 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (t_0 <= -2e-30) or not (t_0 <= 5e-48): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_1) + (0.5 - (math.cos(phi1) / 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) else: tmp = R * (2.0 * math.atan2(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((t_0 <= -2e-30) || !(t_0 <= 5e-48)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_1) + Float64(0.5 - Float64(cos(phi1) / 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if ((t_0 <= -2e-30) || ~((t_0 <= 5e-48))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_1) + (0.5 - (cos(phi1) / 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); else tmp = R * (2.0 * atan2(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[t$95$0, -2e-30], N[Not[LessEqual[t$95$0, 5e-48]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[(0.5 - N[(N[Cos[phi1], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-30} \lor \neg \left(t\_0 \leq 5 \cdot 10^{-48}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_1 + \left(0.5 - \frac{\cos \phi_1}{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -2e-30 or 4.9999999999999999e-48 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 54.2%
Taylor expanded in phi1 around 0 44.9%
+-commutative44.9%
associate--r+44.9%
unpow244.9%
1-sub-sin44.9%
unpow244.9%
Simplified44.9%
unpow255.1%
sin-mult55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
Applied egg-rr44.9%
div-sub55.1%
+-inverses55.1%
cos-055.1%
metadata-eval55.1%
distribute-lft-out55.1%
metadata-eval55.1%
*-rgt-identity55.1%
Simplified44.9%
Taylor expanded in phi2 around 0 27.4%
Taylor expanded in phi2 around 0 30.8%
if -2e-30 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 4.9999999999999999e-48Initial program 71.3%
associate-*l*71.3%
Simplified71.3%
div-sub71.3%
sin-diff72.4%
Applied egg-rr71.8%
Taylor expanded in lambda1 around 0 67.9%
fma-define67.9%
Simplified67.9%
Taylor expanded in lambda2 around 0 42.9%
Final simplification32.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (sqrt (+ t_0 (* t_2 (* t_1 t_2)))))
(t_4 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_5 (* (cos phi1) t_4)))
(if (<= phi1 -9000.0)
(* R (* 2.0 (atan2 t_3 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_5)))))
(if (<= phi1 8.5e-9)
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_4))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (- 1.0 t_0) (* t_1 (* t_2 t_2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((t_0 + (t_2 * (t_1 * t_2))));
double t_4 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_5 = cos(phi1) * t_4;
double tmp;
if (phi1 <= -9000.0) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi1 * 0.5)), 2.0) - t_5))));
} else if (phi1 <= 8.5e-9) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_4)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt((t_0 + (t_2 * (t_1 * t_2))))
t_4 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_5 = cos(phi1) * t_4
if (phi1 <= (-9000.0d0)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - t_5))))
else if (phi1 <= 8.5d-9) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_4)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - t_0) - (t_1 * (t_2 * t_2))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt((t_0 + (t_2 * (t_1 * t_2))));
double t_4 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_5 = Math.cos(phi1) * t_4;
double tmp;
if (phi1 <= -9000.0) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_5))));
} else if (phi1 <= 8.5e-9) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_4)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((t_0 + (t_2 * (t_1 * t_2)))) t_4 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_5 = math.cos(phi1) * t_4 tmp = 0 if phi1 <= -9000.0: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_5)))) elif phi1 <= 8.5e-9: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_4))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64(t_0 + Float64(t_2 * Float64(t_1 * t_2)))) t_4 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_5 = Float64(cos(phi1) * t_4) tmp = 0.0 if (phi1 <= -9000.0) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_5))))); elseif (phi1 <= 8.5e-9) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_4)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - t_0) - Float64(t_1 * Float64(t_2 * t_2))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt((t_0 + (t_2 * (t_1 * t_2)))); t_4 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_5 = cos(phi1) * t_4; tmp = 0.0; if (phi1 <= -9000.0) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_5)))); elseif (phi1 <= 8.5e-9) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_4))))); else tmp = R * (2.0 * atan2(sqrt((t_5 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi1], $MachinePrecision] * t$95$4), $MachinePrecision]}, If[LessEqual[phi1, -9000.0], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 8.5e-9], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{t\_0 + t\_2 \cdot \left(t\_1 \cdot t\_2\right)}\\
t_4 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_5 := \cos \phi_1 \cdot t\_4\\
\mathbf{if}\;\phi_1 \leq -9000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t\_5}}\right)\\
\mathbf{elif}\;\phi_1 \leq 8.5 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - t\_0\right) - t\_1 \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -9e3Initial program 41.4%
Taylor expanded in phi2 around 0 42.6%
+-commutative42.6%
associate--r+42.6%
unpow242.6%
1-sub-sin42.6%
unpow242.6%
*-commutative42.6%
Simplified42.6%
if -9e3 < phi1 < 8.5e-9Initial program 77.7%
Taylor expanded in phi1 around 0 77.7%
+-commutative77.7%
associate--r+77.7%
unpow277.7%
1-sub-sin77.7%
unpow277.7%
Simplified77.7%
if 8.5e-9 < phi1 Initial program 38.0%
associate-*l*38.0%
Simplified38.0%
div-sub38.0%
sin-diff39.5%
Applied egg-rr39.5%
Taylor expanded in phi2 around 0 38.3%
Final simplification57.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 + ((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((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 + ((Math.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((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(Float64(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((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(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{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\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}
Initial program 57.0%
associate-*l*57.0%
Simplified57.0%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr57.0%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified57.0%
Final simplification57.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (- 0.5 (/ (cos (- phi1 phi2)) 2.0)) t_1))
(sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_1)), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt(((0.5d0 - (cos((phi1 - phi2)) / 2.0d0)) + t_1)), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + t_1)), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + t_1)), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + t_1)), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_1)), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_1}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 57.0%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr54.4%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified54.4%
Final simplification54.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 57.0%
associate-*l*57.0%
Simplified57.0%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr54.4%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified54.4%
Final simplification54.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -9000.0) (not (<= phi1 6.8e+33)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- (- 1.0 t_0) (* t_1 (* t_2 t_2)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_1 t_2))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -9000.0) || !(phi1 <= 6.8e+33)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * t_2)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda1 - 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 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-9000.0d0)) .or. (.not. (phi1 <= 6.8d+33))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt(((1.0d0 - t_0) - (t_1 * (t_2 * t_2))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_1 * t_2)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -9000.0) || !(phi1 <= 6.8e+33)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_1 * t_2)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -9000.0) or not (phi1 <= 6.8e+33): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_1 * t_2)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -9000.0) || !(phi1 <= 6.8e+33)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(t_1 * Float64(t_2 * t_2))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_1 * t_2)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -9000.0) || ~((phi1 <= 6.8e+33))) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * t_2)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -9000.0], N[Not[LessEqual[phi1, 6.8e+33]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -9000 \lor \neg \left(\phi_1 \leq 6.8 \cdot 10^{+33}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - t\_0\right) - t\_1 \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_1 \cdot t\_2\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -9e3 or 6.7999999999999999e33 < phi1 Initial program 39.3%
associate-*l*39.3%
Simplified39.4%
div-sub39.4%
sin-diff41.3%
Applied egg-rr40.9%
Taylor expanded in lambda1 around 0 35.4%
fma-define35.4%
Simplified35.4%
Taylor expanded in phi2 around 0 34.2%
if -9e3 < phi1 < 6.7999999999999999e33Initial program 76.0%
Taylor expanded in phi1 around 0 74.9%
+-commutative74.9%
associate--r+74.9%
unpow274.9%
1-sub-sin74.9%
unpow274.9%
Simplified74.9%
Final simplification53.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -9000.0) (not (<= phi1 8.5e-9)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* t_0 (* t_1 t_1)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_1)) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -9000.0) || !(phi1 <= 8.5e-9)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_0 * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda1 - 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) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-9000.0d0)) .or. (.not. (phi1 <= 8.5d-9))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - (t_0 * (t_1 * t_1))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -9000.0) || !(phi1 <= 8.5e-9)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_0 * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_1)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -9000.0) or not (phi1 <= 8.5e-9): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_0 * (t_1 * t_1)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_1)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -9000.0) || !(phi1 <= 8.5e-9)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(t_0 * Float64(t_1 * t_1))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -9000.0) || ~((phi1 <= 8.5e-9))) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - (t_0 * (t_1 * t_1)))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -9000.0], N[Not[LessEqual[phi1, 8.5e-9]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -9000 \lor \neg \left(\phi_1 \leq 8.5 \cdot 10^{-9}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_1\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -9e3 or 8.5e-9 < phi1 Initial program 39.6%
associate-*l*39.6%
Simplified39.6%
div-sub39.6%
sin-diff41.4%
Applied egg-rr41.1%
Taylor expanded in lambda1 around 0 34.8%
fma-define34.8%
Simplified34.8%
Taylor expanded in phi2 around 0 33.6%
if -9e3 < phi1 < 8.5e-9Initial program 77.7%
Taylor expanded in phi1 around 0 77.7%
+-commutative77.7%
associate--r+77.7%
unpow277.7%
1-sub-sin77.7%
unpow277.7%
Simplified77.7%
Taylor expanded in phi1 around 0 76.9%
Final simplification53.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi2) t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (pow (sin (* phi2 -0.5)) 2.0))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (* t_4 (* t_2 t_4))))
(if (<= phi2 -2.55e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_3))
(sqrt (- (- 1.0 (pow (sin (* phi2 0.5)) 2.0)) (* t_2 (* t_4 t_4)))))))
(if (<= phi2 3500000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_5))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 t_3))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = cos(phi2) * t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = pow(sin((phi2 * -0.5)), 2.0);
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_4 * (t_2 * t_4);
double tmp;
if (phi2 <= -2.55e-5) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt(((1.0 - pow(sin((phi2 * 0.5)), 2.0)) - (t_2 * (t_4 * t_4))))));
} else if (phi2 <= 3500000.0) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_5)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 + t_3)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi2) * t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_4 = sin(((lambda1 - lambda2) / 2.0d0))
t_5 = t_4 * (t_2 * t_4)
if (phi2 <= (-2.55d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_3)), sqrt(((1.0d0 - (sin((phi2 * 0.5d0)) ** 2.0d0)) - (t_2 * (t_4 * t_4))))))
else if (phi2 <= 3500000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_5)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_5 + t_3)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.cos(phi2) * t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_4 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_4 * (t_2 * t_4);
double tmp;
if (phi2 <= -2.55e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_3)), Math.sqrt(((1.0 - Math.pow(Math.sin((phi2 * 0.5)), 2.0)) - (t_2 * (t_4 * t_4))))));
} else if (phi2 <= 3500000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_5)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + t_3)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.cos(phi2) * t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_4 = math.sin(((lambda1 - lambda2) / 2.0)) t_5 = t_4 * (t_2 * t_4) tmp = 0 if phi2 <= -2.55e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_3)), math.sqrt(((1.0 - math.pow(math.sin((phi2 * 0.5)), 2.0)) - (t_2 * (t_4 * t_4)))))) elif phi2 <= 3500000.0: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_5)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + t_3)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi2) * t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = Float64(t_4 * Float64(t_2 * t_4)) tmp = 0.0 if (phi2 <= -2.55e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_3)), sqrt(Float64(Float64(1.0 - (sin(Float64(phi2 * 0.5)) ^ 2.0)) - Float64(t_2 * Float64(t_4 * t_4))))))); elseif (phi2 <= 3500000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_5)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + t_3)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = cos(phi2) * t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin((phi2 * -0.5)) ^ 2.0; t_4 = sin(((lambda1 - lambda2) / 2.0)); t_5 = t_4 * (t_2 * t_4); tmp = 0.0; if (phi2 <= -2.55e-5) tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt(((1.0 - (sin((phi2 * 0.5)) ^ 2.0)) - (t_2 * (t_4 * t_4)))))); elseif (phi2 <= 3500000.0) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_5)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); else tmp = R * (2.0 * atan2(sqrt((t_5 + t_3)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * N[(t$95$2 * t$95$4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -2.55e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$2 * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3500000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_2 \cdot t\_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := t\_4 \cdot \left(t\_2 \cdot t\_4\right)\\
\mathbf{if}\;\phi_2 \leq -2.55 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_3}}{\sqrt{\left(1 - {\sin \left(\phi_2 \cdot 0.5\right)}^{2}\right) - t\_2 \cdot \left(t\_4 \cdot t\_4\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 3500000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_5}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + t\_3}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t\_1}}\right)\\
\end{array}
\end{array}
if phi2 < -2.54999999999999998e-5Initial program 49.1%
associate-*l*49.1%
Simplified49.1%
div-sub49.1%
sin-diff50.4%
Applied egg-rr50.4%
Taylor expanded in phi1 around 0 48.8%
*-commutative48.8%
Simplified48.8%
Taylor expanded in phi1 around 0 49.4%
if -2.54999999999999998e-5 < phi2 < 3.5e6Initial program 72.0%
Taylor expanded in phi2 around 0 72.0%
+-commutative72.0%
associate--r+72.0%
unpow272.0%
1-sub-sin71.9%
unpow271.9%
*-commutative71.9%
Simplified71.9%
if 3.5e6 < phi2 Initial program 41.8%
Taylor expanded in phi1 around 0 42.8%
+-commutative42.8%
associate--r+42.7%
unpow242.7%
1-sub-sin42.8%
unpow242.8%
Simplified42.8%
Taylor expanded in phi1 around 0 42.8%
Final simplification57.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0)))))
(if (<= phi1 -11200.0)
(* R (* 2.0 (atan2 (sqrt (+ 0.5 (* (cos phi1) (- t_0 0.5)))) t_2)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))
(pow (sin (* phi2 -0.5)) 2.0)))
t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)));
double tmp;
if (phi1 <= -11200.0) {
tmp = R * (2.0 * atan2(sqrt((0.5 + (cos(phi1) * (t_0 - 0.5)))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + pow(sin((phi2 * -0.5)), 2.0))), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))
if (phi1 <= (-11200.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((0.5d0 + (cos(phi1) * (t_0 - 0.5d0)))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), t_2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_0)));
double tmp;
if (phi1 <= -11200.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((0.5 + (Math.cos(phi1) * (t_0 - 0.5)))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_0))) tmp = 0 if phi1 <= -11200.0: tmp = R * (2.0 * math.atan2(math.sqrt((0.5 + (math.cos(phi1) * (t_0 - 0.5)))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0))) tmp = 0.0 if (phi1 <= -11200.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(t_0 - 0.5)))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))); tmp = 0.0; if (phi1 <= -11200.0) tmp = R * (2.0 * atan2(sqrt((0.5 + (cos(phi1) * (t_0 - 0.5)))), t_2)); else tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (sin((phi2 * -0.5)) ^ 2.0))), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -11200.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;\phi_1 \leq -11200:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \cos \phi_1 \cdot \left(t\_0 - 0.5\right)}}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{t\_2}\right)\\
\end{array}
\end{array}
if phi1 < -11200Initial program 41.4%
Taylor expanded in phi1 around 0 20.5%
+-commutative20.5%
associate--r+20.5%
unpow220.5%
1-sub-sin20.5%
unpow220.5%
Simplified20.5%
unpow242.8%
sin-mult42.8%
div-inv42.8%
metadata-eval42.8%
div-inv42.8%
metadata-eval42.8%
div-inv42.8%
metadata-eval42.8%
div-inv42.8%
metadata-eval42.8%
Applied egg-rr20.5%
div-sub42.8%
+-inverses42.8%
cos-042.8%
metadata-eval42.8%
distribute-lft-out42.8%
metadata-eval42.8%
*-rgt-identity42.8%
Simplified20.5%
Taylor expanded in phi2 around 0 20.3%
Taylor expanded in phi2 around 0 21.2%
associate--l+21.2%
*-commutative21.2%
distribute-lft-out--21.2%
Simplified21.2%
if -11200 < phi1 Initial program 62.4%
Taylor expanded in phi1 around 0 55.9%
+-commutative55.9%
associate--r+55.9%
unpow255.9%
1-sub-sin55.9%
unpow255.9%
Simplified55.9%
Taylor expanded in phi1 around 0 54.4%
Final simplification45.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0)))))
(if (<= phi1 -11200.0)
(* R (* 2.0 (atan2 (sqrt (+ 0.5 (* (cos phi1) (- t_0 0.5)))) t_2)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))
(- 0.5 (/ (cos phi2) 2.0))))
t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)));
double tmp;
if (phi1 <= -11200.0) {
tmp = R * (2.0 * atan2(sqrt((0.5 + (cos(phi1) * (t_0 - 0.5)))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (0.5 - (cos(phi2) / 2.0)))), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))
if (phi1 <= (-11200.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((0.5d0 + (cos(phi1) * (t_0 - 0.5d0)))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (0.5d0 - (cos(phi2) / 2.0d0)))), t_2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_0)));
double tmp;
if (phi1 <= -11200.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((0.5 + (Math.cos(phi1) * (t_0 - 0.5)))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + (0.5 - (Math.cos(phi2) / 2.0)))), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_0))) tmp = 0 if phi1 <= -11200.0: tmp = R * (2.0 * math.atan2(math.sqrt((0.5 + (math.cos(phi1) * (t_0 - 0.5)))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + (0.5 - (math.cos(phi2) / 2.0)))), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0))) tmp = 0.0 if (phi1 <= -11200.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(t_0 - 0.5)))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + Float64(0.5 - Float64(cos(phi2) / 2.0)))), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))); tmp = 0.0; if (phi1 <= -11200.0) tmp = R * (2.0 * atan2(sqrt((0.5 + (cos(phi1) * (t_0 - 0.5)))), t_2)); else tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + (0.5 - (cos(phi2) / 2.0)))), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -11200.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[phi2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}\\
\mathbf{if}\;\phi_1 \leq -11200:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \cos \phi_1 \cdot \left(t\_0 - 0.5\right)}}{t\_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + \left(0.5 - \frac{\cos \phi_2}{2}\right)}}{t\_2}\right)\\
\end{array}
\end{array}
if phi1 < -11200Initial program 41.4%
Taylor expanded in phi1 around 0 20.5%
+-commutative20.5%
associate--r+20.5%
unpow220.5%
1-sub-sin20.5%
unpow220.5%
Simplified20.5%
unpow242.8%
sin-mult42.8%
div-inv42.8%
metadata-eval42.8%
div-inv42.8%
metadata-eval42.8%
div-inv42.8%
metadata-eval42.8%
div-inv42.8%
metadata-eval42.8%
Applied egg-rr20.5%
div-sub42.8%
+-inverses42.8%
cos-042.8%
metadata-eval42.8%
distribute-lft-out42.8%
metadata-eval42.8%
*-rgt-identity42.8%
Simplified20.5%
Taylor expanded in phi2 around 0 20.3%
Taylor expanded in phi2 around 0 21.2%
associate--l+21.2%
*-commutative21.2%
distribute-lft-out--21.2%
Simplified21.2%
if -11200 < phi1 Initial program 62.4%
Taylor expanded in phi1 around 0 55.9%
+-commutative55.9%
associate--r+55.9%
unpow255.9%
1-sub-sin55.9%
unpow255.9%
Simplified55.9%
unpow263.0%
sin-mult63.0%
div-inv63.0%
metadata-eval63.0%
div-inv63.0%
metadata-eval63.0%
div-inv63.0%
metadata-eval63.0%
div-inv63.0%
metadata-eval63.0%
Applied egg-rr52.4%
div-sub63.0%
+-inverses63.0%
cos-063.0%
metadata-eval63.0%
distribute-lft-out63.0%
metadata-eval63.0%
*-rgt-identity63.0%
Simplified52.4%
Taylor expanded in phi1 around 0 51.4%
cos-neg51.4%
Simplified51.4%
Final simplification43.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((0.5d0 - (cos((phi1 - phi2)) / 2.0d0)) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 57.0%
Taylor expanded in phi1 around 0 46.8%
+-commutative46.8%
associate--r+46.8%
unpow246.8%
1-sub-sin46.8%
unpow246.8%
Simplified46.8%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr44.2%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified44.2%
Final simplification44.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi1) t_0) (- 0.5 (/ (cos phi1) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + (0.5 - (cos(phi1) / 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_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) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt(((cos(phi1) * t_0) + (0.5d0 - (cos(phi1) / 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * t_0) + (0.5 - (Math.cos(phi1) / 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * t_0) + (0.5 - (math.cos(phi1) / 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * t_0) + Float64(0.5 - Float64(cos(phi1) / 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * t_0) + (0.5 - (cos(phi1) / 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(0.5 - N[(N[Cos[phi1], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot t\_0 + \left(0.5 - \frac{\cos \phi_1}{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}}\right)
\end{array}
\end{array}
Initial program 57.0%
Taylor expanded in phi1 around 0 46.8%
+-commutative46.8%
associate--r+46.8%
unpow246.8%
1-sub-sin46.8%
unpow246.8%
Simplified46.8%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr44.2%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified44.2%
Taylor expanded in phi2 around 0 25.8%
Taylor expanded in phi2 around 0 28.7%
Final simplification28.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ 0.5 (* (cos phi1) (- t_0 0.5))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((0.5 + (cos(phi1) * (t_0 - 0.5)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_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) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((0.5d0 + (cos(phi1) * (t_0 - 0.5d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((0.5 + (Math.cos(phi1) * (t_0 - 0.5)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((0.5 + (math.cos(phi1) * (t_0 - 0.5)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(0.5 + Float64(cos(phi1) * Float64(t_0 - 0.5)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((0.5 + (cos(phi1) * (t_0 - 0.5)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(0.5 + N[(N[Cos[phi1], $MachinePrecision] * N[(t$95$0 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \cos \phi_1 \cdot \left(t\_0 - 0.5\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}}\right)
\end{array}
\end{array}
Initial program 57.0%
Taylor expanded in phi1 around 0 46.8%
+-commutative46.8%
associate--r+46.8%
unpow246.8%
1-sub-sin46.8%
unpow246.8%
Simplified46.8%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr44.2%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified44.2%
Taylor expanded in phi2 around 0 25.8%
Taylor expanded in phi2 around 0 26.6%
associate--l+26.6%
*-commutative26.6%
distribute-lft-out--26.6%
Simplified26.6%
Final simplification26.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
(* R 2.0)
(atan2
(sin (* (- lambda1 lambda2) 0.5))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
(* t_0 t_0)
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return (R * 2.0) * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), (t_0 * t_0), pow(sin(((phi1 - phi2) / 2.0)), 2.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(Float64(R * 2.0) * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), Float64(t_0 * t_0), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $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(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0 \cdot t\_0, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}
\end{array}
\end{array}
Initial program 57.0%
associate-*r*57.0%
*-commutative57.0%
Simplified57.0%
Taylor expanded in phi2 around 0 34.0%
Taylor expanded in phi1 around 0 15.4%
Final simplification15.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- lambda1 lambda2) 0.5))))
(*
R
(*
2.0
(atan2
(* t_0 (sqrt (cos phi2)))
(sqrt
(- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) (pow t_0 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
return R * (2.0 * atan2((t_0 * sqrt(cos(phi2))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(t_0, 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) * 0.5d0))
code = r * (2.0d0 * atan2((t_0 * sqrt(cos(phi2))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (t_0 ** 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) * 0.5));
return R * (2.0 * Math.atan2((t_0 * Math.sqrt(Math.cos(phi2))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(t_0, 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) return R * (2.0 * math.atan2((t_0 * math.sqrt(math.cos(phi2))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(t_0, 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) return Float64(R * Float64(2.0 * atan(Float64(t_0 * sqrt(cos(phi2))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (t_0 ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)); tmp = R * (2.0 * atan2((t_0 * sqrt(cos(phi2))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (t_0 ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[(t$95$0 * N[Sqrt[N[Cos[phi2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0 \cdot \sqrt{\cos \phi_2}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {t\_0}^{2}}}\right)
\end{array}
\end{array}
Initial program 57.0%
Taylor expanded in phi1 around 0 46.8%
+-commutative46.8%
associate--r+46.8%
unpow246.8%
1-sub-sin46.8%
unpow246.8%
Simplified46.8%
unpow257.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr44.2%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
distribute-lft-out57.8%
metadata-eval57.8%
*-rgt-identity57.8%
Simplified44.2%
Taylor expanded in phi2 around 0 25.8%
Taylor expanded in phi1 around 0 12.8%
Final simplification12.8%
herbie shell --seed 2024136
(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))))))))))