
(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 27 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+
(- 1.0 t_1)
(*
t_0
(-
(/
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2)))
2.0)
0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \left(\frac{\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
div-sub63.2%
sin-diff64.3%
Applied egg-rr64.3%
div-sub63.2%
sin-diff64.3%
Applied egg-rr79.1%
sin-mult79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
cos-sum79.1%
cos-279.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
associate-*r*79.1%
metadata-eval79.1%
*-lft-identity79.1%
Simplified79.1%
cos-diff79.7%
Applied egg-rr79.7%
Final simplification79.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_1 t_1))))
(sqrt
(+
(-
1.0
(pow
(fma
(sin (* phi1 0.5))
(cos (* phi2 0.5))
(* (- (cos (* phi1 0.5))) (sin (* phi2 0.5))))
2.0))
(* t_0 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(fma(sin((phi1 * 0.5)), cos((phi2 * 0.5)), (-cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0)) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (fma(sin(Float64(phi1 * 0.5)), cos(Float64(phi2 * 0.5)), Float64(Float64(-cos(Float64(phi1 * 0.5))) * sin(Float64(phi2 * 0.5)))) ^ 2.0)) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] + N[((-N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]) * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - {\left(\mathsf{fma}\left(\sin \left(\phi_1 \cdot 0.5\right), \cos \left(\phi_2 \cdot 0.5\right), \left(-\cos \left(\phi_1 \cdot 0.5\right)\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)\right)}^{2}\right) + t\_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
div-sub63.2%
sin-diff64.3%
Applied egg-rr64.3%
div-sub63.2%
sin-diff64.3%
Applied egg-rr79.1%
sin-mult79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
cos-sum79.1%
cos-279.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
associate-*r*79.1%
metadata-eval79.1%
*-lft-identity79.1%
Simplified79.1%
cancel-sign-sub-inv79.1%
fma-define79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
div-inv79.2%
metadata-eval79.2%
Applied egg-rr79.2%
Final simplification79.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3 (- 1.0 t_2)))
(if (or (<= lambda1 -3.9e-5) (not (<= lambda1 5.2e-7)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0)))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)))
(sqrt (+ t_3 (* t_1 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_1 (* t_0 t_0))))
(sqrt (+ t_3 (* t_1 (- (/ (cos lambda2) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = 1.0 - t_2;
double tmp;
if ((lambda1 <= -3.9e-5) || !(lambda1 <= 5.2e-7)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))) + pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0))), sqrt((t_3 + (t_1 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (t_1 * (t_0 * t_0)))), sqrt((t_3 + (t_1 * ((cos(lambda2) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_3 = 1.0d0 - t_2
if ((lambda1 <= (-3.9d-5)) .or. (.not. (lambda1 <= 5.2d-7))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))) + (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0))), sqrt((t_3 + (t_1 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (t_1 * (t_0 * t_0)))), sqrt((t_3 + (t_1 * ((cos(lambda2) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_3 = 1.0 - t_2;
double tmp;
if ((lambda1 <= -3.9e-5) || !(lambda1 <= 5.2e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))) + Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0))), Math.sqrt((t_3 + (t_1 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_1 * (t_0 * t_0)))), Math.sqrt((t_3 + (t_1 * ((Math.cos(lambda2) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_3 = 1.0 - t_2 tmp = 0 if (lambda1 <= -3.9e-5) or not (lambda1 <= 5.2e-7): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))) + math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0))), math.sqrt((t_3 + (t_1 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (t_1 * (t_0 * t_0)))), math.sqrt((t_3 + (t_1 * ((math.cos(lambda2) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_3 = Float64(1.0 - t_2) tmp = 0.0 if ((lambda1 <= -3.9e-5) || !(lambda1 <= 5.2e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))) + (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0))), sqrt(Float64(t_3 + Float64(t_1 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_1 * Float64(t_0 * t_0)))), sqrt(Float64(t_3 + Float64(t_1 * Float64(Float64(cos(lambda2) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_3 = 1.0 - t_2; tmp = 0.0; if ((lambda1 <= -3.9e-5) || ~((lambda1 <= 5.2e-7))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))) + (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0))), sqrt((t_3 + (t_1 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (t_1 * (t_0 * t_0)))), sqrt((t_3 + (t_1 * ((cos(lambda2) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - t$95$2), $MachinePrecision]}, If[Or[LessEqual[lambda1, -3.9e-5], N[Not[LessEqual[lambda1, 5.2e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 + N[(t$95$1 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 + N[(t$95$1 * N[(N[(N[Cos[lambda2], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_3 := 1 - t\_2\\
\mathbf{if}\;\lambda_1 \leq -3.9 \cdot 10^{-5} \lor \neg \left(\lambda_1 \leq 5.2 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right) + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}}}{\sqrt{t\_3 + t\_1 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_1 \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{t\_3 + t\_1 \cdot \left(\frac{\cos \lambda_2}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -3.8999999999999999e-5 or 5.19999999999999998e-7 < lambda1 Initial program 50.9%
associate-*l*50.9%
Simplified50.9%
div-sub50.9%
sin-diff52.0%
Applied egg-rr52.0%
div-sub50.9%
sin-diff52.0%
Applied egg-rr62.5%
sin-mult62.5%
div-inv62.5%
metadata-eval62.5%
*-commutative62.5%
div-inv62.5%
metadata-eval62.5%
*-commutative62.5%
cos-sum62.5%
cos-262.5%
div-inv62.5%
metadata-eval62.5%
*-commutative62.5%
Applied egg-rr62.5%
div-sub62.5%
+-inverses62.5%
cos-062.5%
metadata-eval62.5%
associate-*r*62.5%
metadata-eval62.5%
*-lft-identity62.5%
Simplified62.5%
Taylor expanded in lambda2 around 0 62.6%
if -3.8999999999999999e-5 < lambda1 < 5.19999999999999998e-7Initial program 76.3%
associate-*l*76.3%
Simplified76.3%
div-sub76.3%
sin-diff77.4%
Applied egg-rr77.4%
div-sub76.3%
sin-diff77.4%
Applied egg-rr96.8%
sin-mult96.8%
div-inv96.8%
metadata-eval96.8%
*-commutative96.8%
div-inv96.8%
metadata-eval96.8%
*-commutative96.8%
cos-sum96.8%
cos-296.8%
div-inv96.8%
metadata-eval96.8%
*-commutative96.8%
Applied egg-rr96.8%
div-sub96.8%
+-inverses96.8%
cos-096.8%
metadata-eval96.8%
associate-*r*96.8%
metadata-eval96.8%
*-lft-identity96.8%
Simplified96.8%
Taylor expanded in lambda1 around 0 96.8%
cos-neg96.8%
Simplified96.8%
Final simplification79.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0))
(t_1
(sqrt
(+
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))
(if (or (<= lambda2 -3000000000000.0) (not (<= lambda2 2.85e-9)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+ (* (cos phi1) (* (cos phi2) (pow (sin (* lambda1 0.5)) 2.0))) t_0))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0);
double t_1 = sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))));
double tmp;
if ((lambda2 <= -3000000000000.0) || !(lambda2 <= 2.85e-9)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((lambda1 * 0.5)), 2.0))) + t_0)), 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) :: tmp
t_0 = ((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0
t_1 = sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))
if ((lambda2 <= (-3000000000000.0d0)) .or. (.not. (lambda2 <= 2.85d-9))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5d0)) ** 2.0d0))) + t_0)), 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.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0);
double t_1 = Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))));
double tmp;
if ((lambda2 <= -3000000000000.0) || !(lambda2 <= 2.85e-9)) {
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_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))) + t_0)), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0) t_1 = math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))) tmp = 0 if (lambda2 <= -3000000000000.0) or not (lambda2 <= 2.85e-9): 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_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda1 * 0.5)), 2.0))) + t_0)), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0 t_1 = sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)))) tmp = 0.0 if ((lambda2 <= -3000000000000.0) || !(lambda2 <= 2.85e-9)) 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_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))) + t_0)), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0; t_1 = sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))); tmp = 0.0; if ((lambda2 <= -3000000000000.0) || ~((lambda2 <= 2.85e-9))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_1)); else tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((lambda1 * 0.5)) ^ 2.0))) + t_0)), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -3000000000000.0], N[Not[LessEqual[lambda2, 2.85e-9]], $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$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2}\\
t_1 := \sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}\\
\mathbf{if}\;\lambda_2 \leq -3000000000000 \lor \neg \left(\lambda_2 \leq 2.85 \cdot 10^{-9}\right):\\
\;\;\;\;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\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right) + t\_0}}{t\_1}\right)\\
\end{array}
\end{array}
if lambda2 < -3e12 or 2.8499999999999999e-9 < lambda2 Initial program 54.3%
associate-*l*54.3%
Simplified54.3%
div-sub54.3%
sin-diff55.0%
Applied egg-rr55.0%
div-sub54.3%
sin-diff55.0%
Applied egg-rr64.5%
sin-mult64.6%
div-inv64.6%
metadata-eval64.6%
*-commutative64.6%
div-inv64.6%
metadata-eval64.6%
*-commutative64.6%
cos-sum64.6%
cos-264.6%
div-inv64.6%
metadata-eval64.6%
*-commutative64.6%
Applied egg-rr64.6%
div-sub64.6%
+-inverses64.6%
cos-064.6%
metadata-eval64.6%
associate-*r*64.6%
metadata-eval64.6%
*-lft-identity64.6%
Simplified64.6%
Taylor expanded in lambda1 around 0 64.7%
if -3e12 < lambda2 < 2.8499999999999999e-9Initial program 72.9%
associate-*l*72.9%
Simplified72.9%
div-sub72.9%
sin-diff74.4%
Applied egg-rr74.4%
div-sub72.9%
sin-diff74.4%
Applied egg-rr95.1%
sin-mult95.2%
div-inv95.2%
metadata-eval95.2%
*-commutative95.2%
div-inv95.2%
metadata-eval95.2%
*-commutative95.2%
cos-sum95.1%
cos-295.2%
div-inv95.2%
metadata-eval95.2%
*-commutative95.2%
Applied egg-rr95.2%
div-sub95.2%
+-inverses95.2%
cos-095.2%
metadata-eval95.2%
associate-*r*95.2%
metadata-eval95.2%
*-lft-identity95.2%
Simplified95.2%
Taylor expanded in lambda2 around 0 94.7%
Final simplification79.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (* t_2 (* t_1 t_1)))
(t_4 (* t_2 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))
(t_5 (- 1.0 t_0)))
(if (<= lambda1 -3.8e-40)
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- t_5 t_3)))))
(if (<= lambda1 0.000235)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (sin (* phi2 0.5)) (cos (* phi1 0.5))))
2.0)
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
(sqrt (+ t_5 t_4)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_3))
(sqrt (+ (+ 1.0 (- (/ (cos (- phi2 phi1)) 2.0) 0.5)) t_4)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = t_2 * (t_1 * t_1);
double t_4 = t_2 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5);
double t_5 = 1.0 - t_0;
double tmp;
if (lambda1 <= -3.8e-40) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((t_5 - t_3))));
} else if (lambda1 <= 0.000235) {
tmp = R * (2.0 * atan2(sqrt((pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))), 2.0) + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), sqrt((t_5 + t_4))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt(((1.0 + ((cos((phi2 - phi1)) / 2.0) - 0.5)) + 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) :: t_5
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
t_3 = t_2 * (t_1 * t_1)
t_4 = t_2 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)
t_5 = 1.0d0 - t_0
if (lambda1 <= (-3.8d-40)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((t_5 - t_3))))
else if (lambda1 <= 0.000235d0) then
tmp = r * (2.0d0 * atan2(sqrt(((((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (sin((phi2 * 0.5d0)) * cos((phi1 * 0.5d0)))) ** 2.0d0) + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), sqrt((t_5 + t_4))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_3)), sqrt(((1.0d0 + ((cos((phi2 - phi1)) / 2.0d0) - 0.5d0)) + t_4))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = t_2 * (t_1 * t_1);
double t_4 = t_2 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5);
double t_5 = 1.0 - t_0;
double tmp;
if (lambda1 <= -3.8e-40) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((t_5 - t_3))));
} else if (lambda1 <= 0.000235) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.sin((phi2 * 0.5)) * Math.cos((phi1 * 0.5)))), 2.0) + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), Math.sqrt((t_5 + t_4))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_3)), Math.sqrt(((1.0 + ((Math.cos((phi2 - phi1)) / 2.0) - 0.5)) + t_4))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = t_2 * (t_1 * t_1) t_4 = t_2 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5) t_5 = 1.0 - t_0 tmp = 0 if lambda1 <= -3.8e-40: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((t_5 - t_3)))) elif lambda1 <= 0.000235: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.sin((phi2 * 0.5)) * math.cos((phi1 * 0.5)))), 2.0) + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), math.sqrt((t_5 + t_4)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_3)), math.sqrt(((1.0 + ((math.cos((phi2 - phi1)) / 2.0) - 0.5)) + t_4)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64(t_2 * Float64(t_1 * t_1)) t_4 = Float64(t_2 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)) t_5 = Float64(1.0 - t_0) tmp = 0.0 if (lambda1 <= -3.8e-40) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(t_5 - t_3))))); elseif (lambda1 <= 0.000235) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(sin(Float64(phi2 * 0.5)) * cos(Float64(phi1 * 0.5)))) ^ 2.0) + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), sqrt(Float64(t_5 + t_4))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi2 - phi1)) / 2.0) - 0.5)) + t_4))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); t_3 = t_2 * (t_1 * t_1); t_4 = t_2 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5); t_5 = 1.0 - t_0; tmp = 0.0; if (lambda1 <= -3.8e-40) tmp = R * (2.0 * atan2(sqrt((t_3 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((t_5 - t_3)))); elseif (lambda1 <= 0.000235) tmp = R * (2.0 * atan2(sqrt(((((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (sin((phi2 * 0.5)) * cos((phi1 * 0.5)))) ^ 2.0) + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), sqrt((t_5 + t_4)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt(((1.0 + ((cos((phi2 - phi1)) / 2.0) - 0.5)) + t_4)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[(t$95$2 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(1.0 - t$95$0), $MachinePrecision]}, If[LessEqual[lambda1, -3.8e-40], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$5 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 0.000235], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + 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] / N[Sqrt[N[(t$95$5 + t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + t$95$4), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := t\_2 \cdot \left(t\_1 \cdot t\_1\right)\\
t_4 := t\_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)\\
t_5 := 1 - t\_0\\
\mathbf{if}\;\lambda_1 \leq -3.8 \cdot 10^{-40}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{t\_5 - t\_3}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 0.000235:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \sin \left(\phi_2 \cdot 0.5\right) \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)}^{2} + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{t\_5 + t\_4}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_2 - \phi_1\right)}{2} - 0.5\right)\right) + t\_4}}\right)\\
\end{array}
\end{array}
if lambda1 < -3.7999999999999999e-40Initial program 57.8%
associate-*l*57.8%
Simplified57.8%
div-sub57.8%
sin-diff58.7%
Applied egg-rr58.7%
if -3.7999999999999999e-40 < lambda1 < 2.34999999999999993e-4Initial program 74.6%
associate-*l*74.6%
Simplified74.6%
div-sub74.6%
sin-diff75.7%
Applied egg-rr75.7%
div-sub74.6%
sin-diff75.7%
Applied egg-rr97.0%
sin-mult97.1%
div-inv97.1%
metadata-eval97.1%
*-commutative97.1%
div-inv97.1%
metadata-eval97.1%
*-commutative97.1%
cos-sum97.1%
cos-297.1%
div-inv97.1%
metadata-eval97.1%
*-commutative97.1%
Applied egg-rr97.1%
div-sub97.1%
+-inverses97.1%
cos-097.1%
metadata-eval97.1%
associate-*r*97.1%
metadata-eval97.1%
*-lft-identity97.1%
Simplified97.1%
Taylor expanded in lambda1 around 0 94.1%
if 2.34999999999999993e-4 < lambda1 Initial program 49.7%
associate-*l*49.7%
Simplified49.8%
div-sub49.8%
sin-diff50.9%
Applied egg-rr50.9%
div-sub49.8%
sin-diff50.9%
Applied egg-rr60.0%
sin-mult60.1%
div-inv60.1%
metadata-eval60.1%
*-commutative60.1%
div-inv60.1%
metadata-eval60.1%
*-commutative60.1%
cos-sum60.1%
cos-260.1%
div-inv60.1%
metadata-eval60.1%
*-commutative60.1%
Applied egg-rr60.1%
div-sub60.1%
+-inverses60.1%
cos-060.1%
metadata-eval60.1%
associate-*r*60.1%
metadata-eval60.1%
*-lft-identity60.1%
Simplified60.1%
sin-diff51.2%
div-sub51.2%
unpow251.2%
sin-mult51.2%
Applied egg-rr51.2%
div-sub51.2%
+-inverses51.2%
+-inverses51.2%
+-inverses51.2%
cos-051.2%
metadata-eval51.2%
Simplified51.2%
Final simplification72.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+ (- 1.0 t_1) (* t_0 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
div-sub63.2%
sin-diff64.3%
Applied egg-rr64.3%
div-sub63.2%
sin-diff64.3%
Applied egg-rr79.1%
sin-mult79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
cos-sum79.1%
cos-279.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
associate-*r*79.1%
metadata-eval79.1%
*-lft-identity79.1%
Simplified79.1%
Final simplification79.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (* phi1 0.5)))
(t_2 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(t_3
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (sqrt (+ t_3 (* t_0 (* t_4 t_4))))))
(if (or (<= phi2 -0.017) (not (<= phi2 0.0029)))
(* R (* 2.0 (atan2 t_5 (sqrt (+ (- 1.0 t_3) (* (cos phi2) t_2))))))
(*
R
(*
2.0
(atan2
t_5
(sqrt
(+
(-
1.0
(pow
(+
t_1
(* phi2 (- (* -0.125 (* phi2 t_1)) (* 0.5 (cos (* phi1 0.5))))))
2.0))
(* t_0 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin((phi1 * 0.5));
double t_2 = (cos((lambda1 - lambda2)) / 2.0) - 0.5;
double t_3 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = sqrt((t_3 + (t_0 * (t_4 * t_4))));
double tmp;
if ((phi2 <= -0.017) || !(phi2 <= 0.0029)) {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_3) + (cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - pow((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * cos((phi1 * 0.5)))))), 2.0)) + (t_0 * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin((phi1 * 0.5d0))
t_2 = (cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0
t_3 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_4 = sin(((lambda1 - lambda2) / 2.0d0))
t_5 = sqrt((t_3 + (t_0 * (t_4 * t_4))))
if ((phi2 <= (-0.017d0)) .or. (.not. (phi2 <= 0.0029d0))) then
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 - t_3) + (cos(phi2) * t_2)))))
else
tmp = r * (2.0d0 * atan2(t_5, sqrt(((1.0d0 - ((t_1 + (phi2 * (((-0.125d0) * (phi2 * t_1)) - (0.5d0 * cos((phi1 * 0.5d0)))))) ** 2.0d0)) + (t_0 * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin((phi1 * 0.5));
double t_2 = (Math.cos((lambda1 - lambda2)) / 2.0) - 0.5;
double t_3 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_4 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_5 = Math.sqrt((t_3 + (t_0 * (t_4 * t_4))));
double tmp;
if ((phi2 <= -0.017) || !(phi2 <= 0.0029)) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 - t_3) + (Math.cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt(((1.0 - Math.pow((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * Math.cos((phi1 * 0.5)))))), 2.0)) + (t_0 * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin((phi1 * 0.5)) t_2 = (math.cos((lambda1 - lambda2)) / 2.0) - 0.5 t_3 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_4 = math.sin(((lambda1 - lambda2) / 2.0)) t_5 = math.sqrt((t_3 + (t_0 * (t_4 * t_4)))) tmp = 0 if (phi2 <= -0.017) or not (phi2 <= 0.0029): tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 - t_3) + (math.cos(phi2) * t_2))))) else: tmp = R * (2.0 * math.atan2(t_5, math.sqrt(((1.0 - math.pow((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * math.cos((phi1 * 0.5)))))), 2.0)) + (t_0 * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(phi1 * 0.5)) t_2 = Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5) t_3 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = sqrt(Float64(t_3 + Float64(t_0 * Float64(t_4 * t_4)))) tmp = 0.0 if ((phi2 <= -0.017) || !(phi2 <= 0.0029)) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 - t_3) + Float64(cos(phi2) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(Float64(1.0 - (Float64(t_1 + Float64(phi2 * Float64(Float64(-0.125 * Float64(phi2 * t_1)) - Float64(0.5 * cos(Float64(phi1 * 0.5)))))) ^ 2.0)) + Float64(t_0 * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin((phi1 * 0.5)); t_2 = (cos((lambda1 - lambda2)) / 2.0) - 0.5; t_3 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_4 = sin(((lambda1 - lambda2) / 2.0)); t_5 = sqrt((t_3 + (t_0 * (t_4 * t_4)))); tmp = 0.0; if ((phi2 <= -0.017) || ~((phi2 <= 0.0029))) tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - t_3) + (cos(phi2) * t_2))))); else tmp = R * (2.0 * atan2(t_5, sqrt(((1.0 - ((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * cos((phi1 * 0.5)))))) ^ 2.0)) + (t_0 * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(t$95$3 + N[(t$95$0 * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.017], N[Not[LessEqual[phi2, 0.0029]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 - t$95$3), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(N[(1.0 - N[Power[N[(t$95$1 + N[(phi2 * N[(N[(-0.125 * N[(phi2 * t$95$1), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$2), $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(\phi_1 \cdot 0.5\right)\\
t_2 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\\
t_3 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := \sqrt{t\_3 + t\_0 \cdot \left(t\_4 \cdot t\_4\right)}\\
\mathbf{if}\;\phi_2 \leq -0.017 \lor \neg \left(\phi_2 \leq 0.0029\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{\left(1 - t\_3\right) + \cos \phi_2 \cdot t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{\left(1 - {\left(t\_1 + \phi_2 \cdot \left(-0.125 \cdot \left(\phi_2 \cdot t\_1\right) - 0.5 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}\right) + t\_0 \cdot t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -0.017000000000000001 or 0.0029 < phi2 Initial program 47.6%
associate-*l*47.6%
Simplified47.6%
div-sub47.6%
sin-diff49.8%
Applied egg-rr49.8%
div-sub47.6%
sin-diff49.8%
Applied egg-rr78.7%
sin-mult78.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
cos-sum78.7%
cos-278.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
Applied egg-rr78.7%
div-sub78.7%
+-inverses78.7%
cos-078.7%
metadata-eval78.7%
associate-*r*78.7%
metadata-eval78.7%
*-lft-identity78.7%
Simplified78.7%
Taylor expanded in phi1 around 0 62.3%
if -0.017000000000000001 < phi2 < 0.0029Initial program 78.5%
associate-*l*78.5%
Simplified78.5%
div-sub78.5%
sin-diff78.6%
Applied egg-rr78.6%
div-sub78.5%
sin-diff78.6%
Applied egg-rr79.5%
sin-mult79.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
cos-sum79.5%
cos-279.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
Applied egg-rr79.6%
div-sub79.6%
+-inverses79.6%
cos-079.6%
metadata-eval79.6%
associate-*r*79.6%
metadata-eval79.6%
*-lft-identity79.6%
Simplified79.6%
Taylor expanded in phi2 around 0 79.3%
Final simplification70.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (* phi1 0.5)))
(t_2 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(t_3
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_4 (- 1.0 t_3))
(t_5 (sin (/ (- lambda1 lambda2) 2.0)))
(t_6 (* t_0 (* t_5 t_5))))
(if (or (<= phi2 -0.0026) (not (<= phi2 0.005)))
(* R (* 2.0 (atan2 (sqrt (+ t_3 t_6)) (sqrt (+ t_4 (* (cos phi2) t_2))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_6
(pow
(+
t_1
(* phi2 (- (* -0.125 (* phi2 t_1)) (* 0.5 (cos (* phi1 0.5))))))
2.0)))
(sqrt (+ t_4 (* t_0 t_2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin((phi1 * 0.5));
double t_2 = (cos((lambda1 - lambda2)) / 2.0) - 0.5;
double t_3 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_4 = 1.0 - t_3;
double t_5 = sin(((lambda1 - lambda2) / 2.0));
double t_6 = t_0 * (t_5 * t_5);
double tmp;
if ((phi2 <= -0.0026) || !(phi2 <= 0.005)) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_6)), sqrt((t_4 + (cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_6 + pow((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * cos((phi1 * 0.5)))))), 2.0))), sqrt((t_4 + (t_0 * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin((phi1 * 0.5d0))
t_2 = (cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0
t_3 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_4 = 1.0d0 - t_3
t_5 = sin(((lambda1 - lambda2) / 2.0d0))
t_6 = t_0 * (t_5 * t_5)
if ((phi2 <= (-0.0026d0)) .or. (.not. (phi2 <= 0.005d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_6)), sqrt((t_4 + (cos(phi2) * t_2)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_6 + ((t_1 + (phi2 * (((-0.125d0) * (phi2 * t_1)) - (0.5d0 * cos((phi1 * 0.5d0)))))) ** 2.0d0))), sqrt((t_4 + (t_0 * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin((phi1 * 0.5));
double t_2 = (Math.cos((lambda1 - lambda2)) / 2.0) - 0.5;
double t_3 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_4 = 1.0 - t_3;
double t_5 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_6 = t_0 * (t_5 * t_5);
double tmp;
if ((phi2 <= -0.0026) || !(phi2 <= 0.005)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_6)), Math.sqrt((t_4 + (Math.cos(phi2) * t_2)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_6 + Math.pow((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * Math.cos((phi1 * 0.5)))))), 2.0))), Math.sqrt((t_4 + (t_0 * t_2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin((phi1 * 0.5)) t_2 = (math.cos((lambda1 - lambda2)) / 2.0) - 0.5 t_3 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_4 = 1.0 - t_3 t_5 = math.sin(((lambda1 - lambda2) / 2.0)) t_6 = t_0 * (t_5 * t_5) tmp = 0 if (phi2 <= -0.0026) or not (phi2 <= 0.005): tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_6)), math.sqrt((t_4 + (math.cos(phi2) * t_2))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_6 + math.pow((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * math.cos((phi1 * 0.5)))))), 2.0))), math.sqrt((t_4 + (t_0 * t_2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(phi1 * 0.5)) t_2 = Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5) t_3 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_4 = Float64(1.0 - t_3) t_5 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_6 = Float64(t_0 * Float64(t_5 * t_5)) tmp = 0.0 if ((phi2 <= -0.0026) || !(phi2 <= 0.005)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_6)), sqrt(Float64(t_4 + Float64(cos(phi2) * t_2)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_6 + (Float64(t_1 + Float64(phi2 * Float64(Float64(-0.125 * Float64(phi2 * t_1)) - Float64(0.5 * cos(Float64(phi1 * 0.5)))))) ^ 2.0))), sqrt(Float64(t_4 + Float64(t_0 * t_2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin((phi1 * 0.5)); t_2 = (cos((lambda1 - lambda2)) / 2.0) - 0.5; t_3 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_4 = 1.0 - t_3; t_5 = sin(((lambda1 - lambda2) / 2.0)); t_6 = t_0 * (t_5 * t_5); tmp = 0.0; if ((phi2 <= -0.0026) || ~((phi2 <= 0.005))) tmp = R * (2.0 * atan2(sqrt((t_3 + t_6)), sqrt((t_4 + (cos(phi2) * t_2))))); else tmp = R * (2.0 * atan2(sqrt((t_6 + ((t_1 + (phi2 * ((-0.125 * (phi2 * t_1)) - (0.5 * cos((phi1 * 0.5)))))) ^ 2.0))), sqrt((t_4 + (t_0 * t_2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(1.0 - t$95$3), $MachinePrecision]}, Block[{t$95$5 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$0 * N[(t$95$5 * t$95$5), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0026], N[Not[LessEqual[phi2, 0.005]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$6), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 + 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$6 + N[Power[N[(t$95$1 + N[(phi2 * N[(N[(-0.125 * N[(phi2 * t$95$1), $MachinePrecision]), $MachinePrecision] - N[(0.5 * N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 + N[(t$95$0 * t$95$2), $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(\phi_1 \cdot 0.5\right)\\
t_2 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\\
t_3 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_4 := 1 - t\_3\\
t_5 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_6 := t\_0 \cdot \left(t\_5 \cdot t\_5\right)\\
\mathbf{if}\;\phi_2 \leq -0.0026 \lor \neg \left(\phi_2 \leq 0.005\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_6}}{\sqrt{t\_4 + \cos \phi_2 \cdot t\_2}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6 + {\left(t\_1 + \phi_2 \cdot \left(-0.125 \cdot \left(\phi_2 \cdot t\_1\right) - 0.5 \cdot \cos \left(\phi_1 \cdot 0.5\right)\right)\right)}^{2}}}{\sqrt{t\_4 + t\_0 \cdot t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -0.0025999999999999999 or 0.0050000000000000001 < phi2 Initial program 47.6%
associate-*l*47.6%
Simplified47.6%
div-sub47.6%
sin-diff49.8%
Applied egg-rr49.8%
div-sub47.6%
sin-diff49.8%
Applied egg-rr78.7%
sin-mult78.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
cos-sum78.7%
cos-278.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
Applied egg-rr78.7%
div-sub78.7%
+-inverses78.7%
cos-078.7%
metadata-eval78.7%
associate-*r*78.7%
metadata-eval78.7%
*-lft-identity78.7%
Simplified78.7%
Taylor expanded in phi1 around 0 62.3%
if -0.0025999999999999999 < phi2 < 0.0050000000000000001Initial program 78.5%
associate-*l*78.5%
Simplified78.5%
div-sub78.5%
sin-diff78.6%
Applied egg-rr78.6%
div-sub78.5%
sin-diff78.6%
Applied egg-rr79.5%
sin-mult79.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
cos-sum79.5%
cos-279.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
Applied egg-rr79.6%
div-sub79.6%
+-inverses79.6%
cos-079.6%
metadata-eval79.6%
associate-*r*79.6%
metadata-eval79.6%
*-lft-identity79.6%
Simplified79.6%
Taylor expanded in phi2 around 0 79.3%
Final simplification70.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(t_2
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sqrt (+ t_2 (* t_0 (* t_3 t_3))))))
(if (or (<= phi2 -0.0026) (not (<= phi2 0.00086)))
(* R (* 2.0 (atan2 t_4 (sqrt (+ (- 1.0 t_2) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
t_4
(sqrt
(+
(-
1.0
(pow
(+ (sin (* phi1 0.5)) (* (cos (* phi1 0.5)) (* phi2 -0.5)))
2.0))
(* t_0 t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = (cos((lambda1 - lambda2)) / 2.0) - 0.5;
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sqrt((t_2 + (t_0 * (t_3 * t_3))));
double tmp;
if ((phi2 <= -0.0026) || !(phi2 <= 0.00086)) {
tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - t_2) + (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - pow((sin((phi1 * 0.5)) + (cos((phi1 * 0.5)) * (phi2 * -0.5))), 2.0)) + (t_0 * 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) :: t_4
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = (cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0
t_2 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sqrt((t_2 + (t_0 * (t_3 * t_3))))
if ((phi2 <= (-0.0026d0)) .or. (.not. (phi2 <= 0.00086d0))) then
tmp = r * (2.0d0 * atan2(t_4, sqrt(((1.0d0 - t_2) + (cos(phi2) * t_1)))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt(((1.0d0 - ((sin((phi1 * 0.5d0)) + (cos((phi1 * 0.5d0)) * (phi2 * (-0.5d0)))) ** 2.0d0)) + (t_0 * 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.cos(phi1) * Math.cos(phi2);
double t_1 = (Math.cos((lambda1 - lambda2)) / 2.0) - 0.5;
double t_2 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.sqrt((t_2 + (t_0 * (t_3 * t_3))));
double tmp;
if ((phi2 <= -0.0026) || !(phi2 <= 0.00086)) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt(((1.0 - t_2) + (Math.cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt(((1.0 - Math.pow((Math.sin((phi1 * 0.5)) + (Math.cos((phi1 * 0.5)) * (phi2 * -0.5))), 2.0)) + (t_0 * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = (math.cos((lambda1 - lambda2)) / 2.0) - 0.5 t_2 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.sqrt((t_2 + (t_0 * (t_3 * t_3)))) tmp = 0 if (phi2 <= -0.0026) or not (phi2 <= 0.00086): tmp = R * (2.0 * math.atan2(t_4, math.sqrt(((1.0 - t_2) + (math.cos(phi2) * t_1))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt(((1.0 - math.pow((math.sin((phi1 * 0.5)) + (math.cos((phi1 * 0.5)) * (phi2 * -0.5))), 2.0)) + (t_0 * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5) t_2 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sqrt(Float64(t_2 + Float64(t_0 * Float64(t_3 * t_3)))) tmp = 0.0 if ((phi2 <= -0.0026) || !(phi2 <= 0.00086)) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(1.0 - t_2) + Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(Float64(1.0 - (Float64(sin(Float64(phi1 * 0.5)) + Float64(cos(Float64(phi1 * 0.5)) * Float64(phi2 * -0.5))) ^ 2.0)) + Float64(t_0 * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = (cos((lambda1 - lambda2)) / 2.0) - 0.5; t_2 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sqrt((t_2 + (t_0 * (t_3 * t_3)))); tmp = 0.0; if ((phi2 <= -0.0026) || ~((phi2 <= 0.00086))) tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - t_2) + (cos(phi2) * t_1))))); else tmp = R * (2.0 * atan2(t_4, sqrt(((1.0 - ((sin((phi1 * 0.5)) + (cos((phi1 * 0.5)) * (phi2 * -0.5))) ^ 2.0)) + (t_0 * t_1))))); 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[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$2 + N[(t$95$0 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0026], N[Not[LessEqual[phi2, 0.00086]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sqrt{t\_2 + t\_0 \cdot \left(t\_3 \cdot t\_3\right)}\\
\mathbf{if}\;\phi_2 \leq -0.0026 \lor \neg \left(\phi_2 \leq 0.00086\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{\left(1 - t\_2\right) + \cos \phi_2 \cdot t\_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{\left(1 - {\left(\sin \left(\phi_1 \cdot 0.5\right) + \cos \left(\phi_1 \cdot 0.5\right) \cdot \left(\phi_2 \cdot -0.5\right)\right)}^{2}\right) + t\_0 \cdot t\_1}}\right)\\
\end{array}
\end{array}
if phi2 < -0.0025999999999999999 or 8.59999999999999979e-4 < phi2 Initial program 47.6%
associate-*l*47.6%
Simplified47.6%
div-sub47.6%
sin-diff49.8%
Applied egg-rr49.8%
div-sub47.6%
sin-diff49.8%
Applied egg-rr78.7%
sin-mult78.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
cos-sum78.7%
cos-278.7%
div-inv78.7%
metadata-eval78.7%
*-commutative78.7%
Applied egg-rr78.7%
div-sub78.7%
+-inverses78.7%
cos-078.7%
metadata-eval78.7%
associate-*r*78.7%
metadata-eval78.7%
*-lft-identity78.7%
Simplified78.7%
Taylor expanded in phi1 around 0 62.3%
if -0.0025999999999999999 < phi2 < 8.59999999999999979e-4Initial program 78.5%
associate-*l*78.5%
Simplified78.5%
div-sub78.5%
sin-diff78.6%
Applied egg-rr78.6%
div-sub78.5%
sin-diff78.6%
Applied egg-rr79.5%
sin-mult79.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
cos-sum79.5%
cos-279.6%
div-inv79.6%
metadata-eval79.6%
*-commutative79.6%
Applied egg-rr79.6%
div-sub79.6%
+-inverses79.6%
cos-079.6%
metadata-eval79.6%
associate-*r*79.6%
metadata-eval79.6%
*-lft-identity79.6%
Simplified79.6%
Taylor expanded in phi2 around 0 78.9%
associate-*r*78.9%
*-commutative78.9%
Simplified78.9%
Final simplification70.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 t_0))
(t_2
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_3 (* (cos phi1) (cos phi2)))
(t_4
(sqrt
(+ (- 1.0 t_2) (* t_3 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))
(if (or (<= phi2 -0.0018) (not (<= phi2 2.9e+14)))
(* R (* 2.0 (atan2 (sqrt (+ t_2 (* (cos phi2) t_1))) t_4)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_3 t_1)
(pow
(+ (sin (* phi1 0.5)) (* (cos (* phi1 0.5)) (* phi2 -0.5)))
2.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 * t_0;
double t_2 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_3 = cos(phi1) * cos(phi2);
double t_4 = sqrt(((1.0 - t_2) + (t_3 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))));
double tmp;
if ((phi2 <= -0.0018) || !(phi2 <= 2.9e+14)) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * t_1))), t_4));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_3 * t_1) + pow((sin((phi1 * 0.5)) + (cos((phi1 * 0.5)) * (phi2 * -0.5))), 2.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 * t_0
t_2 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_3 = cos(phi1) * cos(phi2)
t_4 = sqrt(((1.0d0 - t_2) + (t_3 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))
if ((phi2 <= (-0.0018d0)) .or. (.not. (phi2 <= 2.9d+14))) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (cos(phi2) * t_1))), t_4))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_3 * t_1) + ((sin((phi1 * 0.5d0)) + (cos((phi1 * 0.5d0)) * (phi2 * (-0.5d0)))) ** 2.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 * t_0;
double t_2 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = Math.sqrt(((1.0 - t_2) + (t_3 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))));
double tmp;
if ((phi2 <= -0.0018) || !(phi2 <= 2.9e+14)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (Math.cos(phi2) * t_1))), t_4));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_3 * t_1) + Math.pow((Math.sin((phi1 * 0.5)) + (Math.cos((phi1 * 0.5)) * (phi2 * -0.5))), 2.0))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * t_0 t_2 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_3 = math.cos(phi1) * math.cos(phi2) t_4 = math.sqrt(((1.0 - t_2) + (t_3 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))) tmp = 0 if (phi2 <= -0.0018) or not (phi2 <= 2.9e+14): tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (math.cos(phi2) * t_1))), t_4)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_3 * t_1) + math.pow((math.sin((phi1 * 0.5)) + (math.cos((phi1 * 0.5)) * (phi2 * -0.5))), 2.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 * t_0) t_2 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = sqrt(Float64(Float64(1.0 - t_2) + Float64(t_3 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)))) tmp = 0.0 if ((phi2 <= -0.0018) || !(phi2 <= 2.9e+14)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(cos(phi2) * t_1))), t_4))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_3 * t_1) + (Float64(sin(Float64(phi1 * 0.5)) + Float64(cos(Float64(phi1 * 0.5)) * Float64(phi2 * -0.5))) ^ 2.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 * t_0; t_2 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_3 = cos(phi1) * cos(phi2); t_4 = sqrt(((1.0 - t_2) + (t_3 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))); tmp = 0.0; if ((phi2 <= -0.0018) || ~((phi2 <= 2.9e+14))) tmp = R * (2.0 * atan2(sqrt((t_2 + (cos(phi2) * t_1))), t_4)); else tmp = R * (2.0 * atan2(sqrt(((t_3 * t_1) + ((sin((phi1 * 0.5)) + (cos((phi1 * 0.5)) * (phi2 * -0.5))) ^ 2.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 * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] + N[(t$95$3 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0018], N[Not[LessEqual[phi2, 2.9e+14]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$3 * t$95$1), $MachinePrecision] + N[Power[N[(N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] + N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[(phi2 * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $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 t\_0\\
t_2 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := \sqrt{\left(1 - t\_2\right) + t\_3 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}\\
\mathbf{if}\;\phi_2 \leq -0.0018 \lor \neg \left(\phi_2 \leq 2.9 \cdot 10^{+14}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \cos \phi_2 \cdot t\_1}}{t\_4}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 \cdot t\_1 + {\left(\sin \left(\phi_1 \cdot 0.5\right) + \cos \left(\phi_1 \cdot 0.5\right) \cdot \left(\phi_2 \cdot -0.5\right)\right)}^{2}}}{t\_4}\right)\\
\end{array}
\end{array}
if phi2 < -0.0018 or 2.9e14 < phi2 Initial program 48.0%
associate-*l*48.0%
Simplified48.0%
div-sub48.0%
sin-diff50.1%
Applied egg-rr50.1%
div-sub48.0%
sin-diff50.1%
Applied egg-rr79.1%
sin-mult79.2%
div-inv79.2%
metadata-eval79.2%
*-commutative79.2%
div-inv79.2%
metadata-eval79.2%
*-commutative79.2%
cos-sum79.2%
cos-279.2%
div-inv79.2%
metadata-eval79.2%
*-commutative79.2%
Applied egg-rr79.2%
div-sub79.2%
+-inverses79.2%
cos-079.2%
metadata-eval79.2%
associate-*r*79.2%
metadata-eval79.2%
*-lft-identity79.2%
Simplified79.2%
Taylor expanded in phi1 around 0 61.7%
if -0.0018 < phi2 < 2.9e14Initial program 77.9%
associate-*l*77.9%
Simplified77.9%
div-sub77.9%
sin-diff78.0%
Applied egg-rr78.0%
div-sub77.9%
sin-diff78.0%
Applied egg-rr79.0%
sin-mult79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
cos-sum79.1%
cos-279.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
associate-*r*79.1%
metadata-eval79.1%
*-lft-identity79.1%
Simplified79.1%
Taylor expanded in phi2 around 0 78.4%
associate-*r*78.3%
*-commutative78.3%
Simplified78.4%
Final simplification70.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_1 (* t_0 t_0))
(pow (expm1 (log1p (sin (* 0.5 (- phi1 phi2))))) 2.0)))
(sqrt
(+
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(* t_1 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + pow(expm1(log1p(sin((0.5 * (phi1 - phi2))))), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) + (t_1 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_0)) + Math.pow(Math.expm1(Math.log1p(Math.sin((0.5 * (phi1 - phi2))))), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) + (t_1 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_0)) + math.pow(math.expm1(math.log1p(math.sin((0.5 * (phi1 - phi2))))), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) + (t_1 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_0)) + (expm1(log1p(sin(Float64(0.5 * Float64(phi1 - phi2))))) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) + Float64(t_1 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[(Exp[N[Log[1 + N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_0\right) + {\left(\mathsf{expm1}\left(\mathsf{log1p}\left(\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)\right)\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) + t\_1 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
div-sub63.2%
sin-diff64.3%
Applied egg-rr64.3%
div-sub63.2%
sin-diff64.3%
Applied egg-rr79.1%
sin-mult79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
cos-sum79.1%
cos-279.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
associate-*r*79.1%
metadata-eval79.1%
*-lft-identity79.1%
Simplified79.1%
expm1-log1p-u79.1%
sin-diff64.3%
div-sub64.3%
div-inv64.3%
metadata-eval64.3%
*-commutative64.3%
Applied egg-rr64.3%
Final simplification64.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
div-sub63.2%
sin-diff64.3%
Applied egg-rr64.3%
Final simplification64.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_1 t_1))))
(sqrt
(+
(+ 1.0 (- (/ (cos (- phi2 phi1)) 2.0) 0.5))
(* t_0 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 + ((cos((phi2 - phi1)) / 2.0) - 0.5)) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 + ((cos((phi2 - phi1)) / 2.0d0) - 0.5d0)) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 + ((Math.cos((phi2 - phi1)) / 2.0) - 0.5)) + (t_0 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 + ((math.cos((phi2 - phi1)) / 2.0) - 0.5)) + (t_0 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi2 - phi1)) / 2.0) - 0.5)) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 + ((cos((phi2 - phi1)) / 2.0) - 0.5)) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi2 - phi1), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_2 - \phi_1\right)}{2} - 0.5\right)\right) + t\_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
div-sub63.2%
sin-diff64.3%
Applied egg-rr64.3%
div-sub63.2%
sin-diff64.3%
Applied egg-rr79.1%
sin-mult79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
cos-sum79.1%
cos-279.1%
div-inv79.1%
metadata-eval79.1%
*-commutative79.1%
Applied egg-rr79.1%
div-sub79.1%
+-inverses79.1%
cos-079.1%
metadata-eval79.1%
associate-*r*79.1%
metadata-eval79.1%
*-lft-identity79.1%
Simplified79.1%
sin-diff64.2%
div-sub64.2%
unpow264.2%
sin-mult64.3%
Applied egg-rr64.3%
div-sub64.3%
+-inverses64.3%
+-inverses64.3%
+-inverses64.3%
cos-064.3%
metadata-eval64.3%
Simplified64.3%
Final simplification64.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_0)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(fabs
(-
(* t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (cos (* 0.5 (- phi1 phi2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(fabs(((t_1 * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) - pow(cos((0.5 * (phi1 - phi2))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
code = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(abs(((t_1 * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) - (cos((0.5d0 * (phi1 - phi2))) ** 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));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
return R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(Math.abs(((t_1 * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) - Math.pow(Math.cos((0.5 * (phi1 - phi2))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) return R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(math.fabs(((t_1 * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) - math.pow(math.cos((0.5 * (phi1 - phi2))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(abs(Float64(Float64(t_1 * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) - (cos(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(abs(((t_1 * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) - (cos((0.5 * (phi1 - phi2))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Abs[N[(N[(t$95$1 * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[Power[N[Cos[N[(0.5 * N[(phi1 - phi2), $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)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left|t\_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} - {\cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right|}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
unpow263.2%
1-sub-sin63.3%
div-inv63.3%
metadata-eval63.3%
div-inv63.3%
metadata-eval63.3%
Applied egg-rr63.3%
add-sqr-sqrt63.3%
pow1/263.3%
pow1/263.3%
pow-prod-down63.8%
Applied egg-rr63.8%
unpow1/263.8%
unpow263.8%
rem-sqrt-square63.8%
*-commutative63.8%
*-commutative63.8%
*-commutative63.8%
Simplified63.8%
Final simplification63.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_2 (cos (* 0.5 (- phi1 phi2)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (* t_2 t_2) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = cos((0.5 * (phi1 - phi2)));
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((t_2 * t_2) - 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
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = cos((0.5d0 * (phi1 - phi2)))
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((t_2 * t_2) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_2 = Math.cos((0.5 * (phi1 - phi2)));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((t_2 * t_2) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_2 = math.cos((0.5 * (phi1 - phi2))) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((t_2 * t_2) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_2 = cos(Float64(0.5 * Float64(phi1 - phi2))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(t_2 * t_2) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = cos((0.5 * (phi1 - phi2))); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((t_2 * t_2) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Cos[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(t$95$2 * t$95$2), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
t_2 := \cos \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{t\_2 \cdot t\_2 - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
unpow263.2%
1-sub-sin63.3%
div-inv63.3%
metadata-eval63.3%
div-inv63.3%
metadata-eval63.3%
Applied egg-rr63.3%
Final simplification63.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (/ (+ 1.0 (cos (* 2.0 (* 0.5 (- phi1 phi2))))) 2.0) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((((1.0 + cos((2.0 * (0.5 * (phi1 - phi2))))) / 2.0) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((((1.0d0 + cos((2.0d0 * (0.5d0 * (phi1 - phi2))))) / 2.0d0) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((((1.0 + Math.cos((2.0 * (0.5 * (phi1 - phi2))))) / 2.0) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((((1.0 + math.cos((2.0 * (0.5 * (phi1 - phi2))))) / 2.0) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(Float64(1.0 + cos(Float64(2.0 * Float64(0.5 * Float64(phi1 - phi2))))) / 2.0) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((((1.0 + cos((2.0 * (0.5 * (phi1 - phi2))))) / 2.0) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(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[(1.0 + N[Cos[N[(2.0 * N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\frac{1 + \cos \left(2 \cdot \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{2} - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
unpow263.2%
1-sub-sin63.3%
div-inv63.3%
metadata-eval63.3%
div-inv63.3%
metadata-eval63.3%
Applied egg-rr63.3%
cos-mult63.3%
cos-sum63.2%
cos-263.3%
Applied egg-rr63.3%
+-commutative63.3%
+-inverses63.3%
cos-063.3%
*-commutative63.3%
Simplified63.3%
Final simplification63.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (+ 1.0 (- (/ (cos (- phi1 phi2)) 2.0) 0.5)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 + ((cos((phi1 - phi2)) / 2.0d0) - 0.5d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 + ((Math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 + ((math.cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 + Float64(Float64(cos(Float64(phi1 - phi2)) / 2.0) - 0.5)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 + ((cos((phi1 - phi2)) / 2.0) - 0.5)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 + N[(N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 + \left(\frac{\cos \left(\phi_1 - \phi_2\right)}{2} - 0.5\right)\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
unpow263.2%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr63.2%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified63.2%
Final simplification63.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 63.2%
associate-*l*63.2%
Simplified63.2%
unpow263.2%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr62.4%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified62.4%
Final simplification62.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (* (cos phi1) (cos phi2)) t_0)))
(if (or (<= phi2 -0.0016) (not (<= phi2 0.000105)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (sin (* lambda2 -0.5)) t_2)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ phi1 2.0)) 2.0) (* t_0 t_2)))
(sqrt
(- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = (cos(phi1) * cos(phi2)) * t_0;
double tmp;
if ((phi2 <= -0.0016) || !(phi2 <= 0.000105)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (sin((lambda2 * -0.5)) * t_2))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 / 2.0)), 2.0) + (t_0 * t_2))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = (cos(phi1) * cos(phi2)) * t_0
if ((phi2 <= (-0.0016d0)) .or. (.not. (phi2 <= 0.000105d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - ((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (sin((lambda2 * (-0.5d0))) * t_2))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 / 2.0d0)) ** 2.0d0) + (t_0 * t_2))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * t_0;
double tmp;
if ((phi2 <= -0.0016) || !(phi2 <= 0.000105)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.sin((lambda2 * -0.5)) * t_2))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 / 2.0)), 2.0) + (t_0 * t_2))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = (math.cos(phi1) * math.cos(phi2)) * t_0 tmp = 0 if (phi2 <= -0.0016) or not (phi2 <= 0.000105): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.sin((lambda2 * -0.5)) * t_2)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 / 2.0)), 2.0) + (t_0 * t_2))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * t_0) tmp = 0.0 if ((phi2 <= -0.0016) || !(phi2 <= 0.000105)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(sin(Float64(lambda2 * -0.5)) * t_2))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 / 2.0)) ^ 2.0) + Float64(t_0 * t_2))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = (cos(phi1) * cos(phi2)) * t_0; tmp = 0.0; if ((phi2 <= -0.0016) || ~((phi2 <= 0.000105))) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - ((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (sin((lambda2 * -0.5)) * t_2)))))); else tmp = R * (2.0 * atan2(sqrt(((sin((phi1 / 2.0)) ^ 2.0) + (t_0 * t_2))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0016], N[Not[LessEqual[phi2, 0.000105]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\\
\mathbf{if}\;\phi_2 \leq -0.0016 \lor \neg \left(\phi_2 \leq 0.000105\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\lambda_2 \cdot -0.5\right) \cdot t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1}{2}\right)}^{2} + t\_0 \cdot t\_2}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -0.00160000000000000008 or 1.05e-4 < phi2 Initial program 47.6%
Taylor expanded in lambda1 around 0 38.5%
Taylor expanded in phi1 around 0 39.8%
if -0.00160000000000000008 < phi2 < 1.05e-4Initial program 78.5%
Taylor expanded in phi2 around 0 78.3%
Taylor expanded in phi1 around inf 77.3%
Final simplification58.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi2 -0.0022) (not (<= phi2 2.7e+21)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(sin (* lambda2 -0.5))
(*
(* (cos phi1) (cos phi2))
(sin (/ (- lambda1 lambda2) 2.0))))))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))
(* t_0 (log1p (expm1 (cos phi1))))))
(sqrt
(- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 2.7e+21)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (sin((lambda2 * -0.5)) * ((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0)))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + (t_0 * log1p(expm1(cos(phi1)))))), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -0.0022) || !(phi2 <= 2.7e+21)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * t_0) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.sin((lambda2 * -0.5)) * ((Math.cos(phi1) * Math.cos(phi2)) * Math.sin(((lambda1 - lambda2) / 2.0)))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + (t_0 * Math.log1p(Math.expm1(Math.cos(phi1)))))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi2 <= -0.0022) or not (phi2 <= 2.7e+21): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * t_0) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.sin((lambda2 * -0.5)) * ((math.cos(phi1) * math.cos(phi2)) * math.sin(((lambda1 - lambda2) / 2.0))))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + (t_0 * math.log1p(math.expm1(math.cos(phi1)))))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi2 <= -0.0022) || !(phi2 <= 2.7e+21)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(sin(Float64(lambda2 * -0.5)) * Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0)))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + Float64(t_0 * log1p(expm1(cos(phi1)))))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0022], N[Not[LessEqual[phi2, 2.7e+21]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision] * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[Log[1 + N[(Exp[N[Cos[phi1], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -0.0022 \lor \neg \left(\phi_2 \leq 2.7 \cdot 10^{+21}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \sin \left(\lambda_2 \cdot -0.5\right) \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_0 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\cos \phi_1\right)\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -0.00220000000000000013 or 2.7e21 < phi2 Initial program 48.4%
Taylor expanded in lambda1 around 0 39.3%
Taylor expanded in phi1 around 0 40.4%
if -0.00220000000000000013 < phi2 < 2.7e21Initial program 77.0%
Taylor expanded in phi2 around 0 76.8%
unpow277.1%
sin-mult77.1%
div-inv77.1%
metadata-eval77.1%
div-inv77.1%
metadata-eval77.1%
div-inv77.1%
metadata-eval77.1%
div-inv77.1%
metadata-eval77.1%
Applied egg-rr75.4%
div-sub77.1%
+-inverses77.1%
cos-077.1%
metadata-eval77.1%
distribute-lft-out77.1%
metadata-eval77.1%
*-rgt-identity77.1%
Simplified75.4%
Taylor expanded in phi2 around 0 75.6%
log1p-expm1-u75.6%
Applied egg-rr75.6%
Final simplification58.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi1) t_0))
(t_2 (* (cos phi1) 0.5))
(t_3 (sqrt (- 1.0 (+ t_1 (pow (sin (* phi1 0.5)) 2.0)))))
(t_4 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi1 -31000000.0)
(* R (* 2.0 (atan2 (sqrt (- (+ 0.5 t_1) t_2)) t_3)))
(if (<= phi1 8.2e-6)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (* (cos phi1) (cos phi2)) (* t_4 t_4))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))
(* R (* 2.0 (atan2 (sqrt (+ 0.5 (- t_1 t_2))) t_3)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = cos(phi1) * t_0;
double t_2 = cos(phi1) * 0.5;
double t_3 = sqrt((1.0 - (t_1 + pow(sin((phi1 * 0.5)), 2.0))));
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -31000000.0) {
tmp = R * (2.0 * atan2(sqrt(((0.5 + t_1) - t_2)), t_3));
} else if (phi1 <= 8.2e-6) {
tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_4 * t_4)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((0.5 + (t_1 - t_2))), t_3));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * t_0
t_2 = cos(phi1) * 0.5d0
t_3 = sqrt((1.0d0 - (t_1 + (sin((phi1 * 0.5d0)) ** 2.0d0))))
t_4 = sin(((lambda1 - lambda2) / 2.0d0))
if (phi1 <= (-31000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((0.5d0 + t_1) - t_2)), t_3))
else if (phi1 <= 8.2d-6) then
tmp = r * (2.0d0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_4 * t_4)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((0.5d0 + (t_1 - t_2))), 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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.cos(phi1) * t_0;
double t_2 = Math.cos(phi1) * 0.5;
double t_3 = Math.sqrt((1.0 - (t_1 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))));
double t_4 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi1 <= -31000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 + t_1) - t_2)), t_3));
} else if (phi1 <= 8.2e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((((Math.cos(phi1) * Math.cos(phi2)) * (t_4 * t_4)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((0.5 + (t_1 - t_2))), t_3));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.cos(phi1) * t_0 t_2 = math.cos(phi1) * 0.5 t_3 = math.sqrt((1.0 - (t_1 + math.pow(math.sin((phi1 * 0.5)), 2.0)))) t_4 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if phi1 <= -31000000.0: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 + t_1) - t_2)), t_3)) elif phi1 <= 8.2e-6: tmp = R * (2.0 * math.atan2(math.sqrt((((math.cos(phi1) * math.cos(phi2)) * (t_4 * t_4)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((0.5 + (t_1 - t_2))), t_3)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * t_0) t_2 = Float64(cos(phi1) * 0.5) t_3 = sqrt(Float64(1.0 - Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0)))) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi1 <= -31000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 + t_1) - t_2)), t_3))); elseif (phi1 <= 8.2e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_4 * t_4)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(0.5 + Float64(t_1 - t_2))), t_3))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = cos(phi1) * t_0; t_2 = cos(phi1) * 0.5; t_3 = sqrt((1.0 - (t_1 + (sin((phi1 * 0.5)) ^ 2.0)))); t_4 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (phi1 <= -31000000.0) tmp = R * (2.0 * atan2(sqrt(((0.5 + t_1) - t_2)), t_3)); elseif (phi1 <= 8.2e-6) tmp = R * (2.0 * atan2(sqrt((((cos(phi1) * cos(phi2)) * (t_4 * t_4)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_0))))); else tmp = R * (2.0 * atan2(sqrt((0.5 + (t_1 - t_2))), t_3)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -31000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 8.2e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(0.5 + N[(t$95$1 - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_1 \cdot t\_0\\
t_2 := \cos \phi_1 \cdot 0.5\\
t_3 := \sqrt{1 - \left(t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_1 \leq -31000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 + t\_1\right) - t\_2}}{t\_3}\right)\\
\mathbf{elif}\;\phi_1 \leq 8.2 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_4 \cdot t\_4\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t\_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \left(t\_1 - t\_2\right)}}{t\_3}\right)\\
\end{array}
\end{array}
if phi1 < -3.1e7Initial program 44.3%
Taylor expanded in phi2 around 0 45.9%
unpow244.3%
sin-mult44.4%
div-inv44.4%
metadata-eval44.4%
div-inv44.4%
metadata-eval44.4%
div-inv44.4%
metadata-eval44.4%
div-inv44.4%
metadata-eval44.4%
Applied egg-rr45.9%
div-sub44.4%
+-inverses44.4%
cos-044.4%
metadata-eval44.4%
distribute-lft-out44.4%
metadata-eval44.4%
*-rgt-identity44.4%
Simplified45.9%
Taylor expanded in phi2 around 0 45.8%
Taylor expanded in phi2 around 0 46.2%
if -3.1e7 < phi1 < 8.1999999999999994e-6Initial program 77.7%
associate-*l*77.7%
Simplified77.6%
unpow277.6%
1-sub-sin77.8%
div-inv77.8%
metadata-eval77.8%
div-inv77.8%
metadata-eval77.8%
Applied egg-rr77.8%
Taylor expanded in phi1 around 0 77.8%
if 8.1999999999999994e-6 < phi1 Initial program 44.7%
Taylor expanded in phi2 around 0 45.1%
unpow244.9%
sin-mult44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
Applied egg-rr45.1%
div-sub44.9%
+-inverses44.9%
cos-044.9%
metadata-eval44.9%
distribute-lft-out44.9%
metadata-eval44.9%
*-rgt-identity44.9%
Simplified45.1%
Taylor expanded in phi2 around 0 45.0%
Taylor expanded in phi2 around 0 47.4%
associate--l+47.4%
Simplified47.4%
Final simplification64.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((0.5d0 - (cos((phi1 - phi2)) / 2.0d0)) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
Taylor expanded in phi2 around 0 49.6%
unpow263.2%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr48.9%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified48.9%
Final simplification48.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* phi1 0.5)) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi1) t_1)))
(if (or (<= phi1 -2.5e+32) (not (<= phi1 4.2e-7)))
(*
R
(*
2.0
(atan2
(sqrt (+ 0.5 (- t_2 (* (cos phi1) 0.5))))
(sqrt (- 1.0 (+ t_2 t_0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (- 0.5 (/ (cos (- phi1 phi2)) 2.0)) t_2))
(sqrt (- 1.0 (+ t_1 t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi1 * 0.5)), 2.0);
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi1) * t_1;
double tmp;
if ((phi1 <= -2.5e+32) || !(phi1 <= 4.2e-7)) {
tmp = R * (2.0 * atan2(sqrt((0.5 + (t_2 - (cos(phi1) * 0.5)))), sqrt((1.0 - (t_2 + t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_2)), sqrt((1.0 - (t_1 + t_0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = cos(phi1) * t_1
if ((phi1 <= (-2.5d+32)) .or. (.not. (phi1 <= 4.2d-7))) then
tmp = r * (2.0d0 * atan2(sqrt((0.5d0 + (t_2 - (cos(phi1) * 0.5d0)))), sqrt((1.0d0 - (t_2 + t_0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((0.5d0 - (cos((phi1 - phi2)) / 2.0d0)) + t_2)), sqrt((1.0d0 - (t_1 + t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi1) * t_1;
double tmp;
if ((phi1 <= -2.5e+32) || !(phi1 <= 4.2e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((0.5 + (t_2 - (Math.cos(phi1) * 0.5)))), Math.sqrt((1.0 - (t_2 + t_0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + t_2)), Math.sqrt((1.0 - (t_1 + t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi1) * t_1 tmp = 0 if (phi1 <= -2.5e+32) or not (phi1 <= 4.2e-7): tmp = R * (2.0 * math.atan2(math.sqrt((0.5 + (t_2 - (math.cos(phi1) * 0.5)))), math.sqrt((1.0 - (t_2 + t_0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + t_2)), math.sqrt((1.0 - (t_1 + t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi1) * t_1) tmp = 0.0 if ((phi1 <= -2.5e+32) || !(phi1 <= 4.2e-7)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(0.5 + Float64(t_2 - Float64(cos(phi1) * 0.5)))), sqrt(Float64(1.0 - Float64(t_2 + t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + t_2)), sqrt(Float64(1.0 - Float64(t_1 + t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = cos(phi1) * t_1; tmp = 0.0; if ((phi1 <= -2.5e+32) || ~((phi1 <= 4.2e-7))) tmp = R * (2.0 * atan2(sqrt((0.5 + (t_2 - (cos(phi1) * 0.5)))), sqrt((1.0 - (t_2 + t_0))))); else tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_2)), sqrt((1.0 - (t_1 + t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi1, -2.5e+32], N[Not[LessEqual[phi1, 4.2e-7]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(0.5 + N[(t$95$2 - N[(N[Cos[phi1], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t$95$2), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_1 \cdot t\_1\\
\mathbf{if}\;\phi_1 \leq -2.5 \cdot 10^{+32} \lor \neg \left(\phi_1 \leq 4.2 \cdot 10^{-7}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \left(t\_2 - \cos \phi_1 \cdot 0.5\right)}}{\sqrt{1 - \left(t\_2 + t\_0\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_2}}{\sqrt{1 - \left(t\_1 + t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -2.4999999999999999e32 or 4.2e-7 < phi1 Initial program 45.0%
Taylor expanded in phi2 around 0 46.0%
unpow245.1%
sin-mult45.1%
div-inv45.1%
metadata-eval45.1%
div-inv45.1%
metadata-eval45.1%
div-inv45.1%
metadata-eval45.1%
div-inv45.1%
metadata-eval45.1%
Applied egg-rr46.0%
div-sub45.1%
+-inverses45.1%
cos-045.1%
metadata-eval45.1%
distribute-lft-out45.1%
metadata-eval45.1%
*-rgt-identity45.1%
Simplified46.0%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi2 around 0 47.2%
associate--l+47.2%
Simplified47.2%
if -2.4999999999999999e32 < phi1 < 4.2e-7Initial program 76.9%
Taylor expanded in phi2 around 0 52.3%
unpow276.8%
sin-mult76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
Applied egg-rr51.0%
div-sub76.9%
+-inverses76.9%
cos-076.9%
metadata-eval76.9%
distribute-lft-out76.9%
metadata-eval76.9%
*-rgt-identity76.9%
Simplified51.0%
Taylor expanded in phi2 around 0 50.8%
Taylor expanded in phi1 around 0 50.8%
Final simplification49.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi1) t_0))
(t_2 (* (cos phi1) 0.5))
(t_3 (pow (sin (* phi1 0.5)) 2.0))
(t_4 (sqrt (- 1.0 (+ t_1 t_3)))))
(if (<= phi1 -2.5e+32)
(* R (* 2.0 (atan2 (sqrt (- (+ 0.5 t_1) t_2)) t_4)))
(if (<= phi1 9.2e-8)
(*
R
(*
2.0
(atan2
(sqrt (+ (- 0.5 (/ (cos (- phi1 phi2)) 2.0)) t_1))
(sqrt (- 1.0 (+ t_0 t_3))))))
(* R (* 2.0 (atan2 (sqrt (+ 0.5 (- t_1 t_2))) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = cos(phi1) * t_0;
double t_2 = cos(phi1) * 0.5;
double t_3 = pow(sin((phi1 * 0.5)), 2.0);
double t_4 = sqrt((1.0 - (t_1 + t_3)));
double tmp;
if (phi1 <= -2.5e+32) {
tmp = R * (2.0 * atan2(sqrt(((0.5 + t_1) - t_2)), t_4));
} else if (phi1 <= 9.2e-8) {
tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_1)), sqrt((1.0 - (t_0 + t_3)))));
} else {
tmp = R * (2.0 * atan2(sqrt((0.5 + (t_1 - t_2))), 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) * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * t_0
t_2 = cos(phi1) * 0.5d0
t_3 = sin((phi1 * 0.5d0)) ** 2.0d0
t_4 = sqrt((1.0d0 - (t_1 + t_3)))
if (phi1 <= (-2.5d+32)) then
tmp = r * (2.0d0 * atan2(sqrt(((0.5d0 + t_1) - t_2)), t_4))
else if (phi1 <= 9.2d-8) then
tmp = r * (2.0d0 * atan2(sqrt(((0.5d0 - (cos((phi1 - phi2)) / 2.0d0)) + t_1)), sqrt((1.0d0 - (t_0 + t_3)))))
else
tmp = r * (2.0d0 * atan2(sqrt((0.5d0 + (t_1 - t_2))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.cos(phi1) * t_0;
double t_2 = Math.cos(phi1) * 0.5;
double t_3 = Math.pow(Math.sin((phi1 * 0.5)), 2.0);
double t_4 = Math.sqrt((1.0 - (t_1 + t_3)));
double tmp;
if (phi1 <= -2.5e+32) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 + t_1) - t_2)), t_4));
} else if (phi1 <= 9.2e-8) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + t_1)), Math.sqrt((1.0 - (t_0 + t_3)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((0.5 + (t_1 - t_2))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.cos(phi1) * t_0 t_2 = math.cos(phi1) * 0.5 t_3 = math.pow(math.sin((phi1 * 0.5)), 2.0) t_4 = math.sqrt((1.0 - (t_1 + t_3))) tmp = 0 if phi1 <= -2.5e+32: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 + t_1) - t_2)), t_4)) elif phi1 <= 9.2e-8: tmp = R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + t_1)), math.sqrt((1.0 - (t_0 + t_3))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((0.5 + (t_1 - t_2))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * t_0) t_2 = Float64(cos(phi1) * 0.5) t_3 = sin(Float64(phi1 * 0.5)) ^ 2.0 t_4 = sqrt(Float64(1.0 - Float64(t_1 + t_3))) tmp = 0.0 if (phi1 <= -2.5e+32) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 + t_1) - t_2)), t_4))); elseif (phi1 <= 9.2e-8) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + t_1)), sqrt(Float64(1.0 - Float64(t_0 + t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(0.5 + Float64(t_1 - t_2))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = cos(phi1) * t_0; t_2 = cos(phi1) * 0.5; t_3 = sin((phi1 * 0.5)) ^ 2.0; t_4 = sqrt((1.0 - (t_1 + t_3))); tmp = 0.0; if (phi1 <= -2.5e+32) tmp = R * (2.0 * atan2(sqrt(((0.5 + t_1) - t_2)), t_4)); elseif (phi1 <= 9.2e-8) tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_1)), sqrt((1.0 - (t_0 + t_3))))); else tmp = R * (2.0 * atan2(sqrt((0.5 + (t_1 - t_2))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - N[(t$95$1 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -2.5e+32], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 + t$95$1), $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 9.2e-8], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(0.5 + N[(t$95$1 - t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_1 \cdot t\_0\\
t_2 := \cos \phi_1 \cdot 0.5\\
t_3 := {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_4 := \sqrt{1 - \left(t\_1 + t\_3\right)}\\
\mathbf{if}\;\phi_1 \leq -2.5 \cdot 10^{+32}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 + t\_1\right) - t\_2}}{t\_4}\right)\\
\mathbf{elif}\;\phi_1 \leq 9.2 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_1}}{\sqrt{1 - \left(t\_0 + t\_3\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \left(t\_1 - t\_2\right)}}{t\_4}\right)\\
\end{array}
\end{array}
if phi1 < -2.4999999999999999e32Initial program 45.2%
Taylor expanded in phi2 around 0 46.8%
unpow245.2%
sin-mult45.3%
div-inv45.3%
metadata-eval45.3%
div-inv45.3%
metadata-eval45.3%
div-inv45.3%
metadata-eval45.3%
div-inv45.3%
metadata-eval45.3%
Applied egg-rr46.8%
div-sub45.3%
+-inverses45.3%
cos-045.3%
metadata-eval45.3%
distribute-lft-out45.3%
metadata-eval45.3%
*-rgt-identity45.3%
Simplified46.8%
Taylor expanded in phi2 around 0 46.7%
Taylor expanded in phi2 around 0 47.1%
if -2.4999999999999999e32 < phi1 < 9.2000000000000003e-8Initial program 76.9%
Taylor expanded in phi2 around 0 52.3%
unpow276.8%
sin-mult76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
div-inv76.9%
metadata-eval76.9%
Applied egg-rr51.0%
div-sub76.9%
+-inverses76.9%
cos-076.9%
metadata-eval76.9%
distribute-lft-out76.9%
metadata-eval76.9%
*-rgt-identity76.9%
Simplified51.0%
Taylor expanded in phi2 around 0 50.8%
Taylor expanded in phi1 around 0 50.8%
if 9.2000000000000003e-8 < phi1 Initial program 44.7%
Taylor expanded in phi2 around 0 45.1%
unpow244.9%
sin-mult44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
div-inv44.9%
metadata-eval44.9%
Applied egg-rr45.1%
div-sub44.9%
+-inverses44.9%
cos-044.9%
metadata-eval44.9%
distribute-lft-out44.9%
metadata-eval44.9%
*-rgt-identity44.9%
Simplified45.1%
Taylor expanded in phi2 around 0 45.0%
Taylor expanded in phi2 around 0 47.4%
associate--l+47.4%
Simplified47.4%
Final simplification49.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (- 0.5 (/ (cos (- phi1 phi2)) 2.0)) t_0))
(sqrt (- 1.0 (+ t_0 (pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_0)), sqrt((1.0 - (t_0 + pow(sin((phi1 * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
code = r * (2.0d0 * atan2(sqrt(((0.5d0 - (cos((phi1 - phi2)) / 2.0d0)) + t_0)), sqrt((1.0d0 - (t_0 + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt(((0.5 - (Math.cos((phi1 - phi2)) / 2.0)) + t_0)), Math.sqrt((1.0 - (t_0 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt(((0.5 - (math.cos((phi1 - phi2)) / 2.0)) + t_0)), math.sqrt((1.0 - (t_0 + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)) + t_0)), sqrt(Float64(1.0 - Float64(t_0 + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); tmp = R * (2.0 * atan2(sqrt(((0.5 - (cos((phi1 - phi2)) / 2.0)) + t_0)), sqrt((1.0 - (t_0 + (sin((phi1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right) + t\_0}}{\sqrt{1 - \left(t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
Taylor expanded in phi2 around 0 49.6%
unpow263.2%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr48.9%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified48.9%
Taylor expanded in phi2 around 0 48.7%
Final simplification48.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((t_0 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_0 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_0 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_0 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
Taylor expanded in phi2 around 0 49.6%
unpow263.2%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr48.9%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified48.9%
Taylor expanded in phi2 around 0 48.7%
Taylor expanded in phi1 around 0 40.7%
Final simplification40.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ 0.5 (- t_0 (* (cos phi2) 0.5))))
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * atan2(sqrt((0.5 + (t_0 - (cos(phi2) * 0.5)))), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((0.5d0 + (t_0 - (cos(phi2) * 0.5d0)))), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((0.5 + (t_0 - (Math.cos(phi2) * 0.5)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) return R * (2.0 * math.atan2(math.sqrt((0.5 + (t_0 - (math.cos(phi2) * 0.5)))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(0.5 + Float64(t_0 - Float64(cos(phi2) * 0.5)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((0.5 + (t_0 - (cos(phi2) * 0.5)))), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(0.5 + N[(t$95$0 - N[(N[Cos[phi2], $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{0.5 + \left(t\_0 - \cos \phi_2 \cdot 0.5\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 63.2%
Taylor expanded in phi2 around 0 49.6%
unpow263.2%
sin-mult63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
div-inv63.2%
metadata-eval63.2%
Applied egg-rr48.9%
div-sub63.2%
+-inverses63.2%
cos-063.2%
metadata-eval63.2%
distribute-lft-out63.2%
metadata-eval63.2%
*-rgt-identity63.2%
Simplified48.9%
Taylor expanded in phi2 around 0 48.7%
Taylor expanded in phi1 around 0 36.1%
associate--l+36.1%
cos-neg36.1%
Simplified36.1%
Final simplification36.1%
herbie shell --seed 2024149
(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))))))))))