
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+
(- 1.0 t_1)
(*
t_0
(-
(/
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin 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 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(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[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \left(\frac{\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
div-sub66.3%
sin-diff67.5%
Applied egg-rr67.5%
div-sub66.3%
sin-diff67.5%
Applied egg-rr79.6%
sin-mult79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
cos-sum79.6%
cos-279.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
Applied egg-rr79.7%
div-sub79.7%
+-inverses79.7%
cos-079.7%
metadata-eval79.7%
associate-*r*79.7%
metadata-eval79.7%
*-lft-identity79.7%
Simplified79.7%
cos-diff80.2%
Applied egg-rr80.2%
Final simplification80.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_1 t_1))))
(sqrt
(+
(-
1.0
(pow
(fma
(sin (* phi1 0.5))
(cos (* phi2 0.5))
(* (cos (* phi1 0.5)) (- (sin (* phi2 0.5)))))
2.0))
(* 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));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(fma(sin((phi1 * 0.5)), cos((phi2 * 0.5)), (cos((phi1 * 0.5)) * -sin((phi2 * 0.5)))), 2.0)) + (t_0 * ((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)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (fma(sin(Float64(phi1 * 0.5)), cos(Float64(phi2 * 0.5)), Float64(cos(Float64(phi1 * 0.5)) * Float64(-sin(Float64(phi2 * 0.5))))) ^ 2.0)) + Float64(t_0 * Float64(Float64(cos(Float64(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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * (-N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $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)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right), \cos \left(\phi_1 \cdot 0.5\right) \cdot \left(-\sin \left(\phi_2 \cdot 0.5\right)\right)\right)\right)}^{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 66.3%
associate-*l*66.3%
Simplified66.3%
div-sub66.3%
sin-diff67.5%
Applied egg-rr67.5%
div-sub66.3%
sin-diff67.5%
Applied egg-rr79.6%
sin-mult79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
cos-sum79.6%
cos-279.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
Applied egg-rr79.7%
div-sub79.7%
+-inverses79.7%
cos-079.7%
metadata-eval79.7%
associate-*r*79.7%
metadata-eval79.7%
*-lft-identity79.7%
Simplified79.7%
cancel-sign-sub-inv79.7%
fma-define79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
div-inv79.7%
metadata-eval79.7%
Applied egg-rr79.7%
Final simplification79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (sqrt (+ t_1 (* t_0 (* t_2 t_2)))))
(t_4 (- 1.0 t_1)))
(if (or (<= lambda2 -3.4e-5) (not (<= lambda2 5.9e-16)))
(*
R
(* 2.0 (atan2 t_3 (sqrt (+ t_4 (* t_0 (- (/ (cos lambda2) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2 t_3 (sqrt (+ t_4 (* t_0 (- (/ (cos lambda1) 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 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((t_1 + (t_0 * (t_2 * t_2))));
double t_4 = 1.0 - t_1;
double tmp;
if ((lambda2 <= -3.4e-5) || !(lambda2 <= 5.9e-16)) {
tmp = R * (2.0 * atan2(t_3, sqrt((t_4 + (t_0 * ((cos(lambda2) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((t_4 + (t_0 * ((cos(lambda1) / 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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt((t_1 + (t_0 * (t_2 * t_2))))
t_4 = 1.0d0 - t_1
if ((lambda2 <= (-3.4d-5)) .or. (.not. (lambda2 <= 5.9d-16))) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((t_4 + (t_0 * ((cos(lambda2) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt((t_4 + (t_0 * ((cos(lambda1) / 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(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt((t_1 + (t_0 * (t_2 * t_2))));
double t_4 = 1.0 - t_1;
double tmp;
if ((lambda2 <= -3.4e-5) || !(lambda2 <= 5.9e-16)) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((t_4 + (t_0 * ((Math.cos(lambda2) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((t_4 + (t_0 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((t_1 + (t_0 * (t_2 * t_2)))) t_4 = 1.0 - t_1 tmp = 0 if (lambda2 <= -3.4e-5) or not (lambda2 <= 5.9e-16): tmp = R * (2.0 * math.atan2(t_3, math.sqrt((t_4 + (t_0 * ((math.cos(lambda2) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((t_4 + (t_0 * ((math.cos(lambda1) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))) t_4 = Float64(1.0 - t_1) tmp = 0.0 if ((lambda2 <= -3.4e-5) || !(lambda2 <= 5.9e-16)) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(t_4 + Float64(t_0 * Float64(Float64(cos(lambda2) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(t_4 + Float64(t_0 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt((t_1 + (t_0 * (t_2 * t_2)))); t_4 = 1.0 - t_1; tmp = 0.0; if ((lambda2 <= -3.4e-5) || ~((lambda2 <= 5.9e-16))) tmp = R * (2.0 * atan2(t_3, sqrt((t_4 + (t_0 * ((cos(lambda2) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(t_3, sqrt((t_4 + (t_0 * ((cos(lambda1) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$1), $MachinePrecision]}, If[Or[LessEqual[lambda2, -3.4e-5], N[Not[LessEqual[lambda2, 5.9e-16]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(t$95$4 + N[(t$95$0 * N[(N[(N[Cos[lambda2], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(t$95$4 + N[(t$95$0 * N[(N[(N[Cos[lambda1], $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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}\\
t_4 := 1 - t\_1\\
\mathbf{if}\;\lambda_2 \leq -3.4 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 5.9 \cdot 10^{-16}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{t\_4 + t\_0 \cdot \left(\frac{\cos \lambda_2}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{t\_4 + t\_0 \cdot \left(\frac{\cos \lambda_1}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -3.4e-5 or 5.90000000000000022e-16 < lambda2 Initial program 49.3%
associate-*l*49.3%
Simplified49.4%
div-sub49.4%
sin-diff50.9%
Applied egg-rr50.9%
div-sub49.4%
sin-diff50.9%
Applied egg-rr59.7%
sin-mult59.8%
div-inv59.8%
metadata-eval59.8%
*-commutative59.8%
div-inv59.8%
metadata-eval59.8%
*-commutative59.8%
cos-sum59.7%
cos-259.8%
div-inv59.8%
metadata-eval59.8%
*-commutative59.8%
Applied egg-rr59.8%
div-sub59.8%
+-inverses59.8%
cos-059.8%
metadata-eval59.8%
associate-*r*59.8%
metadata-eval59.8%
*-lft-identity59.8%
Simplified59.8%
Taylor expanded in lambda1 around 0 59.9%
cos-neg59.9%
Simplified59.9%
if -3.4e-5 < lambda2 < 5.90000000000000022e-16Initial program 82.5%
associate-*l*82.5%
Simplified82.5%
div-sub82.5%
sin-diff83.3%
Applied egg-rr83.3%
div-sub82.5%
sin-diff83.3%
Applied egg-rr98.6%
sin-mult98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
cos-sum98.6%
cos-298.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
Applied egg-rr98.6%
div-sub98.6%
+-inverses98.6%
cos-098.6%
metadata-eval98.6%
associate-*r*98.6%
metadata-eval98.6%
*-lft-identity98.6%
Simplified98.6%
Taylor expanded in lambda2 around 0 98.6%
Final simplification79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (* t_2 (* t_1 t_1)))
(t_4 (- 1.0 t_0)))
(if (<= lambda2 -0.00035)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- t_4 (* t_2 (pow (sin (* lambda2 -0.5)) 2.0)))))))
(if (<= lambda2 0.00034)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_3))
(sqrt (+ t_4 (* t_2 (- (/ (cos lambda1) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(+ t_4 (* t_2 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = t_2 * (t_1 * t_1);
double t_4 = 1.0 - t_0;
double tmp;
if (lambda2 <= -0.00035) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((t_4 - (t_2 * pow(sin((lambda2 * -0.5)), 2.0))))));
} else if (lambda2 <= 0.00034) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((t_4 + (t_2 * ((cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((t_4 + (t_2 * ((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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
t_3 = t_2 * (t_1 * t_1)
t_4 = 1.0d0 - t_0
if (lambda2 <= (-0.00035d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((t_4 - (t_2 * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
else if (lambda2 <= 0.00034d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_3)), sqrt((t_4 + (t_2 * ((cos(lambda1) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((t_4 + (t_2 * ((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.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = t_2 * (t_1 * t_1);
double t_4 = 1.0 - t_0;
double tmp;
if (lambda2 <= -0.00035) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((t_4 - (t_2 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
} else if (lambda2 <= 0.00034) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_3)), Math.sqrt((t_4 + (t_2 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((t_4 + (t_2 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = t_2 * (t_1 * t_1) t_4 = 1.0 - t_0 tmp = 0 if lambda2 <= -0.00035: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((t_4 - (t_2 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) elif lambda2 <= 0.00034: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_3)), math.sqrt((t_4 + (t_2 * ((math.cos(lambda1) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((t_4 + (t_2 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64(t_2 * Float64(t_1 * t_1)) t_4 = Float64(1.0 - t_0) tmp = 0.0 if (lambda2 <= -0.00035) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(t_4 - Float64(t_2 * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); elseif (lambda2 <= 0.00034) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), sqrt(Float64(t_4 + Float64(t_2 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(t_4 + Float64(t_2 * 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 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); t_3 = t_2 * (t_1 * t_1); t_4 = 1.0 - t_0; tmp = 0.0; if (lambda2 <= -0.00035) tmp = R * (2.0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((t_4 - (t_2 * (sin((lambda2 * -0.5)) ^ 2.0)))))); elseif (lambda2 <= 0.00034) tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((t_4 + (t_2 * ((cos(lambda1) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((t_4 + (t_2 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[lambda2, -0.00035], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - N[(t$95$2 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 0.00034], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 + 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$3 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 + N[(t$95$2 * 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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := t\_2 \cdot \left(t\_1 \cdot t\_1\right)\\
t_4 := 1 - t\_0\\
\mathbf{if}\;\lambda_2 \leq -0.00035:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{t\_4 - t\_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{elif}\;\lambda_2 \leq 0.00034:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3}}{\sqrt{t\_4 + 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\_3 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{t\_4 + t\_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -3.49999999999999996e-4Initial program 51.9%
associate-*l*51.9%
Simplified52.0%
div-sub52.0%
sin-diff53.8%
Applied egg-rr53.8%
Taylor expanded in lambda1 around 0 54.2%
if -3.49999999999999996e-4 < lambda2 < 3.4e-4Initial program 82.2%
associate-*l*82.2%
Simplified82.2%
div-sub82.2%
sin-diff82.9%
Applied egg-rr82.9%
div-sub82.2%
sin-diff82.9%
Applied egg-rr98.6%
sin-mult98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
cos-sum98.6%
cos-298.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
Applied egg-rr98.6%
div-sub98.6%
+-inverses98.6%
cos-098.6%
metadata-eval98.6%
associate-*r*98.6%
metadata-eval98.6%
*-lft-identity98.6%
Simplified98.6%
Taylor expanded in lambda2 around 0 98.4%
if 3.4e-4 < lambda2 Initial program 47.3%
associate-*l*47.3%
Simplified47.3%
div-sub47.3%
sin-diff48.7%
Applied egg-rr48.7%
div-sub47.3%
sin-diff48.7%
Applied egg-rr56.0%
sin-mult56.0%
div-inv56.0%
metadata-eval56.0%
*-commutative56.0%
div-inv56.0%
metadata-eval56.0%
*-commutative56.0%
cos-sum56.0%
cos-256.0%
div-inv56.0%
metadata-eval56.0%
*-commutative56.0%
Applied egg-rr56.0%
div-sub56.0%
+-inverses56.0%
cos-056.0%
metadata-eval56.0%
associate-*r*56.0%
metadata-eval56.0%
*-lft-identity56.0%
Simplified56.0%
sin-diff48.7%
div-sub48.7%
unpow248.7%
sin-mult48.8%
Applied egg-rr48.8%
div-sub48.8%
+-inverses48.8%
cos-048.8%
metadata-eval48.8%
distribute-rgt-out48.8%
metadata-eval48.8%
*-rgt-identity48.8%
Simplified48.8%
Final simplification75.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+ (- 1.0 t_1) (* 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 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (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((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (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.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (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.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (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 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + 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((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (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[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $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 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
div-sub66.3%
sin-diff67.5%
Applied egg-rr67.5%
div-sub66.3%
sin-diff67.5%
Applied egg-rr79.6%
sin-mult79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
cos-sum79.6%
cos-279.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
Applied egg-rr79.7%
div-sub79.7%
+-inverses79.7%
cos-079.7%
metadata-eval79.7%
associate-*r*79.7%
metadata-eval79.7%
*-lft-identity79.7%
Simplified79.7%
Final simplification79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
div-sub66.3%
sin-diff67.5%
Applied egg-rr67.5%
Final simplification67.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(fabs
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* 0.5 (- phi1 phi2))) 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(fabs((1.0 - fma(cos(phi1), (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)), pow(sin((0.5 * (phi1 - phi2))), 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(abs(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 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[Abs[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 66.3%
expm1-log1p-u66.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr66.3%
Applied egg-rr67.1%
unpow1/267.1%
*-commutative67.1%
fma-define67.1%
distribute-rgt-out--67.1%
+-commutative67.1%
Simplified67.1%
Final simplification67.1%
(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)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(fabs
(-
1.0
(fma
(pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)
t_1
(pow (sin (* 0.5 (- phi1 phi2))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(fabs((1.0 - fma(pow(sin(((lambda1 - lambda2) * 0.5)), 2.0), t_1, pow(sin((0.5 * (phi1 - phi2))), 2.0)))))));
}
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)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(abs(Float64(1.0 - fma((sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0), t_1, (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)))))))) 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * t$95$1 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $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) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|1 - \mathsf{fma}\left({\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}, t\_1, {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
associate--l-66.3%
+-commutative66.3%
fma-undefine66.3%
add-sqr-sqrt66.3%
pow1/266.3%
pow1/266.3%
Applied egg-rr67.1%
unpow1/267.1%
unpow267.1%
rem-sqrt-square67.1%
*-commutative67.1%
*-commutative67.1%
Simplified67.1%
Final simplification67.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_1 t_1))))
(sqrt
(+
(+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5))
(* 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));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) + (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
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) + (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));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) + (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)) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) + (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)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) + 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)); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) + (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]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $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)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) + t\_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
div-sub66.3%
sin-diff67.5%
Applied egg-rr67.5%
div-sub66.3%
sin-diff67.5%
Applied egg-rr79.6%
sin-mult79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
cos-sum79.6%
cos-279.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
Applied egg-rr79.7%
div-sub79.7%
+-inverses79.7%
cos-079.7%
metadata-eval79.7%
associate-*r*79.7%
metadata-eval79.7%
*-lft-identity79.7%
Simplified79.7%
sin-diff67.5%
div-sub67.5%
unpow267.5%
sin-mult64.9%
Applied egg-rr67.0%
div-sub64.9%
+-inverses64.9%
cos-064.9%
metadata-eval64.9%
distribute-rgt-out64.9%
metadata-eval64.9%
*-rgt-identity64.9%
Simplified67.0%
Final simplification67.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (* t_3 (* t_2 t_2)))
(t_5 (* (cos phi1) t_1)))
(if (<= phi1 -5.4e-70)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- (- 1.0 t_0) t_4)))))
(if (<= phi1 5.2e-6)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_2))))
(sqrt
(- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_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 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos(phi1) * cos(phi2);
double t_4 = t_3 * (t_2 * t_2);
double t_5 = cos(phi1) * t_1;
double tmp;
if (phi1 <= -5.4e-70) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - t_0) - t_4))));
} else if (phi1 <= 5.2e-6) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - t_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) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos(phi1) * cos(phi2)
t_4 = t_3 * (t_2 * t_2)
t_5 = cos(phi1) * t_1
if (phi1 <= (-5.4d-70)) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt(((1.0d0 - t_0) - t_4))))
else if (phi1 <= 5.2d-6) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - t_5))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = t_3 * (t_2 * t_2);
double t_5 = Math.cos(phi1) * t_1;
double tmp;
if (phi1 <= -5.4e-70) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt(((1.0 - t_0) - t_4))));
} else if (phi1 <= 5.2e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_2)))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_5))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos(phi1) * math.cos(phi2) t_4 = t_3 * (t_2 * t_2) t_5 = math.cos(phi1) * t_1 tmp = 0 if phi1 <= -5.4e-70: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt(((1.0 - t_0) - t_4)))) elif phi1 <= 5.2e-6: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_2)))), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_5)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = Float64(t_3 * Float64(t_2 * t_2)) t_5 = Float64(cos(phi1) * t_1) tmp = 0.0 if (phi1 <= -5.4e-70) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(Float64(1.0 - t_0) - t_4))))); elseif (phi1 <= 5.2e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_2)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_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 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos(phi1) * cos(phi2); t_4 = t_3 * (t_2 * t_2); t_5 = cos(phi1) * t_1; tmp = 0.0; if (phi1 <= -5.4e-70) tmp = R * (2.0 * atan2(sqrt((t_4 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - t_0) - t_4)))); elseif (phi1 <= 5.2e-6) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_5 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[phi1, -5.4e-70], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 5.2e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := t\_3 \cdot \left(t\_2 \cdot t\_2\right)\\
t_5 := \cos \phi_1 \cdot t\_1\\
\mathbf{if}\;\phi_1 \leq -5.4 \cdot 10^{-70}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{\left(1 - t\_0\right) - t\_4}}\right)\\
\mathbf{elif}\;\phi_1 \leq 5.2 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_3 \cdot t\_2\right)}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t\_5}}\right)\\
\end{array}
\end{array}
if phi1 < -5.4000000000000003e-70Initial program 62.3%
associate-*l*62.4%
Simplified62.4%
unpow262.4%
sin-mult62.5%
div-inv62.5%
metadata-eval62.5%
div-inv62.5%
metadata-eval62.5%
div-inv62.5%
metadata-eval62.5%
div-inv62.5%
metadata-eval62.5%
Applied egg-rr62.4%
div-sub62.5%
+-inverses62.5%
cos-062.5%
metadata-eval62.5%
distribute-lft-out62.5%
metadata-eval62.5%
*-rgt-identity62.5%
Simplified62.4%
if -5.4000000000000003e-70 < phi1 < 5.20000000000000019e-6Initial program 79.9%
expm1-log1p-u79.9%
div-inv79.9%
metadata-eval79.9%
Applied egg-rr79.9%
Taylor expanded in phi1 around 0 79.9%
if 5.20000000000000019e-6 < phi1 Initial program 41.9%
associate-*l*41.9%
Simplified41.9%
Taylor expanded in phi2 around 0 45.0%
add-log-exp45.0%
fma-define45.0%
*-commutative45.0%
Applied egg-rr45.0%
Taylor expanded in R around 0 45.0%
Simplified26.8%
Taylor expanded in phi2 around 0 45.4%
Final simplification67.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi1) t_0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -5e-5) (not (<= phi1 2.8e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_1)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_2 (* (* (cos phi1) (cos phi2)) t_2))))
(sqrt
(- 1.0 (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = cos(phi1) * t_0;
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -5e-5) || !(phi1 <= 2.8e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * ((cos(phi1) * cos(phi2)) * t_2)))), sqrt((1.0 - ((cos(phi2) * t_0) + pow(sin((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) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * t_0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-5d-5)) .or. (.not. (phi1 <= 2.8d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_2 * ((cos(phi1) * cos(phi2)) * t_2)))), sqrt((1.0d0 - ((cos(phi2) * t_0) + (sin((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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.cos(phi1) * t_0;
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -5e-5) || !(phi1 <= 2.8e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2)))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.cos(phi1) * t_0 t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -5e-5) or not (phi1 <= 2.8e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2)))), math.sqrt((1.0 - ((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * t_0) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -5e-5) || !(phi1 <= 2.8e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = cos(phi1) * t_0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -5e-5) || ~((phi1 <= 2.8e-5))) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_1)))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_2 * ((cos(phi1) * cos(phi2)) * t_2)))), sqrt((1.0 - ((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -5e-5], N[Not[LessEqual[phi1, 2.8e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_1 \cdot t\_0\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -5 \cdot 10^{-5} \lor \neg \left(\phi_1 \leq 2.8 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right)}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -5.00000000000000024e-5 or 2.79999999999999996e-5 < phi1 Initial program 47.8%
associate-*l*47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 47.6%
add-log-exp47.6%
fma-define47.6%
*-commutative47.6%
Applied egg-rr47.6%
Taylor expanded in R around 0 47.6%
Simplified27.2%
Taylor expanded in phi2 around 0 48.0%
if -5.00000000000000024e-5 < phi1 < 2.79999999999999996e-5Initial program 80.7%
expm1-log1p-u80.7%
div-inv80.7%
metadata-eval80.7%
Applied egg-rr80.7%
Taylor expanded in phi1 around 0 80.7%
Final simplification66.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi1) t_0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -1e-5) (not (<= phi1 4.4e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_1)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_2 t_2))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(- 1.0 (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = cos(phi1) * t_0;
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1e-5) || !(phi1 <= 4.4e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - t_1))));
} else {
tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_2 * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi2) * t_0) + pow(sin((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) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * t_0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-1d-5)) .or. (.not. (phi1 <= 4.4d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - t_1))))
else
tmp = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_2 * t_2)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi2) * t_0) + (sin((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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.cos(phi1) * t_0;
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -1e-5) || !(phi1 <= 4.4e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_2 * t_2)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.cos(phi1) * t_0 t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -1e-5) or not (phi1 <= 4.4e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_1)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_2 * t_2)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * t_0) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -1e-5) || !(phi1 <= 4.4e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_2 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = cos(phi1) * t_0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -1e-5) || ~((phi1 <= 4.4e-5))) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_1)))); else tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_2 * t_2)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi2) * t_0) + (sin((phi2 * -0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -1e-5], N[Not[LessEqual[phi1, 4.4e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_1 \cdot t\_0\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -1 \cdot 10^{-5} \lor \neg \left(\phi_1 \leq 4.4 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_2 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.00000000000000008e-5 or 4.3999999999999999e-5 < phi1 Initial program 47.8%
associate-*l*47.9%
Simplified47.9%
Taylor expanded in phi2 around 0 47.6%
add-log-exp47.6%
fma-define47.6%
*-commutative47.6%
Applied egg-rr47.6%
Taylor expanded in R around 0 47.6%
Simplified27.2%
Taylor expanded in phi2 around 0 48.0%
if -1.00000000000000008e-5 < phi1 < 4.3999999999999999e-5Initial program 80.7%
associate-*l*80.6%
Simplified80.7%
Taylor expanded in phi1 around 0 80.6%
Final simplification66.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
unpow266.3%
sin-mult66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
Applied egg-rr66.4%
div-sub66.4%
+-inverses66.4%
cos-066.4%
metadata-eval66.4%
distribute-lft-out66.4%
metadata-eval66.4%
*-rgt-identity66.4%
Simplified66.4%
Final simplification66.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2))))
(if (or (<= phi2 -3.6e+21) (not (<= phi2 850.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (pow (sin (* lambda1 0.5)) 2.0))))
(sqrt
(-
1.0
(+
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi2 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_1)) t_0))
(sqrt
(+
1.0
(-
(* (cos phi1) (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5))
(pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -3.6e+21) || !(phi2 <= 850.0)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * pow(sin((lambda1 * 0.5)), 2.0)))), sqrt((1.0 - ((cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi2 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt((1.0 + ((cos(phi1) * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)) - pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
if ((phi2 <= (-3.6d+21)) .or. (.not. (phi2 <= 850.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (sin((lambda1 * 0.5d0)) ** 2.0d0)))), sqrt((1.0d0 - ((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi2 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt((1.0d0 + ((cos(phi1) * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0)) - (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((phi2 <= -3.6e+21) || !(phi2 <= 850.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * Math.pow(Math.sin((lambda1 * 0.5)), 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi2 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_1 * t_1)) + t_0)), Math.sqrt((1.0 + ((Math.cos(phi1) * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5)) - Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (phi2 <= -3.6e+21) or not (phi2 <= 850.0): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * math.pow(math.sin((lambda1 * 0.5)), 2.0)))), math.sqrt((1.0 - ((math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi2 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_1 * t_1)) + t_0)), math.sqrt((1.0 + ((math.cos(phi1) * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5)) - math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -3.6e+21) || !(phi2 <= 850.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * (sin(Float64(lambda1 * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi2 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_1)) + t_0)), sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5)) - (sin(Float64(phi1 * 0.5)) ^ 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 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if ((phi2 <= -3.6e+21) || ~((phi2 <= 850.0))) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (sin((lambda1 * 0.5)) ^ 2.0)))), sqrt((1.0 - ((cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi2 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + t_0)), sqrt((1.0 + ((cos(phi1) * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)) - (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -3.6e+21], N[Not[LessEqual[phi2, 850.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{+21} \lor \neg \left(\phi_2 \leq 850\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_2 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_1\right) + t\_0}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right) - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -3.6e21 or 850 < phi2 Initial program 54.8%
associate-*l*54.8%
Simplified54.8%
div-sub54.8%
sin-diff56.9%
Applied egg-rr56.9%
Taylor expanded in lambda2 around 0 45.5%
Taylor expanded in phi1 around 0 42.9%
if -3.6e21 < phi2 < 850Initial program 77.1%
associate-*l*77.1%
Simplified77.2%
Taylor expanded in phi2 around 0 76.2%
add-log-exp76.1%
Applied egg-rr76.1%
rem-log-exp76.2%
unpow276.2%
sin-mult76.3%
Applied egg-rr76.3%
div-sub76.3%
+-inverses76.3%
+-inverses76.3%
+-inverses76.3%
cos-076.3%
metadata-eval76.3%
distribute-rgt-out76.3%
metadata-eval76.3%
*-rgt-identity76.3%
sub-neg76.3%
+-commutative76.3%
remove-double-neg76.3%
mul-1-neg76.3%
distribute-neg-in76.3%
cos-neg76.3%
mul-1-neg76.3%
unsub-neg76.3%
Simplified76.3%
Final simplification60.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2))))
(if (or (<= phi2 -5e+54) (not (<= phi2 880.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_1)) (+ (+ 1.0 t_0) -1.0)))
(sqrt (- 1.0 t_0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(+
1.0
(-
(* (cos phi1) (- (/ (cos (- lambda2 lambda1)) 2.0) 0.5))
(pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi2 <= -5e+54) || !(phi2 <= 880.0)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + ((1.0 + t_0) + -1.0))), sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 + ((cos(phi1) * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)) - pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((0.5d0 * (phi1 - phi2))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
if ((phi2 <= (-5d+54)) .or. (.not. (phi2 <= 880.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + ((1.0d0 + t_0) + (-1.0d0)))), sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 + ((cos(phi1) * ((cos((lambda2 - lambda1)) / 2.0d0) - 0.5d0)) - (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((phi2 <= -5e+54) || !(phi2 <= 880.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_1)) + ((1.0 + t_0) + -1.0))), Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_1 * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 + ((Math.cos(phi1) * ((Math.cos((lambda2 - lambda1)) / 2.0) - 0.5)) - Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (phi2 <= -5e+54) or not (phi2 <= 880.0): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_1)) + ((1.0 + t_0) + -1.0))), math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_1 * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 + ((math.cos(phi1) * ((math.cos((lambda2 - lambda1)) / 2.0) - 0.5)) - math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi2 <= -5e+54) || !(phi2 <= 880.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_1)) + Float64(Float64(1.0 + t_0) + -1.0))), sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 + Float64(Float64(cos(phi1) * Float64(Float64(cos(Float64(lambda2 - lambda1)) / 2.0) - 0.5)) - (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if ((phi2 <= -5e+54) || ~((phi2 <= 880.0))) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + ((1.0 + t_0) + -1.0))), sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 + ((cos(phi1) * ((cos((lambda2 - lambda1)) / 2.0) - 0.5)) - (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -5e+54], N[Not[LessEqual[phi2, 880.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_2 \leq -5 \cdot 10^{+54} \lor \neg \left(\phi_2 \leq 880\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_1\right) + \left(\left(1 + t\_0\right) + -1\right)}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 + \left(\cos \phi_1 \cdot \left(\frac{\cos \left(\lambda_2 - \lambda_1\right)}{2} - 0.5\right) - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -5.00000000000000005e54 or 880 < phi2 Initial program 55.6%
expm1-log1p-u55.6%
expm1-undefine55.1%
log1p-undefine55.1%
add-exp-log55.1%
div-inv55.1%
metadata-eval55.1%
Applied egg-rr55.1%
Taylor expanded in lambda1 around 0 44.4%
add-cube-cbrt23.6%
pow223.6%
div-inv23.6%
metadata-eval23.6%
div-inv23.6%
metadata-eval23.6%
Applied egg-rr23.6%
Taylor expanded in lambda2 around 0 20.6%
sub-neg20.6%
mul-1-neg20.6%
rem-cube-cbrt33.3%
mul-1-neg33.3%
sub-neg33.3%
Simplified33.3%
if -5.00000000000000005e54 < phi2 < 880Initial program 75.3%
associate-*l*75.3%
Simplified75.4%
Taylor expanded in phi2 around 0 73.2%
add-log-exp73.2%
Applied egg-rr73.2%
rem-log-exp73.2%
unpow273.2%
sin-mult73.3%
Applied egg-rr73.3%
div-sub73.3%
+-inverses73.3%
+-inverses73.3%
+-inverses73.3%
cos-073.3%
metadata-eval73.3%
distribute-rgt-out73.3%
metadata-eval73.3%
*-rgt-identity73.3%
sub-neg73.3%
+-commutative73.3%
remove-double-neg73.3%
mul-1-neg73.3%
distribute-neg-in73.3%
cos-neg73.3%
mul-1-neg73.3%
unsub-neg73.3%
Simplified73.3%
Final simplification55.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(if (or (<= phi2 -1.12e+27) (not (<= phi2 56000.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+ (* t_1 (* (* (cos phi1) (cos phi2)) t_1)) (+ (+ 1.0 t_0) -1.0)))
(sqrt (- 1.0 t_0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -1.12e+27) || !(phi2 <= 56000.0)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + ((1.0 + t_0) + -1.0))), sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((0.5d0 * (phi1 - phi2))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
if ((phi2 <= (-1.12d+27)) .or. (.not. (phi2 <= 56000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + ((1.0d0 + t_0) + (-1.0d0)))), sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -1.12e+27) || !(phi2 <= 56000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + ((1.0 + t_0) + -1.0))), Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi2 <= -1.12e+27) or not (phi2 <= 56000.0): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + ((1.0 + t_0) + -1.0))), math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) tmp = 0.0 if ((phi2 <= -1.12e+27) || !(phi2 <= 56000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + Float64(Float64(1.0 + t_0) + -1.0))), sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); tmp = 0.0; if ((phi2 <= -1.12e+27) || ~((phi2 <= 56000.0))) tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + ((1.0 + t_0) + -1.0))), sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -1.12e+27], N[Not[LessEqual[phi2, 56000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -1.12 \cdot 10^{+27} \lor \neg \left(\phi_2 \leq 56000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right) + \left(\left(1 + t\_0\right) + -1\right)}}{\sqrt{1 - t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -1.12e27 or 56000 < phi2 Initial program 54.8%
expm1-log1p-u54.8%
expm1-undefine54.3%
log1p-undefine54.3%
add-exp-log54.3%
div-inv54.3%
metadata-eval54.3%
Applied egg-rr54.3%
Taylor expanded in lambda1 around 0 43.7%
add-cube-cbrt23.5%
pow223.5%
div-inv23.5%
metadata-eval23.5%
div-inv23.5%
metadata-eval23.5%
Applied egg-rr23.5%
Taylor expanded in lambda2 around 0 20.6%
sub-neg20.6%
mul-1-neg20.6%
rem-cube-cbrt33.0%
mul-1-neg33.0%
sub-neg33.0%
Simplified33.0%
if -1.12e27 < phi2 < 56000Initial program 76.5%
associate-*l*76.5%
Simplified76.5%
Taylor expanded in phi2 around 0 74.4%
add-log-exp74.4%
fma-define74.4%
*-commutative74.4%
Applied egg-rr74.4%
Taylor expanded in R around 0 74.4%
Simplified59.6%
Taylor expanded in phi2 around 0 71.9%
Final simplification53.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- phi1 phi2))))
(t_1 (pow t_0 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (sin (* (- lambda1 lambda2) 0.5))))
(if (or (<= phi2 -0.00186) (not (<= phi2 2.3e-8)))
(*
R
(*
2.0
(atan2
(sqrt
(+ (* t_2 (* (* (cos phi1) (cos phi2)) t_2)) (+ (+ 1.0 t_1) -1.0)))
(sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(hypot t_0 (* t_3 (sqrt (cos phi2))))
(sqrt
(- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) (pow t_3 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (phi1 - phi2)));
double t_1 = pow(t_0, 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sin(((lambda1 - lambda2) * 0.5));
double tmp;
if ((phi2 <= -0.00186) || !(phi2 <= 2.3e-8)) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(hypot(t_0, (t_3 * sqrt(cos(phi2)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(t_3, 2.0))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * (phi1 - phi2)));
double t_1 = Math.pow(t_0, 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sin(((lambda1 - lambda2) * 0.5));
double tmp;
if ((phi2 <= -0.00186) || !(phi2 <= 2.3e-8)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot(t_0, (t_3 * Math.sqrt(Math.cos(phi2)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(t_3, 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (phi1 - phi2))) t_1 = math.pow(t_0, 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sin(((lambda1 - lambda2) * 0.5)) tmp = 0 if (phi2 <= -0.00186) or not (phi2 <= 2.3e-8): tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.hypot(t_0, (t_3 * math.sqrt(math.cos(phi2)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(t_3, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) t_1 = t_0 ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) tmp = 0.0 if ((phi2 <= -0.00186) || !(phi2 <= 2.3e-8)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) + Float64(Float64(1.0 + t_1) + -1.0))), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(t_0, Float64(t_3 * sqrt(cos(phi2)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (t_3 ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))); t_1 = t_0 ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((lambda1 - lambda2) * 0.5)); tmp = 0.0; if ((phi2 <= -0.00186) || ~((phi2 <= 2.3e-8))) tmp = R * (2.0 * atan2(sqrt(((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(hypot(t_0, (t_3 * sqrt(cos(phi2)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (t_3 ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00186], N[Not[LessEqual[phi2, 2.3e-8]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + t$95$1), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0 ^ 2 + N[(t$95$3 * N[Sqrt[N[Cos[phi2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
t_1 := {t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
\mathbf{if}\;\phi_2 \leq -0.00186 \lor \neg \left(\phi_2 \leq 2.3 \cdot 10^{-8}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) + \left(\left(1 + t\_1\right) + -1\right)}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_0, t\_3 \cdot \sqrt{\cos \phi_2}\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {t\_3}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -0.0018600000000000001 or 2.3000000000000001e-8 < phi2 Initial program 54.4%
expm1-log1p-u54.4%
expm1-undefine53.9%
log1p-undefine53.9%
add-exp-log53.9%
div-inv53.9%
metadata-eval53.9%
Applied egg-rr53.9%
Taylor expanded in lambda1 around 0 43.0%
add-cube-cbrt23.5%
pow223.5%
div-inv23.5%
metadata-eval23.5%
div-inv23.5%
metadata-eval23.5%
Applied egg-rr23.5%
Taylor expanded in lambda2 around 0 20.4%
sub-neg20.4%
mul-1-neg20.4%
rem-cube-cbrt31.9%
mul-1-neg31.9%
sub-neg31.9%
Simplified31.9%
if -0.0018600000000000001 < phi2 < 2.3000000000000001e-8Initial program 78.8%
associate-*l*78.8%
Simplified78.8%
Taylor expanded in phi2 around 0 78.8%
add-log-exp78.8%
fma-define78.8%
*-commutative78.8%
Applied egg-rr78.8%
Taylor expanded in R around 0 78.8%
Simplified63.7%
Taylor expanded in phi1 around 0 63.3%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- phi1 phi2))))
(t_1 (pow t_0 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (sin (* (- lambda1 lambda2) 0.5))))
(if (or (<= phi2 -0.00035) (not (<= phi2 850.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+ (* t_2 (* (* (cos phi1) (cos phi2)) t_2)) (+ (+ 1.0 t_1) -1.0)))
(sqrt (- 1.0 t_1)))))
(*
R
(*
2.0
(atan2
(hypot t_0 (* t_3 (sqrt (cos phi1))))
(sqrt
(- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) (pow t_3 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (phi1 - phi2)));
double t_1 = pow(t_0, 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sin(((lambda1 - lambda2) * 0.5));
double tmp;
if ((phi2 <= -0.00035) || !(phi2 <= 850.0)) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * atan2(hypot(t_0, (t_3 * sqrt(cos(phi1)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(t_3, 2.0))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * (phi1 - phi2)));
double t_1 = Math.pow(t_0, 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sin(((lambda1 - lambda2) * 0.5));
double tmp;
if ((phi2 <= -0.00035) || !(phi2 <= 850.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), Math.sqrt((1.0 - t_1))));
} else {
tmp = R * (2.0 * Math.atan2(Math.hypot(t_0, (t_3 * Math.sqrt(Math.cos(phi1)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(t_3, 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (phi1 - phi2))) t_1 = math.pow(t_0, 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sin(((lambda1 - lambda2) * 0.5)) tmp = 0 if (phi2 <= -0.00035) or not (phi2 <= 850.0): tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), math.sqrt((1.0 - t_1)))) else: tmp = R * (2.0 * math.atan2(math.hypot(t_0, (t_3 * math.sqrt(math.cos(phi1)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(t_3, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) t_1 = t_0 ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) tmp = 0.0 if ((phi2 <= -0.00035) || !(phi2 <= 850.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) + Float64(Float64(1.0 + t_1) + -1.0))), sqrt(Float64(1.0 - t_1))))); else tmp = Float64(R * Float64(2.0 * atan(hypot(t_0, Float64(t_3 * sqrt(cos(phi1)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (t_3 ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))); t_1 = t_0 ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((lambda1 - lambda2) * 0.5)); tmp = 0.0; if ((phi2 <= -0.00035) || ~((phi2 <= 850.0))) tmp = R * (2.0 * atan2(sqrt(((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + ((1.0 + t_1) + -1.0))), sqrt((1.0 - t_1)))); else tmp = R * (2.0 * atan2(hypot(t_0, (t_3 * sqrt(cos(phi1)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (t_3 ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[t$95$0, 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00035], N[Not[LessEqual[phi2, 850.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + t$95$1), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0 ^ 2 + N[(t$95$3 * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
t_1 := {t\_0}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\\
\mathbf{if}\;\phi_2 \leq -0.00035 \lor \neg \left(\phi_2 \leq 850\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) + \left(\left(1 + t\_1\right) + -1\right)}}{\sqrt{1 - t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(t\_0, t\_3 \cdot \sqrt{\cos \phi_1}\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {t\_3}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -3.49999999999999996e-4 or 850 < phi2 Initial program 54.6%
expm1-log1p-u54.6%
expm1-undefine54.1%
log1p-undefine54.2%
add-exp-log54.2%
div-inv54.2%
metadata-eval54.2%
Applied egg-rr54.2%
Taylor expanded in lambda1 around 0 43.3%
add-cube-cbrt23.6%
pow223.6%
div-inv23.6%
metadata-eval23.6%
div-inv23.6%
metadata-eval23.6%
Applied egg-rr23.6%
Taylor expanded in lambda2 around 0 20.4%
sub-neg20.4%
mul-1-neg20.4%
rem-cube-cbrt32.0%
mul-1-neg32.0%
sub-neg32.0%
Simplified32.0%
if -3.49999999999999996e-4 < phi2 < 850Initial program 78.2%
associate-*l*78.2%
Simplified78.2%
Taylor expanded in phi2 around 0 78.2%
add-log-exp78.2%
fma-define78.2%
*-commutative78.2%
Applied egg-rr78.2%
Taylor expanded in R around 0 78.2%
Simplified63.2%
Taylor expanded in phi2 around 0 62.5%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= (- lambda1 lambda2) -5e-5)
(not (<= (- lambda1 lambda2) 20000000.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_2)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_2)) (+ (+ 1.0 t_0) -1.0)))
(sqrt (- 1.0 t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (((lambda1 - lambda2) <= -5e-5) || !((lambda1 - lambda2) <= 20000000.0)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + ((1.0 + t_0) + -1.0))), sqrt((1.0 - t_0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((0.5d0 * (phi1 - phi2))) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if (((lambda1 - lambda2) <= (-5d-5)) .or. (.not. ((lambda1 - lambda2) <= 20000000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + ((1.0d0 + t_0) + (-1.0d0)))), sqrt((1.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.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (((lambda1 - lambda2) <= -5e-5) || !((lambda1 - lambda2) <= 20000000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_1 * t_2)) + ((1.0 + t_0) + -1.0))), Math.sqrt((1.0 - t_0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if ((lambda1 - lambda2) <= -5e-5) or not ((lambda1 - lambda2) <= 20000000.0): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_1 * t_2)) + ((1.0 + t_0) + -1.0))), math.sqrt((1.0 - t_0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -5e-5) || !(Float64(lambda1 - lambda2) <= 20000000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_2)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_2)) + Float64(Float64(1.0 + t_0) + -1.0))), sqrt(Float64(1.0 - t_0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (((lambda1 - lambda2) <= -5e-5) || ~(((lambda1 - lambda2) <= 20000000.0))) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + ((1.0 + t_0) + -1.0))), sqrt((1.0 - t_0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -5e-5], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 20000000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.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], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -5 \cdot 10^{-5} \lor \neg \left(\lambda_1 - \lambda_2 \leq 20000000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_2\right) + \left(\left(1 + t\_0\right) + -1\right)}}{\sqrt{1 - t\_0}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -5.00000000000000024e-5 or 2e7 < (-.f64 lambda1 lambda2) Initial program 62.1%
associate-*l*62.1%
Simplified62.2%
Taylor expanded in phi2 around 0 47.4%
Taylor expanded in phi1 around 0 37.3%
unpow262.2%
sin-mult62.2%
div-inv62.2%
metadata-eval62.2%
div-inv62.2%
metadata-eval62.2%
div-inv62.2%
metadata-eval62.2%
div-inv62.2%
metadata-eval62.2%
Applied egg-rr37.3%
div-sub62.2%
+-inverses62.2%
cos-062.2%
metadata-eval62.2%
distribute-lft-out62.2%
metadata-eval62.2%
*-rgt-identity62.2%
Simplified37.3%
if -5.00000000000000024e-5 < (-.f64 lambda1 lambda2) < 2e7Initial program 78.6%
expm1-log1p-u78.5%
expm1-undefine67.8%
log1p-undefine67.9%
add-exp-log67.9%
div-inv67.9%
metadata-eval67.9%
Applied egg-rr67.9%
Taylor expanded in lambda1 around 0 65.5%
add-cube-cbrt33.7%
pow233.7%
div-inv33.7%
metadata-eval33.7%
div-inv33.7%
metadata-eval33.7%
Applied egg-rr33.7%
Taylor expanded in lambda2 around 0 27.8%
sub-neg27.8%
mul-1-neg27.8%
rem-cube-cbrt64.6%
mul-1-neg64.6%
sub-neg64.6%
Simplified64.6%
Final simplification44.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), 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.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.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.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.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(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(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{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi1 around 0 37.7%
Final simplification37.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(+
(*
(* (cos phi1) (cos phi2))
(- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (or (<= lambda2 -0.00025) (not (<= lambda2 7e-49)))
(* R (* 2.0 (atan2 t_0 (sqrt (pow (cos (* lambda2 -0.5)) 2.0)))))
(* R (* 2.0 (atan2 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 = sqrt((((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((lambda2 <= -0.00025) || !(lambda2 <= 7e-49)) {
tmp = R * (2.0 * atan2(t_0, sqrt(pow(cos((lambda2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt(pow(cos((lambda1 * 0.5)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt((((cos(phi1) * cos(phi2)) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if ((lambda2 <= (-0.00025d0)) .or. (.not. (lambda2 <= 7d-49))) then
tmp = r * (2.0d0 * atan2(t_0, sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt((cos((lambda1 * 0.5d0)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if ((lambda2 <= -0.00025) || !(lambda2 <= 7e-49)) {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt(Math.pow(Math.cos((lambda1 * 0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if (lambda2 <= -0.00025) or not (lambda2 <= 7e-49): tmp = R * (2.0 * math.atan2(t_0, math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt(math.pow(math.cos((lambda1 * 0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if ((lambda2 <= -0.00025) || !(lambda2 <= 7e-49)) tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt((cos(Float64(lambda1 * 0.5)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt((((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if ((lambda2 <= -0.00025) || ~((lambda2 <= 7e-49))) tmp = R * (2.0 * atan2(t_0, sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_0, sqrt((cos((lambda1 * 0.5)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(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] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -0.00025], N[Not[LessEqual[lambda2, 7e-49]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / 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 := \sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\lambda_2 \leq -0.00025 \lor \neg \left(\lambda_2 \leq 7 \cdot 10^{-49}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{{\cos \left(\lambda_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < -2.5000000000000001e-4 or 7.00000000000000012e-49 < lambda2 Initial program 51.0%
associate-*l*51.0%
Simplified51.1%
Taylor expanded in phi2 around 0 37.5%
Taylor expanded in phi1 around 0 29.6%
sin-mult61.6%
div-inv61.6%
metadata-eval61.6%
*-commutative61.6%
div-inv61.6%
metadata-eval61.6%
*-commutative61.6%
cos-sum61.6%
cos-261.6%
div-inv61.6%
metadata-eval61.6%
*-commutative61.6%
Applied egg-rr29.5%
div-sub61.6%
+-inverses61.6%
cos-061.6%
metadata-eval61.6%
associate-*r*61.6%
metadata-eval61.6%
*-lft-identity61.6%
Simplified29.5%
Taylor expanded in lambda1 around 0 30.0%
unpow230.0%
1-sub-sin30.1%
unpow230.1%
Simplified30.1%
if -2.5000000000000001e-4 < lambda2 < 7.00000000000000012e-49Initial program 82.3%
associate-*l*82.3%
Simplified82.3%
Taylor expanded in phi2 around 0 62.1%
Taylor expanded in phi1 around 0 46.2%
sin-mult98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
cos-sum98.6%
cos-298.6%
div-inv98.6%
metadata-eval98.6%
*-commutative98.6%
Applied egg-rr41.1%
div-sub98.6%
+-inverses98.6%
cos-098.6%
metadata-eval98.6%
associate-*r*98.6%
metadata-eval98.6%
*-lft-identity98.6%
Simplified41.1%
Taylor expanded in lambda2 around 0 41.1%
unpow241.1%
1-sub-sin41.2%
unpow241.2%
Simplified41.2%
Final simplification35.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), 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.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.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.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.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(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.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((((cos(phi1) * cos(phi2)) * (t_0 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.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[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.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{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi1 around 0 37.7%
unpow266.3%
sin-mult66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
div-inv66.4%
metadata-eval66.4%
Applied egg-rr35.2%
div-sub66.4%
+-inverses66.4%
cos-066.4%
metadata-eval66.4%
distribute-lft-out66.4%
metadata-eval66.4%
*-rgt-identity66.4%
Simplified35.2%
Final simplification35.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(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(sqrt((((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.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
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), 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(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), 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(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), 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(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), 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(sqrt((((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), 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[Sqrt[N[(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] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(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{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi1 around 0 37.7%
sin-mult79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
cos-sum79.6%
cos-279.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
Applied egg-rr35.2%
div-sub79.7%
+-inverses79.7%
cos-079.7%
metadata-eval79.7%
associate-*r*79.7%
metadata-eval79.7%
*-lft-identity79.7%
Simplified35.2%
Final simplification35.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0)))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (pow (cos (* lambda2 -0.5)) 2.0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(pow(cos((lambda2 * -0.5)), 2.0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((cos((lambda2 * (-0.5d0))) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.pow(Math.cos((lambda2 * -0.5)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.pow(math.cos((lambda2 * -0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos(Float64(lambda2 * -0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((cos((lambda2 * -0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(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] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)
\end{array}
Initial program 66.3%
associate-*l*66.3%
Simplified66.3%
Taylor expanded in phi2 around 0 49.5%
Taylor expanded in phi1 around 0 37.7%
sin-mult79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
cos-sum79.6%
cos-279.7%
div-inv79.7%
metadata-eval79.7%
*-commutative79.7%
Applied egg-rr35.2%
div-sub79.7%
+-inverses79.7%
cos-079.7%
metadata-eval79.7%
associate-*r*79.7%
metadata-eval79.7%
*-lft-identity79.7%
Simplified35.2%
Taylor expanded in lambda1 around 0 28.0%
unpow228.0%
1-sub-sin28.0%
unpow228.0%
Simplified28.0%
Final simplification28.0%
herbie shell --seed 2024125
(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))))))))))