
(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 17 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 (pow (sin (* phi1 0.5)) 2.0))
(t_4 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))))
(if (<= phi1 -5.9e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 t_3))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))))
(if (<= phi1 1.05e-5)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- (pow (cos (* phi2 0.5)) 2.0) (* (cos phi2) t_0))))))
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
(- 1.0 t_3)
(* (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 = 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 = pow(sin((phi1 * 0.5)), 2.0);
double t_4 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi1 <= -5.9e-5) {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)))));
} else if (phi1 <= 1.05e-5) {
tmp = R * (2.0 * atan2(t_4, sqrt((pow(cos((phi2 * 0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - t_3) - (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) :: 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 = sin((phi1 * 0.5d0)) ** 2.0d0
t_4 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2))
if (phi1 <= (-5.9d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_3)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
else if (phi1 <= 1.05d-5) then
tmp = r * (2.0d0 * atan2(t_4, sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt(((1.0d0 - t_3) - (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.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.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_4 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi1 <= -5.9e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_3)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)))));
} else if (phi1 <= 1.05e-5) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt(((1.0 - t_3) - (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.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.pow(math.sin((phi1 * 0.5)), 2.0) t_4 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)) tmp = 0 if phi1 <= -5.9e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_3)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0))))) elif phi1 <= 1.05e-5: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - (math.cos(phi2) * t_0))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt(((1.0 - t_3) - (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(-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 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_4 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)) tmp = 0.0 if (phi1 <= -5.9e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_3)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0)))))); elseif (phi1 <= 1.05e-5) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(1.0 - t_3) - 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((-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 = sin((phi1 * 0.5)) ^ 2.0; t_4 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2)); tmp = 0.0; if (phi1 <= -5.9e-5) tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); elseif (phi1 <= 1.05e-5) tmp = R * (2.0 * atan2(t_4, sqrt(((cos((phi2 * 0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - t_3) - (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[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[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5.9e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$3), $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], If[LessEqual[phi1, 1.05e-5], N[(R * N[(2.0 * N[ArcTan[t$95$4 / 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[t$95$4 / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\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 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_4 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2}\\
\mathbf{if}\;\phi_1 \leq -5.9 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_3}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_0}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.05 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\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{t_4}{\sqrt{\left(1 - t_3\right) - \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -5.8999999999999998e-5Initial program 37.0%
associate-*l*37.0%
Simplified37.0%
Taylor expanded in phi2 around 0 38.4%
associate--r+38.4%
unpow238.4%
1-sub-sin38.5%
unpow238.5%
*-commutative38.5%
unpow238.5%
associate-*r*38.5%
Simplified38.5%
Taylor expanded in phi2 around 0 39.0%
if -5.8999999999999998e-5 < phi1 < 1.04999999999999994e-5Initial program 74.7%
associate-*l*74.7%
Simplified74.7%
Taylor expanded in phi1 around 0 74.7%
associate--r+74.7%
unpow274.7%
1-sub-sin74.8%
unpow274.8%
metadata-eval74.8%
associate-*r*74.8%
*-commutative74.8%
mul-1-neg74.8%
distribute-lft-neg-out74.8%
cos-neg74.8%
sub-neg74.8%
mul-1-neg74.8%
distribute-lft-in74.8%
associate-*r*74.8%
metadata-eval74.8%
metadata-eval74.8%
associate-*r*74.8%
distribute-lft-in74.8%
Simplified74.8%
if 1.04999999999999994e-5 < phi1 Initial program 48.8%
associate-*l*48.8%
Simplified48.8%
Taylor expanded in phi2 around 0 48.9%
associate--r+48.9%
Simplified48.9%
Final simplification58.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_2 (sin (* (- phi1 phi2) 0.5))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- (/ (- 1.0 (pow t_2 4.0)) (+ 1.0 (pow t_2 2.0))) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = sin(((phi1 - phi2) * 0.5));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((((1.0 - pow(t_2, 4.0)) / (1.0 + pow(t_2, 2.0))) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin(((phi1 - phi2) * 0.5d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((((1.0d0 - (t_2 ** 4.0d0)) / (1.0d0 + (t_2 ** 2.0d0))) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_2 = Math.sin(((phi1 - phi2) * 0.5));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((((1.0 - Math.pow(t_2, 4.0)) / (1.0 + Math.pow(t_2, 2.0))) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_2 = math.sin(((phi1 - phi2) * 0.5)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((((1.0 - math.pow(t_2, 4.0)) / (1.0 + math.pow(t_2, 2.0))) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_2 = sin(Float64(Float64(phi1 - phi2) * 0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(Float64(1.0 - (t_2 ^ 4.0)) / Float64(1.0 + (t_2 ^ 2.0))) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = sin(((phi1 - phi2) * 0.5)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((((1.0 - (t_2 ^ 4.0)) / (1.0 + (t_2 ^ 2.0))) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(N[(1.0 - N[Power[t$95$2, 4.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
t_2 := \sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{\frac{1 - {t_2}^{4}}{1 + {t_2}^{2}} - t_1}}\right)
\end{array}
\end{array}
Initial program 58.0%
associate-*l*58.0%
Simplified58.1%
flip--58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
div-inv58.1%
metadata-eval58.1%
Applied egg-rr58.1%
pow-sqr58.1%
*-commutative58.1%
metadata-eval58.1%
*-commutative58.1%
Simplified58.1%
Final simplification58.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_1 t_2)))
(if (<= lambda1 -4.3e-8)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 (* t_2 t_2))))
(sqrt
(-
1.0
(+
(pow (sin (* (- phi1 phi2) 0.5)) 2.0)
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 t_3)))
(sqrt (- 1.0 (+ t_0 (* t_3 (sin (* lambda2 -0.5))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * t_2;
double tmp;
if (lambda1 <= -4.3e-8) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_2)))), sqrt((1.0 - (pow(sin(((phi1 - phi2) * 0.5)), 2.0) + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * t_3))), sqrt((1.0 - (t_0 + (t_3 * sin((lambda2 * -0.5))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_1 * t_2
if (lambda1 <= (-4.3d-8)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_2)))), sqrt((1.0d0 - ((sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0) + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * t_3))), sqrt((1.0d0 - (t_0 + (t_3 * sin((lambda2 * (-0.5d0)))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 * t_2;
double tmp;
if (lambda1 <= -4.3e-8) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (t_2 * t_2)))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0) + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * t_3))), Math.sqrt((1.0 - (t_0 + (t_3 * Math.sin((lambda2 * -0.5))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_1 * t_2 tmp = 0 if lambda1 <= -4.3e-8: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (t_2 * t_2)))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * t_3))), math.sqrt((1.0 - (t_0 + (t_3 * math.sin((lambda2 * -0.5)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_1 * t_2) tmp = 0.0 if (lambda1 <= -4.3e-8) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(t_2 * t_2)))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0) + Float64(cos(phi2) * 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 * t_3))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_3 * sin(Float64(lambda2 * -0.5))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_1 * t_2; tmp = 0.0; if (lambda1 <= -4.3e-8) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_2)))), sqrt((1.0 - ((sin(((phi1 - phi2) * 0.5)) ^ 2.0) + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * t_3))), sqrt((1.0 - (t_0 + (t_3 * sin((lambda2 * -0.5)))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 * t$95$2), $MachinePrecision]}, If[LessEqual[lambda1, -4.3e-8], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$3 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_1 \cdot t_2\\
\mathbf{if}\;\lambda_1 \leq -4.3 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{1 - \left({\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot t_3}}{\sqrt{1 - \left(t_0 + t_3 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -4.3000000000000001e-8Initial program 51.6%
associate-*l*51.7%
Simplified51.7%
Taylor expanded in lambda2 around 0 51.2%
if -4.3000000000000001e-8 < lambda1 Initial program 60.6%
Taylor expanded in lambda1 around 0 53.0%
Final simplification52.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(* R (* 2.0 (atan2 (sqrt (+ t_2 t_1)) (sqrt (- (- 1.0 t_2) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_2) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0d0 - t_2) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_1)), Math.sqrt(((1.0 - t_2) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + t_1)), math.sqrt(((1.0 - t_2) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_1)), sqrt(Float64(Float64(1.0 - t_2) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_2) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_1}}{\sqrt{\left(1 - t_2\right) - t_1}}\right)
\end{array}
\end{array}
Initial program 58.0%
associate-*l*58.0%
Simplified58.1%
Final simplification58.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_1 (* t_2 t_2))))))
(if (<= lambda1 -4.3e-8)
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(+
t_0
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt (- 1.0 (+ t_0 (* t_1 (pow (sin (* lambda2 -0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_2))));
double tmp;
if (lambda1 <= -4.3e-8) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (t_1 * 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 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (t_2 * t_2))))
if (lambda1 <= (-4.3d-8)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_0 + (t_1 * (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.sin(((phi1 - phi2) * 0.5)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_2))));
double tmp;
if (lambda1 <= -4.3e-8) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_0 + (t_1 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_2)))) tmp = 0 if lambda1 <= -4.3e-8: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_0 + (t_1 * math.pow(math.sin((lambda2 * -0.5)), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_2 * t_2)))) tmp = 0.0 if (lambda1 <= -4.3e-8) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_0 + Float64(t_1 * (sin(Float64(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)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (t_2 * t_2)))); tmp = 0.0; if (lambda1 <= -4.3e-8) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (t_1 * (sin((lambda2 * -0.5)) ^ 2.0))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -4.3e-8], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$1 * 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)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_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_1 \cdot \left(t_2 \cdot t_2\right)}\\
\mathbf{if}\;\lambda_1 \leq -4.3 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(t_0 + t_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -4.3000000000000001e-8Initial program 51.6%
associate-*l*51.7%
Simplified51.7%
Taylor expanded in lambda2 around 0 51.2%
if -4.3000000000000001e-8 < lambda1 Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
Taylor expanded in lambda1 around 0 53.1%
Final simplification52.6%
(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 (pow (sin (* phi1 0.5)) 2.0))
(t_4 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))))
(if (<= phi1 -5e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 t_3))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))))
(if (<= phi1 4.8e-6)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- (pow (cos (* phi2 0.5)) 2.0) (* (cos phi2) t_0))))))
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
1.0
(+
t_3
(*
(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 = 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 = pow(sin((phi1 * 0.5)), 2.0);
double t_4 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi1 <= -5e-5) {
tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)))));
} else if (phi1 <= 4.8e-6) {
tmp = R * (2.0 * atan2(t_4, sqrt((pow(cos((phi2 * 0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_3 + (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) :: 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 = sin((phi1 * 0.5d0)) ** 2.0d0
t_4 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2))
if (phi1 <= (-5d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + t_3)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))))
else if (phi1 <= 4.8d-6) then
tmp = r * (2.0d0 * atan2(t_4, sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - (t_3 + (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.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.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_4 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi1 <= -5e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_3)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)))));
} else if (phi1 <= 4.8e-6) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - (t_3 + (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.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.pow(math.sin((phi1 * 0.5)), 2.0) t_4 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)) tmp = 0 if phi1 <= -5e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + t_3)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0))))) elif phi1 <= 4.8e-6: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - (math.cos(phi2) * t_0))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - (t_3 + (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(-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 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_4 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)) tmp = 0.0 if (phi1 <= -5e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_3)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0)))))); elseif (phi1 <= 4.8e-6) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(t_3 + 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((-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 = sin((phi1 * 0.5)) ^ 2.0; t_4 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2)); tmp = 0.0; if (phi1 <= -5e-5) tmp = R * (2.0 * atan2(sqrt((t_2 + t_3)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))))); elseif (phi1 <= 4.8e-6) tmp = R * (2.0 * atan2(t_4, sqrt(((cos((phi2 * 0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_3 + (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[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[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -5e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$3), $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], If[LessEqual[phi1, 4.8e-6], N[(R * N[(2.0 * N[ArcTan[t$95$4 / 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[t$95$4 / N[Sqrt[N[(1.0 - N[(t$95$3 + 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(-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 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_4 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2}\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_3}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_0}}\right)\\
\mathbf{elif}\;\phi_1 \leq 4.8 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\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{t_4}{\sqrt{1 - \left(t_3 + \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 < -5.00000000000000024e-5Initial program 37.0%
associate-*l*37.0%
Simplified37.0%
Taylor expanded in phi2 around 0 38.4%
associate--r+38.4%
unpow238.4%
1-sub-sin38.5%
unpow238.5%
*-commutative38.5%
unpow238.5%
associate-*r*38.5%
Simplified38.5%
Taylor expanded in phi2 around 0 39.0%
if -5.00000000000000024e-5 < phi1 < 4.7999999999999998e-6Initial program 74.7%
associate-*l*74.7%
Simplified74.7%
Taylor expanded in phi1 around 0 74.7%
associate--r+74.7%
unpow274.7%
1-sub-sin74.8%
unpow274.8%
metadata-eval74.8%
associate-*r*74.8%
*-commutative74.8%
mul-1-neg74.8%
distribute-lft-neg-out74.8%
cos-neg74.8%
sub-neg74.8%
mul-1-neg74.8%
distribute-lft-in74.8%
associate-*r*74.8%
metadata-eval74.8%
metadata-eval74.8%
associate-*r*74.8%
distribute-lft-in74.8%
Simplified74.8%
if 4.7999999999999998e-6 < phi1 Initial program 48.8%
associate-*l*48.8%
Simplified48.8%
Taylor expanded in phi2 around 0 48.9%
Final simplification58.6%
(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 (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_0))))
(t_4 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))))
(if (<= phi1 -0.00082)
(* R (* 2.0 (atan2 (sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0))) t_3)))
(if (<= phi1 3.6e-6)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- (pow (cos (* phi2 0.5)) 2.0) (* (cos phi2) t_0))))))
(* R (* 2.0 (atan2 t_4 t_3)))))))
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(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_0)));
double t_4 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi1 <= -0.00082) {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), t_3));
} else if (phi1 <= 3.6e-6) {
tmp = R * (2.0 * atan2(t_4, sqrt((pow(cos((phi2 * 0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(t_4, t_3));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: 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(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_0)))
t_4 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2))
if (phi1 <= (-0.00082d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), t_3))
else if (phi1 <= 3.6d-6) then
tmp = r * (2.0d0 * atan2(t_4, sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(t_4, t_3))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((-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.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_0)));
double t_4 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi1 <= -0.00082) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), t_3));
} else if (phi1 <= 3.6e-6) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, t_3));
}
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.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_0))) t_4 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)) tmp = 0 if phi1 <= -0.00082: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), t_3)) elif phi1 <= 3.6e-6: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - (math.cos(phi2) * t_0))))) else: tmp = R * (2.0 * math.atan2(t_4, t_3)) 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((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_0))) t_4 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)) tmp = 0.0 if (phi1 <= -0.00082) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), t_3))); elseif (phi1 <= 3.6e-6) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, t_3))); 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(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_0))); t_4 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2)); tmp = 0.0; if (phi1 <= -0.00082) tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), t_3)); elseif (phi1 <= 3.6e-6) tmp = R * (2.0 * atan2(t_4, sqrt(((cos((phi2 * 0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(t_4, t_3)); 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[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.00082], 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$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.6e-6], N[(R * N[(2.0 * N[ArcTan[t$95$4 / 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[t$95$4 / t$95$3], $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{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_0}\\
t_4 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2}\\
\mathbf{if}\;\phi_1 \leq -0.00082:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{t_3}\right)\\
\mathbf{elif}\;\phi_1 \leq 3.6 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\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{t_4}{t_3}\right)\\
\end{array}
\end{array}
if phi1 < -8.1999999999999998e-4Initial program 37.0%
associate-*l*37.0%
Simplified37.0%
Taylor expanded in phi2 around 0 38.4%
associate--r+38.4%
unpow238.4%
1-sub-sin38.5%
unpow238.5%
*-commutative38.5%
unpow238.5%
associate-*r*38.5%
Simplified38.5%
Taylor expanded in phi2 around 0 39.0%
if -8.1999999999999998e-4 < phi1 < 3.59999999999999984e-6Initial program 74.7%
associate-*l*74.7%
Simplified74.7%
Taylor expanded in phi1 around 0 74.7%
associate--r+74.7%
unpow274.7%
1-sub-sin74.8%
unpow274.8%
metadata-eval74.8%
associate-*r*74.8%
*-commutative74.8%
mul-1-neg74.8%
distribute-lft-neg-out74.8%
cos-neg74.8%
sub-neg74.8%
mul-1-neg74.8%
distribute-lft-in74.8%
associate-*r*74.8%
metadata-eval74.8%
metadata-eval74.8%
associate-*r*74.8%
distribute-lft-in74.8%
Simplified74.8%
if 3.59999999999999984e-6 < phi1 Initial program 48.8%
associate-*l*48.8%
Simplified48.8%
Taylor expanded in phi2 around 0 48.9%
associate--r+48.9%
unpow248.9%
1-sub-sin48.9%
unpow248.9%
*-commutative48.9%
unpow248.9%
associate-*r*48.9%
Simplified48.9%
Final simplification58.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 t_2)))
(if (<= (- lambda1 lambda2) -0.0001)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 t_3)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (fma t_1 t_3 t_0))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * t_2;
double tmp;
if ((lambda1 - lambda2) <= -0.0001) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_1, t_3, t_0)), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * t_2) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -0.0001) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * t_3))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(t_1, t_3, t_0)), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * t$95$2), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.0001], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 * t$95$3 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_2 \cdot t_2\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.0001:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_3}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_1, t_3, t_0\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000005e-4Initial program 57.0%
associate-*l*57.0%
Simplified57.1%
Taylor expanded in phi2 around 0 42.4%
associate--r+42.4%
unpow242.4%
1-sub-sin42.4%
unpow242.4%
*-commutative42.4%
unpow242.4%
associate-*r*42.4%
Simplified42.4%
if -1.00000000000000005e-4 < (-.f64 lambda1 lambda2) Initial program 58.8%
Simplified58.8%
Taylor expanded in lambda2 around 0 46.9%
Taylor expanded in lambda1 around 0 37.5%
Final simplification39.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 t_1)))
(if (or (<= phi2 -0.00019) (not (<= phi2 2.75e-18)))
(*
R
(*
2.0
(atan2
(sqrt (fma t_0 t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 t_2) (pow (sin (* phi1 0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * t_1;
double tmp;
if ((phi2 <= -0.00019) || !(phi2 <= 2.75e-18)) {
tmp = R * (2.0 * atan2(sqrt(fma(t_0, t_2, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * t_2) + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * t_1) tmp = 0.0 if ((phi2 <= -0.00019) || !(phi2 <= 2.75e-18)) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(t_0, t_2, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00019], N[Not[LessEqual[phi2, 2.75e-18]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 * t$95$2 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t_1 \cdot t_1\\
\mathbf{if}\;\phi_2 \leq -0.00019 \lor \neg \left(\phi_2 \leq 2.75 \cdot 10^{-18}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, t_2, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot 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 {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -1.9000000000000001e-4 or 2.75e-18 < phi2 Initial program 46.3%
Simplified46.3%
Taylor expanded in lambda2 around 0 36.7%
Taylor expanded in lambda1 around 0 27.4%
if -1.9000000000000001e-4 < phi2 < 2.75e-18Initial program 73.1%
associate-*l*73.1%
Simplified73.1%
Taylor expanded in phi2 around 0 73.1%
associate--r+73.1%
unpow273.1%
1-sub-sin73.1%
unpow273.1%
*-commutative73.1%
unpow273.1%
associate-*r*73.1%
Simplified73.1%
Taylor expanded in phi2 around 0 73.0%
Final simplification47.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (* -0.5 (- lambda2 lambda1))))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 t_3)))
(if (<= (- lambda1 lambda2) -1.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 t_4)))
(sqrt (/ (- 1.0 (pow t_1 4.0)) (+ 1.0 (pow t_1 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (fma t_2 t_4 t_0))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin((-0.5 * (lambda2 - lambda1)));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * t_3;
double tmp;
if ((lambda1 - lambda2) <= -1.0) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * t_4))), sqrt(((1.0 - pow(t_1, 4.0)) / (1.0 + pow(t_1, 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_2, t_4, t_0)), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * t_3) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * t_4))), sqrt(Float64(Float64(1.0 - (t_1 ^ 4.0)) / Float64(1.0 + (t_1 ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(t_2, t_4, t_0)), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); end return 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[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $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]}, Block[{t$95$4 = N[(t$95$3 * t$95$3), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[t$95$1, 4.0], $MachinePrecision]), $MachinePrecision] / N[(1.0 + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 * t$95$4 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t_3 \cdot t_3\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot t_4}}{\sqrt{\frac{1 - {t_1}^{4}}{1 + {t_1}^{2}}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_2, t_4, t_0\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1Initial program 56.5%
associate-*l*56.6%
Simplified56.6%
Taylor expanded in phi2 around 0 41.5%
associate--r+41.5%
unpow241.5%
1-sub-sin41.5%
unpow241.5%
*-commutative41.5%
unpow241.5%
associate-*r*41.5%
Simplified41.5%
Taylor expanded in phi1 around 0 27.8%
flip--27.8%
metadata-eval27.8%
Applied egg-rr27.8%
pow-sqr27.8%
metadata-eval27.8%
Simplified27.8%
if -1 < (-.f64 lambda1 lambda2) Initial program 59.0%
Simplified59.0%
Taylor expanded in lambda2 around 0 47.0%
Taylor expanded in lambda1 around 0 37.5%
Final simplification33.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 t_2)))
(if (<= (- lambda1 lambda2) -1.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 t_3)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (fma t_1 t_3 t_0))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * t_2;
double tmp;
if ((lambda1 - lambda2) <= -1.0) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_1, t_3, t_0)), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * t_2) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * t_3))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(t_1, t_3, t_0)), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * t$95$2), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * t$95$3), $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[(t$95$1 * t$95$3 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_2 \cdot t_2\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_3}}{\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{\mathsf{fma}\left(t_1, t_3, t_0\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1Initial program 56.5%
associate-*l*56.6%
Simplified56.6%
Taylor expanded in phi2 around 0 41.5%
associate--r+41.5%
unpow241.5%
1-sub-sin41.5%
unpow241.5%
*-commutative41.5%
unpow241.5%
associate-*r*41.5%
Simplified41.5%
Taylor expanded in phi1 around 0 27.8%
if -1 < (-.f64 lambda1 lambda2) Initial program 59.0%
Simplified59.0%
Taylor expanded in lambda2 around 0 47.0%
Taylor expanded in lambda1 around 0 37.5%
Final simplification33.5%
(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 (- 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));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
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((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
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((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 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((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 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((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 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[(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)\\
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{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 58.0%
associate-*l*58.0%
Simplified58.1%
Taylor expanded in phi2 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.7%
unpow243.7%
*-commutative43.7%
unpow243.7%
associate-*r*43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.9%
Final simplification30.9%
(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 -7e-5)
(* 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 <= -7e-5) {
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 <= (-7d-5)) 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 <= -7e-5) {
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 <= -7e-5: 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 <= -7e-5) 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 <= -7e-5) 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, -7e-5], 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 \cdot 10^{-5}:\\
\;\;\;\;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 < -6.9999999999999994e-5Initial program 50.9%
associate-*l*51.0%
Simplified51.1%
Taylor expanded in phi2 around 0 37.2%
associate--r+37.2%
unpow237.2%
1-sub-sin37.2%
unpow237.2%
*-commutative37.2%
unpow237.2%
associate-*r*37.2%
Simplified37.2%
Taylor expanded in phi1 around 0 26.0%
Taylor expanded in lambda2 around 0 25.9%
unpow225.9%
1-sub-sin25.9%
unpow225.9%
Simplified25.9%
if -6.9999999999999994e-5 < lambda1 Initial program 60.8%
associate-*l*60.8%
Simplified60.8%
Taylor expanded in phi2 around 0 46.2%
associate--r+46.3%
unpow246.3%
1-sub-sin46.3%
unpow246.3%
*-commutative46.3%
unpow246.3%
associate-*r*46.3%
Simplified46.3%
Taylor expanded in phi1 around 0 32.9%
Taylor expanded in lambda1 around 0 30.5%
unpow230.5%
1-sub-sin30.5%
unpow230.5%
Simplified30.5%
Final simplification29.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt (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 58.0%
associate-*l*58.0%
Simplified58.1%
Taylor expanded in phi2 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.7%
unpow243.7%
*-commutative43.7%
unpow243.7%
associate-*r*43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in lambda1 around 0 27.7%
unpow227.7%
1-sub-sin27.7%
unpow227.7%
Simplified27.7%
Final simplification27.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(fma
(pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)
(cos phi1)
(pow (sin (* phi1 0.5)) 2.0)))
(sqrt (pow (cos (* lambda2 -0.5)) 2.0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(fma(pow(sin((-0.5 * (lambda2 - lambda1))), 2.0), cos(phi1), pow(sin((phi1 * 0.5)), 2.0))), sqrt(pow(cos((lambda2 * -0.5)), 2.0))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(fma((sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0), cos(phi1), (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * N[Cos[phi1], $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left({\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}, \cos \phi_1, {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
Initial program 58.0%
associate-*l*58.0%
Simplified58.1%
Taylor expanded in phi2 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.7%
unpow243.7%
*-commutative43.7%
unpow243.7%
associate-*r*43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in lambda1 around 0 27.7%
unpow227.7%
1-sub-sin27.7%
unpow227.7%
Simplified27.7%
Taylor expanded in phi2 around 0 26.8%
+-commutative26.8%
*-commutative26.8%
fma-def26.8%
Simplified26.8%
Final simplification26.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (pow (cos (* lambda2 -0.5)) 2.0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.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
code = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
Initial program 58.0%
associate-*l*58.0%
Simplified58.1%
Taylor expanded in phi2 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.7%
unpow243.7%
*-commutative43.7%
unpow243.7%
associate-*r*43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in lambda1 around 0 27.7%
unpow227.7%
1-sub-sin27.7%
unpow227.7%
Simplified27.7%
Taylor expanded in phi1 around 0 25.7%
Final simplification25.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (pow (cos (* lambda2 -0.5)) 2.0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.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
code = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\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}}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
Initial program 58.0%
associate-*l*58.0%
Simplified58.1%
Taylor expanded in phi2 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.7%
unpow243.7%
*-commutative43.7%
unpow243.7%
associate-*r*43.7%
Simplified43.7%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in lambda1 around 0 27.7%
unpow227.7%
1-sub-sin27.7%
unpow227.7%
Simplified27.7%
Taylor expanded in phi2 around 0 26.8%
Final simplification26.8%
herbie shell --seed 2023207
(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))))))))))