
(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 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi2) t_1))
(t_3 (sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) t_2)))
(t_4 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= phi2 -3800000.0)
(*
R
(* 2.0 (atan2 t_3 (sqrt (- t_4 (* (cos phi2) (expm1 (log1p t_1))))))))
(if (<= phi2 4.5e-5)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1))))))
(* R (* 2.0 (atan2 t_3 (sqrt (- t_4 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi2) * t_1;
double t_3 = sqrt((pow(sin((phi2 * -0.5)), 2.0) + t_2));
double t_4 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (phi2 <= -3800000.0) {
tmp = R * (2.0 * atan2(t_3, sqrt((t_4 - (cos(phi2) * expm1(log1p(t_1)))))));
} else if (phi2 <= 4.5e-5) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((t_4 - t_2))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi2) * t_1;
double t_3 = Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + t_2));
double t_4 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if (phi2 <= -3800000.0) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((t_4 - (Math.cos(phi2) * Math.expm1(Math.log1p(t_1)))))));
} else if (phi2 <= 4.5e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((t_4 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi2) * t_1 t_3 = math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + t_2)) t_4 = math.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if phi2 <= -3800000.0: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((t_4 - (math.cos(phi2) * math.expm1(math.log1p(t_1))))))) elif phi2 <= 4.5e-5: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((t_4 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi2) * t_1) t_3 = sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + t_2)) t_4 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (phi2 <= -3800000.0) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(t_4 - Float64(cos(phi2) * expm1(log1p(t_1)))))))); elseif (phi2 <= 4.5e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(t_4 - t_2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -3800000.0], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(t$95$4 - N[(N[Cos[phi2], $MachinePrecision] * N[(Exp[N[Log[1 + t$95$1], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.5e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(t$95$4 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_2 \cdot t_1\\
t_3 := \sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_2}\\
t_4 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -3800000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{t_4 - \cos \phi_2 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left(t_1\right)\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 4.5 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{t_4 - t_2}}\right)\\
\end{array}
\end{array}
if phi2 < -3.8e6Initial program 42.1%
Taylor expanded in phi1 around 0 42.5%
associate--r+42.6%
unpow242.6%
1-sub-sin42.8%
unpow242.8%
Simplified42.8%
Taylor expanded in phi1 around 0 43.9%
expm1-log1p-u43.9%
Applied egg-rr43.9%
if -3.8e6 < phi2 < 4.50000000000000028e-5Initial program 74.2%
Taylor expanded in phi2 around 0 74.2%
associate--r+74.3%
unpow274.3%
1-sub-sin74.4%
unpow274.4%
*-commutative74.4%
Simplified74.4%
if 4.50000000000000028e-5 < phi2 Initial program 47.5%
Taylor expanded in phi1 around 0 48.3%
associate--r+48.3%
unpow248.3%
1-sub-sin48.5%
unpow248.5%
Simplified48.5%
Taylor expanded in phi1 around 0 50.2%
Final simplification59.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow
(-
(* (cos (/ phi2 2.0)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (/ phi2 2.0))))
2.0)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(sqrt (/ (- 1.0 (* t_0 t_0)) (+ 1.0 t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = fma(cos(phi1), (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), pow(((cos((phi2 / 2.0)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 / 2.0)))), 2.0));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt(((1.0 - (t_0 * t_0)) / (1.0 + t_0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)), (Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))), sqrt(Float64(Float64(1.0 - Float64(t_0 * t_0)) / Float64(1.0 + t_0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)}}{\sqrt{\frac{1 - t_0 \cdot t_0}{1 + t_0}}}\right)
\end{array}
\end{array}
Initial program 58.3%
+-commutative58.3%
associate-*r*58.3%
associate-*l*58.3%
fma-udef58.3%
flip--58.4%
Applied egg-rr58.4%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.7%
div-inv58.7%
metadata-eval58.7%
div-inv58.7%
metadata-eval58.7%
Applied egg-rr58.7%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.7%
div-inv58.7%
metadata-eval58.7%
div-inv58.7%
metadata-eval58.7%
Applied egg-rr59.1%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.7%
div-inv58.7%
metadata-eval58.7%
div-inv58.7%
metadata-eval58.7%
Applied egg-rr59.3%
Final simplification59.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(t_1
(fma
(cos phi1)
t_0
(pow
(-
(* (cos (/ phi2 2.0)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (/ phi2 2.0))))
2.0)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_2 (* (* (cos phi1) (cos phi2)) t_2))))
(sqrt
(/
(- 1.0 (* t_1 t_1))
(+
1.0
(fma (cos phi1) t_0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = fma(cos(phi1), t_0, pow(((cos((phi2 / 2.0)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 / 2.0)))), 2.0));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * ((cos(phi1) * cos(phi2)) * t_2)))), sqrt(((1.0 - (t_1 * t_1)) / (1.0 + fma(cos(phi1), t_0, pow(sin(((phi1 - phi2) * 0.5)), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) t_1 = fma(cos(phi1), t_0, (Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)))), sqrt(Float64(Float64(1.0 - Float64(t_1 * t_1)) / Float64(1.0 + fma(cos(phi1), t_0, (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[Power[N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \mathsf{fma}\left(\cos \phi_1, t_0, {\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\right)}}{\sqrt{\frac{1 - t_1 \cdot t_1}{1 + \mathsf{fma}\left(\cos \phi_1, t_0, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}}}\right)
\end{array}
\end{array}
Initial program 58.3%
+-commutative58.3%
associate-*r*58.3%
associate-*l*58.3%
fma-udef58.3%
flip--58.4%
Applied egg-rr58.4%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.7%
div-inv58.7%
metadata-eval58.7%
div-inv58.7%
metadata-eval58.7%
Applied egg-rr58.7%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.7%
div-inv58.7%
metadata-eval58.7%
div-inv58.7%
metadata-eval58.7%
Applied egg-rr59.1%
Final simplification59.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(t_2
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(/
(- 1.0 (* t_2 t_2))
(+
1.0
(fma
(cos phi1)
(*
(cos phi2)
(pow
(-
(* (sin (* lambda1 0.5)) (cos (/ lambda2 2.0)))
(* (cos (* lambda1 0.5)) (sin (/ lambda2 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 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double t_2 = fma(cos(phi1), (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), t_1);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((1.0 - (t_2 * t_2)) / (1.0 + fma(cos(phi1), (cos(phi2) * pow(((sin((lambda1 * 0.5)) * cos((lambda2 / 2.0))) - (cos((lambda1 * 0.5)) * sin((lambda2 / 2.0)))), 2.0)), t_1))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_2 = fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)), t_1) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(Float64(1.0 - Float64(t_2 * t_2)) / Float64(1.0 + fma(cos(phi1), Float64(cos(phi2) * (Float64(Float64(sin(Float64(lambda1 * 0.5)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 * 0.5)) * sin(Float64(lambda2 / 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[(N[(N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$1), $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(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, t_1\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{\frac{1 - t_2 \cdot t_2}{1 + \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\left(\sin \left(\lambda_1 \cdot 0.5\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\lambda_1 \cdot 0.5\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}, t_1\right)}}}\right)
\end{array}
\end{array}
Initial program 58.3%
+-commutative58.3%
associate-*r*58.3%
associate-*l*58.3%
fma-udef58.3%
flip--58.4%
Applied egg-rr58.4%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
Applied egg-rr58.4%
Final simplification58.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(t_1 (fma (cos phi1) t_0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_2 (* (* (cos phi1) (cos phi2)) t_2))))
(sqrt
(/
(-
1.0
(*
(fma
(cos phi1)
t_0
(pow
(-
(* (cos (/ phi2 2.0)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (/ phi2 2.0))))
2.0))
t_1))
(+ 1.0 t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = fma(cos(phi1), t_0, pow(sin(((phi1 - phi2) * 0.5)), 2.0));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * ((cos(phi1) * cos(phi2)) * t_2)))), sqrt(((1.0 - (fma(cos(phi1), t_0, pow(((cos((phi2 / 2.0)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 / 2.0)))), 2.0)) * t_1)) / (1.0 + t_1)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) t_1 = fma(cos(phi1), t_0, (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)))), sqrt(Float64(Float64(1.0 - Float64(fma(cos(phi1), t_0, (Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) * t_1)) / Float64(1.0 + t_1)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[Power[N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] / N[(1.0 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \mathsf{fma}\left(\cos \phi_1, t_0, {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\right)}}{\sqrt{\frac{1 - \mathsf{fma}\left(\cos \phi_1, t_0, {\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) \cdot t_1}{1 + t_1}}}\right)
\end{array}
\end{array}
Initial program 58.3%
+-commutative58.3%
associate-*r*58.3%
associate-*l*58.3%
fma-udef58.3%
flip--58.4%
Applied egg-rr58.4%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.7%
div-inv58.7%
metadata-eval58.7%
div-inv58.7%
metadata-eval58.7%
Applied egg-rr58.7%
Final simplification58.7%
(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
(+
t_1
(pow
(cbrt
(*
(pow
(-
(* (cos (/ phi2 2.0)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (/ phi2 2.0))))
2.0)
(sin (* (- phi1 phi2) 0.5))))
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 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(cbrt((pow(((cos((phi2 / 2.0)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 / 2.0)))), 2.0) * sin(((phi1 - phi2) * 0.5)))), 2.0))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
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((t_1 + Math.pow(Math.cbrt((Math.pow(((Math.cos((phi2 / 2.0)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 / 2.0)))), 2.0) * Math.sin(((phi1 - phi2) * 0.5)))), 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(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (cbrt(Float64((Float64(Float64(cos(Float64(phi2 / 2.0)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) * sin(Float64(Float64(phi1 - phi2) * 0.5)))) ^ 2.0))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(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[(t$95$1 + N[Power[N[Power[N[(N[Power[N[(N[(N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] * N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + 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{t_1 + {\left(\sqrt[3]{{\left(\cos \left(\frac{\phi_2}{2}\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} \cdot \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1\right)}}\right)
\end{array}
\end{array}
Initial program 58.3%
add-cbrt-cube57.8%
unpow257.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr57.8%
metadata-eval58.4%
div-inv58.4%
div-sub58.4%
sin-diff58.7%
div-inv58.7%
metadata-eval58.7%
div-inv58.7%
metadata-eval58.7%
Applied egg-rr58.4%
Final simplification58.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))
(sqrt (- (cbrt (* t_0 (* t_0 t_0))) t_2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 - pow(sin(((phi1 - phi2) * 0.5)), 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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)), sqrt((cbrt((t_0 * (t_0 * t_0))) - t_2))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = 1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)), Math.sqrt((Math.cbrt((t_0 * (t_0 * t_0))) - t_2))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)), sqrt(Float64(cbrt(Float64(t_0 * Float64(t_0 * t_0))) - t_2))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $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[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2}}{\sqrt{\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)} - t_2}}\right)
\end{array}
\end{array}
Initial program 58.3%
associate-*l*58.3%
Simplified58.4%
add-cbrt-cube58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
Applied egg-rr58.4%
Final simplification58.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)))
(t_2 (sin (* (- phi1 phi2) 0.5))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- (/ (- 1.0 (pow t_2 4.0)) (+ 1.0 (pow t_2 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);
double t_2 = sin(((phi1 - phi2) * 0.5));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((((1.0 - pow(t_2, 4.0)) / (1.0 + pow(t_2, 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
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin(((phi1 - phi2) * 0.5d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((((1.0d0 - (t_2 ** 4.0d0)) / (1.0d0 + (t_2 ** 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);
double t_2 = Math.sin(((phi1 - phi2) * 0.5));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((((1.0 - Math.pow(t_2, 4.0)) / (1.0 + Math.pow(t_2, 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) t_2 = math.sin(((phi1 - phi2) * 0.5)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((((1.0 - math.pow(t_2, 4.0)) / (1.0 + math.pow(t_2, 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)) t_2 = sin(Float64(Float64(phi1 - phi2) * 0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(Float64(1.0 - (t_2 ^ 4.0)) / Float64(1.0 + (t_2 ^ 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); t_2 = sin(((phi1 - phi2) * 0.5)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((((1.0 - (t_2 ^ 4.0)) / (1.0 + (t_2 ^ 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]}, Block[{t$95$2 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(1.0 - N[Power[t$95$2, 4.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
t_2 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{\frac{1 - {t_2}^{4}}{1 + {t_2}^{2}} - t_1}}\right)
\end{array}
\end{array}
Initial program 58.3%
associate-*l*58.3%
Simplified58.4%
flip--58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
Applied egg-rr58.4%
pow-sqr58.4%
*-commutative58.4%
metadata-eval58.4%
*-commutative58.4%
Simplified58.4%
Final simplification58.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 phi2) 2.0)) 2.0) t_1))
(sqrt
(-
(expm1 (log1p (- 1.0 (pow (sin (* (- phi1 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 - phi2) / 2.0)), 2.0) + t_1)), sqrt((expm1(log1p((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))) - t_1))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((Math.expm1(Math.log1p((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 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((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((math.expm1(math.log1p((1.0 - math.pow(math.sin(((phi1 - 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(expm1(log1p(Float64(1.0 - (sin(Float64(Float64(phi1 - 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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(Exp[N[Log[1 + N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right) - t_1}}\right)
\end{array}
\end{array}
Initial program 58.3%
associate-*l*58.3%
Simplified58.4%
expm1-log1p-u58.4%
div-inv58.4%
metadata-eval58.4%
Applied egg-rr58.4%
Final simplification58.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)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(* R (* 2.0 (atan2 (sqrt (+ t_2 t_1)) (sqrt (- (- 1.0 t_2) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_2) - 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
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0d0 - t_2) - 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);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_1)), Math.sqrt(((1.0 - t_2) - 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) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + t_1)), math.sqrt(((1.0 - t_2) - 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)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_1)), sqrt(Float64(Float64(1.0 - t_2) - 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); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_2) - 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]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_1}}{\sqrt{\left(1 - t_2\right) - t_1}}\right)
\end{array}
\end{array}
Initial program 58.3%
associate-*l*58.3%
Simplified58.4%
Final simplification58.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (cos phi1) (cos phi2))))
(if (<= lambda2 0.0195)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_2))))
(sqrt
(-
1.0
(+
t_1
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_3 (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- (- 1.0 t_0) (* t_3 (* 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 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos(phi1) * cos(phi2);
double tmp;
if (lambda2 <= 0.0195) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0 - (t_1 + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt(((1.0 - t_0) - (t_3 * (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) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos(phi1) * cos(phi2)
if (lambda2 <= 0.0195d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0d0 - (t_1 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_3 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt(((1.0d0 - t_0) - (t_3 * (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.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (lambda2 <= 0.0195) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_2)))), Math.sqrt((1.0 - (t_1 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_3 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt(((1.0 - t_0) - (t_3 * (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.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos(phi1) * math.cos(phi2) tmp = 0 if lambda2 <= 0.0195: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_2)))), math.sqrt((1.0 - (t_1 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_3 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt(((1.0 - t_0) - (t_3 * (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 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (lambda2 <= 0.0195) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_2)))), sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_3 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(t_3 * 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 = sin(((phi1 - phi2) * 0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos(phi1) * cos(phi2); tmp = 0.0; if (lambda2 <= 0.0195) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0 - (t_1 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt(((1.0 - t_0) - (t_3 * (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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 0.0195], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$3 * 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$3 * 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 := {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq 0.0195:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_2\right)}}{\sqrt{1 - \left(t_1 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_3 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - t_0\right) - t_3 \cdot \left(t_2 \cdot t_2\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 0.0195Initial program 62.2%
Taylor expanded in lambda2 around 0 56.4%
if 0.0195 < lambda2 Initial program 47.3%
associate-*l*47.4%
Simplified47.4%
Taylor expanded in lambda1 around 0 47.3%
Final simplification54.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(-
1.0
(+
(pow (sin (* (- phi1 phi2) 0.5)) 2.0)
(*
(cos phi2)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (pow(sin(((phi1 - phi2) * 0.5)), 2.0) + (cos(phi2) * (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - ((sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0) + (cos(phi2) * (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0) + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - ((sin(((phi1 - phi2) * 0.5)) ^ 2.0) + (cos(phi2) * (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{1 - \left({\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\right)}}\right)
\end{array}
\end{array}
Initial program 58.3%
Taylor expanded in phi1 around inf 58.3%
Final simplification58.3%
(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))))
(if (or (<= phi1 -0.095) (not (<= phi1 3.1e-5)))
(*
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_1))))))
(*
R
(*
2.0
(atan2
(sqrt (+ 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 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double tmp;
if ((phi1 <= -0.095) || !(phi1 <= 3.1e-5)) {
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_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((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 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
if ((phi1 <= (-0.095d0)) .or. (.not. (phi1 <= 3.1d-5))) 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_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt((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.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((phi1 <= -0.095) || !(phi1 <= 3.1e-5)) {
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_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((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.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) tmp = 0 if (phi1 <= -0.095) or not (phi1 <= 3.1e-5): 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_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((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 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) tmp = 0.0 if ((phi1 <= -0.095) || !(phi1 <= 3.1e-5)) 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(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(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 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = 0.0; if ((phi1 <= -0.095) || ~((phi1 <= 3.1e-5))) 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_1))))); else tmp = R * (2.0 * atan2(sqrt((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[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]}, If[Or[LessEqual[phi1, -0.095], N[Not[LessEqual[phi1, 3.1e-5]], $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[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + 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 := \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)\\
\mathbf{if}\;\phi_1 \leq -0.095 \lor \neg \left(\phi_1 \leq 3.1 \cdot 10^{-5}\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{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -0.095000000000000001 or 3.10000000000000014e-5 < phi1 Initial program 47.1%
Taylor expanded in lambda1 around 0 37.6%
Taylor expanded in phi2 around 0 38.6%
+-commutative38.6%
fma-def38.6%
Simplified38.6%
Taylor expanded in lambda1 around 0 38.9%
if -0.095000000000000001 < phi1 < 3.10000000000000014e-5Initial program 69.7%
Taylor expanded in phi1 around 0 69.6%
associate--r+69.6%
unpow269.6%
1-sub-sin69.8%
unpow269.8%
Simplified69.8%
Taylor expanded in phi1 around 0 69.8%
Final simplification54.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi2) t_1)))
(if (or (<= phi2 -3800000.0) (not (<= phi2 5.1e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) t_2))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_2)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi2) * t_1;
double tmp;
if ((phi2 <= -3800000.0) || !(phi2 <= 5.1e-5)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + t_2)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_2))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = cos(phi2) * t_1
if ((phi2 <= (-3800000.0d0)) .or. (.not. (phi2 <= 5.1d-5))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + t_2)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_2))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi2) * t_1;
double tmp;
if ((phi2 <= -3800000.0) || !(phi2 <= 5.1e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + t_2)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_2))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi2) * t_1 tmp = 0 if (phi2 <= -3800000.0) or not (phi2 <= 5.1e-5): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + t_2)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_2)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi2) * t_1) tmp = 0.0 if ((phi2 <= -3800000.0) || !(phi2 <= 5.1e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + t_2)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_2))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = cos(phi2) * t_1; tmp = 0.0; if ((phi2 <= -3800000.0) || ~((phi2 <= 5.1e-5))) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + t_2)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_2)))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi2, -3800000.0], N[Not[LessEqual[phi2, 5.1e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_2 \cdot t_1\\
\mathbf{if}\;\phi_2 \leq -3800000 \lor \neg \left(\phi_2 \leq 5.1 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_2}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < -3.8e6 or 5.09999999999999996e-5 < phi2 Initial program 44.7%
Taylor expanded in phi1 around 0 45.3%
associate--r+45.4%
unpow245.4%
1-sub-sin45.5%
unpow245.5%
Simplified45.5%
Taylor expanded in phi1 around 0 47.0%
if -3.8e6 < phi2 < 5.09999999999999996e-5Initial program 74.2%
Taylor expanded in phi2 around 0 74.2%
associate--r+74.3%
unpow274.3%
1-sub-sin74.4%
unpow274.4%
*-commutative74.4%
Simplified74.4%
Final simplification59.6%
(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)))
(if (or (<= phi1 -3.3) (not (<= phi1 0.00021)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
(sin (* lambda2 -0.5)))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) t_1))
(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 tmp;
if ((phi1 <= -3.3) || !(phi1 <= 0.00021)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin((lambda2 * -0.5))))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + t_1)), 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) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi2) * t_0
if ((phi1 <= (-3.3d0)) .or. (.not. (phi1 <= 0.00021d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0d0))) * sin((lambda2 * (-0.5d0)))))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + t_1)), 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 tmp;
if ((phi1 <= -3.3) || !(phi1 <= 0.00021)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0))) * Math.sin((lambda2 * -0.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((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + t_1)), 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 tmp = 0 if (phi1 <= -3.3) or not (phi1 <= 0.00021): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0))) * math.sin((lambda2 * -0.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((math.pow(math.sin((phi2 * -0.5)), 2.0) + t_1)), 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) tmp = 0.0 if ((phi1 <= -3.3) || !(phi1 <= 0.00021)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * sin(Float64(lambda2 * -0.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((sin(Float64(phi2 * -0.5)) ^ 2.0) + t_1)), 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; tmp = 0.0; if ((phi1 <= -3.3) || ~((phi1 <= 0.00021))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin((lambda2 * -0.5))))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); else tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + t_1)), 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]}, If[Or[LessEqual[phi1, -3.3], N[Not[LessEqual[phi1, 0.00021]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $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\\
\mathbf{if}\;\phi_1 \leq -3.3 \lor \neg \left(\phi_1 \leq 0.00021\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\lambda_2 \cdot -0.5\right)}}{\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{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_1}}\right)\\
\end{array}
\end{array}
if phi1 < -3.2999999999999998 or 2.1000000000000001e-4 < phi1 Initial program 47.5%
Taylor expanded in lambda1 around 0 37.9%
Taylor expanded in phi2 around 0 38.6%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
Simplified38.7%
if -3.2999999999999998 < phi1 < 2.1000000000000001e-4Initial program 69.1%
Taylor expanded in phi1 around 0 69.0%
associate--r+69.1%
unpow269.1%
1-sub-sin69.2%
unpow269.2%
Simplified69.2%
Taylor expanded in phi1 around 0 69.4%
Final simplification54.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi2 -0.5)) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi2) t_1)))
(if (<= lambda1 -1.65e+14)
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_2)) (sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi2) * t_1;
double tmp;
if (lambda1 <= -1.65e+14) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt((pow(cos((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((phi2 * (-0.5d0))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = cos(phi2) * t_1
if (lambda1 <= (-1.65d+14)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_2)), sqrt((1.0d0 - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt(((cos((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((phi2 * -0.5)), 2.0);
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi2) * t_1;
double tmp;
if (lambda1 <= -1.65e+14) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_2)), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi2) * t_1 tmp = 0 if lambda1 <= -1.65e+14: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_2)), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi2) * t_1) tmp = 0.0 if (lambda1 <= -1.65e+14) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi2 * -0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = cos(phi2) * t_1; tmp = 0.0; if (lambda1 <= -1.65e+14) tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt(((cos((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[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[lambda1, -1.65e+14], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_2 \cdot t_1\\
\mathbf{if}\;\lambda_1 \leq -1.65 \cdot 10^{+14}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2}}{\sqrt{1 - t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.65e14Initial program 48.4%
Taylor expanded in phi1 around 0 35.7%
associate--r+35.7%
unpow235.7%
1-sub-sin35.7%
unpow235.7%
Simplified35.7%
Taylor expanded in phi1 around 0 35.6%
Taylor expanded in phi2 around 0 25.2%
if -1.65e14 < lambda1 Initial program 61.5%
Taylor expanded in phi1 around 0 47.5%
associate--r+47.5%
unpow247.5%
1-sub-sin47.6%
unpow247.6%
Simplified47.6%
Taylor expanded in phi1 around 0 47.0%
Taylor expanded in lambda1 around 0 40.2%
Final simplification36.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi2 -0.5)) 2.0))
(t_1
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))
(if (<= lambda1 -2.75e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))));
double tmp;
if (lambda1 <= -2.75e-5) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0)))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((lambda2 * -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) :: tmp
t_0 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_1 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))
if (lambda1 <= (-2.75d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0)))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * (-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((phi2 * -0.5)), 2.0);
double t_1 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))));
double tmp;
if (lambda1 <= -2.75e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0)))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_1 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))) tmp = 0 if lambda1 <= -2.75e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))) tmp = 0.0 if (lambda1 <= -2.75e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0)))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi2 * -0.5)) ^ 2.0; t_1 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))); tmp = 0.0; if (lambda1 <= -2.75e-5) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0)))), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * -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[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = 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]}, If[LessEqual[lambda1, -2.75e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := \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}}\\
\mathbf{if}\;\lambda_1 \leq -2.75 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{t_1}\right)\\
\end{array}
\end{array}
if lambda1 < -2.7500000000000001e-5Initial program 48.3%
Taylor expanded in phi1 around 0 36.3%
associate--r+36.3%
unpow236.3%
1-sub-sin36.3%
unpow236.3%
Simplified36.3%
Taylor expanded in phi1 around 0 36.1%
Taylor expanded in lambda2 around 0 35.9%
if -2.7500000000000001e-5 < lambda1 Initial program 61.7%
Taylor expanded in phi1 around 0 47.5%
associate--r+47.5%
unpow247.5%
1-sub-sin47.6%
unpow247.6%
Simplified47.6%
Taylor expanded in phi1 around 0 47.0%
Taylor expanded in lambda1 around 0 40.5%
Final simplification39.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi2 -0.5)) 2.0))
(t_1 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(t_2 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= lambda2 4.2e-10)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_1))
(sqrt (- t_2 (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- t_2 t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda2 <= 4.2e-10) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_1)), sqrt((t_2 - (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt((t_2 - 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((phi2 * (-0.5d0))) ** 2.0d0
t_1 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
t_2 = cos((phi2 * (-0.5d0))) ** 2.0d0
if (lambda2 <= 4.2d-10) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_1)), sqrt((t_2 - (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt((t_2 - 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((phi2 * -0.5)), 2.0);
double t_1 = Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda2 <= 4.2e-10) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_1)), Math.sqrt((t_2 - (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt((t_2 - t_1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_1 = math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if lambda2 <= 4.2e-10: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_1)), math.sqrt((t_2 - (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt((t_2 - t_1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) t_2 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (lambda2 <= 4.2e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_1)), sqrt(Float64(t_2 - Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64(t_2 - t_1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi2 * -0.5)) ^ 2.0; t_1 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); t_2 = cos((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (lambda2 <= 4.2e-10) tmp = R * (2.0 * atan2(sqrt((t_0 + t_1)), sqrt((t_2 - (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt((t_2 - t_1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda2, 4.2e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\lambda_2 \leq 4.2 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1}}{\sqrt{t_2 - \cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{t_2 - t_1}}\right)\\
\end{array}
\end{array}
if lambda2 < 4.2e-10Initial program 63.0%
Taylor expanded in phi1 around 0 48.1%
associate--r+48.1%
unpow248.1%
1-sub-sin48.2%
unpow248.2%
Simplified48.2%
Taylor expanded in phi1 around 0 47.2%
Taylor expanded in lambda2 around 0 43.3%
if 4.2e-10 < lambda2 Initial program 45.9%
Taylor expanded in phi1 around 0 35.4%
associate--r+35.4%
unpow235.4%
1-sub-sin35.5%
unpow235.5%
Simplified35.5%
Taylor expanded in phi1 around 0 36.3%
Taylor expanded in lambda1 around 0 36.4%
Final simplification41.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))
(t_1 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= lambda2 4.2e-10)
(*
R
(*
2.0
(atan2
t_0
(sqrt (- t_1 (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_0
(sqrt (- t_1 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))));
double t_1 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda2 <= 4.2e-10) {
tmp = R * (2.0 * atan2(t_0, sqrt((t_1 - (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt((t_1 - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))
t_1 = cos((phi2 * (-0.5d0))) ** 2.0d0
if (lambda2 <= 4.2d-10) then
tmp = r * (2.0d0 * atan2(t_0, sqrt((t_1 - (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt((t_1 - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))));
double t_1 = Math.pow(Math.cos((phi2 * -0.5)), 2.0);
double tmp;
if (lambda2 <= 4.2e-10) {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((t_1 - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))) t_1 = math.pow(math.cos((phi2 * -0.5)), 2.0) tmp = 0 if lambda2 <= 4.2e-10: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((t_1 - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))) t_1 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (lambda2 <= 4.2e-10) tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(t_1 - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))); t_1 = cos((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (lambda2 <= 4.2e-10) tmp = R * (2.0 * atan2(t_0, sqrt((t_1 - (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_0, sqrt((t_1 - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(N[Power[N[Sin[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]}, Block[{t$95$1 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda2, 4.2e-10], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{\sin \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}}\\
t_1 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\lambda_2 \leq 4.2 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{t_1 - \cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{t_1 - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 4.2e-10Initial program 63.0%
Taylor expanded in phi1 around 0 48.1%
associate--r+48.1%
unpow248.1%
1-sub-sin48.2%
unpow248.2%
Simplified48.2%
Taylor expanded in phi1 around 0 47.2%
Taylor expanded in lambda2 around 0 43.3%
if 4.2e-10 < lambda2 Initial program 45.9%
Taylor expanded in phi1 around 0 35.4%
associate--r+35.4%
unpow235.4%
1-sub-sin35.5%
unpow235.5%
Simplified35.5%
Taylor expanded in phi1 around 0 36.3%
Taylor expanded in lambda1 around 0 36.5%
Final simplification41.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) t_0))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + t_0)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - 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 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + t_0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + t_0)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + t_0)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + t_0)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + t_0)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_0}}\right)
\end{array}
\end{array}
Initial program 58.3%
Taylor expanded in phi1 around 0 44.6%
associate--r+44.6%
unpow244.6%
1-sub-sin44.7%
unpow244.7%
Simplified44.7%
Taylor expanded in phi1 around 0 44.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 (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) t_0)))
(sqrt (- 1.0 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((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * t_0))), sqrt((1.0 - 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(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * t_0))), sqrt((1.0d0 - 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.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * t_0))), Math.sqrt((1.0 - 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.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * t_0))), math.sqrt((1.0 - 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((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * t_0))), sqrt(Float64(1.0 - 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(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * t_0))), sqrt((1.0 - 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[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot t_0}}{\sqrt{1 - t_0}}\right)
\end{array}
\end{array}
Initial program 58.3%
Taylor expanded in phi1 around 0 44.6%
associate--r+44.6%
unpow244.6%
1-sub-sin44.7%
unpow244.7%
Simplified44.7%
Taylor expanded in phi1 around 0 44.2%
Taylor expanded in phi2 around 0 30.4%
Final simplification30.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- lambda1 lambda2) 0.5))) (t_1 (pow t_0 2.0)))
(if (<= (sin (/ (- lambda1 lambda2) 2.0)) -4e-295)
(*
R
(*
2.0
(atan2
(sin (* phi1 0.5))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1))))))
(*
R
(*
2.0
(atan2
t_0
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) * 0.5));
double t_1 = pow(t_0, 2.0);
double tmp;
if (sin(((lambda1 - lambda2) / 2.0)) <= -4e-295) {
tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0))
t_1 = t_0 ** 2.0d0
if (sin(((lambda1 - lambda2) / 2.0d0)) <= (-4d-295)) then
tmp = r * (2.0d0 * atan2(sin((phi1 * 0.5d0)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * 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) * 0.5));
double t_1 = Math.pow(t_0, 2.0);
double tmp;
if (Math.sin(((lambda1 - lambda2) / 2.0)) <= -4e-295) {
tmp = R * (2.0 * Math.atan2(Math.sin((phi1 * 0.5)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) * 0.5)) t_1 = math.pow(t_0, 2.0) tmp = 0 if math.sin(((lambda1 - lambda2) / 2.0)) <= -4e-295: tmp = R * (2.0 * math.atan2(math.sin((phi1 * 0.5)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) t_1 = t_0 ^ 2.0 tmp = 0.0 if (sin(Float64(Float64(lambda1 - lambda2) / 2.0)) <= -4e-295) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(phi1 * 0.5)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)); t_1 = t_0 ^ 2.0; tmp = 0.0; if (sin(((lambda1 - lambda2) / 2.0)) <= -4e-295) tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); else tmp = R * (2.0 * atan2(t_0, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, If[LessEqual[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], -4e-295], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(phi1 * 0.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$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / 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]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
t_1 := {t_0}^{2}\\
\mathbf{if}\;\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \leq -4 \cdot 10^{-295}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_1 \cdot 0.5\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < -4.00000000000000024e-295Initial program 58.0%
Taylor expanded in lambda1 around 0 46.3%
Taylor expanded in phi2 around 0 34.0%
+-commutative34.0%
fma-def34.0%
Simplified34.0%
Taylor expanded in lambda2 around 0 11.4%
Taylor expanded in phi2 around 0 11.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.7%
unpow243.7%
*-commutative43.7%
Simplified11.7%
if -4.00000000000000024e-295 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 58.7%
Taylor expanded in phi1 around 0 45.1%
associate--r+45.1%
unpow245.1%
1-sub-sin45.3%
unpow245.3%
Simplified45.3%
Taylor expanded in phi1 around 0 44.6%
add-log-exp39.0%
Applied egg-rr39.0%
Taylor expanded in phi2 around 0 26.4%
Final simplification18.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* phi1 0.5))
(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) {
return R * (2.0 * atan2(sin((phi1 * 0.5)), 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
code = r * (2.0d0 * atan2(sin((phi1 * 0.5d0)), 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) {
return R * (2.0 * Math.atan2(Math.sin((phi1 * 0.5)), 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): return R * (2.0 * math.atan2(math.sin((phi1 * 0.5)), 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) return Float64(R * Float64(2.0 * atan(sin(Float64(phi1 * 0.5)), 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) tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(phi1 * 0.5), $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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_1 \cdot 0.5\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}
Initial program 58.3%
Taylor expanded in lambda1 around 0 44.3%
Taylor expanded in phi2 around 0 30.3%
+-commutative30.3%
fma-def30.3%
Simplified30.3%
Taylor expanded in lambda2 around 0 10.6%
Taylor expanded in phi1 around 0 8.5%
associate--r+44.6%
unpow244.6%
1-sub-sin44.7%
unpow244.7%
Simplified8.5%
Final simplification8.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* phi1 0.5))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * 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
code = r * (2.0d0 * atan2(sin((phi1 * 0.5d0)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin((phi1 * 0.5)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((phi1 * 0.5)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(phi1 * 0.5)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((phi1 * 0.5)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_1 \cdot 0.5\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 58.3%
Taylor expanded in lambda1 around 0 44.3%
Taylor expanded in phi2 around 0 30.3%
+-commutative30.3%
fma-def30.3%
Simplified30.3%
Taylor expanded in lambda2 around 0 10.6%
Taylor expanded in phi2 around 0 10.8%
associate--r+44.9%
unpow244.9%
1-sub-sin45.0%
unpow245.0%
*-commutative45.0%
Simplified10.8%
Final simplification10.8%
herbie shell --seed 2023215
(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))))))))))