
(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 15 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi1 -0.000118) (not (<= phi1 130000.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi1 0.5)) 2.0) t_1))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- (pow (cos (* phi2 0.5)) 2.0) (* (cos phi2) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -0.000118) || !(phi1 <= 130000.0)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + t_1)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((pow(cos((phi2 * 0.5)), 2.0) - (cos(phi2) * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi1 <= (-0.000118d0)) .or. (.not. (phi1 <= 130000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + t_1)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_2)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - (cos(phi2) * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi1 <= -0.000118) || !(phi1 <= 130000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_1)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_2 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi1 <= -0.000118) or not (phi1 <= 130000.0): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + t_1)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_2))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - (math.cos(phi2) * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi1 <= -0.000118) || !(phi1 <= 130000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_1)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi1 <= -0.000118) || ~((phi1 <= 130000.0))) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + t_1)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_2))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((cos((phi2 * 0.5)) ^ 2.0) - (cos(phi2) * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -0.000118], N[Not[LessEqual[phi1, 130000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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[Power[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -0.000118 \lor \neg \left(\phi_1 \leq 130000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t_1}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{{\cos \left(\phi_2 \cdot 0.5\right)}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\end{array}
\end{array}
if phi1 < -1.18e-4 or 1.3e5 < phi1 Initial program 45.6%
Taylor expanded in phi2 around 0 46.4%
associate--r+46.4%
unpow246.4%
1-sub-sin46.5%
unpow246.5%
*-commutative46.5%
unpow246.5%
associate-*r*46.5%
Simplified46.5%
Taylor expanded in phi2 around 0 47.4%
if -1.18e-4 < phi1 < 1.3e5Initial program 74.4%
Taylor expanded in phi1 around 0 74.4%
associate--r+74.4%
unpow274.4%
1-sub-sin74.5%
unpow274.5%
metadata-eval74.5%
associate-*r*74.5%
*-commutative74.5%
mul-1-neg74.5%
distribute-lft-neg-out74.5%
cos-neg74.5%
sub-neg74.5%
mul-1-neg74.5%
+-commutative74.5%
Simplified74.5%
Final simplification61.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (cos (* 2.0 (* (- lambda1 lambda2) 0.5))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4 (* 0.5 t_1)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (* t_0 (* t_2 t_2))))
(sqrt
(-
(- 1.0 t_3)
(*
t_0
(/
(- 0.125 (* 0.125 (pow t_1 3.0)))
(+ 0.25 (* t_4 (+ 0.5 t_4))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((2.0 * ((lambda1 - lambda2) * 0.5)));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = 0.5 * t_1;
return R * (2.0 * atan2(sqrt((t_3 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_3) - (t_0 * ((0.125 - (0.125 * pow(t_1, 3.0))) / (0.25 + (t_4 * (0.5 + t_4)))))))));
}
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
t_0 = cos(phi1) * cos(phi2)
t_1 = cos((2.0d0 * ((lambda1 - lambda2) * 0.5d0)))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_4 = 0.5d0 * t_1
code = r * (2.0d0 * atan2(sqrt((t_3 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_3) - (t_0 * ((0.125d0 - (0.125d0 * (t_1 ** 3.0d0))) / (0.25d0 + (t_4 * (0.5d0 + t_4)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.cos((2.0 * ((lambda1 - lambda2) * 0.5)));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = 0.5 * t_1;
return R * (2.0 * Math.atan2(Math.sqrt((t_3 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_3) - (t_0 * ((0.125 - (0.125 * Math.pow(t_1, 3.0))) / (0.25 + (t_4 * (0.5 + t_4)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = 0.5 * t_1 return R * (2.0 * math.atan2(math.sqrt((t_3 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_3) - (t_0 * ((0.125 - (0.125 * math.pow(t_1, 3.0))) / (0.25 + (t_4 * (0.5 + t_4)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = Float64(0.5 * t_1) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_3) - Float64(t_0 * Float64(Float64(0.125 - Float64(0.125 * (t_1 ^ 3.0))) / Float64(0.25 + Float64(t_4 * Float64(0.5 + t_4)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = cos((2.0 * ((lambda1 - lambda2) * 0.5))); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_4 = 0.5 * t_1; tmp = R * (2.0 * atan2(sqrt((t_3 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_3) - (t_0 * ((0.125 - (0.125 * (t_1 ^ 3.0))) / (0.25 + (t_4 * (0.5 + t_4))))))))); 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[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(0.5 * t$95$1), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] - N[(t$95$0 * N[(N[(0.125 - N[(0.125 * N[Power[t$95$1, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(0.25 + N[(t$95$4 * N[(0.5 + t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := 0.5 \cdot t_1\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + t_0 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\left(1 - t_3\right) - t_0 \cdot \frac{0.125 - 0.125 \cdot {t_1}^{3}}{0.25 + t_4 \cdot \left(0.5 + t_4\right)}}}\right)
\end{array}
\end{array}
Initial program 60.7%
associate-*l*60.7%
Simplified60.7%
sqr-sin-a60.7%
div-inv60.7%
metadata-eval60.7%
Applied egg-rr60.7%
flip3--60.7%
metadata-eval60.7%
metadata-eval60.7%
Applied egg-rr60.7%
cube-prod60.7%
metadata-eval60.7%
distribute-rgt-out60.7%
+-commutative60.7%
Simplified60.7%
Final simplification60.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_0 t_0))
(log1p (expm1 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(*
t_1
(- 0.5 (* 0.5 (cos (* 2.0 (* (- lambda1 lambda2) 0.5)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + log1p(expm1(pow(sin(((phi1 - phi2) * 0.5)), 2.0))))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_1 * (0.5 - (0.5 * cos((2.0 * ((lambda1 - lambda2) * 0.5))))))))));
}
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);
return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_0)) + Math.log1p(Math.expm1(Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0))))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_1 * (0.5 - (0.5 * Math.cos((2.0 * ((lambda1 - lambda2) * 0.5))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_0)) + math.log1p(math.expm1(math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_1 * (0.5 - (0.5 * math.cos((2.0 * ((lambda1 - lambda2) * 0.5))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_0)) + log1p(expm1((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(t_1 * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5))))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Log[1 + N[(Exp[N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$1 * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_0 \cdot t_0\right) + \mathsf{log1p}\left(\mathsf{expm1}\left({\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t_1 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.7%
associate-*l*60.7%
Simplified60.7%
sqr-sin-a60.7%
div-inv60.7%
metadata-eval60.7%
Applied egg-rr60.7%
log1p-expm1-u60.7%
div-inv60.7%
metadata-eval60.7%
Applied egg-rr60.7%
Final simplification60.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 t_2)
(*
t_0
(- 0.5 (* 0.5 (cos (* 2.0 (* (- lambda1 lambda2) 0.5)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * (0.5 - (0.5 * cos((2.0 * ((lambda1 - lambda2) * 0.5))))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) - (t_0 * (0.5d0 - (0.5d0 * cos((2.0d0 * ((lambda1 - lambda2) * 0.5d0))))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) - (t_0 * (0.5 - (0.5 * Math.cos((2.0 * ((lambda1 - lambda2) * 0.5))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) - (t_0 * (0.5 - (0.5 * math.cos((2.0 * ((lambda1 - lambda2) * 0.5))))))))))
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 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) - Float64(t_0 * Float64(0.5 - Float64(0.5 * cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5))))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) - (t_0 * (0.5 - (0.5 * cos((2.0 * ((lambda1 - lambda2) * 0.5)))))))))); 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[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 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(t$95$0 * N[(0.5 - N[(0.5 * N[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - t_2\right) - t_0 \cdot \left(0.5 - 0.5 \cdot \cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.7%
associate-*l*60.7%
Simplified60.7%
sqr-sin-a60.7%
div-inv60.7%
metadata-eval60.7%
Applied egg-rr60.7%
Final simplification60.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sqrt (+ t_0 (* t_2 (* t_3 t_3))))))
(if (<= lambda2 2.9e-5)
(*
R
(* 2.0 (atan2 t_4 (sqrt (+ t_1 (* t_2 (- (* 0.5 (cos lambda1)) 0.5)))))))
(*
R
(*
2.0
(atan2 t_4 (sqrt (- t_1 (* t_2 (- 0.5 (* 0.5 (cos lambda2))))))))))))
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 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda2 <= 2.9e-5) {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((0.5 * cos(lambda1)) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 - (t_2 * (0.5 - (0.5 * cos(lambda2))))))));
}
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(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))))
if (lambda2 <= 2.9d-5) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 + (t_2 * ((0.5d0 * cos(lambda1)) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 - (t_2 * (0.5d0 - (0.5d0 * cos(lambda2))))))))
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 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda2 <= 2.9e-5) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 + (t_2 * ((0.5 * Math.cos(lambda1)) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 - (t_2 * (0.5 - (0.5 * Math.cos(lambda2))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.sqrt((t_0 + (t_2 * (t_3 * t_3)))) tmp = 0 if lambda2 <= 2.9e-5: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 + (t_2 * ((0.5 * math.cos(lambda1)) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 - (t_2 * (0.5 - (0.5 * math.cos(lambda2)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))) tmp = 0.0 if (lambda2 <= 2.9e-5) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(0.5 * cos(lambda1)) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 - Float64(t_2 * Float64(0.5 - Float64(0.5 * cos(lambda2))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3)))); tmp = 0.0; if (lambda2 <= 2.9e-5) tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((0.5 * cos(lambda1)) - 0.5)))))); else tmp = R * (2.0 * atan2(t_4, sqrt((t_1 - (t_2 * (0.5 - (0.5 * cos(lambda2)))))))); 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[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 2.9e-5], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(0.5 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 - N[(t$95$2 * N[(0.5 - N[(0.5 * N[Cos[lambda2], $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 := 1 - t_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}\\
\mathbf{if}\;\lambda_2 \leq 2.9 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_1 + t_2 \cdot \left(0.5 \cdot \cos \lambda_1 - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_1 - t_2 \cdot \left(0.5 - 0.5 \cdot \cos \lambda_2\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 2.9e-5Initial program 65.9%
associate-*l*65.9%
Simplified65.9%
sqr-sin-a65.9%
div-inv65.9%
metadata-eval65.9%
Applied egg-rr65.9%
Taylor expanded in lambda2 around 0 56.5%
*-commutative56.5%
Simplified56.5%
if 2.9e-5 < lambda2 Initial program 47.2%
associate-*l*47.2%
Simplified47.2%
sqr-sin-a47.2%
div-inv47.2%
metadata-eval47.2%
Applied egg-rr47.2%
Taylor expanded in lambda1 around 0 47.2%
cos-neg47.2%
Simplified47.2%
Final simplification53.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))))))
(if (<= phi2 -2.05e-8)
(*
R
(* 2.0 (atan2 t_2 (sqrt (- 1.0 (+ t_0 (pow (sin (* phi2 -0.5)) 2.0)))))))
(if (<= phi2 0.000245)
(*
R
(*
2.0
(atan2
t_2
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(* 2.0 (atan2 t_2 (sqrt (- (pow (cos (* phi2 0.5)) 2.0) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))));
double tmp;
if (phi2 <= -2.05e-8) {
tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + pow(sin((phi2 * -0.5)), 2.0))))));
} else if (phi2 <= 0.000245) {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((pow(cos((phi2 * 0.5)), 2.0) - t_0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))))
if (phi2 <= (-2.05d-8)) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((1.0d0 - (t_0 + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else if (phi2 <= 0.000245d0) then
tmp = r * (2.0d0 * atan2(t_2, sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - t_0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1))));
double tmp;
if (phi2 <= -2.05e-8) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((1.0 - (t_0 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else if (phi2 <= 0.000245) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)))) tmp = 0 if phi2 <= -2.05e-8: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((1.0 - (t_0 + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) elif phi2 <= 0.000245: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))) tmp = 0.0 if (phi2 <= -2.05e-8) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(1.0 - Float64(t_0 + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); elseif (phi2 <= 0.000245) tmp = Float64(R * Float64(2.0 * atan(t_2, 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(t_2, sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))); tmp = 0.0; if (phi2 <= -2.05e-8) tmp = R * (2.0 * atan2(t_2, sqrt((1.0 - (t_0 + (sin((phi2 * -0.5)) ^ 2.0)))))); elseif (phi2 <= 0.000245) tmp = R * (2.0 * atan2(t_2, sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt(((cos((phi2 * 0.5)) ^ 2.0) - t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -2.05e-8], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.000245], N[(R * N[(2.0 * N[ArcTan[t$95$2 / 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[t$95$2 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)}\\
\mathbf{if}\;\phi_2 \leq -2.05 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{1 - \left(t_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.000245:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{{\cos \left(\phi_2 \cdot 0.5\right)}^{2} - t_0}}\right)\\
\end{array}
\end{array}
if phi2 < -2.05000000000000016e-8Initial program 38.5%
Taylor expanded in lambda1 around 0 31.6%
+-commutative31.6%
*-commutative31.6%
fma-def31.6%
Simplified31.6%
Taylor expanded in phi1 around 0 32.4%
if -2.05000000000000016e-8 < phi2 < 2.4499999999999999e-4Initial program 78.0%
Taylor expanded in phi2 around 0 78.0%
associate--r+78.0%
unpow278.0%
1-sub-sin78.1%
unpow278.1%
*-commutative78.1%
unpow278.1%
associate-*r*78.1%
Simplified78.1%
if 2.4499999999999999e-4 < phi2 Initial program 49.0%
Taylor expanded in lambda1 around 0 36.1%
+-commutative36.1%
*-commutative36.1%
fma-def36.0%
Simplified36.0%
Taylor expanded in phi1 around 0 36.4%
+-commutative36.4%
associate--r+36.4%
unpow236.4%
1-sub-sin36.6%
unpow236.6%
metadata-eval36.6%
associate-*r*36.6%
*-commutative36.6%
mul-1-neg36.6%
distribute-lft-neg-out36.6%
cos-neg36.6%
Simplified36.6%
Final simplification56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(if (or (<= phi2 -5.4e-26) (not (<= phi2 0.00142)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt
(-
(pow (cos (* phi2 0.5)) 2.0)
(* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi1 0.5)) 2.0) t_1))
(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 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double tmp;
if ((phi2 <= -5.4e-26) || !(phi2 <= 0.00142)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((pow(cos((phi2 * 0.5)), 2.0) - (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + t_1)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
if ((phi2 <= (-5.4d-26)) .or. (.not. (phi2 <= 0.00142d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + t_1)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((phi2 <= -5.4e-26) || !(phi2 <= 0.00142)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_1)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) tmp = 0 if (phi2 <= -5.4e-26) or not (phi2 <= 0.00142): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + t_1)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) tmp = 0.0 if ((phi2 <= -5.4e-26) || !(phi2 <= 0.00142)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_1)), 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
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = 0.0; if ((phi2 <= -5.4e-26) || ~((phi2 <= 0.00142))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((cos((phi2 * 0.5)) ^ 2.0) - (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + t_1)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -5.4e-26], N[Not[LessEqual[phi2, 0.00142]], $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[Power[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $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 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
\mathbf{if}\;\phi_2 \leq -5.4 \cdot 10^{-26} \lor \neg \left(\phi_2 \leq 0.00142\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{{\cos \left(\phi_2 \cdot 0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t_1}}{\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 < -5.39999999999999963e-26 or 0.00142000000000000004 < phi2 Initial program 45.2%
Taylor expanded in lambda1 around 0 35.4%
+-commutative35.4%
*-commutative35.4%
fma-def35.4%
Simplified35.4%
Taylor expanded in phi1 around 0 35.9%
+-commutative35.9%
associate--r+35.9%
unpow235.9%
1-sub-sin36.0%
unpow236.0%
metadata-eval36.0%
associate-*r*36.0%
*-commutative36.0%
mul-1-neg36.0%
distribute-lft-neg-out36.0%
cos-neg36.0%
Simplified36.0%
if -5.39999999999999963e-26 < phi2 < 0.00142000000000000004Initial program 77.5%
Taylor expanded in phi2 around 0 77.5%
associate--r+77.5%
unpow277.5%
1-sub-sin77.6%
unpow277.6%
*-commutative77.6%
unpow277.6%
associate-*r*77.6%
Simplified77.6%
Taylor expanded in phi2 around 0 76.4%
Final simplification55.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))
(t_3 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_2))))
(if (<= phi2 -5.4e-26)
(*
R
(* 2.0 (atan2 t_3 (sqrt (- 1.0 (+ t_0 (pow (sin (* phi2 -0.5)) 2.0)))))))
(if (<= phi2 0.000185)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi1 0.5)) 2.0) t_2))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(* 2.0 (atan2 t_3 (sqrt (- (pow (cos (* phi2 0.5)) 2.0) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1);
double t_3 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi2 <= -5.4e-26) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + pow(sin((phi2 * -0.5)), 2.0))))));
} else if (phi2 <= 0.000185) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + t_2)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((pow(cos((phi2 * 0.5)), 2.0) - t_0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1)
t_3 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_2))
if (phi2 <= (-5.4d-26)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_0 + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else if (phi2 <= 0.000185d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + t_2)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt(((cos((phi2 * 0.5d0)) ** 2.0d0) - t_0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1);
double t_3 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2));
double tmp;
if (phi2 <= -5.4e-26) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_0 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else if (phi2 <= 0.000185) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_2)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((Math.pow(Math.cos((phi2 * 0.5)), 2.0) - t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1) t_3 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_2)) tmp = 0 if phi2 <= -5.4e-26: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_0 + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) elif phi2 <= 0.000185: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + t_2)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((math.pow(math.cos((phi2 * 0.5)), 2.0) - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) t_3 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_2)) tmp = 0.0 if (phi2 <= -5.4e-26) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_0 + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); elseif (phi2 <= 0.000185) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_2)), 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(t_3, sqrt(Float64((cos(Float64(phi2 * 0.5)) ^ 2.0) - t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_1 * ((cos(phi1) * cos(phi2)) * t_1); t_3 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_2)); tmp = 0.0; if (phi2 <= -5.4e-26) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (sin((phi2 * -0.5)) ^ 2.0)))))); elseif (phi2 <= 0.000185) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + t_2)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_3, sqrt(((cos((phi2 * 0.5)) ^ 2.0) - t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -5.4e-26], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.000185], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$2), $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[t$95$3 / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)\\
t_3 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_2}\\
\mathbf{if}\;\phi_2 \leq -5.4 \cdot 10^{-26}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(t_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.000185:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t_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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{{\cos \left(\phi_2 \cdot 0.5\right)}^{2} - t_0}}\right)\\
\end{array}
\end{array}
if phi2 < -5.39999999999999963e-26Initial program 41.2%
Taylor expanded in lambda1 around 0 34.7%
+-commutative34.7%
*-commutative34.7%
fma-def34.7%
Simplified34.7%
Taylor expanded in phi1 around 0 35.4%
if -5.39999999999999963e-26 < phi2 < 1.85e-4Initial program 77.5%
Taylor expanded in phi2 around 0 77.5%
associate--r+77.5%
unpow277.5%
1-sub-sin77.6%
unpow277.6%
*-commutative77.6%
unpow277.6%
associate-*r*77.6%
Simplified77.6%
Taylor expanded in phi2 around 0 76.4%
if 1.85e-4 < phi2 Initial program 49.0%
Taylor expanded in lambda1 around 0 36.1%
+-commutative36.1%
*-commutative36.1%
fma-def36.0%
Simplified36.0%
Taylor expanded in phi1 around 0 36.4%
+-commutative36.4%
associate--r+36.4%
unpow236.4%
1-sub-sin36.6%
unpow236.6%
metadata-eval36.6%
associate-*r*36.6%
*-commutative36.6%
mul-1-neg36.6%
distribute-lft-neg-out36.6%
cos-neg36.6%
Simplified36.6%
Final simplification55.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= (- lambda1 lambda2) -1e-51)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi1 0.5)) 2.0) t_1))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(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 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double tmp;
if ((lambda1 - lambda2) <= -1e-51) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + t_1)), 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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
if ((lambda1 - lambda2) <= (-1d-51)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + t_1)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((lambda1 - lambda2) <= -1e-51) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + t_1)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) tmp = 0 if (lambda1 - lambda2) <= -1e-51: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + t_1)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1e-51) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + t_1)), 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(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = 0.0; if ((lambda1 - lambda2) <= -1e-51) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + t_1)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e-51], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $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[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $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{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{-51}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + t_1}}{\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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1e-51Initial program 55.4%
Taylor expanded in phi2 around 0 43.3%
associate--r+43.3%
unpow243.3%
1-sub-sin43.3%
unpow243.3%
*-commutative43.3%
unpow243.3%
associate-*r*43.3%
Simplified43.3%
Taylor expanded in phi2 around 0 41.4%
if -1e-51 < (-.f64 lambda1 lambda2) Initial program 64.9%
Taylor expanded in lambda1 around 0 54.9%
+-commutative54.9%
*-commutative54.9%
fma-def54.9%
Simplified54.9%
Taylor expanded in lambda2 around 0 42.9%
unpow242.9%
cancel-sign-sub-inv42.9%
sub-neg42.9%
mul-1-neg42.9%
distribute-lft-in42.9%
metadata-eval42.9%
associate-*r*42.9%
associate-*r*42.9%
metadata-eval42.9%
distribute-lft-in42.9%
+-commutative42.9%
mul-1-neg42.9%
sub-neg42.9%
sub-neg42.9%
mul-1-neg42.9%
distribute-lft-in42.9%
Simplified42.9%
Final simplification42.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= (- lambda1 lambda2) -1e+24)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(pow
(+ (sin (* phi2 -0.5)) (* 0.5 (* phi1 (cos (* phi2 -0.5)))))
2.0)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- 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 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double tmp;
if ((lambda1 - lambda2) <= -1e+24) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))), 2.0))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
if ((lambda1 - lambda2) <= (-1d+24)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + ((sin((phi2 * (-0.5d0))) + (0.5d0 * (phi1 * cos((phi2 * (-0.5d0)))))) ** 2.0d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((lambda1 - lambda2) <= -1e+24) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow((Math.sin((phi2 * -0.5)) + (0.5 * (phi1 * Math.cos((phi2 * -0.5))))), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) tmp = 0 if (lambda1 - lambda2) <= -1e+24: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow((math.sin((phi2 * -0.5)) + (0.5 * (phi1 * math.cos((phi2 * -0.5))))), 2.0))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1e+24) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (Float64(sin(Float64(phi2 * -0.5)) + Float64(0.5 * Float64(phi1 * cos(Float64(phi2 * -0.5))))) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = 0.0; if ((lambda1 - lambda2) <= -1e+24) tmp = R * (2.0 * atan2(sqrt((t_1 + ((sin((phi2 * -0.5)) + (0.5 * (phi1 * cos((phi2 * -0.5))))) ^ 2.0))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+24], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(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{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+24}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\left(\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot \left(\phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -9.9999999999999998e23Initial program 55.4%
Taylor expanded in phi2 around 0 43.3%
associate--r+43.3%
unpow243.3%
1-sub-sin43.3%
unpow243.3%
*-commutative43.3%
unpow243.3%
associate-*r*43.3%
Simplified43.3%
Taylor expanded in phi1 around 0 35.6%
Taylor expanded in phi1 around 0 35.5%
if -9.9999999999999998e23 < (-.f64 lambda1 lambda2) Initial program 64.1%
Taylor expanded in lambda1 around 0 54.9%
+-commutative54.9%
*-commutative54.9%
fma-def54.9%
Simplified54.9%
Taylor expanded in lambda2 around 0 42.3%
unpow242.3%
cancel-sign-sub-inv42.3%
sub-neg42.3%
mul-1-neg42.3%
distribute-lft-in42.3%
metadata-eval42.3%
associate-*r*42.3%
associate-*r*42.3%
metadata-eval42.3%
distribute-lft-in42.3%
+-commutative42.3%
mul-1-neg42.3%
sub-neg42.3%
sub-neg42.3%
mul-1-neg42.3%
distribute-lft-in42.3%
Simplified42.3%
Final simplification39.7%
(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)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))))
(if (<= (- lambda1 lambda2) -1e+24)
(*
R
(*
2.0
(atan2
t_1
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(*
R
(*
2.0
(atan2 t_1 (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 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -1e+24) {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - pow(sin(((phi1 - phi2) * 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) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))))
if ((lambda1 - lambda2) <= (-1d+24)) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((1.0d0 - (sin(((phi1 - phi2) * 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) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -1e+24) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 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) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))) tmp = 0 if (lambda1 - lambda2) <= -1e+24: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 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(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1e+24) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 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) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))); tmp = 0.0; if ((lambda1 - lambda2) <= -1e+24) tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(t_1, sqrt((1.0 - (sin(((phi1 - phi2) * 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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+24], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(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{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+24}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -9.9999999999999998e23Initial program 55.4%
Taylor expanded in phi2 around 0 43.3%
associate--r+43.3%
unpow243.3%
1-sub-sin43.3%
unpow243.3%
*-commutative43.3%
unpow243.3%
associate-*r*43.3%
Simplified43.3%
Taylor expanded in phi1 around 0 35.6%
if -9.9999999999999998e23 < (-.f64 lambda1 lambda2) Initial program 64.1%
Taylor expanded in lambda1 around 0 54.9%
+-commutative54.9%
*-commutative54.9%
fma-def54.9%
Simplified54.9%
Taylor expanded in lambda2 around 0 42.3%
unpow242.3%
cancel-sign-sub-inv42.3%
sub-neg42.3%
mul-1-neg42.3%
distribute-lft-in42.3%
metadata-eval42.3%
associate-*r*42.3%
associate-*r*42.3%
metadata-eval42.3%
distribute-lft-in42.3%
+-commutative42.3%
mul-1-neg42.3%
sub-neg42.3%
sub-neg42.3%
mul-1-neg42.3%
distribute-lft-in42.3%
Simplified42.3%
Final simplification39.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- 1.0 (pow (sin (* -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) + (t_0 * ((cos(phi1) * cos(phi2)) * 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) + (t_0 * ((cos(phi1) * cos(phi2)) * 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) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * 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) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * 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(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * 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) + (t_0 * ((cos(phi1) * cos(phi2)) * 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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[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} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \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 60.7%
Taylor expanded in phi2 around 0 48.1%
associate--r+48.1%
unpow248.1%
1-sub-sin48.2%
unpow248.2%
*-commutative48.2%
unpow248.2%
associate-*r*48.2%
Simplified48.2%
Taylor expanded in phi1 around 0 35.3%
Final simplification35.3%
(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)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))))
(if (<= lambda2 0.00026)
(* 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) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))));
double tmp;
if (lambda2 <= 0.00026) {
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) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))))
if (lambda2 <= 0.00026d0) 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) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0))));
double tmp;
if (lambda2 <= 0.00026) {
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) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))) tmp = 0 if lambda2 <= 0.00026: 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(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))) tmp = 0.0 if (lambda2 <= 0.00026) 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) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))); tmp = 0.0; if (lambda2 <= 0.00026) 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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 0.00026], 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} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}\\
\mathbf{if}\;\lambda_2 \leq 0.00026:\\
\;\;\;\;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 lambda2 < 2.59999999999999977e-4Initial program 65.9%
Taylor expanded in phi2 around 0 51.9%
associate--r+51.9%
unpow251.9%
1-sub-sin52.0%
unpow252.0%
*-commutative52.0%
unpow252.0%
associate-*r*52.0%
Simplified52.0%
Taylor expanded in phi1 around 0 36.7%
Taylor expanded in lambda2 around 0 32.4%
unpow232.4%
1-sub-sin32.4%
unpow232.4%
*-commutative32.4%
Simplified32.4%
if 2.59999999999999977e-4 < lambda2 Initial program 47.2%
Taylor expanded in phi2 around 0 38.2%
associate--r+38.2%
unpow238.2%
1-sub-sin38.2%
unpow238.2%
*-commutative38.2%
unpow238.2%
associate-*r*38.2%
Simplified38.2%
Taylor expanded in phi1 around 0 31.6%
Taylor expanded in lambda1 around 0 31.6%
unpow231.6%
1-sub-sin31.7%
unpow231.7%
metadata-eval31.7%
associate-*r*31.7%
neg-mul-131.7%
distribute-rgt-neg-out31.7%
cos-neg31.7%
*-commutative31.7%
Simplified31.7%
Final simplification32.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)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (pow (cos (* lambda1 0.5)) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda1 * 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} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 60.7%
Taylor expanded in phi2 around 0 48.1%
associate--r+48.1%
unpow248.1%
1-sub-sin48.2%
unpow248.2%
*-commutative48.2%
unpow248.2%
associate-*r*48.2%
Simplified48.2%
Taylor expanded in phi1 around 0 35.3%
Taylor expanded in lambda2 around 0 29.1%
unpow229.1%
1-sub-sin29.1%
unpow229.1%
*-commutative29.1%
Simplified29.1%
Final simplification29.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* -0.5 (- phi2 phi1)))))
(*
R
(*
2.0
(atan2
t_0
(sqrt
(-
(pow t_0 2.0)
(fma
(* (cos phi1) (cos phi2))
(- 0.5 (/ (cos (- lambda2 lambda1)) 2.0))
-1.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((-0.5 * (phi2 - phi1)));
return R * (2.0 * atan2(t_0, sqrt((pow(t_0, 2.0) - fma((cos(phi1) * cos(phi2)), (0.5 - (cos((lambda2 - lambda1)) / 2.0)), -1.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(phi2 - phi1))) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64((t_0 ^ 2.0) - fma(Float64(cos(phi1) * cos(phi2)), Float64(0.5 - Float64(cos(Float64(lambda2 - lambda1)) / 2.0)), -1.0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(N[Power[t$95$0, 2.0], $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{{t_0}^{2} - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, 0.5 - \frac{\cos \left(\lambda_2 - \lambda_1\right)}{2}, -1\right)}}\right)
\end{array}
\end{array}
Initial program 60.7%
Simplified34.5%
Taylor expanded in lambda2 around 0 26.0%
Taylor expanded in lambda1 around 0 11.0%
sin-mult11.0%
Applied egg-rr11.0%
Simplified11.0%
Final simplification11.0%
herbie shell --seed 2023199
(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))))))))))