
(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 30 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))
(t_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(log1p
(expm1
(*
t_2
(pow
(-
(* (sin (/ lambda1 2.0)) (cos (/ lambda2 2.0)))
(* (cos (/ lambda1 2.0)) (sin (/ lambda2 2.0))))
2.0))))))
(sqrt (- 1.0 (+ t_1 (* t_0 (* t_2 t_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);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt((t_1 + log1p(expm1((t_2 * pow(((sin((lambda1 / 2.0)) * cos((lambda2 / 2.0))) - (cos((lambda1 / 2.0)) * sin((lambda2 / 2.0)))), 2.0)))))), sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_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);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.log1p(Math.expm1((t_2 * 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.sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_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) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.log1p(math.expm1((t_2 * 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.sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_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 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + log1p(expm1(Float64(t_2 * (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)))))), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_0 * Float64(t_2 * t_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]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Log[1 + N[(Exp[N[(t$95$2 * 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]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\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_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \mathsf{log1p}\left(\mathsf{expm1}\left(t_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)}}{\sqrt{1 - \left(t_1 + t_0 \cdot \left(t_2 \cdot t_0\right)\right)}}\right)
\end{array}
\end{array}
Initial program 68.1%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr69.0%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr83.4%
log1p-expm1-u83.4%
associate-*l*83.4%
pow283.4%
div-inv83.4%
metadata-eval83.4%
Applied egg-rr83.4%
metadata-eval83.4%
div-inv83.4%
div-sub83.4%
sin-diff83.8%
Applied egg-rr83.8%
Final simplification83.8%
(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_2 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(log1p (expm1 (* t_2 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))
(sqrt (- 1.0 (+ t_1 (* t_0 (* t_2 t_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);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt((t_1 + log1p(expm1((t_2 * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))), sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_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);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.log1p(Math.expm1((t_2 * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))), Math.sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_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) t_2 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.log1p(math.expm1((t_2 * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))), math.sqrt((1.0 - (t_1 + (t_0 * (t_2 * t_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 t_2 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + log1p(expm1(Float64(t_2 * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_0 * Float64(t_2 * t_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]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Log[1 + N[(Exp[N[(t$95$2 * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\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_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \mathsf{log1p}\left(\mathsf{expm1}\left(t_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\right)}}{\sqrt{1 - \left(t_1 + t_0 \cdot \left(t_2 \cdot t_0\right)\right)}}\right)
\end{array}
\end{array}
Initial program 68.1%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr69.0%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr83.4%
log1p-expm1-u83.4%
associate-*l*83.4%
pow283.4%
div-inv83.4%
metadata-eval83.4%
Applied egg-rr83.4%
Final simplification83.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* (* (cos phi1) (cos phi2)) t_2)))
(t_4 (cos (* 0.5 phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (- (* t_4 t_0) (* t_1 (sin (* 0.5 phi2)))) 2.0) t_3))
(sqrt
(-
1.0
(+ t_3 (pow (fma t_4 t_0 (* t_1 (sin (* phi2 -0.5)))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2);
double t_4 = cos((0.5 * phi2));
return R * (2.0 * atan2(sqrt((pow(((t_4 * t_0) - (t_1 * sin((0.5 * phi2)))), 2.0) + t_3)), sqrt((1.0 - (t_3 + pow(fma(t_4, t_0, (t_1 * sin((phi2 * -0.5)))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) t_4 = cos(Float64(0.5 * phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(t_4 * t_0) - Float64(t_1 * sin(Float64(0.5 * phi2)))) ^ 2.0) + t_3)), sqrt(Float64(1.0 - Float64(t_3 + (fma(t_4, t_0, Float64(t_1 * sin(Float64(phi2 * -0.5)))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[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[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(t$95$4 * t$95$0), $MachinePrecision] - N[(t$95$1 * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[Power[N[(t$95$4 * t$95$0 + N[(t$95$1 * N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\right)\\
t_4 := \cos \left(0.5 \cdot \phi_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(t_4 \cdot t_0 - t_1 \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t_3}}{\sqrt{1 - \left(t_3 + {\left(\mathsf{fma}\left(t_4, t_0, t_1 \cdot \sin \left(\phi_2 \cdot -0.5\right)\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 68.1%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr69.0%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr83.4%
Taylor expanded in phi1 around inf 83.4%
fma-neg83.4%
distribute-rgt-neg-in83.4%
sin-neg83.4%
distribute-lft-neg-in83.4%
metadata-eval83.4%
*-commutative83.4%
Simplified83.4%
Final simplification83.4%
(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 68.1%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr69.0%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr83.4%
Final simplification83.4%
(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))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (sqrt (- 1.0 (+ t_0 (* t_1 (* (* (cos phi1) (cos phi2)) t_1)))))))
(if (or (<= lambda1 -2.1e+18) (not (<= lambda1 7e-7)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
t_2)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_2))))))
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);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = sqrt((1.0 - (t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))));
double tmp;
if ((lambda1 <= -2.1e+18) || !(lambda1 <= 7e-7)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), t_2));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), t_2));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sqrt((1.0d0 - (t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))))
if ((lambda1 <= (-2.1d+18)) .or. (.not. (lambda1 <= 7d-7))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), t_2))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.sqrt((1.0 - (t_0 + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)))));
double tmp;
if ((lambda1 <= -2.1e+18) || !(lambda1 <= 7e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), t_2));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), t_2));
}
return tmp;
}
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) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.sqrt((1.0 - (t_0 + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1))))) tmp = 0 if (lambda1 <= -2.1e+18) or not (lambda1 <= 7e-7): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), t_2)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), t_2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_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 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = sqrt(Float64(1.0 - Float64(t_0 + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1))))) tmp = 0.0 if ((lambda1 <= -2.1e+18) || !(lambda1 <= 7e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), t_2))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), t_2))); end return tmp end
function tmp_2 = 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; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = sqrt((1.0 - (t_0 + (t_1 * ((cos(phi1) * cos(phi2)) * t_1))))); tmp = 0.0; if ((lambda1 <= -2.1e+18) || ~((lambda1 <= 7e-7))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), t_2)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$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]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -2.1e+18], N[Not[LessEqual[lambda1, 7e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + 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]), $MachinePrecision]], $MachinePrecision] / t$95$2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$2], $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}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \sqrt{1 - \left(t_0 + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)\right)}\\
\mathbf{if}\;\lambda_1 \leq -2.1 \cdot 10^{+18} \lor \neg \left(\lambda_1 \leq 7 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{t_2}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{t_2}\right)\\
\end{array}
\end{array}
if lambda1 < -2.1e18 or 6.99999999999999968e-7 < lambda1 Initial program 53.6%
div-sub53.6%
sin-diff55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
Applied egg-rr55.0%
div-sub53.6%
sin-diff55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
Applied egg-rr66.9%
Taylor expanded in lambda2 around 0 66.9%
if -2.1e18 < lambda1 < 6.99999999999999968e-7Initial program 81.2%
div-sub81.2%
sin-diff81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
Applied egg-rr81.7%
div-sub81.2%
sin-diff81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
Applied egg-rr98.3%
Taylor expanded in lambda1 around 0 95.9%
*-commutative95.9%
Simplified95.9%
Final simplification82.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (+ t_1 (* t_2 (* t_0 t_2)))))
(if (or (<= lambda1 -2.1e+18) (not (<= lambda1 4.8e-6)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_1 (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
(sqrt (- 1.0 t_3)))))
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt (- 1.0 (+ t_1 (* t_0 (pow (sin (* lambda2 -0.5)) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 + (t_2 * (t_0 * t_2));
double tmp;
if ((lambda1 <= -2.1e+18) || !(lambda1 <= 4.8e-6)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_1 + (t_0 * pow(sin((lambda2 * -0.5)), 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_1 + (t_2 * (t_0 * t_2))
if ((lambda1 <= (-2.1d+18)) .or. (.not. (lambda1 <= 4.8d-6))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), sqrt((1.0d0 - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_1 + (t_0 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
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);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_1 + (t_2 * (t_0 * t_2));
double tmp;
if ((lambda1 <= -2.1e+18) || !(lambda1 <= 4.8e-6)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), Math.sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_1 + (t_0 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) 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_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_1 + (t_2 * (t_0 * t_2)) tmp = 0 if (lambda1 <= -2.1e+18) or not (lambda1 <= 4.8e-6): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), math.sqrt((1.0 - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_1 + (t_0 * math.pow(math.sin((lambda2 * -0.5)), 2.0))))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) 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 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_1 + Float64(t_2 * Float64(t_0 * t_2))) tmp = 0.0 if ((lambda1 <= -2.1e+18) || !(lambda1 <= 4.8e-6)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), sqrt(Float64(1.0 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_1 + Float64(t_0 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_1 + (t_2 * (t_0 * t_2)); tmp = 0.0; if ((lambda1 <= -2.1e+18) || ~((lambda1 <= 4.8e-6))) tmp = R * (2.0 * atan2(sqrt((t_1 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), sqrt((1.0 - t_3)))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_1 + (t_0 * (sin((lambda2 * -0.5)) ^ 2.0))))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[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]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$1 + N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda1, -2.1e+18], N[Not[LessEqual[lambda1, 4.8e-6]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + 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]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[(t$95$0 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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 := {\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_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t_1 + t_2 \cdot \left(t_0 \cdot t_2\right)\\
\mathbf{if}\;\lambda_1 \leq -2.1 \cdot 10^{+18} \lor \neg \left(\lambda_1 \leq 4.8 \cdot 10^{-6}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{\sqrt{1 - t_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3}}{\sqrt{1 - \left(t_1 + t_0 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -2.1e18 or 4.7999999999999998e-6 < lambda1 Initial program 53.6%
div-sub53.6%
sin-diff55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
Applied egg-rr55.0%
div-sub53.6%
sin-diff55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
div-inv55.0%
metadata-eval55.0%
Applied egg-rr66.9%
Taylor expanded in lambda2 around 0 66.9%
if -2.1e18 < lambda1 < 4.7999999999999998e-6Initial program 81.2%
div-sub81.2%
sin-diff81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
Applied egg-rr81.7%
div-sub81.2%
sin-diff81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
div-inv81.7%
metadata-eval81.7%
Applied egg-rr98.3%
Taylor expanded in lambda1 around 0 98.3%
associate-*r*98.3%
*-commutative98.3%
*-commutative98.3%
*-commutative98.3%
Simplified98.3%
Final simplification83.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_3 (sqrt (- 1.0 (+ t_2 t_1)))))
(if (<= lambda2 -7.5e-69)
(*
R
(* 2.0 (atan2 (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))) t_3)))
(if (<= lambda2 8.6e-10)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_2
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
t_3)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (cbrt (pow (sin (* 0.5 (- phi1 phi2))) 6.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 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_3 = sqrt((1.0 - (t_2 + t_1)));
double tmp;
if (lambda2 <= -7.5e-69) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), t_3));
} else if (lambda2 <= 8.6e-10) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), t_3));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + cbrt(pow(sin((0.5 * (phi1 - phi2))), 6.0)))), t_3));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_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);
double t_3 = Math.sqrt((1.0 - (t_2 + t_1)));
double tmp;
if (lambda2 <= -7.5e-69) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), t_3));
} else if (lambda2 <= 8.6e-10) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), t_3));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.cbrt(Math.pow(Math.sin((0.5 * (phi1 - phi2))), 6.0)))), t_3));
}
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 = 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_3 = sqrt(Float64(1.0 - Float64(t_2 + t_1))) tmp = 0.0 if (lambda2 <= -7.5e-69) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), t_3))); elseif (lambda2 <= 8.6e-10) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), t_3))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + cbrt((sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 6.0)))), t_3))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(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[(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]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(t$95$2 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, -7.5e-69], 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] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 8.6e-10], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + 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]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 6.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $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 := {\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_3 := \sqrt{1 - \left(t_2 + t_1\right)}\\
\mathbf{if}\;\lambda_2 \leq -7.5 \cdot 10^{-69}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{t_3}\right)\\
\mathbf{elif}\;\lambda_2 \leq 8.6 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{t_3}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \sqrt[3]{{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{6}}}}{t_3}\right)\\
\end{array}
\end{array}
if lambda2 < -7.5e-69Initial program 59.6%
div-sub59.6%
sin-diff60.7%
div-inv60.7%
metadata-eval60.7%
div-inv60.7%
metadata-eval60.7%
div-inv60.7%
metadata-eval60.7%
div-inv60.7%
metadata-eval60.7%
Applied egg-rr60.7%
if -7.5e-69 < lambda2 < 8.60000000000000029e-10Initial program 79.4%
div-sub79.4%
sin-diff80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr80.4%
div-sub79.4%
sin-diff80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr99.0%
Taylor expanded in lambda2 around 0 96.5%
if 8.60000000000000029e-10 < lambda2 Initial program 56.5%
div-sub56.5%
sin-diff57.0%
div-inv57.0%
metadata-eval57.0%
div-inv57.0%
metadata-eval57.0%
div-inv57.0%
metadata-eval57.0%
div-inv57.0%
metadata-eval57.0%
Applied egg-rr57.0%
add-cbrt-cube56.9%
pow357.0%
pow-pow57.0%
div-inv57.0%
metadata-eval57.0%
metadata-eval57.0%
Applied egg-rr57.0%
Final simplification76.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (cos (* 0.5 phi2)))
(t_3
(pow
(-
(* t_2 (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_4 (+ t_3 t_1)))
(if (or (<= phi1 -0.005) (not (<= phi1 0.0045)))
(*
R
(*
2.0
(atan2
(sqrt t_4)
(sqrt
(-
1.0
(+
t_3
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_1
(pow
(-
(* t_2 (* phi1 0.5))
(* (sin (* phi2 -0.5)) (- -1.0 (* -0.125 (pow phi1 2.0)))))
2.0)))
(sqrt (- 1.0 t_4))))))))
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 = cos((0.5 * phi2));
double t_3 = pow(((t_2 * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_4 = t_3 + t_1;
double tmp;
if ((phi1 <= -0.005) || !(phi1 <= 0.0045)) {
tmp = R * (2.0 * atan2(sqrt(t_4), 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(((t_2 * (phi1 * 0.5)) - (sin((phi2 * -0.5)) * (-1.0 - (-0.125 * pow(phi1, 2.0))))), 2.0))), sqrt((1.0 - t_4))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = cos((0.5d0 * phi2))
t_3 = ((t_2 * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_4 = t_3 + t_1
if ((phi1 <= (-0.005d0)) .or. (.not. (phi1 <= 0.0045d0))) then
tmp = r * (2.0d0 * atan2(sqrt(t_4), sqrt((1.0d0 - (t_3 + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (((t_2 * (phi1 * 0.5d0)) - (sin((phi2 * (-0.5d0))) * ((-1.0d0) - ((-0.125d0) * (phi1 ** 2.0d0))))) ** 2.0d0))), sqrt((1.0d0 - t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.cos((0.5 * phi2));
double t_3 = Math.pow(((t_2 * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_4 = t_3 + t_1;
double tmp;
if ((phi1 <= -0.005) || !(phi1 <= 0.0045)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_4), 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(((t_2 * (phi1 * 0.5)) - (Math.sin((phi2 * -0.5)) * (-1.0 - (-0.125 * Math.pow(phi1, 2.0))))), 2.0))), Math.sqrt((1.0 - t_4))));
}
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.cos((0.5 * phi2)) t_3 = math.pow(((t_2 * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_4 = t_3 + t_1 tmp = 0 if (phi1 <= -0.005) or not (phi1 <= 0.0045): tmp = R * (2.0 * math.atan2(math.sqrt(t_4), 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(((t_2 * (phi1 * 0.5)) - (math.sin((phi2 * -0.5)) * (-1.0 - (-0.125 * math.pow(phi1, 2.0))))), 2.0))), math.sqrt((1.0 - t_4)))) 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 = cos(Float64(0.5 * phi2)) t_3 = Float64(Float64(t_2 * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_4 = Float64(t_3 + t_1) tmp = 0.0 if ((phi1 <= -0.005) || !(phi1 <= 0.0045)) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_4), 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 + (Float64(Float64(t_2 * Float64(phi1 * 0.5)) - Float64(sin(Float64(phi2 * -0.5)) * Float64(-1.0 - Float64(-0.125 * (phi1 ^ 2.0))))) ^ 2.0))), sqrt(Float64(1.0 - t_4))))); 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 = cos((0.5 * phi2)); t_3 = ((t_2 * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_4 = t_3 + t_1; tmp = 0.0; if ((phi1 <= -0.005) || ~((phi1 <= 0.0045))) tmp = R * (2.0 * atan2(sqrt(t_4), sqrt((1.0 - (t_3 + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (((t_2 * (phi1 * 0.5)) - (sin((phi2 * -0.5)) * (-1.0 - (-0.125 * (phi1 ^ 2.0))))) ^ 2.0))), sqrt((1.0 - t_4)))); 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[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(t$95$2 * 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]}, Block[{t$95$4 = N[(t$95$3 + t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi1, -0.005], N[Not[LessEqual[phi1, 0.0045]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$4], $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[(N[(t$95$2 * N[(phi1 * 0.5), $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] * N[(-1.0 - N[(-0.125 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$4), $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 := \cos \left(0.5 \cdot \phi_2\right)\\
t_3 := {\left(t_2 \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_4 := t_3 + t_1\\
\mathbf{if}\;\phi_1 \leq -0.005 \lor \neg \left(\phi_1 \leq 0.0045\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_4}}{\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 + {\left(t_2 \cdot \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot -0.5\right) \cdot \left(-1 - -0.125 \cdot {\phi_1}^{2}\right)\right)}^{2}}}{\sqrt{1 - t_4}}\right)\\
\end{array}
\end{array}
if phi1 < -0.0050000000000000001 or 0.00449999999999999966 < phi1 Initial program 56.6%
div-sub56.6%
sin-diff58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
Applied egg-rr58.4%
div-sub56.6%
sin-diff58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
div-inv58.4%
metadata-eval58.4%
Applied egg-rr86.7%
Taylor expanded in phi2 around 0 66.3%
*-commutative18.8%
Simplified66.3%
if -0.0050000000000000001 < phi1 < 0.00449999999999999966Initial program 79.6%
div-sub79.6%
sin-diff79.6%
div-inv79.6%
metadata-eval79.6%
div-inv79.6%
metadata-eval79.6%
div-inv79.6%
metadata-eval79.6%
div-inv79.6%
metadata-eval79.6%
Applied egg-rr79.6%
Taylor expanded in phi1 around 0 80.0%
associate-+r+80.0%
+-commutative80.0%
associate-*r*80.0%
*-commutative80.0%
metadata-eval80.0%
associate-*r*80.0%
mul-1-neg80.0%
distribute-rgt-neg-out80.0%
*-commutative80.0%
cos-neg80.0%
associate-*r*80.0%
distribute-rgt1-in80.0%
Simplified80.0%
Final simplification73.2%
(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
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_3 (sqrt (- 1.0 (+ t_2 t_1)))))
(if (<= phi2 2.15e+17)
(*
R
(* 2.0 (atan2 (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))) t_3)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_2 (* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.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 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_3 = sqrt((1.0 - (t_2 + t_1)));
double tmp;
if (phi2 <= 2.15e+17) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), t_3));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_3 = sqrt((1.0d0 - (t_2 + t_1)))
if (phi2 <= 2.15d+17) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), t_3))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.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 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_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);
double t_3 = Math.sqrt((1.0 - (t_2 + t_1)));
double tmp;
if (phi2 <= 2.15e+17) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), t_3));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), t_3));
}
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.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_3 = math.sqrt((1.0 - (t_2 + t_1))) tmp = 0 if phi2 <= 2.15e+17: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), t_3)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), t_3)) 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 = 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_3 = sqrt(Float64(1.0 - Float64(t_2 + t_1))) tmp = 0.0 if (phi2 <= 2.15e+17) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), t_3))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.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 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_3 = sqrt((1.0 - (t_2 + t_1))); tmp = 0.0; if (phi2 <= 2.15e+17) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), t_3)); else tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.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[(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[(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]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(t$95$2 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 2.15e+17], 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] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $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 := {\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_3 := \sqrt{1 - \left(t_2 + t_1\right)}\\
\mathbf{if}\;\phi_2 \leq 2.15 \cdot 10^{+17}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{t_3}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{t_3}\right)\\
\end{array}
\end{array}
if phi2 < 2.15e17Initial program 75.0%
div-sub75.0%
sin-diff75.5%
div-inv75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
Applied egg-rr75.5%
if 2.15e17 < phi2 Initial program 43.2%
div-sub43.2%
sin-diff45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
Applied egg-rr45.8%
div-sub43.2%
sin-diff45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
Applied egg-rr84.8%
Taylor expanded in phi1 around 0 55.6%
Final simplification71.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
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_3 (+ t_2 t_1)))
(if (<= phi2 1.26e+16)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 t_3)))))
(*
R
(*
2.0
(atan2
(sqrt t_3)
(sqrt
(-
1.0
(+
t_2
(* (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 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_3 = t_2 + t_1;
double tmp;
if (phi2 <= 1.26e+16) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_2 + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_3 = t_2 + t_1
if (phi2 <= 1.26d+16) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt(t_3), sqrt((1.0d0 - (t_2 + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_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);
double t_3 = t_2 + t_1;
double tmp;
if (phi2 <= 1.26e+16) {
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_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - (t_2 + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 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.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_3 = t_2 + t_1 tmp = 0 if phi2 <= 1.26e+16: 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_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(t_3), math.sqrt((1.0 - (t_2 + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 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 = 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_3 = Float64(t_2 + t_1) tmp = 0.0 if (phi2 <= 1.26e+16) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(t_3), sqrt(Float64(1.0 - Float64(t_2 + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 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 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_3 = t_2 + t_1; tmp = 0.0; if (phi2 <= 1.26e+16) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - t_3)))); else tmp = R * (2.0 * atan2(sqrt(t_3), sqrt((1.0 - (t_2 + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 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[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]}, Block[{t$95$3 = N[(t$95$2 + t$95$1), $MachinePrecision]}, If[LessEqual[phi2, 1.26e+16], 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 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\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}\\
t_3 := t_2 + t_1\\
\mathbf{if}\;\phi_2 \leq 1.26 \cdot 10^{+16}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - t_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3}}{\sqrt{1 - \left(t_2 + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < 1.26e16Initial program 75.0%
div-sub75.0%
sin-diff75.5%
div-inv75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
div-inv75.5%
metadata-eval75.5%
Applied egg-rr75.5%
if 1.26e16 < phi2 Initial program 43.2%
div-sub43.2%
sin-diff45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
Applied egg-rr45.8%
div-sub43.2%
sin-diff45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
div-inv45.8%
metadata-eval45.8%
Applied egg-rr84.8%
Taylor expanded in phi1 around 0 57.6%
Final simplification71.6%
(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 68.1%
div-sub68.1%
sin-diff69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
div-inv69.0%
metadata-eval69.0%
Applied egg-rr69.0%
Final simplification69.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* t_1 t_1)))
(*
(atan2
(sqrt (fma t_0 t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (fma t_0 t_2 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(* R 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 = t_1 * t_1;
return atan2(sqrt(fma(t_0, t_2, pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - fma(t_0, t_2, (0.5 - (cos((phi1 - phi2)) / 2.0)))))) * (R * 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(t_1 * t_1) return Float64(atan(sqrt(fma(t_0, t_2, (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - fma(t_0, t_2, Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))))) * Float64(R * 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[(t$95$1 * t$95$1), $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(t$95$0 * 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$0 * t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := t_1 \cdot t_1\\
\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t_0, t_2, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \mathsf{fma}\left(t_0, t_2, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 68.1%
associate-*r*68.1%
*-commutative68.1%
Simplified68.1%
unpow254.8%
sin-mult52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
Applied egg-rr68.2%
div-sub52.8%
+-inverses52.8%
cos-052.8%
metadata-eval52.8%
distribute-lft-out52.8%
metadata-eval52.8%
*-rgt-identity52.8%
Simplified68.2%
Final simplification68.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(if (or (<= t_1 -0.208) (not (<= t_1 0.2)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* (* (cos phi1) (cos phi2)) t_1)) t_2))
(sqrt (- 1.0 t_0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* (cos phi2) t_0)))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 lambda1)) 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(((lambda1 - lambda2) / 2.0));
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((t_1 <= -0.208) || !(t_1 <= 0.2)) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_2)), sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * t_0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((0.5 * lambda1)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
if ((t_1 <= (-0.208d0)) .or. (.not. (t_1 <= 0.2d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_2)), sqrt((1.0d0 - t_0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (cos(phi2) * t_0))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((t_1 <= -0.208) || !(t_1 <= 0.2)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)) + t_2)), Math.sqrt((1.0 - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi2) * t_0))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((0.5 * lambda1)), 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(((lambda1 - lambda2) / 2.0)) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if (t_1 <= -0.208) or not (t_1 <= 0.2): tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)) + t_2)), math.sqrt((1.0 - t_0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (math.cos(phi2) * t_0))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((0.5 * lambda1)), 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(Float64(lambda1 - lambda2) / 2.0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 tmp = 0.0 if ((t_1 <= -0.208) || !(t_1 <= 0.2)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)) + t_2)), sqrt(Float64(1.0 - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi2) * t_0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(0.5 * lambda1)) ^ 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(((lambda1 - lambda2) / 2.0)); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = 0.0; if ((t_1 <= -0.208) || ~((t_1 <= 0.2))) tmp = R * (2.0 * atan2(sqrt(((t_1 * ((cos(phi1) * cos(phi2)) * t_1)) + t_2)), sqrt((1.0 - t_0)))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * t_0))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((0.5 * lambda1)) ^ 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[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[t$95$1, -0.208], N[Not[LessEqual[t$95$1, 0.2]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $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 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;t_1 \leq -0.208 \lor \neg \left(t_1 \leq 0.2\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right) + t_2}}{\sqrt{1 - t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + \cos \phi_2 \cdot t_0}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < -0.20799999999999999 or 0.20000000000000001 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 64.9%
Taylor expanded in phi2 around 0 51.8%
+-commutative9.5%
associate--r+9.5%
unpow29.5%
1-sub-sin9.5%
unpow29.5%
*-commutative9.5%
Simplified51.9%
Taylor expanded in phi1 around 0 36.3%
sub-neg9.3%
mul-1-neg9.3%
distribute-lft-in9.3%
metadata-eval9.3%
associate-*r*9.3%
associate-*r*9.3%
metadata-eval9.3%
distribute-lft-in9.3%
+-commutative9.3%
mul-1-neg9.3%
sub-neg9.3%
Simplified36.3%
if -0.20799999999999999 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.20000000000000001Initial program 73.6%
Taylor expanded in phi2 around 0 59.8%
+-commutative25.7%
associate--r+25.7%
unpow225.7%
1-sub-sin25.8%
unpow225.8%
*-commutative25.8%
Simplified60.0%
cancel-sign-sub-inv60.0%
*-commutative60.0%
pow260.0%
fma-def60.0%
Applied egg-rr60.0%
Taylor expanded in phi1 around 0 52.4%
Taylor expanded in lambda2 around 0 52.5%
+-commutative52.5%
mul-1-neg52.5%
sub-neg52.5%
Simplified52.5%
Final simplification42.2%
(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 (+ (- (- (/ (cos (- phi1 phi2)) 2.0) 0.5) t_1) 1.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);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1) + 1.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
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(((((cos((phi1 - phi2)) / 2.0d0) - 0.5d0) - t_1) + 1.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));
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(((((Math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1) + 1.0))));
}
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(((((math.cos((phi1 - phi2)) / 2.0) - 0.5) - t_1) + 1.0))))
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(Float64(Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5) - t_1) + 1.0))))) 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(((((cos((phi1 - phi2)) / 2.0) - 0.5) - t_1) + 1.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[(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[(N[(N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision] - t$95$1), $MachinePrecision] + 1.0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := 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{\left(\left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right) - t_1\right) + 1}}\right)
\end{array}
\end{array}
Initial program 68.1%
unpow254.8%
sin-mult52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
Applied egg-rr68.2%
div-sub52.8%
+-inverses52.8%
cos-052.8%
metadata-eval52.8%
distribute-lft-out52.8%
metadata-eval52.8%
*-rgt-identity52.8%
Simplified68.2%
Final simplification68.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_1)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(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(((t_1 * (t_0 * t_1)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), 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(((t_1 * (t_0 * t_1)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), 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(((t_1 * (t_0 * t_1)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), 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(((t_1 * (t_0 * t_1)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), 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(Float64(t_1 * Float64(t_0 * t_1)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), 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(((t_1 * (t_0 * t_1)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), 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[(t$95$1 * N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(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{t_1 \cdot \left(t_0 \cdot t_1\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\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 68.1%
associate--r+17.6%
associate-*l*17.6%
cancel-sign-sub-inv17.6%
div-inv17.6%
metadata-eval17.6%
sqr-sin-a17.6%
cancel-sign-sub-inv17.6%
metadata-eval17.6%
cos-217.6%
Applied egg-rr68.1%
Final simplification68.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 (- lambda2 lambda1))) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2)))
(if (or (<= phi2 -3.6e-9) (not (<= phi2 0.0068)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_3 (sin (* 0.5 lambda1)))))
(sqrt (- (pow (cos (* 0.5 phi2)) 2.0) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 t_3) t_0))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double tmp;
if ((phi2 <= -3.6e-9) || !(phi2 <= 0.0068)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * sin((0.5 * lambda1))))), sqrt((pow(cos((0.5 * phi2)), 2.0) - (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * t_3) + t_0)), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
if ((phi2 <= (-3.6d-9)) .or. (.not. (phi2 <= 0.0068d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_3 * sin((0.5d0 * lambda1))))), sqrt(((cos((0.5d0 * phi2)) ** 2.0d0) - (cos(phi2) * t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * t_3) + t_0)), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double tmp;
if ((phi2 <= -3.6e-9) || !(phi2 <= 0.0068)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * Math.sin((0.5 * lambda1))))), Math.sqrt((Math.pow(Math.cos((0.5 * phi2)), 2.0) - (Math.cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * t_3) + t_0)), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 tmp = 0 if (phi2 <= -3.6e-9) or not (phi2 <= 0.0068): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_3 * math.sin((0.5 * lambda1))))), math.sqrt((math.pow(math.cos((0.5 * phi2)), 2.0) - (math.cos(phi2) * t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * t_3) + t_0)), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) 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(lambda2 - lambda1))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) tmp = 0.0 if ((phi2 <= -3.6e-9) || !(phi2 <= 0.0068)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * sin(Float64(0.5 * lambda1))))), sqrt(Float64((cos(Float64(0.5 * phi2)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * t_3) + t_0)), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; tmp = 0.0; if ((phi2 <= -3.6e-9) || ~((phi2 <= 0.0068))) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * sin((0.5 * lambda1))))), sqrt(((cos((0.5 * phi2)) ^ 2.0) - (cos(phi2) * t_1))))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * t_3) + t_0)), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, If[Or[LessEqual[phi2, -3.6e-9], N[Not[LessEqual[phi2, 0.0068]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * t$95$3), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $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_2 - \lambda_1\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\\
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{-9} \lor \neg \left(\phi_2 \leq 0.0068\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot \sin \left(0.5 \cdot \lambda_1\right)}}{\sqrt{{\cos \left(0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 \cdot t_3 + t_0}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < -3.6e-9 or 0.00679999999999999962 < phi2 Initial program 50.9%
Taylor expanded in lambda2 around 0 38.4%
Taylor expanded in phi1 around 0 39.8%
Simplified39.9%
if -3.6e-9 < phi2 < 0.00679999999999999962Initial program 81.8%
Taylor expanded in phi2 around 0 81.8%
+-commutative18.7%
associate--r+18.7%
unpow218.7%
1-sub-sin18.7%
unpow218.7%
*-commutative18.7%
Simplified82.0%
Final simplification63.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_4 (cos (* phi1 0.5))))
(if (<= phi1 -4.9e-14)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_3 (* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (fma t_4 t_4 (* t_2 (- (cos phi1))))))))
(if (<= phi1 1.6e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 t_3))
(sqrt (- (pow (cos (* 0.5 phi2)) 2.0) (* (cos phi2) t_2))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- (pow t_4 2.0) (* (cos phi1) t_2))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_3 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_4 = cos((phi1 * 0.5));
double tmp;
if (phi1 <= -4.9e-14) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt(fma(t_4, t_4, (t_2 * -cos(phi1))))));
} else if (phi1 <= 1.6e-5) {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_3)), sqrt((pow(cos((0.5 * phi2)), 2.0) - (cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((pow(t_4, 2.0) - (cos(phi1) * t_2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_3 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_4 = cos(Float64(phi1 * 0.5)) tmp = 0.0 if (phi1 <= -4.9e-14) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(fma(t_4, t_4, Float64(t_2 * Float64(-cos(phi1)))))))); elseif (phi1 <= 1.6e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_3)), sqrt(Float64((cos(Float64(0.5 * phi2)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64((t_4 ^ 2.0) - Float64(cos(phi1) * t_2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -4.9e-14], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[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] / N[Sqrt[N[(t$95$4 * t$95$4 + N[(t$95$2 * (-N[Cos[phi1], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.6e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[t$95$4, 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
t_2 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_3 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_4 := \cos \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\phi_1 \leq -4.9 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{\mathsf{fma}\left(t_4, t_4, t_2 \cdot \left(-\cos \phi_1\right)\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.6 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + t_3}}{\sqrt{{\cos \left(0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{{t_4}^{2} - \cos \phi_1 \cdot t_2}}\right)\\
\end{array}
\end{array}
if phi1 < -4.89999999999999995e-14Initial program 52.4%
Taylor expanded in phi2 around 0 53.6%
+-commutative16.7%
associate--r+16.7%
unpow216.7%
1-sub-sin16.8%
unpow216.8%
*-commutative16.8%
Simplified53.8%
cancel-sign-sub-inv53.8%
*-commutative53.8%
pow253.8%
fma-def53.8%
Applied egg-rr53.8%
Taylor expanded in phi2 around 0 54.3%
*-commutative16.5%
Simplified54.3%
if -4.89999999999999995e-14 < phi1 < 1.59999999999999993e-5Initial program 79.9%
Taylor expanded in phi1 around 0 79.9%
Simplified80.0%
if 1.59999999999999993e-5 < phi1 Initial program 62.3%
Taylor expanded in phi2 around 0 62.9%
+-commutative20.3%
associate--r+20.3%
unpow220.3%
1-sub-sin20.3%
unpow220.3%
*-commutative20.3%
Simplified63.0%
Taylor expanded in phi2 around 0 63.4%
Final simplification68.9%
(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 (- lambda2 lambda1))) 2.0))
(t_2 (cos (* phi1 0.5))))
(if (or (<= phi2 -3.6e-9) (not (<= phi2 0.0068)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(*
(* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
(sin (* 0.5 lambda1)))))
(sqrt (- (pow (cos (* 0.5 phi2)) 2.0) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (fma t_2 t_2 (* t_1 (- (cos phi1)))))))))))
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 * (lambda2 - lambda1))), 2.0);
double t_2 = cos((phi1 * 0.5));
double tmp;
if ((phi2 <= -3.6e-9) || !(phi2 <= 0.0068)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin((0.5 * lambda1))))), sqrt((pow(cos((0.5 * phi2)), 2.0) - (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt(fma(t_2, t_2, (t_1 * -cos(phi1))))));
}
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(lambda2 - lambda1))) ^ 2.0 t_2 = cos(Float64(phi1 * 0.5)) tmp = 0.0 if ((phi2 <= -3.6e-9) || !(phi2 <= 0.0068)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * sin(Float64(0.5 * lambda1))))), sqrt(Float64((cos(Float64(0.5 * phi2)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(fma(t_2, t_2, Float64(t_1 * Float64(-cos(phi1)))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -3.6e-9], N[Not[LessEqual[phi2, 0.0068]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$2 * t$95$2 + N[(t$95$1 * (-N[Cos[phi1], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_2 := \cos \left(\phi_1 \cdot 0.5\right)\\
\mathbf{if}\;\phi_2 \leq -3.6 \cdot 10^{-9} \lor \neg \left(\phi_2 \leq 0.0068\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(0.5 \cdot \lambda_1\right)}}{\sqrt{{\cos \left(0.5 \cdot \phi_2\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{\mathsf{fma}\left(t_2, t_2, t_1 \cdot \left(-\cos \phi_1\right)\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -3.6e-9 or 0.00679999999999999962 < phi2 Initial program 50.9%
Taylor expanded in lambda2 around 0 38.4%
Taylor expanded in phi1 around 0 39.8%
Simplified39.9%
if -3.6e-9 < phi2 < 0.00679999999999999962Initial program 81.8%
Taylor expanded in phi2 around 0 81.8%
+-commutative18.7%
associate--r+18.7%
unpow218.7%
1-sub-sin18.7%
unpow218.7%
*-commutative18.7%
Simplified82.0%
cancel-sign-sub-inv82.0%
*-commutative82.0%
pow282.0%
fma-def82.0%
Applied egg-rr82.0%
Taylor expanded in phi2 around 0 82.0%
*-commutative18.7%
Simplified82.0%
Final simplification63.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt
(fma
t_0
t_0
(* (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0) (- (cos phi1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt(fma(t_0, t_0, (pow(sin((-0.5 * (lambda2 - lambda1))), 2.0) * -cos(phi1))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(fma(t_0, t_0, Float64((sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0) * Float64(-cos(phi1)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $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[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$0 * t$95$0 + N[(N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] * (-N[Cos[phi1], $MachinePrecision])), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_1 \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{\mathsf{fma}\left(t_0, t_0, {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2} \cdot \left(-\cos \phi_1\right)\right)}}\right)
\end{array}
\end{array}
Initial program 68.1%
Taylor expanded in phi2 around 0 54.7%
+-commutative15.4%
associate--r+15.4%
unpow215.4%
1-sub-sin15.4%
unpow215.4%
*-commutative15.4%
Simplified54.8%
cancel-sign-sub-inv54.8%
*-commutative54.8%
pow254.8%
fma-def54.8%
Applied egg-rr54.8%
Taylor expanded in phi2 around 0 54.9%
*-commutative16.7%
Simplified54.9%
Final simplification54.9%
(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))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
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)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
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)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
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) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 68.1%
Taylor expanded in phi2 around 0 54.7%
+-commutative15.4%
associate--r+15.4%
unpow215.4%
1-sub-sin15.4%
unpow215.4%
*-commutative15.4%
Simplified54.8%
unpow254.8%
sin-mult52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
div-inv52.8%
metadata-eval52.8%
Applied egg-rr52.8%
div-sub52.8%
+-inverses52.8%
cos-052.8%
metadata-eval52.8%
distribute-lft-out52.8%
metadata-eval52.8%
*-rgt-identity52.8%
Simplified52.8%
Final simplification52.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt
(fma
t_0
t_0
(*
(cos phi1)
(- (* 0.5 (cos (* 2.0 (* -0.5 (- lambda2 lambda1))))) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt(fma(t_0, t_0, (cos(phi1) * ((0.5 * cos((2.0 * (-0.5 * (lambda2 - lambda1))))) - 0.5))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(fma(t_0, t_0, Float64(cos(phi1) * Float64(Float64(0.5 * cos(Float64(2.0 * Float64(-0.5 * Float64(lambda2 - lambda1))))) - 0.5))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $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[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$0 * t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(2.0 * N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_1 \cdot 0.5\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{\mathsf{fma}\left(t_0, t_0, \cos \phi_1 \cdot \left(0.5 \cdot \cos \left(2 \cdot \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right) - 0.5\right)\right)}}\right)
\end{array}
\end{array}
Initial program 68.1%
Taylor expanded in phi2 around 0 54.7%
+-commutative15.4%
associate--r+15.4%
unpow215.4%
1-sub-sin15.4%
unpow215.4%
*-commutative15.4%
Simplified54.8%
cancel-sign-sub-inv54.8%
*-commutative54.8%
pow254.8%
fma-def54.8%
Applied egg-rr54.8%
Taylor expanded in phi1 around 0 42.2%
unpow215.4%
sqr-sin-a15.4%
Applied egg-rr42.2%
Final simplification42.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sqrt (+ t_1 (* (cos phi2) t_0))))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (pow (cos (* phi1 0.5)) 2.0)))
(if (<= lambda1 -7.5e+54)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_3 (* (* (cos phi1) (cos phi2)) t_3)) t_1))
(sqrt (- 1.0 t_0)))))
(if (<= lambda1 6600.0)
(*
R
(*
2.0
(atan2
t_2
(sqrt (- t_4 (* (cos phi1) (pow (sin (* lambda2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
t_2
(sqrt (- t_4 (* (cos phi1) (pow (sin (* 0.5 lambda1)) 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 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sqrt((t_1 + (cos(phi2) * t_0)));
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = pow(cos((phi1 * 0.5)), 2.0);
double tmp;
if (lambda1 <= -7.5e+54) {
tmp = R * (2.0 * atan2(sqrt(((t_3 * ((cos(phi1) * cos(phi2)) * t_3)) + t_1)), sqrt((1.0 - t_0))));
} else if (lambda1 <= 6600.0) {
tmp = R * (2.0 * atan2(t_2, sqrt((t_4 - (cos(phi1) * pow(sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_2, sqrt((t_4 - (cos(phi1) * pow(sin((0.5 * lambda1)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = sqrt((t_1 + (cos(phi2) * t_0)))
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = cos((phi1 * 0.5d0)) ** 2.0d0
if (lambda1 <= (-7.5d+54)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_3 * ((cos(phi1) * cos(phi2)) * t_3)) + t_1)), sqrt((1.0d0 - t_0))))
else if (lambda1 <= 6600.0d0) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((t_4 - (cos(phi1) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_2, sqrt((t_4 - (cos(phi1) * (sin((0.5d0 * lambda1)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sqrt((t_1 + (Math.cos(phi2) * t_0)));
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.pow(Math.cos((phi1 * 0.5)), 2.0);
double tmp;
if (lambda1 <= -7.5e+54) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_3 * ((Math.cos(phi1) * Math.cos(phi2)) * t_3)) + t_1)), Math.sqrt((1.0 - t_0))));
} else if (lambda1 <= 6600.0) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((t_4 - (Math.cos(phi1) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt((t_4 - (Math.cos(phi1) * Math.pow(Math.sin((0.5 * lambda1)), 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.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sqrt((t_1 + (math.cos(phi2) * t_0))) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.pow(math.cos((phi1 * 0.5)), 2.0) tmp = 0 if lambda1 <= -7.5e+54: tmp = R * (2.0 * math.atan2(math.sqrt(((t_3 * ((math.cos(phi1) * math.cos(phi2)) * t_3)) + t_1)), math.sqrt((1.0 - t_0)))) elif lambda1 <= 6600.0: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((t_4 - (math.cos(phi1) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_2, math.sqrt((t_4 - (math.cos(phi1) * math.pow(math.sin((0.5 * lambda1)), 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(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sqrt(Float64(t_1 + Float64(cos(phi2) * t_0))) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = cos(Float64(phi1 * 0.5)) ^ 2.0 tmp = 0.0 if (lambda1 <= -7.5e+54) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_3 * Float64(Float64(cos(phi1) * cos(phi2)) * t_3)) + t_1)), sqrt(Float64(1.0 - t_0))))); elseif (lambda1 <= 6600.0) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(t_4 - Float64(cos(phi1) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt(Float64(t_4 - Float64(cos(phi1) * (sin(Float64(0.5 * lambda1)) ^ 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 - phi2) / 2.0)) ^ 2.0; t_2 = sqrt((t_1 + (cos(phi2) * t_0))); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = cos((phi1 * 0.5)) ^ 2.0; tmp = 0.0; if (lambda1 <= -7.5e+54) tmp = R * (2.0 * atan2(sqrt(((t_3 * ((cos(phi1) * cos(phi2)) * t_3)) + t_1)), sqrt((1.0 - t_0)))); elseif (lambda1 <= 6600.0) tmp = R * (2.0 * atan2(t_2, sqrt((t_4 - (cos(phi1) * (sin((lambda2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_2, sqrt((t_4 - (cos(phi1) * (sin((0.5 * lambda1)) ^ 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[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[lambda1, -7.5e+54], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$3 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 6600.0], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(t$95$4 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[(t$95$4 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sqrt{t_1 + \cos \phi_2 \cdot t_0}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := {\cos \left(\phi_1 \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 \leq -7.5 \cdot 10^{+54}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_3 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_3\right) + t_1}}{\sqrt{1 - t_0}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 6600:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{t_4 - \cos \phi_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{t_4 - \cos \phi_1 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}}}\right)\\
\end{array}
\end{array}
if lambda1 < -7.50000000000000042e54Initial program 49.5%
Taylor expanded in phi2 around 0 46.7%
+-commutative8.4%
associate--r+8.4%
unpow28.4%
1-sub-sin8.4%
unpow28.4%
*-commutative8.4%
Simplified46.7%
Taylor expanded in phi1 around 0 34.6%
sub-neg8.0%
mul-1-neg8.0%
distribute-lft-in8.0%
metadata-eval8.0%
associate-*r*8.0%
associate-*r*8.0%
metadata-eval8.0%
distribute-lft-in8.0%
+-commutative8.0%
mul-1-neg8.0%
sub-neg8.0%
Simplified34.6%
if -7.50000000000000042e54 < lambda1 < 6600Initial program 78.8%
Taylor expanded in phi2 around 0 60.5%
+-commutative20.1%
associate--r+20.1%
unpow220.1%
1-sub-sin20.1%
unpow220.1%
*-commutative20.1%
Simplified60.6%
cancel-sign-sub-inv60.6%
*-commutative60.6%
pow260.6%
fma-def60.6%
Applied egg-rr60.6%
Taylor expanded in phi1 around 0 48.5%
Taylor expanded in lambda1 around 0 48.5%
mul-1-neg48.5%
+-commutative48.5%
sub-neg48.5%
*-commutative48.5%
Simplified48.5%
if 6600 < lambda1 Initial program 58.1%
Taylor expanded in phi2 around 0 47.9%
+-commutative10.1%
associate--r+10.1%
unpow210.1%
1-sub-sin10.1%
unpow210.1%
*-commutative10.1%
Simplified48.0%
cancel-sign-sub-inv48.0%
*-commutative48.0%
pow248.0%
fma-def48.0%
Applied egg-rr48.0%
Taylor expanded in phi1 around 0 34.1%
Taylor expanded in lambda2 around 0 34.2%
+-commutative34.2%
mul-1-neg34.2%
sub-neg34.2%
Simplified34.2%
Final simplification42.3%
(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 68.1%
Taylor expanded in phi2 around 0 54.7%
+-commutative15.4%
associate--r+15.4%
unpow215.4%
1-sub-sin15.4%
unpow215.4%
*-commutative15.4%
Simplified54.8%
Taylor expanded in phi1 around 0 36.3%
sub-neg11.5%
mul-1-neg11.5%
distribute-lft-in11.5%
metadata-eval11.5%
associate-*r*11.5%
associate-*r*11.5%
metadata-eval11.5%
distribute-lft-in11.5%
+-commutative11.5%
mul-1-neg11.5%
sub-neg11.5%
Simplified36.3%
Final simplification36.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((1.0 - pow(sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt((1.0d0 - (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt((1.0 - (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 68.1%
Taylor expanded in phi2 around 0 54.7%
+-commutative15.4%
associate--r+15.4%
unpow215.4%
1-sub-sin15.4%
unpow215.4%
*-commutative15.4%
Simplified54.8%
cancel-sign-sub-inv54.8%
*-commutative54.8%
pow254.8%
fma-def54.8%
Applied egg-rr54.8%
Taylor expanded in phi1 around 0 42.2%
Taylor expanded in phi1 around 0 36.0%
neg-mul-136.0%
sub-neg36.0%
Simplified36.0%
Final simplification36.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (cos phi1) (cos phi2)) (pow (sin (* 0.5 lambda1)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + ((cos(phi1) * cos(phi2)) * pow(sin((0.5 * lambda1)), 2.0)))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + ((cos(phi1) * cos(phi2)) * (sin((0.5d0 * lambda1)) ** 2.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.pow(Math.sin((0.5 * lambda1)), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + ((math.cos(phi1) * math.cos(phi2)) * math.pow(math.sin((0.5 * lambda1)), 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(cos(phi1) * cos(phi2)) * (sin(Float64(0.5 * lambda1)) ^ 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + ((cos(phi1) * cos(phi2)) * (sin((0.5 * lambda1)) ^ 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}\right)
\end{array}
Initial program 68.1%
Taylor expanded in lambda2 around 0 47.9%
Taylor expanded in lambda1 around 0 17.6%
Taylor expanded in lambda2 around 0 17.6%
associate-*r*17.6%
*-commutative17.6%
*-commutative17.6%
Simplified17.6%
Final simplification17.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- phi1 phi2)))))
(*
R
(*
2.0
(atan2
t_0
(sqrt
(-
(- 1.0 (pow t_0 2.0))
(*
(* (cos phi1) (cos phi2))
(+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (phi1 - phi2)));
return R * (2.0 * atan2(t_0, sqrt(((1.0 - pow(t_0, 2.0)) - ((cos(phi1) * cos(phi2)) * (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
t_0 = sin((0.5d0 * (phi1 - phi2)))
code = r * (2.0d0 * atan2(t_0, sqrt(((1.0d0 - (t_0 ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (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.sin((0.5 * (phi1 - phi2)));
return R * (2.0 * Math.atan2(t_0, Math.sqrt(((1.0 - Math.pow(t_0, 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (phi1 - phi2))) return R * (2.0 * math.atan2(t_0, math.sqrt(((1.0 - math.pow(t_0, 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(phi1 - phi2))) return Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(Float64(1.0 - (t_0 ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (phi1 - phi2))); tmp = R * (2.0 * atan2(t_0, sqrt(((1.0 - (t_0 ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (0.5 + (-0.5 * cos((lambda1 - lambda2))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision] - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * 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 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_0}{\sqrt{\left(1 - {t_0}^{2}\right) - \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)
\end{array}
\end{array}
Initial program 68.1%
Taylor expanded in lambda2 around 0 47.9%
Taylor expanded in lambda1 around 0 17.6%
associate--r+17.6%
associate-*l*17.6%
cancel-sign-sub-inv17.6%
div-inv17.6%
metadata-eval17.6%
sqr-sin-a17.6%
cancel-sign-sub-inv17.6%
metadata-eval17.6%
cos-217.6%
Applied egg-rr17.6%
Final simplification17.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * 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
code = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)
\end{array}
Initial program 68.1%
Taylor expanded in lambda2 around 0 47.9%
Taylor expanded in lambda1 around 0 17.6%
Taylor expanded in phi1 around 0 16.4%
Final simplification16.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi1) * 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
code = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[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]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)}}\right)
\end{array}
Initial program 68.1%
Taylor expanded in lambda2 around 0 47.9%
Taylor expanded in lambda1 around 0 17.6%
Taylor expanded in phi2 around 0 16.7%
*-commutative16.7%
Simplified16.7%
Final simplification16.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(+
(pow (cos (* phi1 0.5)) 2.0)
(*
(cos phi1)
(- (* 0.5 (cos (* 2.0 (* -0.5 (- lambda2 lambda1))))) 0.5))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((pow(cos((phi1 * 0.5)), 2.0) + (cos(phi1) * ((0.5 * cos((2.0 * (-0.5 * (lambda2 - lambda1))))) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * ((0.5d0 * cos((2.0d0 * ((-0.5d0) * (lambda2 - lambda1))))) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * ((0.5 * Math.cos((2.0 * (-0.5 * (lambda2 - lambda1))))) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) + (math.cos(phi1) * ((0.5 * math.cos((2.0 * (-0.5 * (lambda2 - lambda1))))) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * Float64(Float64(0.5 * cos(Float64(2.0 * Float64(-0.5 * Float64(lambda2 - lambda1))))) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * ((0.5 * cos((2.0 * (-0.5 * (lambda2 - lambda1))))) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(2.0 * N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot \left(0.5 \cdot \cos \left(2 \cdot \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)\right) - 0.5\right)}}\right)
\end{array}
Initial program 68.1%
Taylor expanded in lambda2 around 0 47.9%
Taylor expanded in lambda1 around 0 17.6%
Taylor expanded in phi2 around 0 15.4%
+-commutative15.4%
associate--r+15.4%
unpow215.4%
1-sub-sin15.4%
unpow215.4%
*-commutative15.4%
Simplified15.4%
unpow215.4%
sqr-sin-a15.4%
Applied egg-rr15.4%
Final simplification15.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), 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
code = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), 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) {
return R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $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}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
Initial program 68.1%
Taylor expanded in lambda2 around 0 47.9%
Taylor expanded in lambda1 around 0 17.6%
Taylor expanded in phi2 around 0 15.4%
+-commutative15.4%
associate--r+15.4%
unpow215.4%
1-sub-sin15.4%
unpow215.4%
*-commutative15.4%
Simplified15.4%
Taylor expanded in phi1 around 0 11.5%
sub-neg11.5%
mul-1-neg11.5%
distribute-lft-in11.5%
metadata-eval11.5%
associate-*r*11.5%
associate-*r*11.5%
metadata-eval11.5%
distribute-lft-in11.5%
+-commutative11.5%
mul-1-neg11.5%
sub-neg11.5%
Simplified11.5%
Final simplification11.5%
herbie shell --seed 2023333
(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))))))))))