
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 27 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1)))
(t_3 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2)))
(t_4 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0)))))
(if (<= phi1 -0.64)
(* R (* 2.0 (atan2 t_3 t_4)))
(if (<= phi1 0.000165)
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (pow (cos (* phi2 0.5)) 2.0) (* (cos phi2) t_0))))))
(*
R
(* 2.0 (atan2 (sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0))) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double t_3 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double t_4 = sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)));
double tmp;
if (phi1 <= -0.64) {
tmp = R * (2.0 * atan2(t_3, t_4));
} else if (phi1 <= 0.000165) {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi2 * 0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), t_4));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
t_3 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2))
t_4 = sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))
if (phi1 <= (-0.64d0)) then
tmp = r * (2.0d0 * atan2(t_3, t_4))
else if (phi1 <= 0.000165d0) then
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double t_3 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double t_4 = Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)));
double tmp;
if (phi1 <= -0.64) {
tmp = R * (2.0 * Math.atan2(t_3, t_4));
} else if (phi1 <= 0.000165) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) t_3 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)) t_4 = math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0))) tmp = 0 if phi1 <= -0.64: tmp = R * (2.0 * math.atan2(t_3, t_4)) elif phi1 <= 0.000165: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - (math.cos(phi2) * t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) t_3 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)) t_4 = sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0))) tmp = 0.0 if (phi1 <= -0.64) tmp = Float64(R * Float64(2.0 * atan(t_3, t_4))); elseif (phi1 <= 0.000165) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); t_3 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2)); t_4 = sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))); tmp = 0.0; if (phi1 <= -0.64) tmp = R * (2.0 * atan2(t_3, t_4)); elseif (phi1 <= 0.000165) tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi2 * 0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.64], N[(R * N[(2.0 * N[ArcTan[t$95$3 / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.000165], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_1 \cdot t_1\right)\\
t_3 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2}\\
t_4 := \sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_0}\\
\mathbf{if}\;\phi_1 \leq -0.64:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{t_4}\right)\\
\mathbf{elif}\;\phi_1 \leq 0.000165:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{{\cos \left(\phi_2 \cdot 0.5\right)}^{2} - \cos \phi_2 \cdot t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{t_4}\right)\\
\end{array}
\end{array}
if phi1 < -0.640000000000000013Initial program 48.8%
associate-*l*48.8%
Simplified48.8%
Taylor expanded in phi2 around 0 48.9%
associate--r+49.0%
unpow249.0%
1-sub-sin49.2%
unpow249.2%
*-commutative49.2%
unpow249.2%
associate-*r*49.2%
Simplified49.2%
if -0.640000000000000013 < phi1 < 1.65e-4Initial program 81.6%
associate-*l*81.6%
Simplified81.6%
Taylor expanded in phi1 around 0 81.6%
associate--r+81.6%
unpow281.6%
1-sub-sin81.6%
unpow281.6%
metadata-eval81.6%
associate-*r*81.6%
*-commutative81.6%
mul-1-neg81.6%
distribute-lft-neg-out81.6%
cos-neg81.6%
sub-neg81.6%
mul-1-neg81.6%
+-commutative81.6%
Simplified81.6%
if 1.65e-4 < phi1 Initial program 46.7%
associate-*l*46.8%
Simplified46.8%
Taylor expanded in phi2 around 0 48.3%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
unpow248.4%
associate-*r*48.4%
Simplified48.4%
Taylor expanded in phi2 around 0 48.9%
Final simplification64.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt
(- (- 1.0 (log (exp (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(((1.0 - log(exp(pow(sin(((phi1 - phi2) * 0.5)), 2.0)))) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 - log(exp((sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 - Math.log(Math.exp(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(((1.0 - math.log(math.exp(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(Float64(1.0 - log(exp((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 - log(exp((sin(((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[(1.0 - N[Log[N[Exp[N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $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)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{\left(1 - \log \left(e^{{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}\right)\right) - t_1}}\right)
\end{array}
\end{array}
Initial program 63.6%
associate-*l*63.6%
Simplified63.6%
add-log-exp63.6%
div-inv63.6%
metadata-eval63.6%
Applied egg-rr63.6%
Final simplification63.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_2 t_2))))))
(if (<= lambda2 0.000235)
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(+
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))
t_1))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt (- (- 1.0 t_1) (* t_0 (pow (sin (* lambda2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_2))));
double tmp;
if (lambda2 <= 0.000235) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))) + t_1)))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_1) - (t_0 * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_2 * t_2))))
if (lambda2 <= 0.000235d0) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - ((cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))) + t_1)))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt(((1.0d0 - t_1) - (t_0 * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
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.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_2))));
double tmp;
if (lambda2 <= 0.000235) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - ((Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))) + t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt(((1.0 - t_1) - (t_0 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_2 * t_2)))) tmp = 0 if lambda2 <= 0.000235: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - ((math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0))) + t_1))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt(((1.0 - t_1) - (t_0 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_2 * t_2)))) tmp = 0.0 if (lambda2 <= 0.000235) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))) + t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((phi1 - phi2) * 0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_2 * t_2)))); tmp = 0.0; if (lambda2 <= 0.000235) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0))) + t_1))))); else tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_1) - (t_0 * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[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[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 0.000235], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(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] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_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 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_2 \cdot t_2\right)}\\
\mathbf{if}\;\lambda_2 \leq 0.000235:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right) + t_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{\left(1 - t_1\right) - t_0 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 2.34999999999999993e-4Initial program 66.6%
associate-*l*66.6%
Simplified66.6%
Taylor expanded in lambda2 around 0 57.7%
if 2.34999999999999993e-4 < lambda2 Initial program 54.8%
associate-*l*54.8%
Simplified54.8%
Taylor expanded in lambda1 around 0 54.1%
associate--r+54.1%
Simplified54.1%
Final simplification56.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(* t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)) - (t_0 * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)) - (t_0 * (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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)) - (t_0 * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0)) - (t_0 * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)) - Float64(t_0 * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0)) - (t_0 * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right) - t_0 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 63.6%
associate-*l*63.6%
Simplified63.6%
cancel-sign-sub-inv63.6%
div-inv63.6%
metadata-eval63.6%
pow263.6%
div-inv63.6%
metadata-eval63.6%
Applied egg-rr63.6%
Final simplification63.6%
(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))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_3 (* (cos phi1) (cos phi2))))
(if (or (<= phi2 -0.00145) (not (<= phi2 500000000000.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* (sin (* lambda1 0.5)) (* t_3 t_0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_3 (* t_0 t_0))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) 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(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = cos(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -0.00145) || !(phi2 <= 500000000000.0)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((lambda1 * 0.5)) * (t_3 * t_0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * (t_0 * t_0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * 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(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_3 = cos(phi1) * cos(phi2)
if ((phi2 <= (-0.00145d0)) .or. (.not. (phi2 <= 500000000000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((lambda1 * 0.5d0)) * (t_3 * t_0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_3 * (t_0 * t_0)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((phi2 <= -0.00145) || !(phi2 <= 500000000000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.sin((lambda1 * 0.5)) * (t_3 * t_0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_3 * (t_0 * t_0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * 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(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_3 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (phi2 <= -0.00145) or not (phi2 <= 500000000000.0): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.sin((lambda1 * 0.5)) * (t_3 * t_0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_3 * (t_0 * t_0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * 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(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_3 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.00145) || !(phi2 <= 500000000000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(sin(Float64(lambda1 * 0.5)) * Float64(t_3 * t_0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_3 * Float64(t_0 * t_0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_3 = cos(phi1) * cos(phi2); tmp = 0.0; if ((phi2 <= -0.00145) || ~((phi2 <= 500000000000.0))) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((lambda1 * 0.5)) * (t_3 * t_0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * (t_0 * t_0)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_2))))); 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[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00145], N[Not[LessEqual[phi2, 500000000000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$3 * N[(t$95$0 * 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$2), $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(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00145 \lor \neg \left(\phi_2 \leq 500000000000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \sin \left(\lambda_1 \cdot 0.5\right) \cdot \left(t_3 \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_3 \cdot \left(t_0 \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_2}}\right)\\
\end{array}
\end{array}
if phi2 < -0.00145 or 5e11 < phi2 Initial program 45.8%
Taylor expanded in lambda2 around 0 38.9%
Taylor expanded in phi1 around 0 39.9%
associate--r+18.5%
unpow218.5%
1-sub-sin18.5%
unpow218.5%
*-commutative18.5%
Simplified39.9%
if -0.00145 < phi2 < 5e11Initial program 80.2%
associate-*l*80.2%
Simplified80.2%
Taylor expanded in phi2 around 0 79.7%
associate--r+79.7%
unpow279.7%
1-sub-sin79.8%
unpow279.8%
*-commutative79.8%
unpow279.8%
associate-*r*79.9%
Simplified79.8%
Final simplification60.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(if (or (<= phi1 -0.64) (not (<= phi1 0.0072)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))
(sqrt (- (- 1.0 (* (* phi1 phi1) (+ 0.25 (* -0.5 t_0)))) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1);
double tmp;
if ((phi1 <= -0.64) || !(phi1 <= 0.0072)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)), sqrt(((1.0 - ((phi1 * phi1) * (0.25 + (-0.5 * t_0)))) - t_0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1)
if ((phi1 <= (-0.64d0)) .or. (.not. (phi1 <= 0.0072d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2)), sqrt(((1.0d0 - ((phi1 * phi1) * (0.25d0 + ((-0.5d0) * t_0)))) - t_0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1);
double tmp;
if ((phi1 <= -0.64) || !(phi1 <= 0.0072)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), 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(((phi1 - phi2) / 2.0)), 2.0) + t_2)), Math.sqrt(((1.0 - ((phi1 * phi1) * (0.25 + (-0.5 * t_0)))) - t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1) tmp = 0 if (phi1 <= -0.64) or not (phi1 <= 0.0072): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), 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(((phi1 - phi2) / 2.0)), 2.0) + t_2)), math.sqrt(((1.0 - ((phi1 * phi1) * (0.25 + (-0.5 * t_0)))) - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)) tmp = 0.0 if ((phi1 <= -0.64) || !(phi1 <= 0.0072)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), 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(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)), sqrt(Float64(Float64(1.0 - Float64(Float64(phi1 * phi1) * Float64(0.25 + Float64(-0.5 * t_0)))) - t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = (cos(phi1) * cos(phi2)) * (t_1 * t_1); tmp = 0.0; if ((phi1 <= -0.64) || ~((phi1 <= 0.0072))) tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2)), sqrt(((1.0 - ((phi1 * phi1) * (0.25 + (-0.5 * t_0)))) - t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -0.64], N[Not[LessEqual[phi1, 0.0072]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[(N[(phi1 * phi1), $MachinePrecision] * N[(0.25 + N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_1 := \sin \left(\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)\\
\mathbf{if}\;\phi_1 \leq -0.64 \lor \neg \left(\phi_1 \leq 0.0072\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\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(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2}}{\sqrt{\left(1 - \left(\phi_1 \cdot \phi_1\right) \cdot \left(0.25 + -0.5 \cdot t_0\right)\right) - t_0}}\right)\\
\end{array}
\end{array}
if phi1 < -0.640000000000000013 or 0.0071999999999999998 < phi1 Initial program 47.6%
associate-*l*47.6%
Simplified47.6%
Taylor expanded in phi2 around 0 48.6%
associate--r+48.6%
unpow248.6%
1-sub-sin48.7%
unpow248.7%
*-commutative48.7%
unpow248.7%
associate-*r*48.7%
Simplified48.7%
Taylor expanded in phi2 around 0 48.7%
if -0.640000000000000013 < phi1 < 0.0071999999999999998Initial program 81.6%
associate-*l*81.6%
Simplified81.6%
Taylor expanded in phi2 around 0 53.8%
associate--r+53.8%
unpow253.8%
1-sub-sin53.8%
unpow253.8%
*-commutative53.8%
unpow253.8%
associate-*r*53.8%
Simplified53.8%
Taylor expanded in phi1 around 0 53.8%
mul-1-neg53.8%
unpow253.8%
Simplified53.8%
Final simplification51.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(if (or (<= phi2 -0.00029) (not (<= phi2 2.5e-18)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (sin (* lambda1 0.5)) (* t_2 t_0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -0.00029) || !(phi2 <= 2.5e-18)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (sin((lambda1 * 0.5)) * (t_2 * t_0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + pow(sin((phi1 * 0.5)), 2.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(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
if ((phi2 <= (-0.00029d0)) .or. (.not. (phi2 <= 2.5d-18))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (sin((lambda1 * 0.5d0)) * (t_2 * t_0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((phi2 <= -0.00029) || !(phi2 <= 2.5e-18)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.sin((lambda1 * 0.5)) * (t_2 * t_0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (phi2 <= -0.00029) or not (phi2 <= 2.5e-18): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.sin((lambda1 * 0.5)) * (t_2 * t_0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -0.00029) || !(phi2 <= 2.5e-18)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(sin(Float64(lambda1 * 0.5)) * Float64(t_2 * t_0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if ((phi2 <= -0.00029) || ~((phi2 <= 2.5e-18))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (sin((lambda1 * 0.5)) * (t_2 * t_0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00029], N[Not[LessEqual[phi2, 2.5e-18]], $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[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.00029 \lor \neg \left(\phi_2 \leq 2.5 \cdot 10^{-18}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\lambda_1 \cdot 0.5\right) \cdot \left(t_2 \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot \left(t_0 \cdot t_0\right) + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < -2.9e-4 or 2.50000000000000018e-18 < phi2 Initial program 46.1%
Taylor expanded in lambda2 around 0 38.4%
Taylor expanded in phi1 around 0 39.3%
associate--r+17.6%
unpow217.6%
1-sub-sin17.6%
unpow217.6%
*-commutative17.6%
Simplified39.3%
if -2.9e-4 < phi2 < 2.50000000000000018e-18Initial program 82.5%
associate-*l*82.5%
Simplified82.5%
Taylor expanded in phi2 around 0 82.5%
associate--r+82.5%
unpow282.5%
1-sub-sin82.6%
unpow282.6%
*-commutative82.6%
unpow282.6%
associate-*r*82.7%
Simplified82.6%
Taylor expanded in phi2 around 0 81.5%
Final simplification59.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* t_1 (* t_0 t_0)))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0))))))
(if (<= phi1 -1100000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (* t_1 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
t_4)))
(if (<= phi1 0.0016)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_2))
(sqrt
(log (exp (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
(*
R
(* 2.0 (atan2 (sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0))) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))));
double tmp;
if (phi1 <= -1100000.0) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (t_1 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_4));
} else if (phi1 <= 0.0016) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt(log(exp((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), t_4));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = t_1 * (t_0 * t_0)
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_4 = sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))
if (phi1 <= (-1100000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (t_1 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), t_4))
else if (phi1 <= 0.0016d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_2)), sqrt(log(exp((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = t_1 * (t_0 * t_0);
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))));
double tmp;
if (phi1 <= -1100000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (t_1 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), t_4));
} else if (phi1 <= 0.0016) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_2)), Math.sqrt(Math.log(Math.exp((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = t_1 * (t_0 * t_0) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))) tmp = 0 if phi1 <= -1100000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (t_1 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), t_4)) elif phi1 <= 0.0016: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_2)), math.sqrt(math.log(math.exp((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(t_1 * Float64(t_0 * t_0)) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0)))) tmp = 0.0 if (phi1 <= -1100000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_1 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), t_4))); elseif (phi1 <= 0.0016) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_2)), sqrt(log(exp(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = t_1 * (t_0 * t_0); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_4 = sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))); tmp = 0.0; if (phi1 <= -1100000.0) tmp = R * (2.0 * atan2(sqrt((t_3 + (t_1 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_4)); elseif (phi1 <= 0.0016) tmp = R * (2.0 * atan2(sqrt((t_3 + t_2)), sqrt(log(exp((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1100000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$1 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.0016], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Log[N[Exp[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := t_1 \cdot \left(t_0 \cdot t_0\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := \sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}\\
\mathbf{if}\;\phi_1 \leq -1100000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_1 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{t_4}\right)\\
\mathbf{elif}\;\phi_1 \leq 0.0016:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_2}}{\sqrt{\log \left(e^{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{t_4}\right)\\
\end{array}
\end{array}
if phi1 < -1.1e6Initial program 48.5%
associate-*l*48.5%
Simplified48.5%
Taylor expanded in phi2 around 0 48.2%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
unpow248.4%
associate-*r*48.5%
Simplified48.4%
Taylor expanded in lambda2 around 0 39.6%
sin-mult39.5%
div-inv39.5%
metadata-eval39.5%
div-inv39.5%
metadata-eval39.5%
cos-sum39.4%
cos-239.5%
div-inv39.5%
metadata-eval39.5%
Applied egg-rr39.5%
div-sub39.5%
+-inverses39.5%
cos-039.5%
metadata-eval39.5%
*-commutative39.5%
associate-*r*39.5%
metadata-eval39.5%
*-lft-identity39.5%
Simplified39.5%
if -1.1e6 < phi1 < 0.00160000000000000008Initial program 80.7%
associate-*l*80.7%
Simplified80.7%
Taylor expanded in phi2 around 0 53.9%
associate--r+53.9%
unpow253.9%
1-sub-sin53.9%
unpow253.9%
*-commutative53.9%
unpow253.9%
associate-*r*53.9%
Simplified53.9%
Taylor expanded in phi1 around 0 52.7%
add-log-exp52.7%
Applied egg-rr52.7%
if 0.00160000000000000008 < phi1 Initial program 46.7%
associate-*l*46.8%
Simplified46.8%
Taylor expanded in phi2 around 0 48.3%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
unpow248.4%
associate-*r*48.4%
Simplified48.4%
Taylor expanded in lambda2 around 0 40.2%
Taylor expanded in phi2 around 0 40.6%
Final simplification46.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (* lambda1 0.5)) 2.0))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_3 (pow (cos (* phi1 0.5)) 2.0)))
(if (<= lambda1 -4.1e-10)
(*
R
(*
2.0
(atan2 (sqrt (+ t_2 (* t_0 t_1))) (sqrt (- t_3 (* (cos phi1) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_2
(*
t_0
(* (sin (/ (- lambda1 lambda2) 2.0)) (sin (* lambda2 -0.5))))))
(sqrt
(-
t_3
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin((lambda1 * 0.5)), 2.0);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = pow(cos((phi1 * 0.5)), 2.0);
double tmp;
if (lambda1 <= -4.1e-10) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * t_1))), sqrt((t_3 - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (sin(((lambda1 - lambda2) / 2.0)) * sin((lambda2 * -0.5)))))), sqrt((t_3 - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin((lambda1 * 0.5d0)) ** 2.0d0
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_3 = cos((phi1 * 0.5d0)) ** 2.0d0
if (lambda1 <= (-4.1d-10)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * t_1))), sqrt((t_3 - (cos(phi1) * t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (sin(((lambda1 - lambda2) / 2.0d0)) * sin((lambda2 * (-0.5d0))))))), sqrt((t_3 - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin((lambda1 * 0.5)), 2.0);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = Math.pow(Math.cos((phi1 * 0.5)), 2.0);
double tmp;
if (lambda1 <= -4.1e-10) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * t_1))), Math.sqrt((t_3 - (Math.cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (Math.sin(((lambda1 - lambda2) / 2.0)) * Math.sin((lambda2 * -0.5)))))), Math.sqrt((t_3 - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin((lambda1 * 0.5)), 2.0) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_3 = math.pow(math.cos((phi1 * 0.5)), 2.0) tmp = 0 if lambda1 <= -4.1e-10: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * t_1))), math.sqrt((t_3 - (math.cos(phi1) * t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (math.sin(((lambda1 - lambda2) / 2.0)) * math.sin((lambda2 * -0.5)))))), math.sqrt((t_3 - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(lambda1 * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_3 = cos(Float64(phi1 * 0.5)) ^ 2.0 tmp = 0.0 if (lambda1 <= -4.1e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * t_1))), sqrt(Float64(t_3 - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(sin(Float64(Float64(lambda1 - lambda2) / 2.0)) * sin(Float64(lambda2 * -0.5)))))), sqrt(Float64(t_3 - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin((lambda1 * 0.5)) ^ 2.0; t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_3 = cos((phi1 * 0.5)) ^ 2.0; tmp = 0.0; if (lambda1 <= -4.1e-10) tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * t_1))), sqrt((t_3 - (cos(phi1) * t_1))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (sin(((lambda1 - lambda2) / 2.0)) * sin((lambda2 * -0.5)))))), sqrt((t_3 - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -4.1e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_3 := {\cos \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -4.1 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot t_1}}{\sqrt{t_3 - \cos \phi_1 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(\sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t_3 - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -4.0999999999999998e-10Initial program 57.2%
associate-*l*57.2%
Simplified57.2%
Taylor expanded in phi2 around 0 47.2%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
unpow247.2%
associate-*r*47.2%
Simplified47.2%
Taylor expanded in lambda2 around 0 45.9%
Taylor expanded in lambda2 around 0 45.7%
if -4.0999999999999998e-10 < lambda1 Initial program 65.8%
associate-*l*65.8%
Simplified65.8%
Taylor expanded in phi2 around 0 52.3%
associate--r+52.3%
unpow252.3%
1-sub-sin52.4%
unpow252.4%
*-commutative52.4%
unpow252.4%
associate-*r*52.5%
Simplified52.4%
Taylor expanded in lambda1 around 0 45.9%
Final simplification45.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (cos (* phi1 0.5)) 2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 4.9e-36)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_3))))
(sqrt (- t_1 (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 (sin (* lambda2 -0.5))))))
(sqrt
(-
t_1
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(cos((phi1 * 0.5)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 4.9e-36) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * -0.5)))))), sqrt((t_1 - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos((phi1 * 0.5d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 4.9d-36) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * (-0.5d0))))))), sqrt((t_1 - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.cos((phi1 * 0.5)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 4.9e-36) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), Math.sqrt((t_1 - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * Math.sin((lambda2 * -0.5)))))), Math.sqrt((t_1 - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.cos((phi1 * 0.5)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 4.9e-36: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), math.sqrt((t_1 - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * math.sin((lambda2 * -0.5)))))), math.sqrt((t_1 - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = cos(Float64(phi1 * 0.5)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 4.9e-36) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(t_1 - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * sin(Float64(lambda2 * -0.5)))))), sqrt(Float64(t_1 - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos((phi1 * 0.5)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 4.9e-36) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * sin((lambda2 * -0.5)))))), sqrt((t_1 - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 4.9e-36], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi1], $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[(t$95$2 * N[(t$95$3 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\cos \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 4.9 \cdot 10^{-36}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}}{\sqrt{t_1 - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}{\sqrt{t_1 - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 4.8999999999999997e-36Initial program 66.0%
associate-*l*66.0%
Simplified66.0%
Taylor expanded in phi2 around 0 52.0%
associate--r+52.0%
unpow252.0%
1-sub-sin52.1%
unpow252.1%
*-commutative52.1%
unpow252.1%
associate-*r*52.1%
Simplified52.1%
Taylor expanded in lambda2 around 0 44.8%
if 4.8999999999999997e-36 < lambda2 Initial program 57.8%
associate-*l*57.8%
Simplified57.8%
Taylor expanded in phi2 around 0 48.6%
associate--r+48.6%
unpow248.6%
1-sub-sin48.6%
unpow248.6%
*-commutative48.6%
unpow248.6%
associate-*r*48.6%
Simplified48.6%
Taylor expanded in lambda1 around 0 46.4%
Final simplification45.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (cos (* phi1 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))))))
(if (<= lambda2 2.45e-15)
(*
R
(*
2.0
(atan2
t_2
(sqrt (- t_0 (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- t_0 (* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(cos((phi1 * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1))));
double tmp;
if (lambda2 <= 2.45e-15) {
tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos((phi1 * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1))))
if (lambda2 <= 2.45d-15) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((t_0 - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((t_0 - (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.cos((phi1 * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_1 * t_1))));
double tmp;
if (lambda2 <= 2.45e-15) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((t_0 - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((t_0 - (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.cos((phi1 * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_1 * t_1)))) tmp = 0 if lambda2 <= 2.45e-15: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((t_0 - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((t_0 - (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * t_1)))) tmp = 0.0 if (lambda2 <= 2.45e-15) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(t_0 - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(t_0 - Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi1 * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))); tmp = 0.0; if (lambda2 <= 2.45e-15) tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt((t_0 - (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 2.45e-15], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi1], $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$2 / N[Sqrt[N[(t$95$0 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\cos \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_1 \cdot t_1\right)}\\
\mathbf{if}\;\lambda_2 \leq 2.45 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{t_0 - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{t_0 - \cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 2.45e-15Initial program 66.7%
associate-*l*66.7%
Simplified66.7%
Taylor expanded in phi2 around 0 52.8%
associate--r+52.8%
unpow252.8%
1-sub-sin52.9%
unpow252.9%
*-commutative52.9%
unpow252.9%
associate-*r*52.9%
Simplified52.9%
Taylor expanded in lambda2 around 0 45.8%
if 2.45e-15 < lambda2 Initial program 55.3%
associate-*l*55.3%
Simplified55.3%
Taylor expanded in phi2 around 0 46.3%
associate--r+46.3%
unpow246.3%
1-sub-sin46.4%
unpow246.4%
*-commutative46.4%
unpow246.4%
associate-*r*46.4%
Simplified46.4%
Taylor expanded in lambda1 around 0 45.1%
Final simplification45.6%
(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))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (pow (sin (* lambda1 0.5)) 2.0))
(t_4 (sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_3)))))
(if (<= phi1 -1100000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_2 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
t_4)))
(if (<= phi1 3.8e-26)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_2 (* t_0 t_0))))
(sqrt
(log (exp (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
(* R (* 2.0 (atan2 (sqrt (+ t_1 (* t_2 t_3))) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = pow(sin((lambda1 * 0.5)), 2.0);
double t_4 = sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_3)));
double tmp;
if (phi1 <= -1100000.0) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_4));
} else if (phi1 <= 3.8e-26) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_0 * t_0)))), sqrt(log(exp((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * t_3))), t_4));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin((lambda1 * 0.5d0)) ** 2.0d0
t_4 = sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_3)))
if (phi1 <= (-1100000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), t_4))
else if (phi1 <= 3.8d-26) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * (t_0 * t_0)))), sqrt(log(exp((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_2 * t_3))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.pow(Math.sin((lambda1 * 0.5)), 2.0);
double t_4 = Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_3)));
double tmp;
if (phi1 <= -1100000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), t_4));
} else if (phi1 <= 3.8e-26) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * (t_0 * t_0)))), Math.sqrt(Math.log(Math.exp((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_2 * t_3))), t_4));
}
return tmp;
}
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) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.pow(math.sin((lambda1 * 0.5)), 2.0) t_4 = math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_3))) tmp = 0 if phi1 <= -1100000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), t_4)) elif phi1 <= 3.8e-26: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * (t_0 * t_0)))), math.sqrt(math.log(math.exp((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_2 * t_3))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(lambda1 * 0.5)) ^ 2.0 t_4 = sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_3))) tmp = 0.0 if (phi1 <= -1100000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), t_4))); elseif (phi1 <= 3.8e-26) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * Float64(t_0 * t_0)))), sqrt(log(exp(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_2 * t_3))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = sin((lambda1 * 0.5)) ^ 2.0; t_4 = sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_3))); tmp = 0.0; if (phi1 <= -1100000.0) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), t_4)); elseif (phi1 <= 3.8e-26) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * (t_0 * t_0)))), sqrt(log(exp((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_2 * t_3))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -1100000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.8e-26], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Log[N[Exp[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\\
t_4 := \sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_3}\\
\mathbf{if}\;\phi_1 \leq -1100000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_2 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{t_4}\right)\\
\mathbf{elif}\;\phi_1 \leq 3.8 \cdot 10^{-26}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_2 \cdot \left(t_0 \cdot t_0\right)}}{\sqrt{\log \left(e^{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_2 \cdot t_3}}{t_4}\right)\\
\end{array}
\end{array}
if phi1 < -1.1e6Initial program 48.5%
associate-*l*48.5%
Simplified48.5%
Taylor expanded in phi2 around 0 48.2%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
unpow248.4%
associate-*r*48.5%
Simplified48.4%
Taylor expanded in lambda2 around 0 39.6%
sin-mult39.5%
div-inv39.5%
metadata-eval39.5%
div-inv39.5%
metadata-eval39.5%
cos-sum39.4%
cos-239.5%
div-inv39.5%
metadata-eval39.5%
Applied egg-rr39.5%
div-sub39.5%
+-inverses39.5%
cos-039.5%
metadata-eval39.5%
*-commutative39.5%
associate-*r*39.5%
metadata-eval39.5%
*-lft-identity39.5%
Simplified39.5%
if -1.1e6 < phi1 < 3.80000000000000015e-26Initial program 80.6%
associate-*l*80.5%
Simplified80.6%
Taylor expanded in phi2 around 0 54.2%
associate--r+54.2%
unpow254.2%
1-sub-sin54.2%
unpow254.2%
*-commutative54.2%
unpow254.2%
associate-*r*54.2%
Simplified54.2%
Taylor expanded in phi1 around 0 53.0%
add-log-exp53.0%
Applied egg-rr53.0%
if 3.80000000000000015e-26 < phi1 Initial program 47.4%
associate-*l*47.4%
Simplified47.5%
Taylor expanded in phi2 around 0 48.0%
associate--r+48.0%
unpow248.0%
1-sub-sin48.1%
unpow248.1%
*-commutative48.1%
unpow248.1%
associate-*r*48.1%
Simplified48.1%
Taylor expanded in lambda2 around 0 40.0%
Taylor expanded in lambda2 around 0 40.6%
Final simplification46.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -1100000.0) (not (<= phi1 4e-6)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(expm1
(log1p (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1100000.0) || !(phi1 <= 4e-6)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(expm1(log1p((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1100000.0) || !(phi1 <= 4e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(Math.expm1(Math.log1p((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -1100000.0) or not (phi1 <= 4e-6): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(math.expm1(math.log1p((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -1100000.0) || !(phi1 <= 4e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(expm1(log1p(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1100000.0], N[Not[LessEqual[phi1, 4e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $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] * 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$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1100000 \lor \neg \left(\phi_1 \leq 4 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.1e6 or 3.99999999999999982e-6 < phi1 Initial program 47.4%
associate-*l*47.4%
Simplified47.5%
Taylor expanded in phi2 around 0 48.3%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
unpow248.4%
associate-*r*48.4%
Simplified48.4%
Taylor expanded in lambda2 around 0 40.0%
sin-mult39.9%
div-inv39.9%
metadata-eval39.9%
div-inv39.9%
metadata-eval39.9%
cos-sum39.9%
cos-239.9%
div-inv39.9%
metadata-eval39.9%
Applied egg-rr39.9%
div-sub39.9%
+-inverses39.9%
cos-039.9%
metadata-eval39.9%
*-commutative39.9%
associate-*r*39.9%
metadata-eval39.9%
*-lft-identity39.9%
Simplified39.9%
if -1.1e6 < phi1 < 3.99999999999999982e-6Initial program 80.7%
associate-*l*80.7%
Simplified80.7%
Taylor expanded in phi2 around 0 53.9%
associate--r+53.9%
unpow253.9%
1-sub-sin53.9%
unpow253.9%
*-commutative53.9%
unpow253.9%
associate-*r*53.9%
Simplified53.9%
Taylor expanded in phi1 around 0 52.7%
expm1-log1p-u52.7%
Applied egg-rr52.7%
Final simplification46.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -1100000.0) (not (<= phi1 1.5e-7)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(log
(exp (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1100000.0) || !(phi1 <= 1.5e-7)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(log(exp((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-1100000.0d0)) .or. (.not. (phi1 <= 1.5d-7))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(log(exp((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1100000.0) || !(phi1 <= 1.5e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(Math.log(Math.exp((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -1100000.0) or not (phi1 <= 1.5e-7): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(math.log(math.exp((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -1100000.0) || !(phi1 <= 1.5e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(log(exp(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -1100000.0) || ~((phi1 <= 1.5e-7))) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(log(exp((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1100000.0], N[Not[LessEqual[phi1, 1.5e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $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] * 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$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Log[N[Exp[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1100000 \lor \neg \left(\phi_1 \leq 1.5 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\log \left(e^{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.1e6 or 1.4999999999999999e-7 < phi1 Initial program 47.4%
associate-*l*47.4%
Simplified47.5%
Taylor expanded in phi2 around 0 48.3%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
unpow248.4%
associate-*r*48.4%
Simplified48.4%
Taylor expanded in lambda2 around 0 40.0%
sin-mult39.9%
div-inv39.9%
metadata-eval39.9%
div-inv39.9%
metadata-eval39.9%
cos-sum39.9%
cos-239.9%
div-inv39.9%
metadata-eval39.9%
Applied egg-rr39.9%
div-sub39.9%
+-inverses39.9%
cos-039.9%
metadata-eval39.9%
*-commutative39.9%
associate-*r*39.9%
metadata-eval39.9%
*-lft-identity39.9%
Simplified39.9%
if -1.1e6 < phi1 < 1.4999999999999999e-7Initial program 80.7%
associate-*l*80.7%
Simplified80.7%
Taylor expanded in phi2 around 0 53.9%
associate--r+53.9%
unpow253.9%
1-sub-sin53.9%
unpow253.9%
*-commutative53.9%
unpow253.9%
associate-*r*53.9%
Simplified53.9%
Taylor expanded in phi1 around 0 52.7%
add-log-exp52.7%
Applied egg-rr52.7%
Final simplification46.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -1100000.0) (not (<= phi1 1.2e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1100000.0) || !(phi1 <= 1.2e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-1100000.0d0)) .or. (.not. (phi1 <= 1.2d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1100000.0) || !(phi1 <= 1.2e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -1100000.0) or not (phi1 <= 1.2e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -1100000.0) || !(phi1 <= 1.2e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -1100000.0) || ~((phi1 <= 1.2e-5))) tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1100000.0], N[Not[LessEqual[phi1, 1.2e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $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] * 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$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1100000 \lor \neg \left(\phi_1 \leq 1.2 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -1.1e6 or 1.2e-5 < phi1 Initial program 47.4%
associate-*l*47.4%
Simplified47.5%
Taylor expanded in phi2 around 0 48.3%
associate--r+48.3%
unpow248.3%
1-sub-sin48.4%
unpow248.4%
*-commutative48.4%
unpow248.4%
associate-*r*48.4%
Simplified48.4%
Taylor expanded in lambda2 around 0 40.0%
sin-mult39.9%
div-inv39.9%
metadata-eval39.9%
div-inv39.9%
metadata-eval39.9%
cos-sum39.9%
cos-239.9%
div-inv39.9%
metadata-eval39.9%
Applied egg-rr39.9%
div-sub39.9%
+-inverses39.9%
cos-039.9%
metadata-eval39.9%
*-commutative39.9%
associate-*r*39.9%
metadata-eval39.9%
*-lft-identity39.9%
Simplified39.9%
if -1.1e6 < phi1 < 1.2e-5Initial program 80.7%
associate-*l*80.7%
Simplified80.7%
Taylor expanded in phi2 around 0 53.9%
associate--r+53.9%
unpow253.9%
1-sub-sin53.9%
unpow253.9%
*-commutative53.9%
unpow253.9%
associate-*r*53.9%
Simplified53.9%
Taylor expanded in phi1 around 0 52.7%
Final simplification46.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= (- lambda1 lambda2) -20.0)
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(+
(pow (cos (* phi1 0.5)) 2.0)
(* -0.25 (* (cos phi1) (* lambda1 lambda1)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -20.0) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((pow(cos((phi1 * 0.5)), 2.0) + (-0.25 * (cos(phi1) * (lambda1 * lambda1)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if ((lambda1 - lambda2) <= (-20.0d0)) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) + ((-0.25d0) * (cos(phi1) * (lambda1 * lambda1)))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -20.0) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) + (-0.25 * (Math.cos(phi1) * (lambda1 * lambda1)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if (lambda1 - lambda2) <= -20.0: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) + (-0.25 * (math.cos(phi1) * (lambda1 * lambda1))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -20.0) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) + Float64(-0.25 * Float64(cos(phi1) * Float64(lambda1 * lambda1)))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if ((lambda1 - lambda2) <= -20.0) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_1, sqrt(((cos((phi1 * 0.5)) ^ 2.0) + (-0.25 * (cos(phi1) * (lambda1 * lambda1))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -20.0], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(-0.25 * N[(N[Cos[phi1], $MachinePrecision] * N[(lambda1 * lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -20:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} + -0.25 \cdot \left(\cos \phi_1 \cdot \left(\lambda_1 \cdot \lambda_1\right)\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -20Initial program 65.1%
associate-*l*65.1%
Simplified65.1%
Taylor expanded in phi2 around 0 51.8%
associate--r+51.8%
unpow251.8%
1-sub-sin51.9%
unpow251.9%
*-commutative51.9%
unpow251.9%
associate-*r*51.9%
Simplified51.9%
Taylor expanded in phi1 around 0 37.9%
if -20 < (-.f64 lambda1 lambda2) Initial program 62.6%
associate-*l*62.6%
Simplified62.6%
Taylor expanded in phi2 around 0 50.5%
associate--r+50.5%
unpow250.5%
1-sub-sin50.6%
unpow250.6%
*-commutative50.6%
unpow250.6%
associate-*r*50.6%
Simplified50.6%
Taylor expanded in lambda2 around 0 41.7%
Taylor expanded in lambda1 around 0 28.8%
unpow228.8%
Simplified28.8%
Final simplification32.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= (- lambda1 lambda2) -20.0)
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* phi1 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -20.0) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((phi1 * 0.5)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if ((lambda1 - lambda2) <= (-20.0d0)) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -20.0) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if (lambda1 - lambda2) <= -20.0: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -20.0) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if ((lambda1 - lambda2) <= -20.0) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((phi1 * 0.5)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -20.0], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -20:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -20Initial program 65.1%
associate-*l*65.1%
Simplified65.1%
Taylor expanded in phi2 around 0 51.8%
associate--r+51.8%
unpow251.8%
1-sub-sin51.9%
unpow251.9%
*-commutative51.9%
unpow251.9%
associate-*r*51.9%
Simplified51.9%
Taylor expanded in phi1 around 0 37.9%
if -20 < (-.f64 lambda1 lambda2) Initial program 62.6%
associate-*l*62.6%
Simplified62.6%
Taylor expanded in phi2 around 0 50.5%
associate--r+50.5%
unpow250.5%
1-sub-sin50.6%
unpow250.6%
*-commutative50.6%
unpow250.6%
associate-*r*50.6%
Simplified50.6%
Taylor expanded in lambda2 around 0 41.7%
Taylor expanded in lambda1 around 0 35.4%
Final simplification36.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(if (or (<= phi1 -4e-10) (not (<= phi1 9e-42)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (pow (cos (* phi1 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double tmp;
if ((phi1 <= -4e-10) || !(phi1 <= 9e-42)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(pow(cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
if ((phi1 <= (-4d-10)) .or. (.not. (phi1 <= 9d-42))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double tmp;
if ((phi1 <= -4e-10) || !(phi1 <= 9e-42)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) tmp = 0 if (phi1 <= -4e-10) or not (phi1 <= 9e-42): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) tmp = 0.0 if ((phi1 <= -4e-10) || !(phi1 <= 9e-42)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = 0.0; if ((phi1 <= -4e-10) || ~((phi1 <= 9e-42))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((cos((phi1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -4e-10], N[Not[LessEqual[phi1, 9e-42]], $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[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
\mathbf{if}\;\phi_1 \leq -4 \cdot 10^{-10} \lor \neg \left(\phi_1 \leq 9 \cdot 10^{-42}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -4.00000000000000015e-10 or 9e-42 < phi1 Initial program 50.5%
associate-*l*50.5%
Simplified50.5%
Taylor expanded in phi2 around 0 48.0%
associate--r+48.0%
unpow248.0%
1-sub-sin48.1%
unpow248.1%
*-commutative48.1%
unpow248.1%
associate-*r*48.1%
Simplified48.1%
Taylor expanded in lambda2 around 0 39.6%
Taylor expanded in lambda1 around 0 29.7%
if -4.00000000000000015e-10 < phi1 < 9e-42Initial program 81.5%
associate-*l*81.5%
Simplified81.5%
Taylor expanded in phi2 around 0 55.2%
associate--r+55.2%
unpow255.2%
1-sub-sin55.2%
unpow255.2%
*-commutative55.2%
unpow255.2%
associate-*r*55.2%
Simplified55.2%
Taylor expanded in phi1 around 0 55.2%
Taylor expanded in phi1 around 0 53.5%
Final simplification39.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(if (<= (- lambda1 lambda2) -20.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (pow (cos (* phi1 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double tmp;
if ((lambda1 - lambda2) <= -20.0) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(pow(cos((phi1 * 0.5)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
if ((lambda1 - lambda2) <= (-20.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double tmp;
if ((lambda1 - lambda2) <= -20.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) tmp = 0 if (lambda1 - lambda2) <= -20.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -20.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = 0.0; if ((lambda1 - lambda2) <= -20.0) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((cos((phi1 * 0.5)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -20.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -20:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -20Initial program 65.1%
associate-*l*65.1%
Simplified65.1%
Taylor expanded in phi2 around 0 51.8%
associate--r+51.8%
unpow251.8%
1-sub-sin51.9%
unpow251.9%
*-commutative51.9%
unpow251.9%
associate-*r*51.9%
Simplified51.9%
Taylor expanded in phi1 around 0 37.9%
Taylor expanded in phi2 around 0 34.7%
if -20 < (-.f64 lambda1 lambda2) Initial program 62.6%
associate-*l*62.6%
Simplified62.6%
Taylor expanded in phi2 around 0 50.5%
associate--r+50.5%
unpow250.5%
1-sub-sin50.6%
unpow250.6%
*-commutative50.6%
unpow250.6%
associate-*r*50.6%
Simplified50.6%
Taylor expanded in lambda2 around 0 41.7%
Taylor expanded in lambda1 around 0 35.4%
Final simplification35.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= lambda2 8.6e-73)
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda1 0.5)) 2.0)))))
(if (<= lambda2 1250.0)
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* phi1 0.5)) 2.0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* 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 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if (lambda2 <= 8.6e-73) {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
} else if (lambda2 <= 1250.0) {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((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 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if (lambda2 <= 8.6d-73) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
else if (lambda2 <= 1250.0d0) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((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 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if (lambda2 <= 8.6e-73) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
} else if (lambda2 <= 1250.0) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if lambda2 <= 8.6e-73: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0)))) elif lambda2 <= 1250.0: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((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 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (lambda2 <= 8.6e-73) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); elseif (lambda2 <= 1250.0) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(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 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if (lambda2 <= 8.6e-73) tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); elseif (lambda2 <= 1250.0) tmp = R * (2.0 * atan2(t_1, sqrt((cos((phi1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((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[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 8.6e-73], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 1250.0], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}\\
\mathbf{if}\;\lambda_2 \leq 8.6 \cdot 10^{-73}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{elif}\;\lambda_2 \leq 1250:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 8.5999999999999998e-73Initial program 65.3%
associate-*l*65.3%
Simplified65.3%
Taylor expanded in phi2 around 0 51.6%
associate--r+51.6%
unpow251.6%
1-sub-sin51.7%
unpow251.7%
*-commutative51.7%
unpow251.7%
associate-*r*51.7%
Simplified51.7%
Taylor expanded in phi1 around 0 36.2%
Taylor expanded in lambda2 around 0 31.7%
unpow231.7%
1-sub-sin31.7%
unpow231.7%
Simplified31.7%
if 8.5999999999999998e-73 < lambda2 < 1250Initial program 78.8%
associate-*l*78.8%
Simplified78.9%
Taylor expanded in phi2 around 0 64.6%
associate--r+64.6%
unpow264.6%
1-sub-sin64.5%
unpow264.5%
*-commutative64.5%
unpow264.5%
associate-*r*64.5%
Simplified64.5%
Taylor expanded in lambda2 around 0 57.4%
Taylor expanded in lambda1 around 0 48.4%
if 1250 < lambda2 Initial program 53.8%
associate-*l*53.8%
Simplified53.8%
Taylor expanded in phi2 around 0 45.0%
associate--r+45.0%
unpow245.0%
1-sub-sin45.0%
unpow245.0%
*-commutative45.0%
unpow245.0%
associate-*r*45.0%
Simplified45.0%
Taylor expanded in phi1 around 0 35.7%
Taylor expanded in lambda1 around 0 35.9%
unpow235.9%
1-sub-sin36.1%
unpow236.1%
Simplified36.1%
Final simplification34.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= lambda1 -7.8e-7)
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* lambda1 0.5)) 2.0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* 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 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if (lambda1 <= -7.8e-7) {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((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 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if (lambda1 <= (-7.8d-7)) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((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 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if (lambda1 <= -7.8e-7) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if lambda1 <= -7.8e-7: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((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 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (lambda1 <= -7.8e-7) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(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 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if (lambda1 <= -7.8e-7) tmp = R * (2.0 * atan2(t_1, sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((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[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -7.8e-7], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}\\
\mathbf{if}\;\lambda_1 \leq -7.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -7.80000000000000049e-7Initial program 57.2%
associate-*l*57.2%
Simplified57.2%
Taylor expanded in phi2 around 0 47.2%
associate--r+47.2%
unpow247.2%
1-sub-sin47.2%
unpow247.2%
*-commutative47.2%
unpow247.2%
associate-*r*47.2%
Simplified47.2%
Taylor expanded in phi1 around 0 33.4%
Taylor expanded in lambda2 around 0 33.4%
unpow233.4%
1-sub-sin33.4%
unpow233.4%
Simplified33.4%
if -7.80000000000000049e-7 < lambda1 Initial program 65.8%
associate-*l*65.8%
Simplified65.8%
Taylor expanded in phi2 around 0 52.3%
associate--r+52.3%
unpow252.3%
1-sub-sin52.4%
unpow252.4%
*-commutative52.4%
unpow252.4%
associate-*r*52.5%
Simplified52.4%
Taylor expanded in phi1 around 0 36.8%
Taylor expanded in lambda1 around 0 35.2%
unpow235.2%
1-sub-sin35.3%
unpow235.3%
Simplified35.3%
Final simplification34.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt (pow (cos (* 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) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt(pow(cos((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) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((cos((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) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)))), Math.sqrt(Math.pow(Math.cos((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) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))), math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt((cos(Float64(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) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 63.6%
associate-*l*63.6%
Simplified63.6%
Taylor expanded in phi2 around 0 51.0%
associate--r+51.0%
unpow251.0%
1-sub-sin51.1%
unpow251.1%
*-commutative51.1%
unpow251.1%
associate-*r*51.1%
Simplified51.1%
Taylor expanded in phi1 around 0 35.9%
Taylor expanded in lambda1 around 0 31.8%
unpow231.8%
1-sub-sin31.8%
unpow231.8%
Simplified31.8%
Final simplification31.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* (- phi1 phi2) 0.5))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(sin (* lambda2 -0.5))
(* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin(((phi1 - phi2) * 0.5)), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (sin((lambda2 * -0.5)) * ((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0)))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin(((phi1 - phi2) * 0.5d0)), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (sin((lambda2 * (-0.5d0))) * ((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 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 - phi2) * 0.5)), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.sin((lambda2 * -0.5)) * ((Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin(((phi1 - phi2) * 0.5)), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.sin((lambda2 * -0.5)) * ((math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0)))))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(Float64(phi1 - phi2) * 0.5)), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(sin(Float64(lambda2 * -0.5)) * Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin(((phi1 - phi2) * 0.5)), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (sin((lambda2 * -0.5)) * ((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right)}}\right)
\end{array}
Initial program 63.6%
Taylor expanded in lambda2 around 0 45.3%
Taylor expanded in lambda1 around 0 15.6%
Taylor expanded in lambda1 around 0 15.4%
Final simplification15.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- phi1 phi2) 0.5))))
(*
R
(*
2.0
(atan2
t_0
(sqrt
(-
1.0
(+
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))
(pow t_0 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) * 0.5));
return R * (2.0 * atan2(t_0, sqrt((1.0 - ((cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))) + pow(t_0, 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((phi1 - phi2) * 0.5d0))
code = r * (2.0d0 * atan2(t_0, sqrt((1.0d0 - ((cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))) + (t_0 ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((phi1 - phi2) * 0.5));
return R * (2.0 * Math.atan2(t_0, Math.sqrt((1.0 - ((Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))) + Math.pow(t_0, 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) * 0.5)) return R * (2.0 * math.atan2(t_0, math.sqrt((1.0 - ((math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0))) + math.pow(t_0, 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5)) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))) + (t_0 ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) * 0.5)); tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - ((cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0))) + (t_0 ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[(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] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{1 - \left(\cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right) + {t_0}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.6%
Taylor expanded in lambda2 around 0 45.3%
Taylor expanded in lambda1 around 0 15.6%
Taylor expanded in lambda2 around 0 15.4%
Final simplification15.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- phi1 phi2) 0.5))))
(*
R
(*
2.0
(atan2
t_0
(sqrt
(-
1.0
(+
(pow t_0 2.0)
(* (* (cos phi1) (cos phi2)) (pow (sin (* lambda2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((phi1 - phi2) * 0.5));
return R * (2.0 * atan2(t_0, sqrt((1.0 - (pow(t_0, 2.0) + ((cos(phi1) * cos(phi2)) * pow(sin((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(((phi1 - phi2) * 0.5d0))
code = r * (2.0d0 * atan2(t_0, sqrt((1.0d0 - ((t_0 ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (sin((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(((phi1 - phi2) * 0.5));
return R * (2.0 * Math.atan2(t_0, Math.sqrt((1.0 - (Math.pow(t_0, 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) * 0.5)) return R * (2.0 * math.atan2(t_0, math.sqrt((1.0 - (math.pow(t_0, 2.0) + ((math.cos(phi1) * math.cos(phi2)) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5)) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(1.0 - Float64((t_0 ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) * 0.5)); tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - ((t_0 ^ 2.0) + ((cos(phi1) * cos(phi2)) * (sin((lambda2 * -0.5)) ^ 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[(N[Power[t$95$0, 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{1 - \left({t_0}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.6%
Taylor expanded in lambda2 around 0 45.3%
Taylor expanded in lambda1 around 0 15.6%
Taylor expanded in lambda1 around 0 15.5%
Final simplification15.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* (- phi1 phi2) 0.5))))
(if (<= phi1 3.4e+17)
(*
R
(*
2.0
(atan2
t_0
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
t_0
(sqrt
(-
1.0
(+
(pow (sin (* 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) {
double t_0 = sin(((phi1 - phi2) * 0.5));
double tmp;
if (phi1 <= 3.4e+17) {
tmp = R * (2.0 * atan2(t_0, sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - (pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * 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) :: tmp
t_0 = sin(((phi1 - phi2) * 0.5d0))
if (phi1 <= 3.4d+17) then
tmp = r * (2.0d0 * atan2(t_0, sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt((1.0d0 - ((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (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(((phi1 - phi2) * 0.5));
double tmp;
if (phi1 <= 3.4e+17) {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((1.0 - (Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((phi1 - phi2) * 0.5)) tmp = 0 if phi1 <= 3.4e+17: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((1.0 - (math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5)) tmp = 0.0 if (phi1 <= 3.4e+17) tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(1.0 - Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) * 0.5)); tmp = 0.0; if (phi1 <= 3.4e+17) tmp = R * (2.0 * atan2(t_0, sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_0, sqrt((1.0 - ((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (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[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 3.4e+17], 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] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[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]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
\mathbf{if}\;\phi_1 \leq 3.4 \cdot 10^{+17}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{1 - \left({\sin \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)}}\right)\\
\end{array}
\end{array}
if phi1 < 3.4e17Initial program 68.9%
Taylor expanded in lambda2 around 0 47.0%
Taylor expanded in lambda1 around 0 14.1%
Taylor expanded in phi1 around 0 13.7%
associate--r+13.7%
unpow213.7%
1-sub-sin13.7%
unpow213.7%
*-commutative13.7%
Simplified13.7%
if 3.4e17 < phi1 Initial program 49.4%
Taylor expanded in lambda2 around 0 40.9%
Taylor expanded in lambda1 around 0 19.5%
Taylor expanded in phi2 around 0 20.3%
Final simplification15.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* (- phi1 phi2) 0.5))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin(((phi1 - phi2) * 0.5)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin(((phi1 - phi2) * 0.5d0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin(((phi1 - phi2) * 0.5)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin(((phi1 - phi2) * 0.5)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(Float64(phi1 - phi2) * 0.5)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin(((phi1 - phi2) * 0.5)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 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[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 63.6%
Taylor expanded in lambda2 around 0 45.3%
Taylor expanded in lambda1 around 0 15.6%
Taylor expanded in phi1 around 0 13.2%
associate--r+13.2%
unpow213.2%
1-sub-sin13.2%
unpow213.2%
*-commutative13.2%
Simplified13.2%
Final simplification13.2%
herbie shell --seed 2023229
(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))))))))))