
(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 21 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right) \cdot t_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_0))))
(sqrt
(expm1
(log1p
(-
1.0
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(*
t_1
(expm1
(log1p
(pow
(-
(* (sin (* lambda1 0.5)) (cos (* lambda2 0.5)))
(* (cos (* lambda1 0.5)) (sin (* lambda2 0.5))))
2.0))))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), sqrt(expm1(log1p((1.0 - (pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_1 * expm1(log1p(pow(((sin((lambda1 * 0.5)) * cos((lambda2 * 0.5))) - (cos((lambda1 * 0.5)) * sin((lambda2 * 0.5)))), 2.0)))))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), Math.sqrt(Math.expm1(Math.log1p((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 * Math.expm1(Math.log1p(Math.pow(((Math.sin((lambda1 * 0.5)) * Math.cos((lambda2 * 0.5))) - (Math.cos((lambda1 * 0.5)) * Math.sin((lambda2 * 0.5)))), 2.0)))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), math.sqrt(math.expm1(math.log1p((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 * math.expm1(math.log1p(math.pow(((math.sin((lambda1 * 0.5)) * math.cos((lambda2 * 0.5))) - (math.cos((lambda1 * 0.5)) * math.sin((lambda2 * 0.5)))), 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_0)))), sqrt(expm1(log1p(Float64(1.0 - 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_1 * expm1(log1p((Float64(Float64(sin(Float64(lambda1 * 0.5)) * cos(Float64(lambda2 * 0.5))) - Float64(cos(Float64(lambda1 * 0.5)) * sin(Float64(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]}, 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - 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$1 * N[(Exp[N[Log[1 + N[Power[N[(N[(N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 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 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_0\right)}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - \left({\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 \cdot \mathsf{expm1}\left(\mathsf{log1p}\left({\left(\sin \left(\lambda_1 \cdot 0.5\right) \cdot \cos \left(\lambda_2 \cdot 0.5\right) - \cos \left(\lambda_1 \cdot 0.5\right) \cdot \sin \left(\lambda_2 \cdot 0.5\right)\right)}^{2}\right)\right)\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 59.9%
expm1-log1p-u59.9%
div-inv59.9%
metadata-eval59.9%
associate-*l*59.9%
pow259.9%
div-inv59.9%
metadata-eval59.9%
Applied egg-rr59.9%
metadata-eval59.9%
div-inv59.9%
div-sub59.9%
sin-diff60.6%
Applied egg-rr60.6%
metadata-eval60.6%
div-inv60.6%
div-sub60.6%
sin-diff61.1%
Applied egg-rr61.1%
expm1-log1p-u61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
div-inv61.1%
metadata-eval61.1%
Applied egg-rr61.1%
Final simplification61.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 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_0))))
(sqrt
(expm1
(log1p
(-
1.0
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(*
t_1
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
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((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), sqrt(expm1(log1p((1.0 - (pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_1 * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), Math.sqrt(Math.expm1(Math.log1p((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 * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), math.sqrt(math.expm1(math.log1p((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 * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 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((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_0)))), sqrt(expm1(log1p(Float64(1.0 - 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_1 * (Float64(Float64(sin(Float64(lambda1 / 2.0)) * cos(Float64(lambda2 / 2.0))) - Float64(cos(Float64(lambda1 / 2.0)) * sin(Float64(lambda2 / 2.0)))) ^ 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - 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$1 * N[Power[N[(N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 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 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_0\right)}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - \left({\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 \cdot {\left(\sin \left(\frac{\lambda_1}{2}\right) \cdot \cos \left(\frac{\lambda_2}{2}\right) - \cos \left(\frac{\lambda_1}{2}\right) \cdot \sin \left(\frac{\lambda_2}{2}\right)\right)}^{2}\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 59.9%
expm1-log1p-u59.9%
div-inv59.9%
metadata-eval59.9%
associate-*l*59.9%
pow259.9%
div-inv59.9%
metadata-eval59.9%
Applied egg-rr59.9%
metadata-eval59.9%
div-inv59.9%
div-sub59.9%
sin-diff60.6%
Applied egg-rr60.6%
metadata-eval60.6%
div-inv60.6%
div-sub60.6%
sin-diff61.1%
Applied egg-rr61.1%
Final simplification61.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 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_0))))
(sqrt
(expm1
(log1p
(-
1.0
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_1 (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));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), sqrt(expm1(log1p((1.0 - (pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_1 * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), Math.sqrt(Math.expm1(Math.log1p((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 * 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)) t_1 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), math.sqrt(math.expm1(math.log1p((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 * 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)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_0)))), sqrt(expm1(log1p(Float64(1.0 - 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_1 * (sin(Float64(Float64(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]}, 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - 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$1 * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 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 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_0\right)}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - \left({\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 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 59.9%
expm1-log1p-u59.9%
div-inv59.9%
metadata-eval59.9%
associate-*l*59.9%
pow259.9%
div-inv59.9%
metadata-eval59.9%
Applied egg-rr59.9%
metadata-eval59.9%
div-inv59.9%
div-sub59.9%
sin-diff60.6%
Applied egg-rr60.6%
Final simplification60.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(+
(- 1.0 t_2)
(*
t_0
(-
(/
(+ (* (cos lambda1) (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 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((((cos(lambda1) * 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(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) + (t_0 * ((((cos(lambda1) * 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.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) + (t_0 * ((((Math.cos(lambda1) * 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.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) + (t_0 * ((((math.cos(lambda1) * 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 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_0 * Float64(Float64(Float64(Float64(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(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((((cos(lambda1) * 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$0 * N[(N[(N[(N[(N[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 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - t_2\right) + t_0 \cdot \left(\frac{\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.9%
associate-*l*59.9%
Simplified59.9%
sin-mult57.1%
div-inv57.1%
metadata-eval57.1%
div-inv57.1%
metadata-eval57.1%
div-inv57.1%
metadata-eval57.1%
div-inv57.1%
metadata-eval57.1%
Applied egg-rr60.0%
div-sub57.1%
+-inverses57.1%
cos-057.1%
metadata-eval57.1%
distribute-lft-out57.1%
metadata-eval57.1%
*-rgt-identity57.1%
Simplified60.0%
cos-diff60.3%
Applied egg-rr60.3%
Final simplification60.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* phi2 -0.5)) 2.0))
(t_4 (* t_0 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0))))
(t_5 (sqrt (- (- 1.0 t_1) (* t_0 (* t_2 t_2))))))
(if (<= phi2 -1.5e-5)
(* R (* 2.0 (atan2 (sqrt (+ t_4 t_3)) t_5)))
(if (<= phi2 6e-7)
(* R (* 2.0 (atan2 (sqrt (+ t_4 (pow (sin (* phi1 0.5)) 2.0))) t_5)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_3 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- 1.0 (+ t_1 (* (* t_0 t_2) (sin (* lambda1 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 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin((phi2 * -0.5)), 2.0);
double t_4 = t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0));
double t_5 = sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2))));
double tmp;
if (phi2 <= -1.5e-5) {
tmp = R * (2.0 * atan2(sqrt((t_4 + t_3)), t_5));
} else if (phi2 <= 6e-7) {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin((phi1 * 0.5)), 2.0))), t_5));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 - (t_1 + ((t_0 * t_2) * sin((lambda1 * 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) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_4 = t_0 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))
t_5 = sqrt(((1.0d0 - t_1) - (t_0 * (t_2 * t_2))))
if (phi2 <= (-1.5d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + t_3)), t_5))
else if (phi2 <= 6d-7) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin((phi1 * 0.5d0)) ** 2.0d0))), t_5))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((1.0d0 - (t_1 + ((t_0 * t_2) * sin((lambda1 * 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 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_4 = t_0 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0));
double t_5 = Math.sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2))));
double tmp;
if (phi2 <= -1.5e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + t_3)), t_5));
} else if (phi2 <= 6e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), t_5));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((1.0 - (t_1 + ((t_0 * t_2) * Math.sin((lambda1 * 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 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_4 = t_0 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0)) t_5 = math.sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2)))) tmp = 0 if phi2 <= -1.5e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + t_3)), t_5)) elif phi2 <= 6e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin((phi1 * 0.5)), 2.0))), t_5)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((1.0 - (t_1 + ((t_0 * t_2) * math.sin((lambda1 * 0.5)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_4 = Float64(t_0 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))) t_5 = sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * Float64(t_2 * t_2)))) tmp = 0.0 if (phi2 <= -1.5e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + t_3)), t_5))); elseif (phi2 <= 6e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), t_5))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64(t_1 + Float64(Float64(t_0 * t_2) * sin(Float64(lambda1 * 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 - phi2) / 2.0)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin((phi2 * -0.5)) ^ 2.0; t_4 = t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0)); t_5 = sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2)))); tmp = 0.0; if (phi2 <= -1.5e-5) tmp = R * (2.0 * atan2(sqrt((t_4 + t_3)), t_5)); elseif (phi2 <= 6e-7) tmp = R * (2.0 * atan2(sqrt((t_4 + (sin((phi1 * 0.5)) ^ 2.0))), t_5)); else tmp = R * (2.0 * atan2(sqrt((t_3 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((1.0 - (t_1 + ((t_0 * t_2) * sin((lambda1 * 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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.5e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + t$95$3), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[(t$95$0 * t$95$2), $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_4 := t_0 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)\\
t_5 := \sqrt{\left(1 - t_1\right) - t_0 \cdot \left(t_2 \cdot t_2\right)}\\
\mathbf{if}\;\phi_2 \leq -1.5 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + t_3}}{t_5}\right)\\
\mathbf{elif}\;\phi_2 \leq 6 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{t_5}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left(t_1 + \left(t_0 \cdot t_2\right) \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1.50000000000000004e-5Initial program 52.5%
associate-*l*52.5%
Simplified52.5%
sin-mult52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
Applied egg-rr52.6%
div-sub52.6%
+-inverses52.6%
cos-052.6%
metadata-eval52.6%
distribute-lft-out52.6%
metadata-eval52.6%
*-rgt-identity52.6%
Simplified52.6%
Taylor expanded in phi1 around 0 53.3%
if -1.50000000000000004e-5 < phi2 < 5.9999999999999997e-7Initial program 74.3%
associate-*l*74.3%
Simplified74.3%
sin-mult68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
Applied egg-rr68.9%
div-sub68.9%
+-inverses68.9%
cos-068.9%
metadata-eval68.9%
distribute-lft-out68.9%
metadata-eval68.9%
*-rgt-identity68.9%
Simplified68.9%
Taylor expanded in phi2 around 0 67.3%
if 5.9999999999999997e-7 < phi2 Initial program 37.1%
Taylor expanded in lambda2 around 0 35.7%
Taylor expanded in phi1 around 0 34.8%
Taylor expanded in phi1 around 0 36.7%
Final simplification56.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_0 (* t_1 t_1)))
(t_3 (/ (cos (- lambda1 lambda2)) 2.0))
(t_4 (pow (sin (* phi1 0.5)) 2.0))
(t_5 (sqrt (+ (* t_0 (- 0.5 t_3)) t_4)))
(t_6 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= phi1 -7.4e-8)
(* R (* 2.0 (atan2 t_5 (sqrt (- (- 1.0 t_4) t_2)))))
(if (<= phi1 0.031)
(*
R
(*
2.0
(atan2
(sqrt (+ t_6 t_2))
(sqrt
(+ (- 1.0 (pow (sin (* phi2 -0.5)) 2.0)) (* t_0 (- t_3 0.5)))))))
(* R (* 2.0 (atan2 t_5 (sqrt (- (- 1.0 t_6) t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = cos((lambda1 - lambda2)) / 2.0;
double t_4 = pow(sin((phi1 * 0.5)), 2.0);
double t_5 = sqrt(((t_0 * (0.5 - t_3)) + t_4));
double t_6 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -7.4e-8) {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_4) - t_2))));
} else if (phi1 <= 0.031) {
tmp = R * (2.0 * atan2(sqrt((t_6 + t_2)), sqrt(((1.0 - pow(sin((phi2 * -0.5)), 2.0)) + (t_0 * (t_3 - 0.5))))));
} else {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_6) - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = t_0 * (t_1 * t_1)
t_3 = cos((lambda1 - lambda2)) / 2.0d0
t_4 = sin((phi1 * 0.5d0)) ** 2.0d0
t_5 = sqrt(((t_0 * (0.5d0 - t_3)) + t_4))
t_6 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (phi1 <= (-7.4d-8)) then
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 - t_4) - t_2))))
else if (phi1 <= 0.031d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_6 + t_2)), sqrt(((1.0d0 - (sin((phi2 * (-0.5d0))) ** 2.0d0)) + (t_0 * (t_3 - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 - t_6) - 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.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = t_0 * (t_1 * t_1);
double t_3 = Math.cos((lambda1 - lambda2)) / 2.0;
double t_4 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_5 = Math.sqrt(((t_0 * (0.5 - t_3)) + t_4));
double t_6 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -7.4e-8) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 - t_4) - t_2))));
} else if (phi1 <= 0.031) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_6 + t_2)), Math.sqrt(((1.0 - Math.pow(Math.sin((phi2 * -0.5)), 2.0)) + (t_0 * (t_3 - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 - t_6) - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = t_0 * (t_1 * t_1) t_3 = math.cos((lambda1 - lambda2)) / 2.0 t_4 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_5 = math.sqrt(((t_0 * (0.5 - t_3)) + t_4)) t_6 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if phi1 <= -7.4e-8: tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 - t_4) - t_2)))) elif phi1 <= 0.031: tmp = R * (2.0 * math.atan2(math.sqrt((t_6 + t_2)), math.sqrt(((1.0 - math.pow(math.sin((phi2 * -0.5)), 2.0)) + (t_0 * (t_3 - 0.5)))))) else: tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 - t_6) - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(t_0 * Float64(t_1 * t_1)) t_3 = Float64(cos(Float64(lambda1 - lambda2)) / 2.0) t_4 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_5 = sqrt(Float64(Float64(t_0 * Float64(0.5 - t_3)) + t_4)) t_6 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (phi1 <= -7.4e-8) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 - t_4) - t_2))))); elseif (phi1 <= 0.031) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + t_2)), sqrt(Float64(Float64(1.0 - (sin(Float64(phi2 * -0.5)) ^ 2.0)) + Float64(t_0 * Float64(t_3 - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 - t_6) - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = t_0 * (t_1 * t_1); t_3 = cos((lambda1 - lambda2)) / 2.0; t_4 = sin((phi1 * 0.5)) ^ 2.0; t_5 = sqrt(((t_0 * (0.5 - t_3)) + t_4)); t_6 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (phi1 <= -7.4e-8) tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_4) - t_2)))); elseif (phi1 <= 0.031) tmp = R * (2.0 * atan2(sqrt((t_6 + t_2)), sqrt(((1.0 - (sin((phi2 * -0.5)) ^ 2.0)) + (t_0 * (t_3 - 0.5)))))); else tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_6) - t_2)))); 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(N[(t$95$0 * N[(0.5 - t$95$3), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -7.4e-8], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 - t$95$4), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.031], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$6 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(t$95$3 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 - t$95$6), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t_0 \cdot \left(t_1 \cdot t_1\right)\\
t_3 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\\
t_4 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_5 := \sqrt{t_0 \cdot \left(0.5 - t_3\right) + t_4}\\
t_6 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -7.4 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_5}{\sqrt{\left(1 - t_4\right) - t_2}}\right)\\
\mathbf{elif}\;\phi_1 \leq 0.031:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_6 + t_2}}{\sqrt{\left(1 - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right) + t_0 \cdot \left(t_3 - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_5}{\sqrt{\left(1 - t_6\right) - t_2}}\right)\\
\end{array}
\end{array}
if phi1 < -7.4000000000000001e-8Initial program 38.9%
associate-*l*39.0%
Simplified39.0%
sin-mult39.0%
div-inv39.0%
metadata-eval39.0%
div-inv39.0%
metadata-eval39.0%
div-inv39.0%
metadata-eval39.0%
div-inv39.0%
metadata-eval39.0%
Applied egg-rr39.0%
div-sub39.0%
+-inverses39.0%
cos-039.0%
metadata-eval39.0%
distribute-lft-out39.0%
metadata-eval39.0%
*-rgt-identity39.0%
Simplified39.0%
Taylor expanded in phi2 around 0 38.8%
Taylor expanded in phi2 around 0 38.9%
if -7.4000000000000001e-8 < phi1 < 0.031Initial program 77.7%
associate-*l*77.7%
Simplified77.7%
sin-mult71.4%
div-inv71.4%
metadata-eval71.4%
div-inv71.4%
metadata-eval71.4%
div-inv71.4%
metadata-eval71.4%
div-inv71.4%
metadata-eval71.4%
Applied egg-rr77.8%
div-sub71.4%
+-inverses71.4%
cos-071.4%
metadata-eval71.4%
distribute-lft-out71.4%
metadata-eval71.4%
*-rgt-identity71.4%
Simplified77.8%
Taylor expanded in phi1 around 0 77.8%
if 0.031 < phi1 Initial program 51.6%
associate-*l*51.6%
Simplified51.6%
sin-mult51.6%
div-inv51.6%
metadata-eval51.6%
div-inv51.6%
metadata-eval51.6%
div-inv51.6%
metadata-eval51.6%
div-inv51.6%
metadata-eval51.6%
Applied egg-rr51.6%
div-sub51.6%
+-inverses51.6%
cos-051.6%
metadata-eval51.6%
distribute-lft-out51.6%
metadata-eval51.6%
*-rgt-identity51.6%
Simplified51.6%
Taylor expanded in phi2 around 0 51.1%
Final simplification59.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (/ (cos (- lambda1 lambda2)) 2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_0 (* t_3 t_3)))
(t_5 (pow (sin (* phi2 -0.5)) 2.0)))
(if (<= phi2 -0.00064)
(*
R
(*
2.0
(atan2 (sqrt (+ (* t_0 (- 0.5 t_2)) t_5)) (sqrt (- (- 1.0 t_1) t_4)))))
(if (<= phi2 0.00075)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_4))
(sqrt
(+ (- 1.0 (pow (sin (* phi1 0.5)) 2.0)) (* t_0 (- t_2 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_5 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- 1.0 (+ t_1 (* (* t_0 t_3) (sin (* lambda1 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 - phi2) / 2.0)), 2.0);
double t_2 = cos((lambda1 - lambda2)) / 2.0;
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_0 * (t_3 * t_3);
double t_5 = pow(sin((phi2 * -0.5)), 2.0);
double tmp;
if (phi2 <= -0.00064) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (0.5 - t_2)) + t_5)), sqrt(((1.0 - t_1) - t_4))));
} else if (phi2 <= 0.00075) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt(((1.0 - pow(sin((phi1 * 0.5)), 2.0)) + (t_0 * (t_2 - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 - (t_1 + ((t_0 * t_3) * sin((lambda1 * 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) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos((lambda1 - lambda2)) / 2.0d0
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_0 * (t_3 * t_3)
t_5 = sin((phi2 * (-0.5d0))) ** 2.0d0
if (phi2 <= (-0.00064d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (0.5d0 - t_2)) + t_5)), sqrt(((1.0d0 - t_1) - t_4))))
else if (phi2 <= 0.00075d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_4)), sqrt(((1.0d0 - (sin((phi1 * 0.5d0)) ** 2.0d0)) + (t_0 * (t_2 - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((1.0d0 - (t_1 + ((t_0 * t_3) * sin((lambda1 * 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 - phi2) / 2.0)), 2.0);
double t_2 = Math.cos((lambda1 - lambda2)) / 2.0;
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_0 * (t_3 * t_3);
double t_5 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double tmp;
if (phi2 <= -0.00064) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (0.5 - t_2)) + t_5)), Math.sqrt(((1.0 - t_1) - t_4))));
} else if (phi2 <= 0.00075) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_4)), Math.sqrt(((1.0 - Math.pow(Math.sin((phi1 * 0.5)), 2.0)) + (t_0 * (t_2 - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((1.0 - (t_1 + ((t_0 * t_3) * Math.sin((lambda1 * 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 - phi2) / 2.0)), 2.0) t_2 = math.cos((lambda1 - lambda2)) / 2.0 t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_0 * (t_3 * t_3) t_5 = math.pow(math.sin((phi2 * -0.5)), 2.0) tmp = 0 if phi2 <= -0.00064: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (0.5 - t_2)) + t_5)), math.sqrt(((1.0 - t_1) - t_4)))) elif phi2 <= 0.00075: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_4)), math.sqrt(((1.0 - math.pow(math.sin((phi1 * 0.5)), 2.0)) + (t_0 * (t_2 - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((1.0 - (t_1 + ((t_0 * t_3) * math.sin((lambda1 * 0.5)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(cos(Float64(lambda1 - lambda2)) / 2.0) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_0 * Float64(t_3 * t_3)) t_5 = sin(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (phi2 <= -0.00064) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(0.5 - t_2)) + t_5)), sqrt(Float64(Float64(1.0 - t_1) - t_4))))); elseif (phi2 <= 0.00075) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_4)), sqrt(Float64(Float64(1.0 - (sin(Float64(phi1 * 0.5)) ^ 2.0)) + Float64(t_0 * Float64(t_2 - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64(t_1 + Float64(Float64(t_0 * t_3) * sin(Float64(lambda1 * 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 - phi2) / 2.0)) ^ 2.0; t_2 = cos((lambda1 - lambda2)) / 2.0; t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_0 * (t_3 * t_3); t_5 = sin((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (phi2 <= -0.00064) tmp = R * (2.0 * atan2(sqrt(((t_0 * (0.5 - t_2)) + t_5)), sqrt(((1.0 - t_1) - t_4)))); elseif (phi2 <= 0.00075) tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt(((1.0 - (sin((phi1 * 0.5)) ^ 2.0)) + (t_0 * (t_2 - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_5 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((1.0 - (t_1 + ((t_0 * t_3) * sin((lambda1 * 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[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$0 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -0.00064], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(0.5 - t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00075], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(t$95$2 - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[(t$95$0 * t$95$3), $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t_0 \cdot \left(t_3 \cdot t_3\right)\\
t_5 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -0.00064:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(0.5 - t_2\right) + t_5}}{\sqrt{\left(1 - t_1\right) - t_4}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00075:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_4}}{\sqrt{\left(1 - {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right) + t_0 \cdot \left(t_2 - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_5 + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left(t_1 + \left(t_0 \cdot t_3\right) \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -6.40000000000000052e-4Initial program 52.5%
associate-*l*52.5%
Simplified52.5%
sin-mult52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
Applied egg-rr52.6%
div-sub52.6%
+-inverses52.6%
cos-052.6%
metadata-eval52.6%
distribute-lft-out52.6%
metadata-eval52.6%
*-rgt-identity52.6%
Simplified52.6%
Taylor expanded in phi1 around 0 53.3%
if -6.40000000000000052e-4 < phi2 < 7.5000000000000002e-4Initial program 74.3%
associate-*l*74.3%
Simplified74.3%
sin-mult68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
Applied egg-rr74.4%
div-sub68.9%
+-inverses68.9%
cos-068.9%
metadata-eval68.9%
distribute-lft-out68.9%
metadata-eval68.9%
*-rgt-identity68.9%
Simplified74.4%
Taylor expanded in phi2 around 0 74.4%
if 7.5000000000000002e-4 < phi2 Initial program 37.1%
Taylor expanded in lambda2 around 0 35.7%
Taylor expanded in phi1 around 0 34.8%
Taylor expanded in phi1 around 0 36.7%
Final simplification60.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi1 -6e-62) (not (<= phi1 0.048)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (- 0.5 (/ (cos lambda1) 2.0)))
(pow (sin (* phi1 0.5)) 2.0)))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* t_0 (* t_1 t_1)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_1)) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(*
(sin (* lambda1 0.5))
(* (cos phi2) (sin (* (- lambda1 lambda2) 0.5))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -6e-62) || !(phi1 <= 0.048)) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (0.5 - (cos(lambda1) / 2.0))) + pow(sin((phi1 * 0.5)), 2.0))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_0 * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (sin((lambda1 * 0.5)) * (cos(phi2) * sin(((lambda1 - lambda2) * 0.5))))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi1 <= (-6d-62)) .or. (.not. (phi1 <= 0.048d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (0.5d0 - (cos(lambda1) / 2.0d0))) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - (t_0 * (t_1 * t_1))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (sin((lambda1 * 0.5d0)) * (cos(phi2) * sin(((lambda1 - lambda2) * 0.5d0))))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi1 <= -6e-62) || !(phi1 <= 0.048)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (0.5 - (Math.cos(lambda1) / 2.0))) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_0 * (t_1 * t_1))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_1)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.sin((lambda1 * 0.5)) * (Math.cos(phi2) * Math.sin(((lambda1 - lambda2) * 0.5))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi1 <= -6e-62) or not (phi1 <= 0.048): tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (0.5 - (math.cos(lambda1) / 2.0))) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_0 * (t_1 * t_1)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_1)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.sin((lambda1 * 0.5)) * (math.cos(phi2) * math.sin(((lambda1 - lambda2) * 0.5)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi1 <= -6e-62) || !(phi1 <= 0.048)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(0.5 - Float64(cos(lambda1) / 2.0))) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(t_0 * Float64(t_1 * t_1))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(sin(Float64(lambda1 * 0.5)) * Float64(cos(phi2) * sin(Float64(Float64(lambda1 - lambda2) * 0.5))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi1 <= -6e-62) || ~((phi1 <= 0.048))) tmp = R * (2.0 * atan2(sqrt(((t_0 * (0.5 - (cos(lambda1) / 2.0))) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - (t_0 * (t_1 * t_1)))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_1)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (sin((lambda1 * 0.5)) * (cos(phi2) * sin(((lambda1 - lambda2) * 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -6e-62], N[Not[LessEqual[phi1, 0.048]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(0.5 - N[(N[Cos[lambda1], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -6 \cdot 10^{-62} \lor \neg \left(\phi_1 \leq 0.048\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(0.5 - \frac{\cos \lambda_1}{2}\right) + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t_0 \cdot \left(t_1 \cdot t_1\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(t_0 \cdot t_1\right) + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \sin \left(\lambda_1 \cdot 0.5\right) \cdot \left(\cos \phi_2 \cdot \sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -6.0000000000000002e-62 or 0.048000000000000001 < phi1 Initial program 46.4%
associate-*l*46.5%
Simplified46.5%
sin-mult46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
Applied egg-rr46.5%
div-sub46.5%
+-inverses46.5%
cos-046.5%
metadata-eval46.5%
distribute-lft-out46.5%
metadata-eval46.5%
*-rgt-identity46.5%
Simplified46.5%
Taylor expanded in phi2 around 0 46.1%
Taylor expanded in lambda2 around 0 35.9%
if -6.0000000000000002e-62 < phi1 < 0.048000000000000001Initial program 79.0%
Taylor expanded in lambda2 around 0 56.9%
Taylor expanded in phi1 around 0 56.0%
Taylor expanded in phi1 around 0 56.0%
associate--r+56.0%
unpow256.0%
1-sub-sin56.1%
unpow256.1%
*-commutative56.1%
*-commutative56.1%
associate-*l*56.1%
*-commutative56.1%
*-commutative56.1%
Simplified56.1%
Final simplification44.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi1 0.5)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -0.00026) (not (<= phi2 1.9e-6)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* t_1 t_2) (sin (* lambda1 0.5)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0))) t_0))
(sqrt (- (- 1.0 t_0) (* t_1 (* t_2 t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi1 * 0.5)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00026) || !(phi2 <= 1.9e-6)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_1 * t_2) * sin((lambda1 * 0.5))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + t_0)), sqrt(((1.0 - t_0) - (t_1 * (t_2 * 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((phi1 * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-0.00026d0)) .or. (.not. (phi2 <= 1.9d-6))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((t_1 * t_2) * sin((lambda1 * 0.5d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))) + t_0)), sqrt(((1.0d0 - t_0) - (t_1 * (t_2 * 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((phi1 * 0.5)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -0.00026) || !(phi2 <= 1.9e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_1 * t_2) * Math.sin((lambda1 * 0.5))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0))) + t_0)), Math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -0.00026) or not (phi2 <= 1.9e-6): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((t_1 * t_2) * math.sin((lambda1 * 0.5)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0))) + t_0)), math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -0.00026) || !(phi2 <= 1.9e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(t_1 * t_2) * sin(Float64(lambda1 * 0.5))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))) + t_0)), sqrt(Float64(Float64(1.0 - t_0) - Float64(t_1 * Float64(t_2 * t_2))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -0.00026) || ~((phi2 <= 1.9e-6))) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((t_1 * t_2) * sin((lambda1 * 0.5)))))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (0.5 - (cos((lambda1 - lambda2)) / 2.0))) + t_0)), sqrt(((1.0 - t_0) - (t_1 * (t_2 * t_2)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.00026], N[Not[LessEqual[phi2, 1.9e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(t$95$1 * t$95$2), $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -0.00026 \lor \neg \left(\phi_2 \leq 1.9 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(t_1 \cdot t_2\right) \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right) + t_0}}{\sqrt{\left(1 - t_0\right) - t_1 \cdot \left(t_2 \cdot t_2\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -2.59999999999999977e-4 or 1.9e-6 < phi2 Initial program 44.4%
Taylor expanded in lambda2 around 0 36.8%
Taylor expanded in phi1 around 0 36.6%
Taylor expanded in phi1 around 0 38.0%
if -2.59999999999999977e-4 < phi2 < 1.9e-6Initial program 74.3%
associate-*l*74.3%
Simplified74.3%
sin-mult68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
Applied egg-rr68.9%
div-sub68.9%
+-inverses68.9%
cos-068.9%
metadata-eval68.9%
distribute-lft-out68.9%
metadata-eval68.9%
*-rgt-identity68.9%
Simplified68.9%
Taylor expanded in phi2 around 0 67.3%
Taylor expanded in phi2 around 0 67.3%
Final simplification53.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (* t_0 (- 0.5 (/ (cos (- lambda1 lambda2)) 2.0))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_0 (* t_2 t_2)))
(t_4 (pow (sin (* phi2 -0.5)) 2.0))
(t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_6 (pow (sin (* phi1 0.5)) 2.0)))
(if (<= phi2 -1.45e-5)
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_4)) (sqrt (- (- 1.0 t_5) t_3)))))
(if (<= phi2 0.00029)
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_6)) (sqrt (- (- 1.0 t_6) t_3)))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_4 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- 1.0 (+ t_5 (* (* t_0 t_2) (sin (* lambda1 0.5)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = pow(sin((phi2 * -0.5)), 2.0);
double t_5 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_6 = pow(sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi2 <= -1.45e-5) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt(((1.0 - t_5) - t_3))));
} else if (phi2 <= 0.00029) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_6)), sqrt(((1.0 - t_6) - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 - (t_5 + ((t_0 * t_2) * sin((lambda1 * 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) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = t_0 * (0.5d0 - (cos((lambda1 - lambda2)) / 2.0d0))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_0 * (t_2 * t_2)
t_4 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_5 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_6 = sin((phi1 * 0.5d0)) ** 2.0d0
if (phi2 <= (-1.45d-5)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_4)), sqrt(((1.0d0 - t_5) - t_3))))
else if (phi2 <= 0.00029d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_6)), sqrt(((1.0d0 - t_6) - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((1.0d0 - (t_5 + ((t_0 * t_2) * sin((lambda1 * 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 = t_0 * (0.5 - (Math.cos((lambda1 - lambda2)) / 2.0));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_5 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_6 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double tmp;
if (phi2 <= -1.45e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_4)), Math.sqrt(((1.0 - t_5) - t_3))));
} else if (phi2 <= 0.00029) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_6)), Math.sqrt(((1.0 - t_6) - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((1.0 - (t_5 + ((t_0 * t_2) * Math.sin((lambda1 * 0.5))))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = t_0 * (0.5 - (math.cos((lambda1 - lambda2)) / 2.0)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_0 * (t_2 * t_2) t_4 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_5 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_6 = math.pow(math.sin((phi1 * 0.5)), 2.0) tmp = 0 if phi2 <= -1.45e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_4)), math.sqrt(((1.0 - t_5) - t_3)))) elif phi2 <= 0.00029: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_6)), math.sqrt(((1.0 - t_6) - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((1.0 - (t_5 + ((t_0 * t_2) * math.sin((lambda1 * 0.5)))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(t_0 * Float64(0.5 - Float64(cos(Float64(lambda1 - lambda2)) / 2.0))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_0 * Float64(t_2 * t_2)) t_4 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_5 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_6 = sin(Float64(phi1 * 0.5)) ^ 2.0 tmp = 0.0 if (phi2 <= -1.45e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_4)), sqrt(Float64(Float64(1.0 - t_5) - t_3))))); elseif (phi2 <= 0.00029) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_6)), sqrt(Float64(Float64(1.0 - t_6) - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64(t_5 + Float64(Float64(t_0 * t_2) * sin(Float64(lambda1 * 0.5))))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = t_0 * (0.5 - (cos((lambda1 - lambda2)) / 2.0)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_0 * (t_2 * t_2); t_4 = sin((phi2 * -0.5)) ^ 2.0; t_5 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_6 = sin((phi1 * 0.5)) ^ 2.0; tmp = 0.0; if (phi2 <= -1.45e-5) tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt(((1.0 - t_5) - t_3)))); elseif (phi2 <= 0.00029) tmp = R * (2.0 * atan2(sqrt((t_1 + t_6)), sqrt(((1.0 - t_6) - t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((1.0 - (t_5 + ((t_0 * t_2) * sin((lambda1 * 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[(t$95$0 * N[(0.5 - N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -1.45e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$5), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00029], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$6), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$6), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + N[(N[(t$95$0 * t$95$2), $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := t_0 \cdot \left(0.5 - \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2}\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_0 \cdot \left(t_2 \cdot t_2\right)\\
t_4 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_5 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_6 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -1.45 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_4}}{\sqrt{\left(1 - t_5\right) - t_3}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00029:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_6}}{\sqrt{\left(1 - t_6\right) - t_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4 + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{1 - \left(t_5 + \left(t_0 \cdot t_2\right) \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1.45e-5Initial program 52.5%
associate-*l*52.5%
Simplified52.5%
sin-mult52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
div-inv52.6%
metadata-eval52.6%
Applied egg-rr52.6%
div-sub52.6%
+-inverses52.6%
cos-052.6%
metadata-eval52.6%
distribute-lft-out52.6%
metadata-eval52.6%
*-rgt-identity52.6%
Simplified52.6%
Taylor expanded in phi1 around 0 53.3%
if -1.45e-5 < phi2 < 2.9e-4Initial program 74.3%
associate-*l*74.3%
Simplified74.3%
sin-mult68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
div-inv68.9%
metadata-eval68.9%
Applied egg-rr68.9%
div-sub68.9%
+-inverses68.9%
cos-068.9%
metadata-eval68.9%
distribute-lft-out68.9%
metadata-eval68.9%
*-rgt-identity68.9%
Simplified68.9%
Taylor expanded in phi2 around 0 67.3%
Taylor expanded in phi2 around 0 67.3%
if 2.9e-4 < phi2 Initial program 37.1%
Taylor expanded in lambda2 around 0 35.7%
Taylor expanded in phi1 around 0 34.8%
Taylor expanded in phi1 around 0 36.7%
Final simplification56.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sqrt (+ t_0 (* t_2 (* t_3 t_3))))))
(if (<= lambda1 -1.02e-13)
(*
R
(* 2.0 (atan2 t_4 (sqrt (+ t_1 (* t_2 (- (/ (cos lambda1) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2 t_4 (sqrt (+ t_1 (* t_2 (- (/ (cos lambda2) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda1 <= -1.02e-13) {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(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 - phi2) / 2.0d0)) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))))
if (lambda1 <= (-1.02d-13)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(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 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda1 <= -1.02e-13) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda2) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.sqrt((t_0 + (t_2 * (t_3 * t_3)))) tmp = 0 if lambda1 <= -1.02e-13: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 + (t_2 * ((math.cos(lambda2) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))) tmp = 0.0 if (lambda1 <= -1.02e-13) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda2) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3)))); tmp = 0.0; if (lambda1 <= -1.02e-13) tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda2) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -1.02e-13], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda2], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := 1 - t_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_3\right)}\\
\mathbf{if}\;\lambda_1 \leq -1.02 \cdot 10^{-13}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_1 + t_2 \cdot \left(\frac{\cos \lambda_1}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{t_1 + t_2 \cdot \left(\frac{\cos \lambda_2}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.0199999999999999e-13Initial program 50.5%
associate-*l*50.5%
Simplified50.5%
sin-mult50.6%
div-inv50.6%
metadata-eval50.6%
div-inv50.6%
metadata-eval50.6%
div-inv50.6%
metadata-eval50.6%
div-inv50.6%
metadata-eval50.6%
Applied egg-rr50.6%
div-sub50.6%
+-inverses50.6%
cos-050.6%
metadata-eval50.6%
distribute-lft-out50.6%
metadata-eval50.6%
*-rgt-identity50.6%
Simplified50.6%
Taylor expanded in lambda2 around 0 49.9%
if -1.0199999999999999e-13 < lambda1 Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
sin-mult59.4%
div-inv59.4%
metadata-eval59.4%
div-inv59.4%
metadata-eval59.4%
div-inv59.4%
metadata-eval59.4%
div-inv59.4%
metadata-eval59.4%
Applied egg-rr63.3%
div-sub59.4%
+-inverses59.4%
cos-059.4%
metadata-eval59.4%
distribute-lft-out59.4%
metadata-eval59.4%
*-rgt-identity59.4%
Simplified63.3%
Taylor expanded in lambda1 around 0 57.4%
cos-neg57.4%
Simplified57.4%
Final simplification55.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_2 (* t_3 t_3))))
(if (<= lambda2 0.00011)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_4))
(sqrt (+ t_1 (* t_2 (- (/ (cos lambda1) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (- 0.5 (/ (cos lambda2) 2.0)))))
(sqrt (- t_1 t_4))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 * (t_3 * t_3);
double tmp;
if (lambda2 <= 0.00011) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_4)), sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (0.5 - (cos(lambda2) / 2.0))))), sqrt((t_1 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_2 * (t_3 * t_3)
if (lambda2 <= 0.00011d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_4)), sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (0.5d0 - (cos(lambda2) / 2.0d0))))), sqrt((t_1 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_2 * (t_3 * t_3);
double tmp;
if (lambda2 <= 0.00011) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_4)), Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (0.5 - (Math.cos(lambda2) / 2.0))))), Math.sqrt((t_1 - t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_2 * (t_3 * t_3) tmp = 0 if lambda2 <= 0.00011: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_4)), math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (0.5 - (math.cos(lambda2) / 2.0))))), math.sqrt((t_1 - t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_2 * Float64(t_3 * t_3)) tmp = 0.0 if (lambda2 <= 0.00011) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_4)), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(0.5 - Float64(cos(lambda2) / 2.0))))), sqrt(Float64(t_1 - t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_2 * (t_3 * t_3); tmp = 0.0; if (lambda2 <= 0.00011) tmp = R * (2.0 * atan2(sqrt((t_0 + t_4)), sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (0.5 - (cos(lambda2) / 2.0))))), sqrt((t_1 - t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 0.00011], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(0.5 - N[(N[Cos[lambda2], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := 1 - t_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t_2 \cdot \left(t_3 \cdot t_3\right)\\
\mathbf{if}\;\lambda_2 \leq 0.00011:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_4}}{\sqrt{t_1 + t_2 \cdot \left(\frac{\cos \lambda_1}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(0.5 - \frac{\cos \lambda_2}{2}\right)}}{\sqrt{t_1 - t_4}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.10000000000000004e-4Initial program 64.1%
associate-*l*64.1%
Simplified64.1%
sin-mult60.4%
div-inv60.4%
metadata-eval60.4%
div-inv60.4%
metadata-eval60.4%
div-inv60.4%
metadata-eval60.4%
div-inv60.4%
metadata-eval60.4%
Applied egg-rr64.1%
div-sub60.4%
+-inverses60.4%
cos-060.4%
metadata-eval60.4%
distribute-lft-out60.4%
metadata-eval60.4%
*-rgt-identity60.4%
Simplified64.1%
Taylor expanded in lambda2 around 0 52.2%
if 1.10000000000000004e-4 < lambda2 Initial program 46.3%
associate-*l*46.4%
Simplified46.4%
sin-mult46.3%
div-inv46.3%
metadata-eval46.3%
div-inv46.3%
metadata-eval46.3%
div-inv46.3%
metadata-eval46.3%
div-inv46.3%
metadata-eval46.3%
Applied egg-rr46.3%
div-sub46.3%
+-inverses46.3%
cos-046.3%
metadata-eval46.3%
distribute-lft-out46.3%
metadata-eval46.3%
*-rgt-identity46.3%
Simplified46.3%
Taylor expanded in lambda1 around 0 46.3%
cos-neg46.0%
Simplified46.3%
Final simplification50.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 (* t_1 t_1))))
(sqrt
(+ (- 1.0 t_2) (* t_0 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - t_2) + (t_0 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - t_2) + (t_0 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - t_2) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - t_2) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{\left(1 - t_2\right) + t_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.9%
associate-*l*59.9%
Simplified59.9%
sin-mult57.1%
div-inv57.1%
metadata-eval57.1%
div-inv57.1%
metadata-eval57.1%
div-inv57.1%
metadata-eval57.1%
div-inv57.1%
metadata-eval57.1%
Applied egg-rr60.0%
div-sub57.1%
+-inverses57.1%
cos-057.1%
metadata-eval57.1%
distribute-lft-out57.1%
metadata-eval57.1%
*-rgt-identity57.1%
Simplified60.0%
Final simplification60.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_4 (* t_1 t_2)))
(if (<= lambda1 -0.000176)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) t_3)))
(sqrt (- 1.0 (+ t_0 (* t_4 (sin (* lambda1 0.5)))))))))
(if (<= lambda1 -3.2e-275)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(*
t_2
(*
t_1
(+
(* 0.5 (* lambda1 (cos (* lambda2 -0.5))))
(sin (* lambda2 -0.5)))))))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 t_4)))
(sqrt (expm1 (log1p (- 1.0 t_3)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = t_1 * t_2;
double tmp;
if (lambda1 <= -0.000176) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * t_3))), sqrt((1.0 - (t_0 + (t_4 * sin((lambda1 * 0.5))))))));
} else if (lambda1 <= -3.2e-275) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * ((0.5 * (lambda1 * cos((lambda2 * -0.5)))) + sin((lambda2 * -0.5))))))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * t_4))), sqrt(expm1(log1p((1.0 - t_3))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = t_1 * t_2;
double tmp;
if (lambda1 <= -0.000176) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * t_3))), Math.sqrt((1.0 - (t_0 + (t_4 * Math.sin((lambda1 * 0.5))))))));
} else if (lambda1 <= -3.2e-275) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_1 * ((0.5 * (lambda1 * Math.cos((lambda2 * -0.5)))) + Math.sin((lambda2 * -0.5))))))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * t_4))), Math.sqrt(Math.expm1(Math.log1p((1.0 - t_3))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_4 = t_1 * t_2 tmp = 0 if lambda1 <= -0.000176: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * t_3))), math.sqrt((1.0 - (t_0 + (t_4 * math.sin((lambda1 * 0.5)))))))) elif lambda1 <= -3.2e-275: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_1 * ((0.5 * (lambda1 * math.cos((lambda2 * -0.5)))) + math.sin((lambda2 * -0.5))))))), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * t_4))), math.sqrt(math.expm1(math.log1p((1.0 - t_3)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_4 = Float64(t_1 * t_2) tmp = 0.0 if (lambda1 <= -0.000176) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * t_3))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_4 * sin(Float64(lambda1 * 0.5))))))))); elseif (lambda1 <= -3.2e-275) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_1 * Float64(Float64(0.5 * Float64(lambda1 * cos(Float64(lambda2 * -0.5)))) + sin(Float64(lambda2 * -0.5))))))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * t_4))), sqrt(expm1(log1p(Float64(1.0 - t_3))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$1 * t$95$2), $MachinePrecision]}, If[LessEqual[lambda1, -0.000176], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$4 * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, -3.2e-275], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$1 * N[(N[(0.5 * N[(lambda1 * N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_4 := t_1 \cdot t_2\\
\mathbf{if}\;\lambda_1 \leq -0.000176:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot t_3}}{\sqrt{1 - \left(t_0 + t_4 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\mathbf{elif}\;\lambda_1 \leq -3.2 \cdot 10^{-275}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_1 \cdot \left(0.5 \cdot \left(\lambda_1 \cdot \cos \left(\lambda_2 \cdot -0.5\right)\right) + \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot t_4}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - t_3\right)\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -1.76e-4Initial program 50.5%
Taylor expanded in lambda2 around 0 49.7%
Taylor expanded in phi1 around 0 35.8%
Taylor expanded in phi1 around 0 38.5%
if -1.76e-4 < lambda1 < -3.2e-275Initial program 78.5%
Taylor expanded in lambda2 around 0 39.8%
Taylor expanded in lambda1 around 0 39.8%
Taylor expanded in lambda1 around 0 39.8%
if -3.2e-275 < lambda1 Initial program 57.7%
expm1-log1p-u57.7%
div-inv57.7%
metadata-eval57.7%
associate-*l*57.7%
pow257.7%
div-inv57.7%
metadata-eval57.7%
Applied egg-rr57.7%
metadata-eval57.7%
div-inv57.7%
div-sub57.7%
sin-diff58.3%
Applied egg-rr58.3%
Taylor expanded in phi1 around 0 45.1%
associate--r+45.1%
Simplified45.1%
Taylor expanded in phi2 around 0 34.3%
Final simplification36.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* -0.5 (- lambda2 lambda1))))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2))))
(if (<= t_1 0.054)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_1 (* t_2 t_1))))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (sin (* -0.5 (- phi2 phi1))) 2.0)
(fma t_2 (* t_0 t_0) -1.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((-0.5 * (lambda2 - lambda1)));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if (t_1 <= 0.054) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_1)))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(sin((-0.5 * (phi2 - phi1))), 2.0) - fma(t_2, (t_0 * t_0), -1.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (t_1 <= 0.054) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_2 * t_1)))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0) - fma(t_2, Float64(t_0 * t_0), -1.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[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[LessEqual[t$95$1, 0.054], 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$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;t_1 \leq 0.054:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(t_2 \cdot t_1\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2} - \mathsf{fma}\left(t_2, t_0 \cdot t_0, -1\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.0539999999999999994Initial program 66.0%
Taylor expanded in lambda2 around 0 52.9%
Taylor expanded in lambda1 around 0 40.7%
if 0.0539999999999999994 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 49.5%
Simplified29.6%
expm1-log1p-u29.6%
Applied egg-rr29.6%
Taylor expanded in phi1 around 0 23.5%
unpow223.5%
associate-*r*23.5%
distribute-rgt-out23.5%
Simplified23.5%
Taylor expanded in phi2 around 0 23.9%
sub-neg23.9%
mul-1-neg23.9%
+-commutative23.9%
distribute-lft-in23.9%
associate-*r*23.9%
metadata-eval23.9%
metadata-eval23.9%
associate-*r*23.9%
distribute-lft-in23.9%
mul-1-neg23.9%
sub-neg23.9%
Simplified23.9%
Final simplification34.5%
(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 (<= (- lambda1 lambda2) -2.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 (* t_2 t_1))))
(sqrt
(expm1
(log1p (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(*
t_1
(*
t_2
(+
(* 0.5 (* lambda1 (cos (* lambda2 -0.5))))
(sin (* lambda2 -0.5)))))))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_1)))), sqrt(expm1(log1p((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * ((0.5 * (lambda1 * cos((lambda2 * -0.5)))) + sin((lambda2 * -0.5))))))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
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 ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (t_2 * t_1)))), Math.sqrt(Math.expm1(Math.log1p((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (t_2 * ((0.5 * (lambda1 * Math.cos((lambda2 * -0.5)))) + Math.sin((lambda2 * -0.5))))))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.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 (lambda1 - lambda2) <= -2.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (t_2 * t_1)))), math.sqrt(math.expm1(math.log1p((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (t_2 * ((0.5 * (lambda1 * math.cos((lambda2 * -0.5)))) + math.sin((lambda2 * -0.5))))))), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(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 (Float64(lambda1 - lambda2) <= -2.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(t_2 * t_1)))), sqrt(expm1(log1p(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(t_2 * Float64(Float64(0.5 * Float64(lambda1 * cos(Float64(lambda2 * -0.5)))) + sin(Float64(lambda2 * -0.5))))))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -2.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * N[(N[(0.5 * N[(lambda1 * N[Cos[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\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}\;\lambda_1 - \lambda_2 \leq -2:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_1\right)}}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot \left(0.5 \cdot \left(\lambda_1 \cdot \cos \left(\lambda_2 \cdot -0.5\right)\right) + \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -2Initial program 57.9%
expm1-log1p-u57.9%
div-inv57.9%
metadata-eval57.9%
associate-*l*57.9%
pow257.9%
div-inv57.9%
metadata-eval57.9%
Applied egg-rr57.9%
metadata-eval57.9%
div-inv57.9%
div-sub57.9%
sin-diff58.7%
Applied egg-rr58.7%
Taylor expanded in phi1 around 0 46.3%
associate--r+46.4%
Simplified46.4%
Taylor expanded in phi2 around 0 36.3%
if -2 < (-.f64 lambda1 lambda2) Initial program 61.1%
Taylor expanded in lambda2 around 0 47.1%
Taylor expanded in lambda1 around 0 40.1%
Taylor expanded in lambda1 around 0 35.8%
Final simplification36.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))))
(if (<= (- lambda1 lambda2) -2.0)
(*
R
(*
2.0
(atan2
t_1
(sqrt
(expm1
(log1p (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))))
(*
R
(*
2.0
(atan2
t_1
(sqrt
(expm1 (log1p (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * atan2(t_1, sqrt(expm1(log1p((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(expm1(log1p((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0))));
double tmp;
if ((lambda1 - lambda2) <= -2.0) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.expm1(Math.log1p((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.expm1(Math.log1p((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))) tmp = 0 if (lambda1 - lambda2) <= -2.0: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.expm1(math.log1p((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.expm1(math.log1p((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -2.0) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(expm1(log1p(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt(expm1(log1p(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -2.0], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[(Exp[N[Log[1 + N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 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 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -2:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{\mathsf{expm1}\left(\mathsf{log1p}\left(1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -2Initial program 57.9%
expm1-log1p-u57.9%
div-inv57.9%
metadata-eval57.9%
associate-*l*57.9%
pow257.9%
div-inv57.9%
metadata-eval57.9%
Applied egg-rr57.9%
metadata-eval57.9%
div-inv57.9%
div-sub57.9%
sin-diff58.7%
Applied egg-rr58.7%
Taylor expanded in phi1 around 0 46.3%
associate--r+46.4%
Simplified46.4%
Taylor expanded in phi2 around 0 36.3%
if -2 < (-.f64 lambda1 lambda2) Initial program 61.1%
Taylor expanded in lambda2 around 0 47.1%
Taylor expanded in lambda1 around 0 40.1%
expm1-log1p-u40.1%
Applied egg-rr40.1%
Final simplification38.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))
(t_2 (* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))))
(if (<= lambda2 8e-70)
(* R (* 2.0 (atan2 (sqrt (+ t_0 (* t_2 (sin (* lambda1 0.5))))) t_1)))
(* R (* 2.0 (atan2 (sqrt (+ t_0 (* t_2 (sin (* lambda2 -0.5))))) t_1))))))
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 = sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)));
double t_2 = (cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 8e-70) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda2 * -0.5))))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))
t_2 = (cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 8d-70) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5d0))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * sin((lambda2 * (-0.5d0)))))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)));
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 8e-70) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * Math.sin((lambda1 * 0.5))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * Math.sin((lambda2 * -0.5))))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))) t_2 = (math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 8e-70: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * math.sin((lambda1 * 0.5))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * math.sin((lambda2 * -0.5))))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))) t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) tmp = 0.0 if (lambda2 <= 8e-70) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * sin(Float64(lambda1 * 0.5))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * sin(Float64(lambda2 * -0.5))))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))); t_2 = (cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 8e-70) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda1 * 0.5))))), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * sin((lambda2 * -0.5))))), t_1)); 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[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 8e-70], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 8 \cdot 10^{-70}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \sin \left(\lambda_1 \cdot 0.5\right)}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)}}{t_1}\right)\\
\end{array}
\end{array}
if lambda2 < 7.99999999999999997e-70Initial program 62.6%
Taylor expanded in lambda2 around 0 50.1%
Taylor expanded in lambda1 around 0 35.7%
Taylor expanded in lambda2 around 0 32.5%
if 7.99999999999999997e-70 < lambda2 Initial program 52.8%
Taylor expanded in lambda2 around 0 30.5%
Taylor expanded in lambda1 around 0 26.2%
Taylor expanded in lambda1 around 0 25.0%
Final simplification30.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 59.9%
Taylor expanded in lambda2 around 0 44.7%
Taylor expanded in lambda1 around 0 33.1%
Final simplification33.1%
(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 (<= phi1 112000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 (* t_2 t_1))))
(sqrt (pow (cos (* phi2 -0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (pow (cos (* 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 (phi1 <= 112000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_1)))), sqrt(pow(cos((phi2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt(pow(cos((phi1 * 0.5)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: 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 (phi1 <= 112000000.0d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_1)))), sqrt((cos((phi2 * (-0.5d0))) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.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 (phi1 <= 112000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (t_2 * t_1)))), Math.sqrt(Math.pow(Math.cos((phi2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt(Math.pow(Math.cos((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 phi1 <= 112000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (t_2 * t_1)))), math.sqrt(math.pow(math.cos((phi2 * -0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(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 (phi1 <= 112000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(t_2 * t_1)))), sqrt((cos(Float64(phi2 * -0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt((cos(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 (phi1 <= 112000000.0) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_1)))), sqrt((cos((phi2 * -0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt((cos((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[LessEqual[phi1, 112000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\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_1 \leq 112000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_1\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < 1.12e8Initial program 63.3%
Taylor expanded in lambda2 around 0 45.5%
Taylor expanded in lambda1 around 0 32.8%
Taylor expanded in phi1 around 0 31.9%
unpow231.9%
1-sub-sin32.0%
unpow232.0%
*-commutative32.0%
Simplified32.0%
if 1.12e8 < phi1 Initial program 51.1%
Taylor expanded in lambda2 around 0 42.7%
Taylor expanded in lambda1 around 0 33.9%
Taylor expanded in phi2 around 0 33.9%
unpow233.9%
*-commutative33.9%
*-commutative33.9%
1-sub-sin33.9%
*-commutative33.9%
*-commutative33.9%
unpow233.9%
Simplified33.9%
Taylor expanded in lambda1 around 0 33.7%
Final simplification32.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (pow (cos (* phi1 0.5)) 2.0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt(pow(cos((phi1 * 0.5)), 2.0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((cos((phi1 * 0.5)) ^ 2.0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 59.9%
Taylor expanded in lambda2 around 0 44.7%
Taylor expanded in lambda1 around 0 33.1%
Taylor expanded in phi2 around 0 29.0%
unpow229.0%
*-commutative29.0%
*-commutative29.0%
1-sub-sin29.0%
*-commutative29.0%
*-commutative29.0%
unpow229.0%
Simplified29.0%
Taylor expanded in phi2 around 0 29.5%
Final simplification29.5%
herbie shell --seed 2023242
(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))))))))))