
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 17 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi2 -0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_3 (* (cos phi2) t_2))
(t_4 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_3))))
(if (<= phi2 -4.7e+18)
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_3)) t_4)))
(if (<= phi2 6e-5)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_1 t_1))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_2))))))
(* R (* 2.0 (atan2 (sqrt (fma t_2 (cos phi2) t_0)) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = cos(phi2) * t_2;
double t_4 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_3));
double tmp;
if (phi2 <= -4.7e+18) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), t_4));
} else if (phi2 <= 6e-5) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_1 * t_1)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(t_2, cos(phi2), t_0)), t_4));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_3 = Float64(cos(phi2) * t_2) t_4 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_3)) tmp = 0.0 if (phi2 <= -4.7e+18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), t_4))); elseif (phi2 <= 6e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_1 * 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(fma(t_2, cos(phi2), t_0)), t_4))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.7e+18], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 * N[Cos[phi2], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := \cos \phi_2 \cdot t_2\\
t_4 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_3}\\
\mathbf{if}\;\phi_2 \leq -4.7 \cdot 10^{+18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3}}{t_4}\right)\\
\mathbf{elif}\;\phi_2 \leq 6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_1 \cdot t_1\right)}}{\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{\mathsf{fma}\left(t_2, \cos \phi_2, t_0\right)}}{t_4}\right)\\
\end{array}
\end{array}
if phi2 < -4.7e18Initial program 40.9%
associate-*l*40.9%
Simplified40.9%
Taylor expanded in phi1 around 0 41.7%
associate--r+41.7%
unpow241.7%
1-sub-sin41.7%
unpow241.7%
Simplified41.7%
log1p-expm1-u41.8%
div-inv41.8%
metadata-eval41.8%
Applied egg-rr41.8%
Taylor expanded in phi1 around 0 42.9%
if -4.7e18 < phi2 < 6.00000000000000015e-5Initial program 73.2%
associate-*l*73.2%
Simplified73.2%
Taylor expanded in phi2 around 0 73.2%
associate--r+73.2%
unpow273.2%
1-sub-sin73.3%
unpow273.3%
Simplified73.3%
if 6.00000000000000015e-5 < phi2 Initial program 51.7%
associate-*l*51.6%
Simplified51.7%
Taylor expanded in phi1 around 0 52.2%
associate--r+52.3%
unpow252.3%
1-sub-sin52.4%
unpow252.4%
Simplified52.4%
log1p-expm1-u52.3%
div-inv52.3%
metadata-eval52.3%
Applied egg-rr52.3%
Taylor expanded in phi1 around 0 52.8%
+-commutative52.8%
*-commutative52.8%
fma-def52.8%
Simplified52.8%
Final simplification59.9%
(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
(log
(exp
(-
0.5
(*
0.5
(fma
(cos lambda1)
(cos lambda2)
(* (sin lambda1) (sin lambda2)))))))))))))))
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 * log(exp((0.5 - (0.5 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))))))))));
}
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 * log(exp(Float64(0.5 - Float64(0.5 * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))))))))) 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[Log[N[Exp[N[(0.5 - N[(0.5 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $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 \log \left(e^{0.5 - 0.5 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)}\right)}}\right)
\end{array}
\end{array}
Initial program 59.1%
associate-*l*59.1%
Simplified59.1%
sin-mult59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
Applied egg-rr59.1%
div-sub59.1%
+-inverses59.1%
cos-059.1%
metadata-eval59.1%
distribute-lft-out59.1%
metadata-eval59.1%
*-rgt-identity59.1%
Simplified59.1%
cos-diff59.7%
Applied egg-rr59.7%
add-log-exp59.7%
div-inv59.7%
fma-def59.7%
metadata-eval59.7%
Applied egg-rr59.7%
Final simplification59.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
(-
(/
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))
2.0)
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 * ((((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) / 2.0) - 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 * ((((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) / 2.0d0) - 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 * ((((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))) / 2.0) - 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 * ((((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))) / 2.0) - 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(Float64(Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) / 2.0) - 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 * ((((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))) / 2.0) - 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[(N[(N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $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(\frac{\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.1%
associate-*l*59.1%
Simplified59.1%
sin-mult59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
Applied egg-rr59.1%
div-sub59.1%
+-inverses59.1%
cos-059.1%
metadata-eval59.1%
distribute-lft-out59.1%
metadata-eval59.1%
*-rgt-identity59.1%
Simplified59.1%
cos-diff59.7%
Applied egg-rr59.7%
Final simplification59.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 (/ (cos (- lambda1 lambda2)) 2.0)))
(if (<= lambda2 3e-28)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_3))))
(sqrt (+ t_1 (* t_2 (- (/ (cos lambda1) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (- 0.5 t_4))))
(sqrt (+ t_1 (* t_2 (- t_4 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = cos((lambda1 - lambda2)) / 2.0;
double tmp;
if (lambda2 <= 3e-28) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (0.5 - t_4)))), sqrt((t_1 + (t_2 * (t_4 - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = 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 = cos((lambda1 - lambda2)) / 2.0d0
if (lambda2 <= 3d-28) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (0.5d0 - t_4)))), sqrt((t_1 + (t_2 * (t_4 - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 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.cos((lambda1 - lambda2)) / 2.0;
double tmp;
if (lambda2 <= 3e-28) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (0.5 - t_4)))), Math.sqrt((t_1 + (t_2 * (t_4 - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.cos((lambda1 - lambda2)) / 2.0 tmp = 0 if lambda2 <= 3e-28: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (0.5 - t_4)))), math.sqrt((t_1 + (t_2 * (t_4 - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(cos(Float64(lambda1 - lambda2)) / 2.0) tmp = 0.0 if (lambda2 <= 3e-28) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(0.5 - t_4)))), sqrt(Float64(t_1 + Float64(t_2 * Float64(t_4 - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = cos((lambda1 - lambda2)) / 2.0; tmp = 0.0; if (lambda2 <= 3e-28) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (0.5 - t_4)))), sqrt((t_1 + (t_2 * (t_4 - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(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[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]}, If[LessEqual[lambda2, 3e-28], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(0.5 - t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(t$95$4 - 0.5), $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 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\\
\mathbf{if}\;\lambda_2 \leq 3 \cdot 10^{-28}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}}{\sqrt{t_1 + t_2 \cdot \left(\frac{\cos \lambda_1}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(0.5 - t_4\right)}}{\sqrt{t_1 + t_2 \cdot \left(t_4 - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 3.00000000000000003e-28Initial program 62.8%
associate-*l*62.8%
Simplified62.8%
sin-mult62.8%
div-inv62.8%
metadata-eval62.8%
div-inv62.8%
metadata-eval62.8%
div-inv62.8%
metadata-eval62.8%
div-inv62.8%
metadata-eval62.8%
Applied egg-rr62.8%
div-sub62.8%
+-inverses62.8%
cos-062.8%
metadata-eval62.8%
distribute-lft-out62.8%
metadata-eval62.8%
*-rgt-identity62.8%
Simplified62.8%
Taylor expanded in lambda2 around 0 54.5%
if 3.00000000000000003e-28 < lambda2 Initial program 50.4%
associate-*l*50.4%
Simplified50.4%
sin-mult50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
Applied egg-rr50.4%
div-sub50.4%
+-inverses50.4%
cos-050.4%
metadata-eval50.4%
distribute-lft-out50.4%
metadata-eval50.4%
*-rgt-identity50.4%
Simplified50.4%
sin-mult50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
Applied egg-rr50.4%
div-sub50.4%
+-inverses50.4%
cos-050.4%
metadata-eval50.4%
distribute-lft-out50.4%
metadata-eval50.4%
*-rgt-identity50.4%
Simplified50.4%
Final simplification53.3%
(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 (/ (cos (- lambda1 lambda2)) 2.0))
(t_4 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda1 -1e-48)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (- 0.5 t_3))))
(sqrt (+ t_1 (* t_2 (- t_3 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_4 t_4))))
(sqrt (- t_1 (* t_2 (- 0.5 (/ (cos lambda2) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = cos((lambda1 - lambda2)) / 2.0;
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda1 <= -1e-48) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (0.5 - t_3)))), sqrt((t_1 + (t_2 * (t_3 - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_4 * t_4)))), sqrt((t_1 - (t_2 * (0.5 - (cos(lambda2) / 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = cos((lambda1 - lambda2)) / 2.0d0
t_4 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda1 <= (-1d-48)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (0.5d0 - t_3)))), sqrt((t_1 + (t_2 * (t_3 - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_4 * t_4)))), sqrt((t_1 - (t_2 * (0.5d0 - (cos(lambda2) / 2.0d0)))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.cos((lambda1 - lambda2)) / 2.0;
double t_4 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda1 <= -1e-48) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (0.5 - t_3)))), Math.sqrt((t_1 + (t_2 * (t_3 - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_4 * t_4)))), Math.sqrt((t_1 - (t_2 * (0.5 - (Math.cos(lambda2) / 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.cos((lambda1 - lambda2)) / 2.0 t_4 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda1 <= -1e-48: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (0.5 - t_3)))), math.sqrt((t_1 + (t_2 * (t_3 - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_4 * t_4)))), math.sqrt((t_1 - (t_2 * (0.5 - (math.cos(lambda2) / 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64(cos(Float64(lambda1 - lambda2)) / 2.0) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda1 <= -1e-48) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(0.5 - t_3)))), sqrt(Float64(t_1 + Float64(t_2 * Float64(t_3 - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_4 * t_4)))), sqrt(Float64(t_1 - Float64(t_2 * Float64(0.5 - Float64(cos(lambda2) / 2.0)))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = cos((lambda1 - lambda2)) / 2.0; t_4 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda1 <= -1e-48) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (0.5 - t_3)))), sqrt((t_1 + (t_2 * (t_3 - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_4 * t_4)))), sqrt((t_1 - (t_2 * (0.5 - (cos(lambda2) / 2.0))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(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[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1e-48], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(0.5 - t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(t$95$3 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(t$95$2 * N[(0.5 - N[(N[Cos[lambda2], $MachinePrecision] / 2.0), $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 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 \leq -1 \cdot 10^{-48}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(0.5 - t_3\right)}}{\sqrt{t_1 + t_2 \cdot \left(t_3 - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_4 \cdot t_4\right)}}{\sqrt{t_1 - t_2 \cdot \left(0.5 - \frac{\cos \lambda_2}{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -9.9999999999999997e-49Initial program 42.2%
associate-*l*42.2%
Simplified42.2%
sin-mult42.2%
div-inv42.2%
metadata-eval42.2%
div-inv42.2%
metadata-eval42.2%
div-inv42.2%
metadata-eval42.2%
div-inv42.2%
metadata-eval42.2%
Applied egg-rr42.2%
div-sub42.2%
+-inverses42.2%
cos-042.2%
metadata-eval42.2%
distribute-lft-out42.2%
metadata-eval42.2%
*-rgt-identity42.2%
Simplified42.2%
sin-mult42.2%
div-inv42.2%
metadata-eval42.2%
div-inv42.2%
metadata-eval42.2%
div-inv42.2%
metadata-eval42.2%
div-inv42.2%
metadata-eval42.2%
Applied egg-rr42.2%
div-sub42.2%
+-inverses42.2%
cos-042.2%
metadata-eval42.2%
distribute-lft-out42.2%
metadata-eval42.2%
*-rgt-identity42.2%
Simplified42.2%
if -9.9999999999999997e-49 < lambda1 Initial program 65.4%
associate-*l*65.4%
Simplified65.4%
sin-mult65.5%
div-inv65.5%
metadata-eval65.5%
div-inv65.5%
metadata-eval65.5%
div-inv65.5%
metadata-eval65.5%
div-inv65.5%
metadata-eval65.5%
Applied egg-rr65.5%
div-sub65.5%
+-inverses65.5%
cos-065.5%
metadata-eval65.5%
distribute-lft-out65.5%
metadata-eval65.5%
*-rgt-identity65.5%
Simplified65.5%
Taylor expanded in lambda1 around 0 54.8%
cos-neg54.8%
Simplified54.8%
Final simplification51.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (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 (- (/ (cos (- lambda1 lambda2)) 2.0) 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 * ((cos((lambda1 - lambda2)) / 2.0) - 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 * ((cos((lambda1 - lambda2)) / 2.0d0) - 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 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 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 * ((math.cos((lambda1 - lambda2)) / 2.0) - 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(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 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 * ((cos((lambda1 - lambda2)) / 2.0) - 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[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $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(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.1%
associate-*l*59.1%
Simplified59.1%
sin-mult59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
Applied egg-rr59.1%
div-sub59.1%
+-inverses59.1%
cos-059.1%
metadata-eval59.1%
distribute-lft-out59.1%
metadata-eval59.1%
*-rgt-identity59.1%
Simplified59.1%
Final simplification59.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (/ (cos (- lambda1 lambda2)) 2.0))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (- 0.5 t_1))))
(sqrt (+ (- 1.0 t_2) (* t_0 (- t_1 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((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 * (0.5 - t_1)))), sqrt(((1.0 - t_2) + (t_0 * (t_1 - 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 = cos((lambda1 - lambda2)) / 2.0d0
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (0.5d0 - t_1)))), sqrt(((1.0d0 - t_2) + (t_0 * (t_1 - 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.cos((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 * (0.5 - t_1)))), Math.sqrt(((1.0 - t_2) + (t_0 * (t_1 - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.cos((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 * (0.5 - t_1)))), math.sqrt(((1.0 - t_2) + (t_0 * (t_1 - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(cos(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(0.5 - t_1)))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_0 * Float64(t_1 - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = cos((lambda1 - lambda2)) / 2.0; t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (0.5 - t_1)))), sqrt(((1.0 - t_2) + (t_0 * (t_1 - 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[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(0.5 - t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$0 * N[(t$95$1 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\\
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(0.5 - t_1\right)}}{\sqrt{\left(1 - t_2\right) + t_0 \cdot \left(t_1 - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.1%
associate-*l*59.1%
Simplified59.1%
sin-mult59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
Applied egg-rr59.1%
div-sub59.1%
+-inverses59.1%
cos-059.1%
metadata-eval59.1%
distribute-lft-out59.1%
metadata-eval59.1%
*-rgt-identity59.1%
Simplified59.1%
sin-mult59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
Applied egg-rr56.7%
div-sub59.1%
+-inverses59.1%
cos-059.1%
metadata-eval59.1%
distribute-lft-out59.1%
metadata-eval59.1%
*-rgt-identity59.1%
Simplified56.7%
Final simplification56.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 59.1%
associate-*l*59.1%
Simplified59.1%
Taylor expanded in phi1 around 0 47.6%
associate--r+47.6%
unpow247.6%
1-sub-sin47.6%
unpow247.6%
Simplified47.6%
sin-mult59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
div-inv59.1%
metadata-eval59.1%
Applied egg-rr45.2%
div-sub59.1%
+-inverses59.1%
cos-059.1%
metadata-eval59.1%
distribute-lft-out59.1%
metadata-eval59.1%
*-rgt-identity59.1%
Simplified45.2%
Final simplification45.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) t_0))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + t_0)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + t_0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + t_0)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + t_0)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + t_0)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + t_0)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_0}}\right)
\end{array}
\end{array}
Initial program 59.1%
associate-*l*59.1%
Simplified59.1%
Taylor expanded in phi1 around 0 47.6%
associate--r+47.6%
unpow247.6%
1-sub-sin47.6%
unpow247.6%
Simplified47.6%
log1p-expm1-u47.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr47.6%
Taylor expanded in phi1 around 0 45.1%
Final simplification45.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* -0.5 (- lambda2 lambda1))))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* phi1 (cos (* phi2 -0.5))))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sin (* phi2 -0.5)))
(t_5
(sqrt
(+
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* t_1 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))
(if (<= t_3 -5e-137)
(* R (* 2.0 (atan2 (- (* -0.5 t_2) t_4) t_5)))
(if (<= t_3 0.005)
(* R (* 2.0 (atan2 (+ t_4 (* 0.5 t_2)) t_5)))
(*
R
(*
2.0
(atan2
(sin (* (- lambda1 lambda2) 0.5))
(sqrt
(-
(pow (sin (* -0.5 (- phi2 phi1))) 2.0)
(fma t_1 (* t_0 t_0) -1.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((-0.5 * (lambda2 - lambda1)));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = phi1 * cos((phi2 * -0.5));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sin((phi2 * -0.5));
double t_5 = sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + (t_1 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))));
double tmp;
if (t_3 <= -5e-137) {
tmp = R * (2.0 * atan2(((-0.5 * t_2) - t_4), t_5));
} else if (t_3 <= 0.005) {
tmp = R * (2.0 * atan2((t_4 + (0.5 * t_2)), t_5));
} else {
tmp = R * (2.0 * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((pow(sin((-0.5 * (phi2 - phi1))), 2.0) - fma(t_1, (t_0 * t_0), -1.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(phi1 * cos(Float64(phi2 * -0.5))) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sin(Float64(phi2 * -0.5)) t_5 = sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(t_1 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)))) tmp = 0.0 if (t_3 <= -5e-137) tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(-0.5 * t_2) - t_4), t_5))); elseif (t_3 <= 0.005) tmp = Float64(R * Float64(2.0 * atan(Float64(t_4 + Float64(0.5 * t_2)), t_5))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), sqrt(Float64((sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0) - fma(t_1, Float64(t_0 * t_0), -1.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = 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[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$3, -5e-137], N[(R * N[(2.0 * N[ArcTan[N[(N[(-0.5 * t$95$2), $MachinePrecision] - t$95$4), $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$3, 0.005], N[(R * N[(2.0 * N[ArcTan[N[(t$95$4 + N[(0.5 * t$95$2), $MachinePrecision]), $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sin \left(\phi_2 \cdot -0.5\right)\\
t_5 := \sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + t_1 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}\\
\mathbf{if}\;t_3 \leq -5 \cdot 10^{-137}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot t_2 - t_4}{t_5}\right)\\
\mathbf{elif}\;t_3 \leq 0.005:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4 + 0.5 \cdot t_2}{t_5}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}{\sqrt{{\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2} - \mathsf{fma}\left(t_1, t_0 \cdot t_0, -1\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < -5.00000000000000001e-137Initial program 59.6%
associate-*l*59.6%
Simplified59.6%
sin-mult59.7%
div-inv59.7%
metadata-eval59.7%
div-inv59.7%
metadata-eval59.7%
div-inv59.7%
metadata-eval59.7%
div-inv59.7%
metadata-eval59.7%
Applied egg-rr59.7%
div-sub59.7%
+-inverses59.7%
cos-059.7%
metadata-eval59.7%
distribute-lft-out59.7%
metadata-eval59.7%
*-rgt-identity59.7%
Simplified59.7%
Taylor expanded in phi1 around 0 46.9%
Taylor expanded in phi1 around -inf 13.3%
+-commutative13.3%
mul-1-neg13.3%
unsub-neg13.3%
Simplified13.3%
if -5.00000000000000001e-137 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.0050000000000000001Initial program 77.9%
associate-*l*77.9%
Simplified77.9%
sin-mult77.9%
div-inv77.9%
metadata-eval77.9%
div-inv77.9%
metadata-eval77.9%
div-inv77.9%
metadata-eval77.9%
div-inv77.9%
metadata-eval77.9%
Applied egg-rr77.9%
div-sub77.9%
+-inverses77.9%
cos-077.9%
metadata-eval77.9%
distribute-lft-out77.9%
metadata-eval77.9%
*-rgt-identity77.9%
Simplified77.9%
Taylor expanded in phi1 around 0 58.2%
Taylor expanded in phi1 around inf 25.7%
if 0.0050000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 50.7%
Simplified28.8%
Taylor expanded in phi1 around 0 28.9%
Taylor expanded in phi2 around 0 28.8%
sub-neg28.8%
mul-1-neg28.8%
+-commutative28.8%
distribute-lft-in28.8%
associate-*r*28.8%
metadata-eval28.8%
metadata-eval28.8%
associate-*r*28.8%
distribute-lft-in28.8%
mul-1-neg28.8%
sub-neg28.8%
Simplified28.8%
Final simplification21.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $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)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 59.1%
associate-*l*59.1%
Simplified59.1%
Taylor expanded in phi1 around 0 47.6%
associate--r+47.6%
unpow247.6%
1-sub-sin47.6%
unpow247.6%
Simplified47.6%
Taylor expanded in phi2 around 0 33.4%
Final simplification33.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5))))
(if (<= phi1 -7.2e-27)
(*
R
(*
2.0
(atan2
(* phi1 (* -0.5 t_0))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(+ (sin (* phi2 -0.5)) (* 0.5 (* phi1 t_0)))
(sqrt
(+
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double tmp;
if (phi1 <= -7.2e-27) {
tmp = R * (2.0 * atan2((phi1 * (-0.5 * t_0)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2((sin((phi2 * -0.5)) + (0.5 * (phi1 * t_0))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0)))
if (phi1 <= (-7.2d-27)) then
tmp = r * (2.0d0 * atan2((phi1 * ((-0.5d0) * t_0)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2((sin((phi2 * (-0.5d0))) + (0.5d0 * (phi1 * t_0))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 * -0.5));
double tmp;
if (phi1 <= -7.2e-27) {
tmp = R * (2.0 * Math.atan2((phi1 * (-0.5 * t_0)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2((Math.sin((phi2 * -0.5)) + (0.5 * (phi1 * t_0))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) tmp = 0 if phi1 <= -7.2e-27: tmp = R * (2.0 * math.atan2((phi1 * (-0.5 * t_0)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2((math.sin((phi2 * -0.5)) + (0.5 * (phi1 * t_0))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) tmp = 0.0 if (phi1 <= -7.2e-27) tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(-0.5 * t_0)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(phi2 * -0.5)) + Float64(0.5 * Float64(phi1 * t_0))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); tmp = 0.0; if (phi1 <= -7.2e-27) tmp = R * (2.0 * atan2((phi1 * (-0.5 * t_0)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2((sin((phi2 * -0.5)) + (0.5 * (phi1 * t_0))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -7.2e-27], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
\mathbf{if}\;\phi_1 \leq -7.2 \cdot 10^{-27}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(-0.5 \cdot t_0\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_2 \cdot -0.5\right) + 0.5 \cdot \left(\phi_1 \cdot t_0\right)}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -7.1999999999999997e-27Initial program 43.9%
Taylor expanded in phi1 around 0 25.6%
Taylor expanded in phi1 around -inf 16.2%
associate-*r*16.2%
Simplified16.2%
Taylor expanded in phi2 around 0 16.2%
associate--r+16.2%
unpow216.2%
1-sub-sin16.2%
unpow216.2%
*-commutative16.2%
*-commutative16.2%
unpow216.2%
associate-*l*16.2%
Simplified16.2%
Taylor expanded in lambda2 around 0 16.3%
if -7.1999999999999997e-27 < phi1 Initial program 65.4%
associate-*l*65.3%
Simplified65.4%
sin-mult65.4%
div-inv65.4%
metadata-eval65.4%
div-inv65.4%
metadata-eval65.4%
div-inv65.4%
metadata-eval65.4%
div-inv65.4%
metadata-eval65.4%
Applied egg-rr65.4%
div-sub65.4%
+-inverses65.4%
cos-065.4%
metadata-eval65.4%
distribute-lft-out65.4%
metadata-eval65.4%
*-rgt-identity65.4%
Simplified65.4%
Taylor expanded in phi1 around 0 55.2%
Taylor expanded in phi1 around inf 14.8%
Final simplification15.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (cos (* phi2 -0.5))))
(t_1 (sin (* phi2 -0.5)))
(t_2
(sqrt
(+
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))
(if (<= phi1 3.4e-122)
(* R (* 2.0 (atan2 (- (* -0.5 t_0) t_1) t_2)))
(* R (* 2.0 (atan2 (+ t_1 (* 0.5 t_0)) t_2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * cos((phi2 * -0.5));
double t_1 = sin((phi2 * -0.5));
double t_2 = sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))));
double tmp;
if (phi1 <= 3.4e-122) {
tmp = R * (2.0 * atan2(((-0.5 * t_0) - t_1), t_2));
} else {
tmp = R * (2.0 * atan2((t_1 + (0.5 * t_0)), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = phi1 * cos((phi2 * (-0.5d0)))
t_1 = sin((phi2 * (-0.5d0)))
t_2 = sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))
if (phi1 <= 3.4d-122) then
tmp = r * (2.0d0 * atan2((((-0.5d0) * t_0) - t_1), t_2))
else
tmp = r * (2.0d0 * atan2((t_1 + (0.5d0 * t_0)), 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 = phi1 * Math.cos((phi2 * -0.5));
double t_1 = Math.sin((phi2 * -0.5));
double t_2 = Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))));
double tmp;
if (phi1 <= 3.4e-122) {
tmp = R * (2.0 * Math.atan2(((-0.5 * t_0) - t_1), t_2));
} else {
tmp = R * (2.0 * Math.atan2((t_1 + (0.5 * t_0)), t_2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.cos((phi2 * -0.5)) t_1 = math.sin((phi2 * -0.5)) t_2 = math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))) tmp = 0 if phi1 <= 3.4e-122: tmp = R * (2.0 * math.atan2(((-0.5 * t_0) - t_1), t_2)) else: tmp = R * (2.0 * math.atan2((t_1 + (0.5 * t_0)), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * cos(Float64(phi2 * -0.5))) t_1 = sin(Float64(phi2 * -0.5)) t_2 = sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)))) tmp = 0.0 if (phi1 <= 3.4e-122) tmp = Float64(R * Float64(2.0 * atan(Float64(Float64(-0.5 * t_0) - t_1), t_2))); else tmp = Float64(R * Float64(2.0 * atan(Float64(t_1 + Float64(0.5 * t_0)), t_2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * cos((phi2 * -0.5)); t_1 = sin((phi2 * -0.5)); t_2 = sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))); tmp = 0.0; if (phi1 <= 3.4e-122) tmp = R * (2.0 * atan2(((-0.5 * t_0) - t_1), t_2)); else tmp = R * (2.0 * atan2((t_1 + (0.5 * t_0)), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, 3.4e-122], N[(R * N[(2.0 * N[ArcTan[N[(N[(-0.5 * t$95$0), $MachinePrecision] - t$95$1), $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(t$95$1 + N[(0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \cos \left(\phi_2 \cdot -0.5\right)\\
t_1 := \sin \left(\phi_2 \cdot -0.5\right)\\
t_2 := \sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}\\
\mathbf{if}\;\phi_1 \leq 3.4 \cdot 10^{-122}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{-0.5 \cdot t_0 - t_1}{t_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1 + 0.5 \cdot t_0}{t_2}\right)\\
\end{array}
\end{array}
if phi1 < 3.3999999999999998e-122Initial program 60.8%
associate-*l*60.8%
Simplified60.9%
sin-mult60.9%
div-inv60.9%
metadata-eval60.9%
div-inv60.9%
metadata-eval60.9%
div-inv60.9%
metadata-eval60.9%
div-inv60.9%
metadata-eval60.9%
Applied egg-rr60.9%
div-sub60.9%
+-inverses60.9%
cos-060.9%
metadata-eval60.9%
distribute-lft-out60.9%
metadata-eval60.9%
*-rgt-identity60.9%
Simplified60.9%
Taylor expanded in phi1 around 0 53.0%
Taylor expanded in phi1 around -inf 17.7%
+-commutative17.7%
mul-1-neg17.7%
unsub-neg17.7%
Simplified17.7%
if 3.3999999999999998e-122 < phi1 Initial program 55.4%
associate-*l*55.4%
Simplified55.4%
sin-mult55.4%
div-inv55.4%
metadata-eval55.4%
div-inv55.4%
metadata-eval55.4%
div-inv55.4%
metadata-eval55.4%
div-inv55.4%
metadata-eval55.4%
Applied egg-rr55.4%
div-sub55.4%
+-inverses55.4%
cos-055.4%
metadata-eval55.4%
distribute-lft-out55.4%
metadata-eval55.4%
*-rgt-identity55.4%
Simplified55.4%
Taylor expanded in phi1 around 0 33.2%
Taylor expanded in phi1 around inf 15.7%
Final simplification17.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi2 -0.5))))
(if (<= phi1 -2.25e-113)
(*
R
(*
2.0
(atan2
(* phi1 (* -0.5 t_0))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(* 0.5 (* phi1 t_0))
(sqrt
(+
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi2 * -0.5));
double tmp;
if (phi1 <= -2.25e-113) {
tmp = R * (2.0 * atan2((phi1 * (-0.5 * t_0)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2((0.5 * (phi1 * t_0)), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((phi2 * (-0.5d0)))
if (phi1 <= (-2.25d-113)) then
tmp = r * (2.0d0 * atan2((phi1 * ((-0.5d0) * t_0)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2((0.5d0 * (phi1 * t_0)), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((phi2 * -0.5));
double tmp;
if (phi1 <= -2.25e-113) {
tmp = R * (2.0 * Math.atan2((phi1 * (-0.5 * t_0)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2((0.5 * (phi1 * t_0)), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi2 * -0.5)) tmp = 0 if phi1 <= -2.25e-113: tmp = R * (2.0 * math.atan2((phi1 * (-0.5 * t_0)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2((0.5 * (phi1 * t_0)), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi2 * -0.5)) tmp = 0.0 if (phi1 <= -2.25e-113) tmp = Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(-0.5 * t_0)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(0.5 * Float64(phi1 * t_0)), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi2 * -0.5)); tmp = 0.0; if (phi1 <= -2.25e-113) tmp = R * (2.0 * atan2((phi1 * (-0.5 * t_0)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2((0.5 * (phi1 * t_0)), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.25e-113], N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(-0.5 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(0.5 * N[(phi1 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_2 \cdot -0.5\right)\\
\mathbf{if}\;\phi_1 \leq -2.25 \cdot 10^{-113}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(-0.5 \cdot t_0\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{0.5 \cdot \left(\phi_1 \cdot t_0\right)}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -2.2500000000000001e-113Initial program 52.9%
Taylor expanded in phi1 around 0 38.1%
Taylor expanded in phi1 around -inf 14.7%
associate-*r*14.7%
Simplified14.7%
Taylor expanded in phi2 around 0 14.8%
associate--r+14.8%
unpow214.8%
1-sub-sin14.8%
unpow214.8%
*-commutative14.8%
*-commutative14.8%
unpow214.8%
associate-*l*14.8%
Simplified14.8%
Taylor expanded in lambda2 around 0 14.9%
if -2.2500000000000001e-113 < phi1 Initial program 62.6%
associate-*l*62.6%
Simplified62.6%
sin-mult62.7%
div-inv62.7%
metadata-eval62.7%
div-inv62.7%
metadata-eval62.7%
div-inv62.7%
metadata-eval62.7%
div-inv62.7%
metadata-eval62.7%
Applied egg-rr62.7%
div-sub62.7%
+-inverses62.7%
cos-062.7%
metadata-eval62.7%
distribute-lft-out62.7%
metadata-eval62.7%
*-rgt-identity62.7%
Simplified62.7%
Taylor expanded in phi1 around 0 51.4%
Taylor expanded in phi1 around inf 8.9%
Final simplification11.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* phi1 (* -0.5 (cos (* phi2 -0.5))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((phi1 * (-0.5 * cos((phi2 * -0.5)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((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
code = r * (2.0d0 * atan2((phi1 * ((-0.5d0) * cos((phi2 * (-0.5d0))))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((phi1 * (-0.5 * Math.cos((phi2 * -0.5)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((phi1 * (-0.5 * math.cos((phi2 * -0.5)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(-0.5 * cos(Float64(phi2 * -0.5)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((phi1 * (-0.5 * cos((phi2 * -0.5)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(-0.5 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(-0.5 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 59.1%
Taylor expanded in phi1 around 0 46.5%
Taylor expanded in phi1 around -inf 8.4%
associate-*r*8.4%
Simplified8.4%
Taylor expanded in phi2 around 0 8.6%
associate--r+8.6%
unpow28.6%
1-sub-sin8.6%
unpow28.6%
*-commutative8.6%
*-commutative8.6%
unpow28.6%
associate-*l*8.6%
Simplified8.6%
Taylor expanded in lambda2 around 0 8.6%
Final simplification8.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* phi1 (* -0.5 (cos (* phi2 -0.5))))
(sqrt
(- 1.0 (* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((phi1 * (-0.5 * cos((phi2 * -0.5)))), sqrt((1.0 - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2((phi1 * ((-0.5d0) * cos((phi2 * (-0.5d0))))), sqrt((1.0d0 - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((phi1 * (-0.5 * Math.cos((phi2 * -0.5)))), Math.sqrt((1.0 - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((phi1 * (-0.5 * math.cos((phi2 * -0.5)))), math.sqrt((1.0 - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(-0.5 * cos(Float64(phi2 * -0.5)))), sqrt(Float64(1.0 - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((phi1 * (-0.5 * cos((phi2 * -0.5)))), sqrt((1.0 - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(-0.5 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - 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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(-0.5 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{1 - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 59.1%
Taylor expanded in phi1 around 0 46.5%
Taylor expanded in phi1 around -inf 8.4%
associate-*r*8.4%
Simplified8.4%
Taylor expanded in phi2 around 0 8.6%
associate--r+8.6%
unpow28.6%
1-sub-sin8.6%
unpow28.6%
*-commutative8.6%
*-commutative8.6%
unpow28.6%
associate-*l*8.6%
Simplified8.6%
Taylor expanded in phi1 around 0 8.6%
Final simplification8.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* phi1 (* -0.5 (cos (* phi2 -0.5))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((phi1 * (-0.5 * cos((phi2 * -0.5)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2((phi1 * ((-0.5d0) * cos((phi2 * (-0.5d0))))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((phi1 * (-0.5 * Math.cos((phi2 * -0.5)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((phi1 * (-0.5 * math.cos((phi2 * -0.5)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(phi1 * Float64(-0.5 * cos(Float64(phi2 * -0.5)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((phi1 * (-0.5 * cos((phi2 * -0.5)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(phi1 * N[(-0.5 * N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\phi_1 \cdot \left(-0.5 \cdot \cos \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 59.1%
Taylor expanded in phi1 around 0 46.5%
Taylor expanded in phi1 around -inf 8.4%
associate-*r*8.4%
Simplified8.4%
Taylor expanded in phi2 around 0 8.6%
associate--r+8.6%
unpow28.6%
1-sub-sin8.6%
unpow28.6%
*-commutative8.6%
*-commutative8.6%
unpow28.6%
associate-*l*8.6%
Simplified8.6%
Taylor expanded in phi1 around 0 8.6%
sub-neg8.6%
mul-1-neg8.6%
+-commutative8.6%
unpow28.6%
1-sub-sin8.6%
distribute-lft-in8.6%
associate-*r*8.6%
metadata-eval8.6%
metadata-eval8.6%
associate-*r*8.6%
distribute-lft-in8.6%
mul-1-neg8.6%
sub-neg8.6%
*-commutative8.6%
distribute-lft-in8.6%
associate-*r*8.6%
metadata-eval8.6%
Simplified8.6%
Final simplification8.6%
herbie shell --seed 2023257
(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))))))))))