
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 24 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(-
1.0
(+
t_1
(log1p
(expm1
(*
(cos phi1)
(*
(cos phi2)
(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 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (t_1 + log1p(expm1((cos(phi1) * (cos(phi2) * 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.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - (t_1 + Math.log1p(Math.expm1((Math.cos(phi1) * (Math.cos(phi2) * 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.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - (t_1 + math.log1p(math.expm1((math.cos(phi1) * (math.cos(phi2) * 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(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - Float64(t_1 + log1p(expm1(Float64(cos(phi1) * Float64(cos(phi2) * (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[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + 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[(t$95$1 + N[Log[1 + N[(Exp[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * 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]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{1 - \left(t\_1 + \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1 \cdot \left(\cos \phi_2 \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)}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
associate-*r*76.5%
log1p-expm1-u76.5%
associate-*l*76.6%
pow276.6%
div-inv76.6%
metadata-eval76.6%
*-commutative76.6%
Applied egg-rr76.6%
*-commutative76.6%
metadata-eval76.6%
div-inv76.6%
div-sub76.6%
sin-diff77.2%
Applied egg-rr77.2%
Final simplification77.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(-
1.0
(+
t_1
(log1p
(expm1
(*
(cos phi1)
(*
(cos phi2)
(pow (sin (* 0.5 (- lambda1 lambda2))) 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 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (t_1 + log1p(expm1((cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 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.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - (t_1 + Math.log1p(Math.expm1((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - (t_1 + math.log1p(math.expm1((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - Float64(t_1 + log1p(expm1(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 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[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + 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[(t$95$1 + N[Log[1 + N[(Exp[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{1 - \left(t\_1 + \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
associate-*r*76.5%
log1p-expm1-u76.5%
associate-*l*76.6%
pow276.6%
div-inv76.6%
metadata-eval76.6%
*-commutative76.6%
Applied egg-rr76.6%
Final simplification76.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
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_1 (* t_0 t_1))))
(sqrt
(-
1.0
(+
t_2
(expm1
(log1p (* t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_1 * (t_0 * t_1)))), sqrt((1.0 - (t_2 + expm1(log1p((t_0 * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))))));
}
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.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_1 * (t_0 * t_1)))), Math.sqrt((1.0 - (t_2 + Math.expm1(Math.log1p((t_0 * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))))));
}
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.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_1 * (t_0 * t_1)))), math.sqrt((1.0 - (t_2 + math.expm1(math.log1p((t_0 * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))))))
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(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_1 * Float64(t_0 * t_1)))), sqrt(Float64(1.0 - Float64(t_2 + expm1(log1p(Float64(t_0 * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))))) 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[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(Exp[N[Log[1 + N[(t$95$0 * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $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 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_1 \cdot \left(t\_0 \cdot t\_1\right)}}{\sqrt{1 - \left(t\_2 + \mathsf{expm1}\left(\mathsf{log1p}\left(t\_0 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
expm1-log1p-u76.5%
expm1-undefine76.5%
Applied egg-rr76.5%
expm1-define76.5%
associate-*r*76.5%
*-commutative76.5%
Simplified76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) 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(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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 = (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * 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.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * 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((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * 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 = (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * 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[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $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]}, 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 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))
(* R (* 2.0 (atan2 (sqrt t_0) (sqrt (- 1.0 t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0) + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)));
return R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))
code = r * (2.0d0 * atan2(sqrt(t_0), sqrt((1.0d0 - t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)));
return R * (2.0 * Math.atan2(Math.sqrt(t_0), Math.sqrt((1.0 - t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))) return R * (2.0 * math.atan2(math.sqrt(t_0), math.sqrt((1.0 - t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))) return Float64(R * Float64(2.0 * atan(sqrt(t_0), sqrt(Float64(1.0 - t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0) + (cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))); tmp = R * (2.0 * atan2(sqrt(t_0), sqrt((1.0 - t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$0], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0}}{\sqrt{1 - t\_0}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr76.5%
associate-*r*76.5%
log1p-expm1-u76.5%
associate-*l*76.6%
pow276.6%
div-inv76.6%
metadata-eval76.6%
*-commutative76.6%
Applied egg-rr76.6%
Taylor expanded in phi1 around 0 76.5%
Final simplification76.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (sin (* 0.5 phi2)))
(t_3
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) t_2))
2.0)))
(if (or (<= phi1 -5.4e-12) (not (<= phi1 2.8e-11)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 t_1))
(sqrt
(-
1.0
(+
t_3
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
(*
(cos phi2)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow t_2 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = sin((0.5 * phi2));
double t_3 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * t_2)), 2.0);
double tmp;
if ((phi1 <= -5.4e-12) || !(phi1 <= 2.8e-11)) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_1)), sqrt((1.0 - (t_3 + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi2) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(t_2, 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = sin((0.5d0 * phi2))
t_3 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * t_2)) ** 2.0d0
if ((phi1 <= (-5.4d-12)) .or. (.not. (phi1 <= 2.8d-11))) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_1)), sqrt((1.0d0 - (t_3 + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi2) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)) + (t_2 ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.sin((0.5 * phi2));
double t_3 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * t_2)), 2.0);
double tmp;
if ((phi1 <= -5.4e-12) || !(phi1 <= 2.8e-11)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_1)), Math.sqrt((1.0 - (t_3 + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi2) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)) + Math.pow(t_2, 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_2 = math.sin((0.5 * phi2)) t_3 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * t_2)), 2.0) tmp = 0 if (phi1 <= -5.4e-12) or not (phi1 <= 2.8e-11): tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_1)), math.sqrt((1.0 - (t_3 + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi2) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)) + math.pow(t_2, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sin(Float64(0.5 * phi2)) t_3 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * t_2)) ^ 2.0 tmp = 0.0 if ((phi1 <= -5.4e-12) || !(phi1 <= 2.8e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_1)), sqrt(Float64(1.0 - Float64(t_3 + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * (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)) + (t_2 ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = sin((0.5 * phi2)); t_3 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * t_2)) ^ 2.0; tmp = 0.0; if ((phi1 <= -5.4e-12) || ~((phi1 <= 2.8e-11))) tmp = R * (2.0 * atan2(sqrt((t_3 + t_1)), sqrt((1.0 - (t_3 + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi2) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)) + (t_2 ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -5.4e-12], N[Not[LessEqual[phi1, 2.8e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * 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] + N[Power[t$95$2, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := \sin \left(0.5 \cdot \phi_2\right)\\
t_3 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot t\_2\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -5.4 \cdot 10^{-12} \lor \neg \left(\phi_1 \leq 2.8 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_1}}{\sqrt{1 - \left(t\_3 + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \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} + {t\_2}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -5.39999999999999961e-12 or 2.8e-11 < phi1 Initial program 47.3%
div-sub47.3%
sin-diff49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
Applied egg-rr49.2%
div-sub47.3%
sin-diff49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
div-inv49.2%
metadata-eval49.2%
Applied egg-rr76.8%
Taylor expanded in phi2 around 0 57.9%
*-commutative57.9%
Simplified57.9%
if -5.39999999999999961e-12 < phi1 < 2.8e-11Initial program 76.2%
div-sub76.2%
sin-diff76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in phi1 around 0 76.2%
*-commutative76.2%
metadata-eval76.2%
div-inv76.2%
div-sub76.2%
sin-diff76.9%
Applied egg-rr76.9%
Final simplification66.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sin (* phi1 0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (cos (* phi1 0.5)))
(t_4
(pow (- (* (cos (* 0.5 phi2)) t_1) (* t_3 (sin (* 0.5 phi2)))) 2.0))
(t_5 (+ t_4 (* t_2 (* (* (cos phi1) (cos phi2)) t_2)))))
(if (or (<= phi2 -0.001) (not (<= phi2 4.5e-5)))
(* R (* 2.0 (atan2 (sqrt (+ t_4 (* (cos phi2) t_0))) (sqrt (- 1.0 t_5)))))
(*
R
(*
2.0
(atan2
(sqrt t_5)
(sqrt
(-
(+ 1.0 (* phi2 (* t_1 t_3)))
(+ (* (cos phi1) t_0) (pow t_1 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = sin((phi1 * 0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos((phi1 * 0.5));
double t_4 = pow(((cos((0.5 * phi2)) * t_1) - (t_3 * sin((0.5 * phi2)))), 2.0);
double t_5 = t_4 + (t_2 * ((cos(phi1) * cos(phi2)) * t_2));
double tmp;
if ((phi2 <= -0.001) || !(phi2 <= 4.5e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi2) * t_0))), sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt(((1.0 + (phi2 * (t_1 * t_3))) - ((cos(phi1) * t_0) + pow(t_1, 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = sin((phi1 * 0.5d0))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos((phi1 * 0.5d0))
t_4 = ((cos((0.5d0 * phi2)) * t_1) - (t_3 * sin((0.5d0 * phi2)))) ** 2.0d0
t_5 = t_4 + (t_2 * ((cos(phi1) * cos(phi2)) * t_2))
if ((phi2 <= (-0.001d0)) .or. (.not. (phi2 <= 4.5d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (cos(phi2) * t_0))), sqrt((1.0d0 - t_5))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt(((1.0d0 + (phi2 * (t_1 * t_3))) - ((cos(phi1) * t_0) + (t_1 ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.sin((phi1 * 0.5));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos((phi1 * 0.5));
double t_4 = Math.pow(((Math.cos((0.5 * phi2)) * t_1) - (t_3 * Math.sin((0.5 * phi2)))), 2.0);
double t_5 = t_4 + (t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2));
double tmp;
if ((phi2 <= -0.001) || !(phi2 <= 4.5e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (Math.cos(phi2) * t_0))), Math.sqrt((1.0 - t_5))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt(((1.0 + (phi2 * (t_1 * t_3))) - ((Math.cos(phi1) * t_0) + Math.pow(t_1, 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_1 = math.sin((phi1 * 0.5)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos((phi1 * 0.5)) t_4 = math.pow(((math.cos((0.5 * phi2)) * t_1) - (t_3 * math.sin((0.5 * phi2)))), 2.0) t_5 = t_4 + (t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2)) tmp = 0 if (phi2 <= -0.001) or not (phi2 <= 4.5e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (math.cos(phi2) * t_0))), math.sqrt((1.0 - t_5)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt(((1.0 + (phi2 * (t_1 * t_3))) - ((math.cos(phi1) * t_0) + math.pow(t_1, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = sin(Float64(phi1 * 0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = cos(Float64(phi1 * 0.5)) t_4 = Float64(Float64(cos(Float64(0.5 * phi2)) * t_1) - Float64(t_3 * sin(Float64(0.5 * phi2)))) ^ 2.0 t_5 = Float64(t_4 + Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2))) tmp = 0.0 if ((phi2 <= -0.001) || !(phi2 <= 4.5e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(cos(phi2) * t_0))), sqrt(Float64(1.0 - t_5))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(Float64(1.0 + Float64(phi2 * Float64(t_1 * t_3))) - Float64(Float64(cos(phi1) * t_0) + (t_1 ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_1 = sin((phi1 * 0.5)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos((phi1 * 0.5)); t_4 = ((cos((0.5 * phi2)) * t_1) - (t_3 * sin((0.5 * phi2)))) ^ 2.0; t_5 = t_4 + (t_2 * ((cos(phi1) * cos(phi2)) * t_2)); tmp = 0.0; if ((phi2 <= -0.001) || ~((phi2 <= 4.5e-5))) tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi2) * t_0))), sqrt((1.0 - t_5)))); else tmp = R * (2.0 * atan2(sqrt(t_5), sqrt(((1.0 + (phi2 * (t_1 * t_3))) - ((cos(phi1) * t_0) + (t_1 ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision] - N[(t$95$3 * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 + N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.001], N[Not[LessEqual[phi2, 4.5e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(phi2 * N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_4 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot t\_1 - t\_3 \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_5 := t\_4 + t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right)\\
\mathbf{if}\;\phi_2 \leq -0.001 \lor \neg \left(\phi_2 \leq 4.5 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + \cos \phi_2 \cdot t\_0}}{\sqrt{1 - t\_5}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{\left(1 + \phi_2 \cdot \left(t\_1 \cdot t\_3\right)\right) - \left(\cos \phi_1 \cdot t\_0 + {t\_1}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1e-3 or 4.50000000000000028e-5 < phi2 Initial program 45.5%
div-sub45.5%
sin-diff47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr47.6%
div-sub45.5%
sin-diff47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
div-inv47.6%
metadata-eval47.6%
Applied egg-rr76.7%
Taylor expanded in phi1 around 0 56.5%
if -1e-3 < phi2 < 4.50000000000000028e-5Initial program 75.0%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr75.1%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr76.4%
Taylor expanded in phi2 around 0 75.9%
Final simplification66.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 phi2)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) t_0))
2.0))
(t_2
(+ t_1 (* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* t_3 (* (* (cos phi1) (cos phi2)) t_3)))
(t_5 (+ t_1 t_4)))
(if (<= phi1 -5.4e-12)
(* R (* 2.0 (atan2 (sqrt t_5) (sqrt (- 1.0 t_2)))))
(if (<= phi1 2.8e-11)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
(*
(cos phi2)
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))
(pow t_0 2.0)))))))
(* R (* 2.0 (atan2 (sqrt t_2) (sqrt (- 1.0 t_5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * phi2));
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * t_0)), 2.0);
double t_2 = t_1 + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3);
double t_5 = t_1 + t_4;
double tmp;
if (phi1 <= -5.4e-12) {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_2))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi2) * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)) + pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_5))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin((0.5d0 * phi2))
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * t_0)) ** 2.0d0
t_2 = t_1 + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3)
t_5 = t_1 + t_4
if (phi1 <= (-5.4d-12)) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - t_2))))
else if (phi1 <= 2.8d-11) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi2) * (((sin((lambda1 / 2.0d0)) * cos((lambda2 / 2.0d0))) - (cos((lambda1 / 2.0d0)) * sin((lambda2 / 2.0d0)))) ** 2.0d0)) + (t_0 ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_2), sqrt((1.0d0 - t_5))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * phi2));
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * t_0)), 2.0);
double t_2 = t_1 + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0));
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = t_3 * ((Math.cos(phi1) * Math.cos(phi2)) * t_3);
double t_5 = t_1 + t_4;
double tmp;
if (phi1 <= -5.4e-12) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - t_2))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi2) * Math.pow(((Math.sin((lambda1 / 2.0)) * Math.cos((lambda2 / 2.0))) - (Math.cos((lambda1 / 2.0)) * Math.sin((lambda2 / 2.0)))), 2.0)) + Math.pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_2), Math.sqrt((1.0 - t_5))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * phi2)) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * t_0)), 2.0) t_2 = t_1 + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = t_3 * ((math.cos(phi1) * math.cos(phi2)) * t_3) t_5 = t_1 + t_4 tmp = 0 if phi1 <= -5.4e-12: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - t_2)))) elif phi1 <= 2.8e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi2) * math.pow(((math.sin((lambda1 / 2.0)) * math.cos((lambda2 / 2.0))) - (math.cos((lambda1 / 2.0)) * math.sin((lambda2 / 2.0)))), 2.0)) + math.pow(t_0, 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_2), math.sqrt((1.0 - t_5)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * phi2)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * t_0)) ^ 2.0 t_2 = Float64(t_1 + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) t_5 = Float64(t_1 + t_4) tmp = 0.0 if (phi1 <= -5.4e-12) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - t_2))))); elseif (phi1 <= 2.8e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * (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)) + (t_0 ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_2), sqrt(Float64(1.0 - t_5))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * phi2)); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * t_0)) ^ 2.0; t_2 = t_1 + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = t_3 * ((cos(phi1) * cos(phi2)) * t_3); t_5 = t_1 + t_4; tmp = 0.0; if (phi1 <= -5.4e-12) tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - t_2)))); elseif (phi1 <= 2.8e-11) tmp = R * (2.0 * atan2(sqrt((t_4 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi2) * (((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))) ^ 2.0)) + (t_0 ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(t_2), sqrt((1.0 - t_5)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$1 + t$95$4), $MachinePrecision]}, If[LessEqual[phi1, -5.4e-12], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.8e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * 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] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$2], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \phi_2\right)\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot t\_0\right)}^{2}\\
t_2 := t\_1 + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := t\_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_3\right)\\
t_5 := t\_1 + t\_4\\
\mathbf{if}\;\phi_1 \leq -5.4 \cdot 10^{-12}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - t\_2}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \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} + {t\_0}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2}}{\sqrt{1 - t\_5}}\right)\\
\end{array}
\end{array}
if phi1 < -5.39999999999999961e-12Initial program 45.0%
div-sub45.0%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
div-sub45.0%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr77.3%
Taylor expanded in phi2 around 0 57.8%
*-commutative57.8%
Simplified57.8%
if -5.39999999999999961e-12 < phi1 < 2.8e-11Initial program 76.2%
div-sub76.2%
sin-diff76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
div-inv76.2%
metadata-eval76.2%
Applied egg-rr76.2%
Taylor expanded in phi1 around 0 76.2%
*-commutative76.2%
metadata-eval76.2%
div-inv76.2%
div-sub76.2%
sin-diff76.9%
Applied egg-rr76.9%
if 2.8e-11 < phi1 Initial program 50.2%
div-sub50.2%
sin-diff51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
Applied egg-rr51.7%
div-sub50.2%
sin-diff51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
div-inv51.7%
metadata-eval51.7%
Applied egg-rr76.2%
Taylor expanded in phi2 around 0 59.3%
*-commutative58.2%
Simplified59.3%
Final simplification66.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (cos (* phi1 0.5)))
(t_3
(pow (- (* (cos (* 0.5 phi2)) t_0) (* t_2 (sin (* 0.5 phi2)))) 2.0))
(t_4 (+ t_3 (* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(t_5 (sqrt t_4))
(t_6 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_7 (+ t_3 (* (cos phi2) t_6))))
(if (<= phi2 -0.001)
(* R (* 2.0 (atan2 (sqrt t_7) (sqrt (- 1.0 t_4)))))
(if (<= phi2 0.00011)
(*
R
(*
2.0
(atan2
t_5
(sqrt
(-
(+ 1.0 (* phi2 (* t_0 t_2)))
(+ (* (cos phi1) t_6) (pow t_0 2.0)))))))
(* R (* 2.0 (atan2 t_5 (sqrt (- 1.0 t_7)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos((phi1 * 0.5));
double t_3 = pow(((cos((0.5 * phi2)) * t_0) - (t_2 * sin((0.5 * phi2)))), 2.0);
double t_4 = t_3 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1));
double t_5 = sqrt(t_4);
double t_6 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_7 = t_3 + (cos(phi2) * t_6);
double tmp;
if (phi2 <= -0.001) {
tmp = R * (2.0 * atan2(sqrt(t_7), sqrt((1.0 - t_4))));
} else if (phi2 <= 0.00011) {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 + (phi2 * (t_0 * t_2))) - ((cos(phi1) * t_6) + pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - t_7))));
}
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) :: t_7
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos((phi1 * 0.5d0))
t_3 = ((cos((0.5d0 * phi2)) * t_0) - (t_2 * sin((0.5d0 * phi2)))) ** 2.0d0
t_4 = t_3 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))
t_5 = sqrt(t_4)
t_6 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_7 = t_3 + (cos(phi2) * t_6)
if (phi2 <= (-0.001d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_7), sqrt((1.0d0 - t_4))))
else if (phi2 <= 0.00011d0) then
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 + (phi2 * (t_0 * t_2))) - ((cos(phi1) * t_6) + (t_0 ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - t_7))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((phi1 * 0.5));
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos((phi1 * 0.5));
double t_3 = Math.pow(((Math.cos((0.5 * phi2)) * t_0) - (t_2 * Math.sin((0.5 * phi2)))), 2.0);
double t_4 = t_3 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1));
double t_5 = Math.sqrt(t_4);
double t_6 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_7 = t_3 + (Math.cos(phi2) * t_6);
double tmp;
if (phi2 <= -0.001) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_7), Math.sqrt((1.0 - t_4))));
} else if (phi2 <= 0.00011) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 + (phi2 * (t_0 * t_2))) - ((Math.cos(phi1) * t_6) + Math.pow(t_0, 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - t_7))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos((phi1 * 0.5)) t_3 = math.pow(((math.cos((0.5 * phi2)) * t_0) - (t_2 * math.sin((0.5 * phi2)))), 2.0) t_4 = t_3 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) t_5 = math.sqrt(t_4) t_6 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_7 = t_3 + (math.cos(phi2) * t_6) tmp = 0 if phi2 <= -0.001: tmp = R * (2.0 * math.atan2(math.sqrt(t_7), math.sqrt((1.0 - t_4)))) elif phi2 <= 0.00011: tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 + (phi2 * (t_0 * t_2))) - ((math.cos(phi1) * t_6) + math.pow(t_0, 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - t_7)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = cos(Float64(phi1 * 0.5)) t_3 = Float64(Float64(cos(Float64(0.5 * phi2)) * t_0) - Float64(t_2 * sin(Float64(0.5 * phi2)))) ^ 2.0 t_4 = Float64(t_3 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1))) t_5 = sqrt(t_4) t_6 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_7 = Float64(t_3 + Float64(cos(phi2) * t_6)) tmp = 0.0 if (phi2 <= -0.001) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_7), sqrt(Float64(1.0 - t_4))))); elseif (phi2 <= 0.00011) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 + Float64(phi2 * Float64(t_0 * t_2))) - Float64(Float64(cos(phi1) * t_6) + (t_0 ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - t_7))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos((phi1 * 0.5)); t_3 = ((cos((0.5 * phi2)) * t_0) - (t_2 * sin((0.5 * phi2)))) ^ 2.0; t_4 = t_3 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)); t_5 = sqrt(t_4); t_6 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_7 = t_3 + (cos(phi2) * t_6); tmp = 0.0; if (phi2 <= -0.001) tmp = R * (2.0 * atan2(sqrt(t_7), sqrt((1.0 - t_4)))); elseif (phi2 <= 0.00011) tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 + (phi2 * (t_0 * t_2))) - ((cos(phi1) * t_6) + (t_0 ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - t_7)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(t$95$2 * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(t$95$3 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[t$95$4], $MachinePrecision]}, Block[{t$95$6 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$7 = N[(t$95$3 + N[(N[Cos[phi2], $MachinePrecision] * t$95$6), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.001], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$7], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00011], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 + N[(phi2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$6), $MachinePrecision] + N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - t$95$7), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_3 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot t\_0 - t\_2 \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_4 := t\_3 + t\_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_1\right)\\
t_5 := \sqrt{t\_4}\\
t_6 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_7 := t\_3 + \cos \phi_2 \cdot t\_6\\
\mathbf{if}\;\phi_2 \leq -0.001:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_7}}{\sqrt{1 - t\_4}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00011:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{\left(1 + \phi_2 \cdot \left(t\_0 \cdot t\_2\right)\right) - \left(\cos \phi_1 \cdot t\_6 + {t\_0}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - t\_7}}\right)\\
\end{array}
\end{array}
if phi2 < -1e-3Initial program 45.7%
div-sub45.7%
sin-diff47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
Applied egg-rr47.8%
div-sub45.7%
sin-diff47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
div-inv47.8%
metadata-eval47.8%
Applied egg-rr76.7%
Taylor expanded in phi1 around 0 54.9%
if -1e-3 < phi2 < 1.10000000000000004e-4Initial program 75.0%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr75.1%
div-sub75.0%
sin-diff75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
div-inv75.1%
metadata-eval75.1%
Applied egg-rr76.4%
Taylor expanded in phi2 around 0 75.9%
if 1.10000000000000004e-4 < phi2 Initial program 45.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr47.3%
div-sub45.3%
sin-diff47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
div-inv47.3%
metadata-eval47.3%
Applied egg-rr76.6%
Taylor expanded in phi1 around 0 58.5%
Final simplification66.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)
t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0) + t_1)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0) + t_1)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0) + t_1)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - ((((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0) + t_1))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left({\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t\_1\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
Final simplification61.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt
(-
(-
1.0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 - pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 - (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 - Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 - math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 - (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
Final simplification61.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(sqrt
(fabs
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (+ 0.5 (* -0.5 (cos (- lambda1 lambda2)))))
(pow (sin (* -0.5 (- phi2 phi1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))), sqrt(fabs((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))), pow(sin((-0.5 * (phi2 - phi1))), 2.0)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))), sqrt(abs(Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2))))), (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{\left|1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)\right|}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
Applied egg-rr61.1%
unpow1/261.1%
unpow261.1%
rem-sqrt-square61.1%
*-commutative61.1%
Simplified61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (* (cos phi1) t_1))
(t_3
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(t_4 (sqrt t_3)))
(if (<= phi1 -3000000000000.0)
(*
R
(* 2.0 (atan2 t_4 (sqrt (- 1.0 (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))))))
(if (<= phi1 2.8e-11)
(*
R
(*
2.0
(atan2
t_4
(sqrt (- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* 0.5 phi2)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 t_3)))))))))
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((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = cos(phi1) * t_1;
double t_3 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = sqrt(t_3);
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_2 + pow(sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((0.5 * phi2)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - t_3))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = cos(phi1) * t_1
t_3 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)
t_4 = sqrt(t_3)
if (phi1 <= (-3000000000000.0d0)) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - (t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else if (phi1 <= 2.8d-11) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((0.5d0 * phi2)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - t_3))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.cos(phi1) * t_1;
double t_3 = (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = Math.sqrt(t_3);
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - (t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((0.5 * phi2)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - t_3))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.cos(phi1) * t_1 t_3 = (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_4 = math.sqrt(t_3) tmp = 0 if phi1 <= -3000000000000.0: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - (t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) elif phi1 <= 2.8e-11: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((0.5 * phi2)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - t_3)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = Float64(cos(phi1) * t_1) t_3 = Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) t_4 = sqrt(t_3) tmp = 0.0 if (phi1 <= -3000000000000.0) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); elseif (phi1 <= 2.8e-11) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(0.5 * phi2)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - t_3))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = cos(phi1) * t_1; t_3 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0); t_4 = sqrt(t_3); tmp = 0.0; if (phi1 <= -3000000000000.0) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_2 + (sin((phi1 * 0.5)) ^ 2.0)))))); elseif (phi1 <= 2.8e-11) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((cos(phi2) * t_1) + (sin((0.5 * phi2)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - t_3)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[t$95$3], $MachinePrecision]}, If[LessEqual[phi1, -3000000000000.0], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.8e-11], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $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(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot t\_1\\
t_3 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := \sqrt{t\_3}\\
\mathbf{if}\;\phi_1 \leq -3000000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - t\_3}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12Initial program 44.9%
div-sub44.9%
sin-diff47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
Applied egg-rr47.1%
Taylor expanded in phi2 around 0 46.2%
if -3e12 < phi1 < 2.8e-11Initial program 75.8%
div-sub75.8%
sin-diff75.8%
div-inv75.8%
metadata-eval75.8%
div-inv75.8%
metadata-eval75.8%
div-inv75.8%
metadata-eval75.8%
div-inv75.8%
metadata-eval75.8%
Applied egg-rr75.8%
Taylor expanded in phi1 around 0 75.8%
if 2.8e-11 < phi1 Initial program 50.2%
Taylor expanded in phi1 around inf 49.9%
Taylor expanded in phi2 around 0 50.9%
*-commutative58.2%
Simplified50.9%
Final simplification61.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (* (cos phi1) t_1))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_5 (+ (* t_0 (* t_3 t_0)) t_4)))
(if (<= phi1 -3000000000000.0)
(*
R
(*
2.0
(atan2 (sqrt t_5) (sqrt (- 1.0 (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))))))
(if (<= phi1 2.8e-11)
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (* t_3 (* t_0 t_0))))
(sqrt
(- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 t_5)))))))))
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((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = cos(phi1) * t_1;
double t_3 = cos(phi1) * cos(phi2);
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = (t_0 * (t_3 * t_0)) + t_4;
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - (t_2 + pow(sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * atan2(sqrt((t_4 + (t_3 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - t_5))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = cos(phi1) * t_1
t_3 = cos(phi1) * cos(phi2)
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_5 = (t_0 * (t_3 * t_0)) + t_4
if (phi1 <= (-3000000000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt(t_5), sqrt((1.0d0 - (t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else if (phi1 <= 2.8d-11) then
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (t_3 * (t_0 * t_0)))), sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - t_5))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.cos(phi1) * t_1;
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = (t_0 * (t_3 * t_0)) + t_4;
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_5), Math.sqrt((1.0 - (t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (t_3 * (t_0 * t_0)))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - t_5))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.cos(phi1) * t_1 t_3 = math.cos(phi1) * math.cos(phi2) t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_5 = (t_0 * (t_3 * t_0)) + t_4 tmp = 0 if phi1 <= -3000000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt(t_5), math.sqrt((1.0 - (t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) elif phi1 <= 2.8e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (t_3 * (t_0 * t_0)))), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - t_5)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = Float64(cos(phi1) * t_1) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_5 = Float64(Float64(t_0 * Float64(t_3 * t_0)) + t_4) tmp = 0.0 if (phi1 <= -3000000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_5), sqrt(Float64(1.0 - Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); elseif (phi1 <= 2.8e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(t_3 * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - t_5))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = cos(phi1) * t_1; t_3 = cos(phi1) * cos(phi2); t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_5 = (t_0 * (t_3 * t_0)) + t_4; tmp = 0.0; if (phi1 <= -3000000000000.0) tmp = R * (2.0 * atan2(sqrt(t_5), sqrt((1.0 - (t_2 + (sin((phi1 * 0.5)) ^ 2.0)))))); elseif (phi1 <= 2.8e-11) tmp = R * (2.0 * atan2(sqrt((t_4 + (t_3 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - t_5)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(N[(t$95$0 * N[(t$95$3 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]}, If[LessEqual[phi1, -3000000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$5], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.8e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(t$95$3 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$5), $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(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot t\_1\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_5 := t\_0 \cdot \left(t\_3 \cdot t\_0\right) + t\_4\\
\mathbf{if}\;\phi_1 \leq -3000000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5}}{\sqrt{1 - \left(t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + t\_3 \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - t\_5}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12Initial program 44.9%
div-sub44.9%
sin-diff47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
div-inv47.1%
metadata-eval47.1%
Applied egg-rr47.1%
Taylor expanded in phi2 around 0 46.2%
if -3e12 < phi1 < 2.8e-11Initial program 75.8%
associate-*l*75.7%
Simplified75.8%
Taylor expanded in phi1 around 0 75.8%
if 2.8e-11 < phi1 Initial program 50.2%
Taylor expanded in phi1 around inf 49.9%
Taylor expanded in phi2 around 0 50.9%
*-commutative58.2%
Simplified50.9%
Final simplification61.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (* (cos phi1) t_1))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (sqrt (+ t_0 (* t_3 (* t_4 t_4))))))
(if (<= phi1 -3000000000000.0)
(*
R
(* 2.0 (atan2 t_5 (sqrt (- 1.0 (+ t_2 (pow (sin (* phi1 0.5)) 2.0)))))))
(if (<= phi1 2.8e-11)
(*
R
(*
2.0
(atan2
t_5
(sqrt
(- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* t_4 (* t_3 t_4)) t_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 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = cos(phi1) * t_1;
double t_3 = cos(phi1) * cos(phi2);
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = sqrt((t_0 + (t_3 * (t_4 * t_4))));
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_2 + pow(sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - ((t_4 * (t_3 * t_4)) + t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = cos(phi1) * t_1
t_3 = cos(phi1) * cos(phi2)
t_4 = sin(((lambda1 - lambda2) / 2.0d0))
t_5 = sqrt((t_0 + (t_3 * (t_4 * t_4))))
if (phi1 <= (-3000000000000.0d0)) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - (t_2 + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else if (phi1 <= 2.8d-11) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((t_4 * (t_3 * t_4)) + t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.cos(phi1) * t_1;
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_5 = Math.sqrt((t_0 + (t_3 * (t_4 * t_4))));
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - (t_2 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - ((t_4 * (t_3 * t_4)) + t_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.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.cos(phi1) * t_1 t_3 = math.cos(phi1) * math.cos(phi2) t_4 = math.sin(((lambda1 - lambda2) / 2.0)) t_5 = math.sqrt((t_0 + (t_3 * (t_4 * t_4)))) tmp = 0 if phi1 <= -3000000000000.0: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - (t_2 + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) elif phi1 <= 2.8e-11: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - ((t_4 * (t_3 * t_4)) + t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = Float64(cos(phi1) * t_1) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = sqrt(Float64(t_0 + Float64(t_3 * Float64(t_4 * t_4)))) tmp = 0.0 if (phi1 <= -3000000000000.0) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - Float64(t_2 + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); elseif (phi1 <= 2.8e-11) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(t_4 * Float64(t_3 * t_4)) + t_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((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = cos(phi1) * t_1; t_3 = cos(phi1) * cos(phi2); t_4 = sin(((lambda1 - lambda2) / 2.0)); t_5 = sqrt((t_0 + (t_3 * (t_4 * t_4)))); tmp = 0.0; if (phi1 <= -3000000000000.0) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (t_2 + (sin((phi1 * 0.5)) ^ 2.0)))))); elseif (phi1 <= 2.8e-11) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - ((t_4 * (t_3 * t_4)) + t_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[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3000000000000.0], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.8e-11], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$4 * N[(t$95$3 * t$95$4), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot t\_1\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := \sqrt{t\_0 + t\_3 \cdot \left(t\_4 \cdot t\_4\right)}\\
\mathbf{if}\;\phi_1 \leq -3000000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - \left(t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_4 \cdot \left(t\_3 \cdot t\_4\right) + t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12Initial program 44.9%
associate-*l*44.9%
Simplified44.8%
Taylor expanded in phi2 around 0 46.2%
if -3e12 < phi1 < 2.8e-11Initial program 75.8%
associate-*l*75.7%
Simplified75.8%
Taylor expanded in phi1 around 0 75.8%
if 2.8e-11 < phi1 Initial program 50.2%
Taylor expanded in phi1 around inf 49.9%
Taylor expanded in phi2 around 0 50.9%
*-commutative58.2%
Simplified50.9%
Final simplification61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (cos phi1) t_1))
(t_5 (* (cos phi2) t_1)))
(if (<= phi1 -3000000000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_3))))
(sqrt (- 1.0 (+ t_4 (pow (sin (* phi1 0.5)) 2.0)))))))
(if (<= phi1 2.8e-11)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 t_0))
(sqrt (- 1.0 (+ t_5 (pow (sin (* 0.5 phi2)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* t_3 (* t_2 t_3)) t_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 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = cos(phi1) * t_1;
double t_5 = cos(phi2) * t_1;
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((1.0 - (t_4 + pow(sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * atan2(sqrt((t_5 + t_0)), sqrt((1.0 - (t_5 + pow(sin((0.5 * phi2)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_4 + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - ((t_3 * (t_2 * t_3)) + t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = cos(phi1) * t_1
t_5 = cos(phi2) * t_1
if (phi1 <= (-3000000000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((1.0d0 - (t_4 + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else if (phi1 <= 2.8d-11) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + t_0)), sqrt((1.0d0 - (t_5 + (sin((0.5d0 * phi2)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((t_3 * (t_2 * t_3)) + t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.cos(phi1) * t_1;
double t_5 = Math.cos(phi2) * t_1;
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), Math.sqrt((1.0 - (t_4 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 2.8e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + t_0)), Math.sqrt((1.0 - (t_5 + Math.pow(Math.sin((0.5 * phi2)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - ((t_3 * (t_2 * t_3)) + t_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.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.cos(phi1) * t_1 t_5 = math.cos(phi2) * t_1 tmp = 0 if phi1 <= -3000000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_3)))), math.sqrt((1.0 - (t_4 + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) elif phi1 <= 2.8e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + t_0)), math.sqrt((1.0 - (t_5 + math.pow(math.sin((0.5 * phi2)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - ((t_3 * (t_2 * t_3)) + t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(cos(phi1) * t_1) t_5 = Float64(cos(phi2) * t_1) tmp = 0.0 if (phi1 <= -3000000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(1.0 - Float64(t_4 + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); elseif (phi1 <= 2.8e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + t_0)), sqrt(Float64(1.0 - Float64(t_5 + (sin(Float64(0.5 * phi2)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(t_3 * Float64(t_2 * t_3)) + t_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((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = cos(phi1) * t_1; t_5 = cos(phi2) * t_1; tmp = 0.0; if (phi1 <= -3000000000000.0) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((1.0 - (t_4 + (sin((phi1 * 0.5)) ^ 2.0)))))); elseif (phi1 <= 2.8e-11) tmp = R * (2.0 * atan2(sqrt((t_5 + t_0)), sqrt((1.0 - (t_5 + (sin((0.5 * phi2)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_4 + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - ((t_3 * (t_2 * t_3)) + t_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[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[LessEqual[phi1, -3000000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.8e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(t$95$3 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \cos \phi_1 \cdot t\_1\\
t_5 := \cos \phi_2 \cdot t\_1\\
\mathbf{if}\;\phi_1 \leq -3000000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_3 \cdot t\_3\right)}}{\sqrt{1 - \left(t\_4 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + t\_0}}{\sqrt{1 - \left(t\_5 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_3 \cdot \left(t\_2 \cdot t\_3\right) + t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12Initial program 44.9%
associate-*l*44.9%
Simplified44.8%
Taylor expanded in phi2 around 0 46.2%
if -3e12 < phi1 < 2.8e-11Initial program 75.8%
div-sub75.8%
sin-diff75.8%
div-inv75.8%
metadata-eval75.8%
div-inv75.8%
metadata-eval75.8%
div-inv75.8%
metadata-eval75.8%
div-inv75.8%
metadata-eval75.8%
Applied egg-rr75.8%
Taylor expanded in phi1 around 0 75.8%
Taylor expanded in phi1 around 0 75.8%
if 2.8e-11 < phi1 Initial program 50.2%
Taylor expanded in phi1 around inf 49.9%
Taylor expanded in phi2 around 0 50.9%
*-commutative58.2%
Simplified50.9%
Final simplification61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (pow (sin (/ phi1 2.0)) 2.0))
(t_3 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_4 (* (cos phi1) t_3))
(t_5 (* (cos phi2) t_3))
(t_6 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (<= phi1 -3000000000000.0)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_2))
(sqrt (- 1.0 (+ t_4 (pow (sin (* phi1 0.5)) 2.0)))))))
(if (<= phi1 1.2e-23)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 t_6))
(sqrt (- 1.0 (+ t_5 (pow (sin (* 0.5 phi2)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_4 t_2)) (sqrt (- 1.0 (+ t_1 t_6))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(sin((phi1 / 2.0)), 2.0);
double t_3 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_4 = cos(phi1) * t_3;
double t_5 = cos(phi2) * t_3;
double t_6 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_2)), sqrt((1.0 - (t_4 + pow(sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 1.2e-23) {
tmp = R * (2.0 * atan2(sqrt((t_5 + t_6)), sqrt((1.0 - (t_5 + pow(sin((0.5 * phi2)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_4 + t_2)), sqrt((1.0 - (t_1 + t_6)))));
}
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 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = sin((phi1 / 2.0d0)) ** 2.0d0
t_3 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_4 = cos(phi1) * t_3
t_5 = cos(phi2) * t_3
t_6 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if (phi1 <= (-3000000000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_2)), sqrt((1.0d0 - (t_4 + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else if (phi1 <= 1.2d-23) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + t_6)), sqrt((1.0d0 - (t_5 + (sin((0.5d0 * phi2)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_4 + t_2)), sqrt((1.0d0 - (t_1 + t_6)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.pow(Math.sin((phi1 / 2.0)), 2.0);
double t_3 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_4 = Math.cos(phi1) * t_3;
double t_5 = Math.cos(phi2) * t_3;
double t_6 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if (phi1 <= -3000000000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_2)), Math.sqrt((1.0 - (t_4 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else if (phi1 <= 1.2e-23) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + t_6)), Math.sqrt((1.0 - (t_5 + Math.pow(Math.sin((0.5 * phi2)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + t_2)), Math.sqrt((1.0 - (t_1 + t_6)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_2 = math.pow(math.sin((phi1 / 2.0)), 2.0) t_3 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_4 = math.cos(phi1) * t_3 t_5 = math.cos(phi2) * t_3 t_6 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if phi1 <= -3000000000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_2)), math.sqrt((1.0 - (t_4 + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) elif phi1 <= 1.2e-23: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + t_6)), math.sqrt((1.0 - (t_5 + math.pow(math.sin((0.5 * phi2)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + t_2)), math.sqrt((1.0 - (t_1 + t_6))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sin(Float64(phi1 / 2.0)) ^ 2.0 t_3 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_4 = Float64(cos(phi1) * t_3) t_5 = Float64(cos(phi2) * t_3) t_6 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if (phi1 <= -3000000000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_2)), sqrt(Float64(1.0 - Float64(t_4 + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); elseif (phi1 <= 1.2e-23) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + t_6)), sqrt(Float64(1.0 - Float64(t_5 + (sin(Float64(0.5 * phi2)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + t_2)), sqrt(Float64(1.0 - Float64(t_1 + t_6)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = sin((phi1 / 2.0)) ^ 2.0; t_3 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_4 = cos(phi1) * t_3; t_5 = cos(phi2) * t_3; t_6 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if (phi1 <= -3000000000000.0) tmp = R * (2.0 * atan2(sqrt((t_1 + t_2)), sqrt((1.0 - (t_4 + (sin((phi1 * 0.5)) ^ 2.0)))))); elseif (phi1 <= 1.2e-23) tmp = R * (2.0 * atan2(sqrt((t_5 + t_6)), sqrt((1.0 - (t_5 + (sin((0.5 * phi2)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_4 + t_2)), sqrt((1.0 - (t_1 + t_6))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]}, Block[{t$95$6 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -3000000000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.2e-23], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + t$95$6), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + t$95$6), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := {\sin \left(\frac{\phi_1}{2}\right)}^{2}\\
t_3 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_4 := \cos \phi_1 \cdot t\_3\\
t_5 := \cos \phi_2 \cdot t\_3\\
t_6 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -3000000000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_2}}{\sqrt{1 - \left(t\_4 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.2 \cdot 10^{-23}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + t\_6}}{\sqrt{1 - \left(t\_5 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + t\_2}}{\sqrt{1 - \left(t\_1 + t\_6\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12Initial program 44.9%
Taylor expanded in phi1 around inf 44.6%
Taylor expanded in phi2 around 0 46.0%
if -3e12 < phi1 < 1.19999999999999998e-23Initial program 76.6%
div-sub76.6%
sin-diff76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
Applied egg-rr76.7%
Taylor expanded in phi1 around 0 76.6%
Taylor expanded in phi1 around 0 76.6%
if 1.19999999999999998e-23 < phi1 Initial program 49.4%
Taylor expanded in phi1 around inf 49.1%
Taylor expanded in phi2 around 0 50.0%
*-commutative57.1%
Simplified50.0%
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)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
unpow260.6%
sin-mult60.6%
div-inv60.6%
metadata-eval60.6%
div-inv60.6%
metadata-eval60.6%
div-inv60.6%
metadata-eval60.6%
div-inv60.6%
metadata-eval60.6%
Applied egg-rr60.6%
div-sub60.6%
+-inverses60.6%
cos-060.6%
metadata-eval60.6%
distribute-lft-out60.6%
metadata-eval60.6%
*-rgt-identity60.6%
Simplified60.6%
Final simplification60.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (* (cos phi2) t_1)))
(if (or (<= phi1 -3000000000000.0) (not (<= phi1 1.2e-23)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (+ t_2 (pow (sin (* 0.5 phi2)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = cos(phi2) * t_1;
double tmp;
if ((phi1 <= -3000000000000.0) || !(phi1 <= 1.2e-23)) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_2 + pow(sin((0.5 * phi2)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = cos(phi2) * t_1
if ((phi1 <= (-3000000000000.0d0)) .or. (.not. (phi1 <= 1.2d-23))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (t_2 + (sin((0.5d0 * phi2)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.cos(phi2) * t_1;
double tmp;
if ((phi1 <= -3000000000000.0) || !(phi1 <= 1.2e-23)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (t_2 + Math.pow(Math.sin((0.5 * phi2)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.cos(phi2) * t_1 tmp = 0 if (phi1 <= -3000000000000.0) or not (phi1 <= 1.2e-23): tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (t_2 + math.pow(math.sin((0.5 * phi2)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = Float64(cos(phi2) * t_1) tmp = 0.0 if ((phi1 <= -3000000000000.0) || !(phi1 <= 1.2e-23)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_2 + (sin(Float64(0.5 * phi2)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = cos(phi2) * t_1; tmp = 0.0; if ((phi1 <= -3000000000000.0) || ~((phi1 <= 1.2e-23))) tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (t_2 + (sin((0.5 * phi2)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi1, -3000000000000.0], N[Not[LessEqual[phi1, 1.2e-23]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_2 \cdot t\_1\\
\mathbf{if}\;\phi_1 \leq -3000000000000 \lor \neg \left(\phi_1 \leq 1.2 \cdot 10^{-23}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_2 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12 or 1.19999999999999998e-23 < phi1 Initial program 46.9%
Taylor expanded in phi1 around inf 46.6%
Taylor expanded in phi2 around 0 47.7%
if -3e12 < phi1 < 1.19999999999999998e-23Initial program 76.6%
div-sub76.6%
sin-diff76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
Applied egg-rr76.7%
Taylor expanded in phi1 around 0 76.6%
Taylor expanded in phi1 around 0 76.6%
Final simplification61.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2)))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - (t_0 * (0.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64(t_0 * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, 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$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
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\_1\right)}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - t\_0 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*l*60.6%
Simplified60.6%
*-commutative60.6%
cancel-sign-sub-inv60.6%
div-inv60.6%
metadata-eval60.6%
Applied egg-rr60.6%
Final simplification60.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (* (cos phi2) t_0)))
(if (or (<= phi1 -3000000000000.0) (not (<= phi1 0.0018)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (+ t_1 (pow (sin (* 0.5 phi2)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = cos(phi2) * t_0;
double tmp;
if ((phi1 <= -3000000000000.0) || !(phi1 <= 0.0018)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_1 + pow(sin((0.5 * phi2)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = cos(phi2) * t_0
if ((phi1 <= (-3000000000000.0d0)) .or. (.not. (phi1 <= 0.0018d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (t_1 + (sin((0.5d0 * phi2)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.cos(phi2) * t_0;
double tmp;
if ((phi1 <= -3000000000000.0) || !(phi1 <= 0.0018)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin((0.5 * phi2)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_1 = math.cos(phi2) * t_0 tmp = 0 if (phi1 <= -3000000000000.0) or not (phi1 <= 0.0018): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (t_1 + math.pow(math.sin((0.5 * phi2)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = Float64(cos(phi2) * t_0) tmp = 0.0 if ((phi1 <= -3000000000000.0) || !(phi1 <= 0.0018)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(0.5 * phi2)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_1 = cos(phi2) * t_0; tmp = 0.0; if ((phi1 <= -3000000000000.0) || ~((phi1 <= 0.0018))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (t_1 + (sin((0.5 * phi2)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]}, If[Or[LessEqual[phi1, -3000000000000.0], N[Not[LessEqual[phi1, 0.0018]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \cos \phi_2 \cdot t\_0\\
\mathbf{if}\;\phi_1 \leq -3000000000000 \lor \neg \left(\phi_1 \leq 0.0018\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_1 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3e12 or 0.0018 < phi1 Initial program 46.8%
div-sub46.8%
sin-diff48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
div-inv48.7%
metadata-eval48.7%
Applied egg-rr48.7%
Taylor expanded in lambda2 around 0 37.6%
Taylor expanded in phi2 around 0 36.7%
if -3e12 < phi1 < 0.0018Initial program 76.0%
div-sub76.0%
sin-diff76.0%
div-inv76.0%
metadata-eval76.0%
div-inv76.0%
metadata-eval76.0%
div-inv76.0%
metadata-eval76.0%
div-inv76.0%
metadata-eval76.0%
Applied egg-rr76.0%
Taylor expanded in phi1 around 0 76.0%
Taylor expanded in phi1 around 0 76.0%
Final simplification55.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (+ t_0 (pow (sin (* 0.5 phi2)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * atan2(sqrt((t_0 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_0 + pow(sin((0.5 * phi2)), 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 = cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt((t_0 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (t_0 + (sin((0.5d0 * phi2)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (t_0 + Math.pow(Math.sin((0.5 * phi2)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (t_0 + math.pow(math.sin((0.5 * phi2)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_0 + (sin(Float64(0.5 * phi2)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0); tmp = R * (2.0 * atan2(sqrt((t_0 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (t_0 + (sin((0.5 * phi2)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_0 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
Taylor expanded in phi1 around 0 46.8%
Taylor expanded in phi1 around 0 46.5%
Final simplification46.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 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(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 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(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 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(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 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(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 60.6%
div-sub60.6%
sin-diff61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
div-inv61.6%
metadata-eval61.6%
Applied egg-rr61.6%
Taylor expanded in phi1 around 0 46.8%
Taylor expanded in phi2 around 0 34.2%
Final simplification34.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2)))))
(*
2.0
(*
R
(atan2
(+ t_0 (* -0.25 (/ (* phi1 phi2) t_0)))
(sqrt
(-
1.0
(+ (* (cos phi2) (pow t_0 2.0)) (pow (sin (* phi2 -0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
return 2.0 * (R * atan2((t_0 + (-0.25 * ((phi1 * phi2) / t_0))), sqrt((1.0 - ((cos(phi2) * pow(t_0, 2.0)) + pow(sin((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((0.5d0 * (lambda1 - lambda2)))
code = 2.0d0 * (r * atan2((t_0 + ((-0.25d0) * ((phi1 * phi2) / t_0))), sqrt((1.0d0 - ((cos(phi2) * (t_0 ** 2.0d0)) + (sin((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((0.5 * (lambda1 - lambda2)));
return 2.0 * (R * Math.atan2((t_0 + (-0.25 * ((phi1 * phi2) / t_0))), Math.sqrt((1.0 - ((Math.cos(phi2) * Math.pow(t_0, 2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (lambda1 - lambda2))) return 2.0 * (R * math.atan2((t_0 + (-0.25 * ((phi1 * phi2) / t_0))), math.sqrt((1.0 - ((math.cos(phi2) * math.pow(t_0, 2.0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) return Float64(2.0 * Float64(R * atan(Float64(t_0 + Float64(-0.25 * Float64(Float64(phi1 * phi2) / t_0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * (t_0 ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))); tmp = 2.0 * (R * atan2((t_0 + (-0.25 * ((phi1 * phi2) / t_0))), sqrt((1.0 - ((cos(phi2) * (t_0 ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(2.0 * N[(R * N[ArcTan[N[(t$95$0 + N[(-0.25 * N[(N[(phi1 * phi2), $MachinePrecision] / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
2 \cdot \left(R \cdot \tan^{-1}_* \frac{t\_0 + -0.25 \cdot \frac{\phi_1 \cdot \phi_2}{t\_0}}{\sqrt{1 - \left(\cos \phi_2 \cdot {t\_0}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 60.6%
associate-*r*60.3%
*-commutative60.3%
Simplified60.3%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 15.9%
associate-/l*15.9%
Simplified15.9%
Taylor expanded in lambda1 around 0 15.9%
Taylor expanded in phi1 around 0 16.3%
Final simplification16.3%
herbie shell --seed 2024137
(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))))))))))