
(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 16 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* (* (cos phi1) (cos phi2)) t_2))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (fma (cos (* -0.5 phi2)) t_0 (* (sin (* -0.5 phi2)) t_1)) 2.0)
t_3))
(sqrt
(-
1.0
(+
t_3
(pow
(- (* (cos (* phi2 0.5)) t_0) (* t_1 (sin (* phi2 0.5))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2);
return R * (2.0 * atan2(sqrt((pow(fma(cos((-0.5 * phi2)), t_0, (sin((-0.5 * phi2)) * t_1)), 2.0) + t_3)), sqrt((1.0 - (t_3 + pow(((cos((phi2 * 0.5)) * t_0) - (t_1 * sin((phi2 * 0.5)))), 2.0))))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((fma(cos(Float64(-0.5 * phi2)), t_0, Float64(sin(Float64(-0.5 * phi2)) * t_1)) ^ 2.0) + t_3)), sqrt(Float64(1.0 - Float64(t_3 + (Float64(Float64(cos(Float64(phi2 * 0.5)) * t_0) - Float64(t_1 * sin(Float64(phi2 * 0.5)))) ^ 2.0))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[Cos[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$0 + N[(N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(t$95$1 * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\mathsf{fma}\left(\cos \left(-0.5 \cdot \phi_2\right), t\_0, \sin \left(-0.5 \cdot \phi_2\right) \cdot t\_1\right)\right)}^{2} + t\_3}}{\sqrt{1 - \left(t\_3 + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot t\_0 - t\_1 \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 66.2%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr67.1%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr81.5%
*-commutative81.5%
*-commutative81.5%
fmm-def81.6%
cos-neg81.6%
distribute-rgt-neg-in81.6%
metadata-eval81.6%
*-commutative81.6%
*-commutative81.6%
*-commutative81.6%
*-commutative81.6%
distribute-lft-neg-in81.6%
sin-neg81.6%
distribute-rgt-neg-in81.6%
metadata-eval81.6%
*-commutative81.6%
*-commutative81.6%
Simplified81.6%
Final simplification81.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* phi1 0.5)))
(t_1 (cos (* phi1 0.5)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3
(sqrt
(-
1.0
(+
(* t_2 (* (* (cos phi1) (cos phi2)) t_2))
(pow
(- (* (cos (* phi2 0.5)) t_0) (* t_1 (sin (* phi2 0.5))))
2.0))))))
(if (or (<= lambda2 -10.0) (not (<= lambda2 1.36e-8)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* -0.5 lambda2)) 2.0)))
(pow
(+ (* (cos (* -0.5 phi2)) t_0) (* (sin (* -0.5 phi2)) t_1))
2.0)))
t_3)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
t_3))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((phi1 * 0.5));
double t_1 = cos((phi1 * 0.5));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sqrt((1.0 - ((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + pow(((cos((phi2 * 0.5)) * t_0) - (t_1 * sin((phi2 * 0.5)))), 2.0))));
double tmp;
if ((lambda2 <= -10.0) || !(lambda2 <= 1.36e-8)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((-0.5 * lambda2)), 2.0))) + pow(((cos((-0.5 * phi2)) * t_0) + (sin((-0.5 * phi2)) * t_1)), 2.0))), t_3));
} else {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))) + pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0))), t_3));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin((phi1 * 0.5d0))
t_1 = cos((phi1 * 0.5d0))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sqrt((1.0d0 - ((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + (((cos((phi2 * 0.5d0)) * t_0) - (t_1 * sin((phi2 * 0.5d0)))) ** 2.0d0))))
if ((lambda2 <= (-10.0d0)) .or. (.not. (lambda2 <= 1.36d-8))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin(((-0.5d0) * lambda2)) ** 2.0d0))) + (((cos(((-0.5d0) * phi2)) * t_0) + (sin(((-0.5d0) * phi2)) * t_1)) ** 2.0d0))), t_3))
else
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))) + (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0))), t_3))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((phi1 * 0.5));
double t_1 = Math.cos((phi1 * 0.5));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sqrt((1.0 - ((t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2)) + Math.pow(((Math.cos((phi2 * 0.5)) * t_0) - (t_1 * Math.sin((phi2 * 0.5)))), 2.0))));
double tmp;
if ((lambda2 <= -10.0) || !(lambda2 <= 1.36e-8)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * lambda2)), 2.0))) + Math.pow(((Math.cos((-0.5 * phi2)) * t_0) + (Math.sin((-0.5 * phi2)) * t_1)), 2.0))), t_3));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))) + Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0))), t_3));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((phi1 * 0.5)) t_1 = math.cos((phi1 * 0.5)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sqrt((1.0 - ((t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2)) + math.pow(((math.cos((phi2 * 0.5)) * t_0) - (t_1 * math.sin((phi2 * 0.5)))), 2.0)))) tmp = 0 if (lambda2 <= -10.0) or not (lambda2 <= 1.36e-8): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((-0.5 * lambda2)), 2.0))) + math.pow(((math.cos((-0.5 * phi2)) * t_0) + (math.sin((-0.5 * phi2)) * t_1)), 2.0))), t_3)) else: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))) + math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0))), t_3)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi1 * 0.5)) t_1 = cos(Float64(phi1 * 0.5)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sqrt(Float64(1.0 - Float64(Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) + (Float64(Float64(cos(Float64(phi2 * 0.5)) * t_0) - Float64(t_1 * sin(Float64(phi2 * 0.5)))) ^ 2.0)))) tmp = 0.0 if ((lambda2 <= -10.0) || !(lambda2 <= 1.36e-8)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(-0.5 * lambda2)) ^ 2.0))) + (Float64(Float64(cos(Float64(-0.5 * phi2)) * t_0) + Float64(sin(Float64(-0.5 * phi2)) * t_1)) ^ 2.0))), t_3))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.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_3))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((phi1 * 0.5)); t_1 = cos((phi1 * 0.5)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sqrt((1.0 - ((t_2 * ((cos(phi1) * cos(phi2)) * t_2)) + (((cos((phi2 * 0.5)) * t_0) - (t_1 * sin((phi2 * 0.5)))) ^ 2.0)))); tmp = 0.0; if ((lambda2 <= -10.0) || ~((lambda2 <= 1.36e-8))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((-0.5 * lambda2)) ^ 2.0))) + (((cos((-0.5 * phi2)) * t_0) + (sin((-0.5 * phi2)) * t_1)) ^ 2.0))), t_3)); else tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))) + (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0))), t_3)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] - N[(t$95$1 * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda2, -10.0], N[Not[LessEqual[lambda2, 1.36e-8]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$3], $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[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 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]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sqrt{1 - \left(t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right) + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot t\_0 - t\_1 \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\right)}\\
\mathbf{if}\;\lambda_2 \leq -10 \lor \neg \left(\lambda_2 \leq 1.36 \cdot 10^{-8}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}\right) + {\left(\cos \left(-0.5 \cdot \phi_2\right) \cdot t\_0 + \sin \left(-0.5 \cdot \phi_2\right) \cdot t\_1\right)}^{2}}}{t\_3}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + {\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}\right)\\
\end{array}
\end{array}
if lambda2 < -10 or 1.3599999999999999e-8 < lambda2 Initial program 48.9%
div-sub48.9%
sin-diff50.3%
div-inv50.3%
metadata-eval50.3%
div-inv50.3%
metadata-eval50.3%
div-inv50.3%
metadata-eval50.3%
div-inv50.3%
metadata-eval50.3%
Applied egg-rr50.3%
div-sub48.9%
sin-diff50.3%
div-inv50.3%
metadata-eval50.3%
div-inv50.3%
metadata-eval50.3%
div-inv50.3%
metadata-eval50.3%
div-inv50.3%
metadata-eval50.3%
Applied egg-rr63.5%
*-commutative63.5%
*-commutative63.5%
fmm-def63.6%
cos-neg63.6%
distribute-rgt-neg-in63.6%
metadata-eval63.6%
*-commutative63.6%
*-commutative63.6%
*-commutative63.6%
*-commutative63.6%
distribute-lft-neg-in63.6%
sin-neg63.6%
distribute-rgt-neg-in63.6%
metadata-eval63.6%
*-commutative63.6%
*-commutative63.6%
Simplified63.6%
log1p-expm1-u63.6%
Applied egg-rr63.6%
Taylor expanded in lambda1 around 0 62.8%
if -10 < lambda2 < 1.3599999999999999e-8Initial program 81.9%
div-sub81.9%
sin-diff82.4%
div-inv82.4%
metadata-eval82.4%
div-inv82.4%
metadata-eval82.4%
div-inv82.4%
metadata-eval82.4%
div-inv82.4%
metadata-eval82.4%
Applied egg-rr82.4%
Taylor expanded in lambda2 around 0 80.3%
*-commutative80.3%
metadata-eval80.3%
div-inv80.3%
div-sub80.3%
sin-diff95.9%
Applied egg-rr95.9%
Final simplification80.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (* phi1 0.5)))
(t_1
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* (* (cos phi1) (cos phi2)) t_2)))
(t_4 (sin (* phi1 0.5)))
(t_5
(pow (- (* (cos (* phi2 0.5)) t_4) (* t_0 (sin (* phi2 0.5)))) 2.0))
(t_6 (+ t_3 t_5)))
(if (<= lambda1 -2.7e-59)
(*
R
(*
2.0
(atan2
(sqrt t_6)
(sqrt (- 1.0 (+ t_3 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))
(if (<= lambda1 4.1e-64)
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* -0.5 lambda2)) 2.0)))
(pow
(+ (* (cos (* -0.5 phi2)) t_4) (* (sin (* -0.5 phi2)) t_0))
2.0)))
(sqrt (- 1.0 t_6)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (- 1.0 (+ t_5 t_1))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((phi1 * 0.5));
double t_1 = cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0));
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2);
double t_4 = sin((phi1 * 0.5));
double t_5 = pow(((cos((phi2 * 0.5)) * t_4) - (t_0 * sin((phi2 * 0.5)))), 2.0);
double t_6 = t_3 + t_5;
double tmp;
if (lambda1 <= -2.7e-59) {
tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - (t_3 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else if (lambda1 <= 4.1e-64) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((-0.5 * lambda2)), 2.0))) + pow(((cos((-0.5 * phi2)) * t_4) + (sin((-0.5 * phi2)) * t_0)), 2.0))), sqrt((1.0 - t_6))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - (t_5 + t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = cos((phi1 * 0.5d0))
t_1 = cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2)
t_4 = sin((phi1 * 0.5d0))
t_5 = ((cos((phi2 * 0.5d0)) * t_4) - (t_0 * sin((phi2 * 0.5d0)))) ** 2.0d0
t_6 = t_3 + t_5
if (lambda1 <= (-2.7d-59)) then
tmp = r * (2.0d0 * atan2(sqrt(t_6), sqrt((1.0d0 - (t_3 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))))))
else if (lambda1 <= 4.1d-64) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin(((-0.5d0) * lambda2)) ** 2.0d0))) + (((cos(((-0.5d0) * phi2)) * t_4) + (sin(((-0.5d0) * phi2)) * t_0)) ** 2.0d0))), sqrt((1.0d0 - t_6))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt((1.0d0 - (t_5 + 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 * 0.5));
double t_1 = Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0));
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * ((Math.cos(phi1) * Math.cos(phi2)) * t_2);
double t_4 = Math.sin((phi1 * 0.5));
double t_5 = Math.pow(((Math.cos((phi2 * 0.5)) * t_4) - (t_0 * Math.sin((phi2 * 0.5)))), 2.0);
double t_6 = t_3 + t_5;
double tmp;
if (lambda1 <= -2.7e-59) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(t_6), Math.sqrt((1.0 - (t_3 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else if (lambda1 <= 4.1e-64) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * lambda2)), 2.0))) + Math.pow(((Math.cos((-0.5 * phi2)) * t_4) + (Math.sin((-0.5 * phi2)) * t_0)), 2.0))), Math.sqrt((1.0 - t_6))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((1.0 - (t_5 + t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((phi1 * 0.5)) t_1 = math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_2 * ((math.cos(phi1) * math.cos(phi2)) * t_2) t_4 = math.sin((phi1 * 0.5)) t_5 = math.pow(((math.cos((phi2 * 0.5)) * t_4) - (t_0 * math.sin((phi2 * 0.5)))), 2.0) t_6 = t_3 + t_5 tmp = 0 if lambda1 <= -2.7e-59: tmp = R * (2.0 * math.atan2(math.sqrt(t_6), math.sqrt((1.0 - (t_3 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)))))) elif lambda1 <= 4.1e-64: tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((-0.5 * lambda2)), 2.0))) + math.pow(((math.cos((-0.5 * phi2)) * t_4) + (math.sin((-0.5 * phi2)) * t_0)), 2.0))), math.sqrt((1.0 - t_6)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((1.0 - (t_5 + t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(phi1 * 0.5)) t_1 = Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(Float64(cos(phi1) * cos(phi2)) * t_2)) t_4 = sin(Float64(phi1 * 0.5)) t_5 = Float64(Float64(cos(Float64(phi2 * 0.5)) * t_4) - Float64(t_0 * sin(Float64(phi2 * 0.5)))) ^ 2.0 t_6 = Float64(t_3 + t_5) tmp = 0.0 if (lambda1 <= -2.7e-59) tmp = Float64(R * Float64(2.0 * atan(sqrt(t_6), sqrt(Float64(1.0 - Float64(t_3 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); elseif (lambda1 <= 4.1e-64) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(-0.5 * lambda2)) ^ 2.0))) + (Float64(Float64(cos(Float64(-0.5 * phi2)) * t_4) + Float64(sin(Float64(-0.5 * phi2)) * t_0)) ^ 2.0))), sqrt(Float64(1.0 - t_6))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_5 + t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((phi1 * 0.5)); t_1 = cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_2 * ((cos(phi1) * cos(phi2)) * t_2); t_4 = sin((phi1 * 0.5)); t_5 = ((cos((phi2 * 0.5)) * t_4) - (t_0 * sin((phi2 * 0.5)))) ^ 2.0; t_6 = t_3 + t_5; tmp = 0.0; if (lambda1 <= -2.7e-59) tmp = R * (2.0 * atan2(sqrt(t_6), sqrt((1.0 - (t_3 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0)))))); elseif (lambda1 <= 4.1e-64) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((-0.5 * lambda2)) ^ 2.0))) + (((cos((-0.5 * phi2)) * t_4) + (sin((-0.5 * phi2)) * t_0)) ^ 2.0))), sqrt((1.0 - t_6)))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt((1.0 - (t_5 + t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * t$95$4), $MachinePrecision] - N[(t$95$0 * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$6 = N[(t$95$3 + t$95$5), $MachinePrecision]}, If[LessEqual[lambda1, -2.7e-59], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$6], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 4.1e-64], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * lambda2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[(N[(N[Cos[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$4), $MachinePrecision] + N[(N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$6), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\phi_1 \cdot 0.5\right)\\
t_1 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_2\right)\\
t_4 := \sin \left(\phi_1 \cdot 0.5\right)\\
t_5 := {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot t\_4 - t\_0 \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
t_6 := t\_3 + t\_5\\
\mathbf{if}\;\lambda_1 \leq -2.7 \cdot 10^{-59}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_6}}{\sqrt{1 - \left(t\_3 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 4.1 \cdot 10^{-64}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(-0.5 \cdot \lambda_2\right)}^{2}\right) + {\left(\cos \left(-0.5 \cdot \phi_2\right) \cdot t\_4 + \sin \left(-0.5 \cdot \phi_2\right) \cdot t\_0\right)}^{2}}}{\sqrt{1 - t\_6}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(t\_5 + t\_1\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -2.6999999999999999e-59Initial program 61.5%
div-sub61.5%
sin-diff62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
div-inv62.1%
metadata-eval62.1%
Applied egg-rr62.6%
if -2.6999999999999999e-59 < lambda1 < 4.1e-64Initial program 75.5%
div-sub75.5%
sin-diff76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
Applied egg-rr76.7%
div-sub75.5%
sin-diff76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
div-inv76.7%
metadata-eval76.7%
Applied egg-rr98.9%
*-commutative98.9%
*-commutative98.9%
fmm-def98.9%
cos-neg98.9%
distribute-rgt-neg-in98.9%
metadata-eval98.9%
*-commutative98.9%
*-commutative98.9%
*-commutative98.9%
*-commutative98.9%
distribute-lft-neg-in98.9%
sin-neg98.9%
distribute-rgt-neg-in98.9%
metadata-eval98.9%
*-commutative98.9%
*-commutative98.9%
Simplified98.9%
log1p-expm1-u98.9%
Applied egg-rr98.9%
Taylor expanded in lambda1 around 0 97.0%
if 4.1e-64 < lambda1 Initial program 58.9%
div-sub58.9%
sin-diff59.8%
div-inv59.8%
metadata-eval59.8%
div-inv59.8%
metadata-eval59.8%
div-inv59.8%
metadata-eval59.8%
div-inv59.8%
metadata-eval59.8%
Applied egg-rr59.8%
Taylor expanded in phi1 around 0 59.8%
Final simplification75.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.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 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.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 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0)
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 = (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.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 = (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.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 = (t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.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[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $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[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.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 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
Initial program 66.2%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr67.1%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr81.5%
Final simplification81.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
1.0
(+
t_1
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (t_1 + pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (t_1 + (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - (t_1 + Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - (t_1 + math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(t_1 + (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (t_1 + (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $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]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(t\_1 + {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 66.2%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr67.1%
Final simplification67.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt
(-
(-
1.0
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(((1.0 - pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt(((1.0d0 - (((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(((1.0 - Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(((1.0 - math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(((1.0 - (((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $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] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 66.2%
associate-*l*66.1%
Simplified66.1%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr67.1%
Final simplification67.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(cos phi1)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt
(-
1.0
(+
(pow
(-
(* (cos (* phi2 0.5)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* phi2 0.5))))
2.0)
t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0));
return R * (2.0 * atan2(sqrt((t_0 + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - (pow(((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))), 2.0) + t_0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = cos(phi1) * (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_0 + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt((1.0d0 - ((((cos((phi2 * 0.5d0)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((phi2 * 0.5d0)))) ** 2.0d0) + t_0)))))
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) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_0 + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((1.0 - (Math.pow(((Math.cos((phi2 * 0.5)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((phi2 * 0.5)))), 2.0) + t_0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_0 + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((1.0 - (math.pow(((math.cos((phi2 * 0.5)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((phi2 * 0.5)))), 2.0) + t_0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0))) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - Float64((Float64(Float64(cos(Float64(phi2 * 0.5)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(phi2 * 0.5)))) ^ 2.0) + t_0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)); tmp = R * (2.0 * atan2(sqrt((t_0 + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt((1.0 - ((((cos((phi2 * 0.5)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((phi2 * 0.5)))) ^ 2.0) + t_0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[(N[(N[Cos[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left({\left(\cos \left(\phi_2 \cdot 0.5\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(\phi_2 \cdot 0.5\right)\right)}^{2} + t\_0\right)}}\right)
\end{array}
\end{array}
Initial program 66.2%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr67.1%
Taylor expanded in phi1 around 0 67.1%
Final simplification67.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (* t_0 (* t_2 t_0)))
(t_4
(sqrt (- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 0.5)) 2.0))))))
(if (<= phi2 -760000000.0)
(* R (* 2.0 (atan2 (sqrt (+ t_3 (pow (sin (* -0.5 phi2)) 2.0))) t_4)))
(if (<= phi2 1.05e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_2 (* t_0 t_0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (pow (sin (/ 1.0 (/ 2.0 (- phi1 phi2)))) 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 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = t_0 * (t_2 * t_0);
double t_4 = sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * 0.5)), 2.0))));
double tmp;
if (phi2 <= -760000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin((-0.5 * phi2)), 2.0))), t_4));
} else if (phi2 <= 1.05e-5) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin((1.0 / (2.0 / (phi1 - phi2)))), 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 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = t_0 * (t_2 * t_0)
t_4 = sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * 0.5d0)) ** 2.0d0))))
if (phi2 <= (-760000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin(((-0.5d0) * phi2)) ** 2.0d0))), t_4))
else if (phi2 <= 1.05d-5) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_2 * (t_0 * t_0)))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin((1.0d0 / (2.0d0 / (phi1 - phi2)))) ** 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 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = t_0 * (t_2 * t_0);
double t_4 = Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * 0.5)), 2.0))));
double tmp;
if (phi2 <= -760000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin((-0.5 * phi2)), 2.0))), t_4));
} else if (phi2 <= 1.05e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * (t_0 * t_0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin((1.0 / (2.0 / (phi1 - phi2)))), 2.0))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = t_0 * (t_2 * t_0) t_4 = math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * 0.5)), 2.0)))) tmp = 0 if phi2 <= -760000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin((-0.5 * phi2)), 2.0))), t_4)) elif phi2 <= 1.05e-5: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * (t_0 * t_0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin((1.0 / (2.0 / (phi1 - phi2)))), 2.0))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64(t_0 * Float64(t_2 * t_0)) t_4 = sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * 0.5)) ^ 2.0)))) tmp = 0.0 if (phi2 <= -760000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(-0.5 * phi2)) ^ 2.0))), t_4))); elseif (phi2 <= 1.05e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(1.0 / Float64(2.0 / Float64(phi1 - phi2)))) ^ 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 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = t_0 * (t_2 * t_0); t_4 = sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * 0.5)) ^ 2.0)))); tmp = 0.0; if (phi2 <= -760000000.0) tmp = R * (2.0 * atan2(sqrt((t_3 + (sin((-0.5 * phi2)) ^ 2.0))), t_4)); elseif (phi2 <= 1.05e-5) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_2 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (sin((1.0 / (2.0 / (phi1 - phi2)))) ^ 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[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -760000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.05e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(1.0 / N[(2.0 / N[(phi1 - phi2), $MachinePrecision]), $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 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := t\_0 \cdot \left(t\_2 \cdot t\_0\right)\\
t_4 := \sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot 0.5\right)}^{2}\right)}\\
\mathbf{if}\;\phi_2 \leq -760000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}}}{t\_4}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.05 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2 \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\sin \left(\frac{1}{\frac{2}{\phi_1 - \phi_2}}\right)}^{2}}}{t\_4}\right)\\
\end{array}
\end{array}
if phi2 < -7.6e8Initial program 43.9%
div-sub43.9%
sin-diff46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
Applied egg-rr46.5%
Taylor expanded in phi1 around 0 45.3%
Taylor expanded in phi1 around 0 45.9%
if -7.6e8 < phi2 < 1.04999999999999994e-5Initial program 82.1%
associate-*l*82.1%
Simplified82.1%
Taylor expanded in phi2 around 0 82.1%
if 1.04999999999999994e-5 < phi2 Initial program 42.5%
div-sub42.5%
sin-diff44.1%
div-inv44.1%
metadata-eval44.1%
div-inv44.1%
metadata-eval44.1%
div-inv44.1%
metadata-eval44.1%
div-inv44.1%
metadata-eval44.1%
Applied egg-rr44.1%
Taylor expanded in phi1 around 0 43.1%
clear-num43.2%
inv-pow43.2%
Applied egg-rr43.2%
unpow-143.2%
Simplified43.2%
Final simplification66.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (* t_0 (* t_2 t_0)))
(t_4
(sqrt (- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 0.5)) 2.0))))))
(if (<= phi2 -760000000.0)
(* R (* 2.0 (atan2 (sqrt (+ t_3 (pow (sin (* -0.5 phi2)) 2.0))) t_4)))
(if (<= phi2 0.00027)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_2 (* t_0 t_0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2 (sqrt (+ t_3 (- 0.5 (/ (cos (- phi1 phi2)) 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 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double t_3 = t_0 * (t_2 * t_0);
double t_4 = sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * 0.5)), 2.0))));
double tmp;
if (phi2 <= -760000000.0) {
tmp = R * (2.0 * atan2(sqrt((t_3 + pow(sin((-0.5 * phi2)), 2.0))), t_4));
} else if (phi2 <= 0.00027) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 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 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
t_3 = t_0 * (t_2 * t_0)
t_4 = sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * 0.5d0)) ** 2.0d0))))
if (phi2 <= (-760000000.0d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (sin(((-0.5d0) * phi2)) ** 2.0d0))), t_4))
else if (phi2 <= 0.00027d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_2 * (t_0 * t_0)))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (0.5d0 - (cos((phi1 - phi2)) / 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 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = t_0 * (t_2 * t_0);
double t_4 = Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * 0.5)), 2.0))));
double tmp;
if (phi2 <= -760000000.0) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + Math.pow(Math.sin((-0.5 * phi2)), 2.0))), t_4));
} else if (phi2 <= 0.00027) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * (t_0 * t_0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = t_0 * (t_2 * t_0) t_4 = math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * 0.5)), 2.0)))) tmp = 0 if phi2 <= -760000000.0: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + math.pow(math.sin((-0.5 * phi2)), 2.0))), t_4)) elif phi2 <= 0.00027: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_2 * (t_0 * t_0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = Float64(t_0 * Float64(t_2 * t_0)) t_4 = sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * 0.5)) ^ 2.0)))) tmp = 0.0 if (phi2 <= -760000000.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + (sin(Float64(-0.5 * phi2)) ^ 2.0))), t_4))); elseif (phi2 <= 0.00027) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_2 * Float64(t_0 * t_0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 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 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; t_2 = cos(phi1) * cos(phi2); t_3 = t_0 * (t_2 * t_0); t_4 = sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * 0.5)) ^ 2.0)))); tmp = 0.0; if (phi2 <= -760000000.0) tmp = R * (2.0 * atan2(sqrt((t_3 + (sin((-0.5 * phi2)) ^ 2.0))), t_4)); elseif (phi2 <= 0.00027) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_2 * (t_0 * t_0)))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 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[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -760000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00027], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $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 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := t\_0 \cdot \left(t\_2 \cdot t\_0\right)\\
t_4 := \sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot 0.5\right)}^{2}\right)}\\
\mathbf{if}\;\phi_2 \leq -760000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}}}{t\_4}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00027:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_2 \cdot \left(t\_0 \cdot t\_0\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{t\_4}\right)\\
\end{array}
\end{array}
if phi2 < -7.6e8Initial program 43.9%
div-sub43.9%
sin-diff46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
div-inv46.5%
metadata-eval46.5%
Applied egg-rr46.5%
Taylor expanded in phi1 around 0 45.3%
Taylor expanded in phi1 around 0 45.9%
if -7.6e8 < phi2 < 2.70000000000000003e-4Initial program 82.1%
associate-*l*82.1%
Simplified82.1%
Taylor expanded in phi2 around 0 82.1%
if 2.70000000000000003e-4 < phi2 Initial program 42.5%
div-sub42.5%
sin-diff44.1%
div-inv44.1%
metadata-eval44.1%
div-inv44.1%
metadata-eval44.1%
div-inv44.1%
metadata-eval44.1%
div-inv44.1%
metadata-eval44.1%
Applied egg-rr44.1%
Taylor expanded in phi1 around 0 43.1%
unpow243.1%
sin-mult43.1%
div-inv43.1%
metadata-eval43.1%
div-inv43.1%
metadata-eval43.1%
div-inv43.1%
metadata-eval43.1%
div-inv43.1%
metadata-eval43.1%
Applied egg-rr43.1%
div-sub43.1%
+-inverses43.1%
cos-043.1%
metadata-eval43.1%
distribute-lft-out43.1%
metadata-eval43.1%
*-rgt-identity43.1%
Simplified43.1%
Final simplification66.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(if (or (<= phi1 -6.2e-11) (not (<= phi1 5.3e-68)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (* -0.5 phi2)) 2.0)))
(sqrt
(- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -6.2e-11) || !(phi1 <= 5.3e-68)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin((-0.5 * phi2)), 2.0))), sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
if ((phi1 <= (-6.2d-11)) .or. (.not. (phi1 <= 5.3d-68))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((-0.5d0) * phi2)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -6.2e-11) || !(phi1 <= 5.3e-68)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin((-0.5 * phi2)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi1 <= -6.2e-11) or not (phi1 <= 5.3e-68): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin((-0.5 * phi2)), 2.0))), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 tmp = 0.0 if ((phi1 <= -6.2e-11) || !(phi1 <= 5.3e-68)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(-0.5 * phi2)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = 0.0; if ((phi1 <= -6.2e-11) || ~((phi1 <= 5.3e-68))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin((-0.5 * phi2)) ^ 2.0))), sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * 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[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -6.2e-11], N[Not[LessEqual[phi1, 5.3e-68]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(-0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -6.2 \cdot 10^{-11} \lor \neg \left(\phi_1 \leq 5.3 \cdot 10^{-68}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(-0.5 \cdot \phi_2\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -6.20000000000000056e-11 or 5.3e-68 < phi1 Initial program 54.9%
div-sub54.9%
sin-diff56.5%
div-inv56.5%
metadata-eval56.5%
div-inv56.5%
metadata-eval56.5%
div-inv56.5%
metadata-eval56.5%
div-inv56.5%
metadata-eval56.5%
Applied egg-rr56.5%
Taylor expanded in lambda2 around 0 47.0%
Taylor expanded in phi2 around 0 45.2%
if -6.20000000000000056e-11 < phi1 < 5.3e-68Initial program 81.6%
div-sub81.6%
sin-diff81.6%
div-inv81.6%
metadata-eval81.6%
div-inv81.6%
metadata-eval81.6%
div-inv81.6%
metadata-eval81.6%
div-inv81.6%
metadata-eval81.6%
Applied egg-rr81.6%
Taylor expanded in phi1 around 0 81.6%
Taylor expanded in phi1 around 0 80.7%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (+ 0.5 (* -0.5 (cos (- lambda1 lambda2))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2)))))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - (t_0 * (0.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * Math.cos((lambda1 - lambda2)))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * (0.5 + (-0.5 * math.cos((lambda1 - lambda2)))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64(t_0 * Float64(0.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - (t_0 * (0.5 + (-0.5 * cos((lambda1 - lambda2))))))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[(0.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - t\_0 \cdot \left(0.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)}}\right)
\end{array}
\end{array}
Initial program 66.2%
associate-*l*66.1%
Simplified66.1%
*-commutative66.1%
cancel-sign-sub-inv66.1%
div-inv66.1%
metadata-eval66.1%
Applied egg-rr66.2%
Final simplification66.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(if (or (<= phi1 -6.2e-11) (not (<= phi1 2.2e-85)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(- 1.0 (+ (* (cos phi2) t_1) (pow (sin (* phi2 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -6.2e-11) || !(phi1 <= 2.2e-85)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))) + pow(sin((0.5 * (phi1 - phi2))), 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi2) * t_1) + pow(sin((phi2 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
if ((phi1 <= (-6.2d-11)) .or. (.not. (phi1 <= 2.2d-85))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))) + (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi2) * t_1) + (sin((phi2 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi1 <= -6.2e-11) || !(phi1 <= 2.2e-85)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))) + Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_1) + Math.pow(Math.sin((phi2 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi1 <= -6.2e-11) or not (phi1 <= 2.2e-85): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))) + math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi2) * t_1) + math.pow(math.sin((phi2 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 tmp = 0.0 if ((phi1 <= -6.2e-11) || !(phi1 <= 2.2e-85)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))) + (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_1) + (sin(Float64(phi2 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = 0.0; if ((phi1 <= -6.2e-11) || ~((phi1 <= 2.2e-85))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))) + (sin((0.5 * (phi1 - phi2))) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi2) * t_1) + (sin((phi2 * 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[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -6.2e-11], N[Not[LessEqual[phi1, 2.2e-85]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -6.2 \cdot 10^{-11} \lor \neg \left(\phi_1 \leq 2.2 \cdot 10^{-85}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right) + {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_2 \cdot t\_1 + {\sin \left(\phi_2 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -6.20000000000000056e-11 or 2.2e-85 < phi1 Initial program 55.9%
div-sub55.9%
sin-diff57.4%
div-inv57.4%
metadata-eval57.4%
div-inv57.4%
metadata-eval57.4%
div-inv57.4%
metadata-eval57.4%
div-inv57.4%
metadata-eval57.4%
Applied egg-rr57.4%
Taylor expanded in lambda2 around 0 47.3%
Taylor expanded in phi2 around 0 45.6%
if -6.20000000000000056e-11 < phi1 < 2.2e-85Initial program 82.5%
div-sub82.5%
sin-diff82.5%
div-inv82.5%
metadata-eval82.5%
div-inv82.5%
metadata-eval82.5%
div-inv82.5%
metadata-eval82.5%
div-inv82.5%
metadata-eval82.5%
Applied egg-rr82.5%
Taylor expanded in phi1 around 0 82.5%
unpow282.5%
sin-mult78.5%
div-inv78.5%
metadata-eval78.5%
div-inv78.5%
metadata-eval78.5%
div-inv78.5%
metadata-eval78.5%
div-inv78.5%
metadata-eval78.5%
Applied egg-rr78.5%
div-sub78.5%
+-inverses78.5%
cos-078.5%
metadata-eval78.5%
distribute-lft-out78.5%
metadata-eval78.5%
*-rgt-identity78.5%
Simplified78.5%
Final simplification58.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0)))
(if (or (<= phi2 -760000000.0) (not (<= phi2 5e-22)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (* (cos phi2) t_2) (pow (sin (* phi2 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -760000000.0) || !(phi2 <= 5e-22)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi2) * t_2) + pow(sin((phi2 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0
if ((phi2 <= (-760000000.0d0)) .or. (.not. (phi2 <= 5d-22))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi2) * t_2) + (sin((phi2 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0);
double tmp;
if ((phi2 <= -760000000.0) || !(phi2 <= 5e-22)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi2) * t_2) + Math.pow(Math.sin((phi2 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_2 = math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0) tmp = 0 if (phi2 <= -760000000.0) or not (phi2 <= 5e-22): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi2) * t_2) + math.pow(math.sin((phi2 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 tmp = 0.0 if ((phi2 <= -760000000.0) || !(phi2 <= 5e-22)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi2) * t_2) + (sin(Float64(phi2 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = sin((0.5 * (lambda1 - lambda2))) ^ 2.0; tmp = 0.0; if ((phi2 <= -760000000.0) || ~((phi2 <= 5e-22))) tmp = R * (2.0 * atan2(sqrt((t_1 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi2) * t_2) + (sin((phi2 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -760000000.0], N[Not[LessEqual[phi2, 5e-22]], $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[(1.0 - N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
t_2 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -760000000 \lor \neg \left(\phi_2 \leq 5 \cdot 10^{-22}\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{1 - \left(\cos \phi_2 \cdot t\_2 + {\sin \left(\phi_2 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - t\_2}}\right)\\
\end{array}
\end{array}
if phi2 < -7.6e8 or 4.99999999999999954e-22 < phi2 Initial program 44.7%
div-sub44.7%
sin-diff46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
div-inv46.8%
metadata-eval46.8%
Applied egg-rr46.8%
Taylor expanded in phi1 around 0 43.8%
unpow243.8%
sin-mult43.8%
div-inv43.8%
metadata-eval43.8%
div-inv43.8%
metadata-eval43.8%
div-inv43.8%
metadata-eval43.8%
div-inv43.8%
metadata-eval43.8%
Applied egg-rr43.8%
div-sub43.8%
+-inverses43.8%
cos-043.8%
metadata-eval43.8%
distribute-lft-out43.8%
metadata-eval43.8%
*-rgt-identity43.8%
Simplified43.8%
if -7.6e8 < phi2 < 4.99999999999999954e-22Initial program 81.8%
div-sub81.8%
sin-diff81.8%
div-inv81.8%
metadata-eval81.8%
div-inv81.8%
metadata-eval81.8%
div-inv81.8%
metadata-eval81.8%
div-inv81.8%
metadata-eval81.8%
Applied egg-rr81.8%
Taylor expanded in phi1 around 0 52.8%
Taylor expanded in phi2 around 0 52.8%
Final simplification49.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt((1.0 - (sin((0.5 * (lambda1 - lambda2))) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 66.2%
div-sub66.2%
sin-diff67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
div-inv67.1%
metadata-eval67.1%
Applied egg-rr67.1%
Taylor expanded in phi1 around 0 49.0%
Taylor expanded in phi2 around 0 39.1%
Final simplification39.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
(atan2
(+
(sin (* 0.5 lambda1))
(/ (* -0.25 (* phi2 phi1)) (sin (* 0.5 (- lambda1 lambda2)))))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
(* t_0 t_0)
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))))
(* R 2.0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return atan2((sin((0.5 * lambda1)) + ((-0.25 * (phi2 * phi1)) / sin((0.5 * (lambda1 - lambda2))))), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), (t_0 * t_0), (0.5 - (cos((phi1 - phi2)) / 2.0)))))) * (R * 2.0);
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(atan(Float64(sin(Float64(0.5 * lambda1)) + Float64(Float64(-0.25 * Float64(phi2 * phi1)) / sin(Float64(0.5 * Float64(lambda1 - lambda2))))), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), Float64(t_0 * t_0), Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))))) * Float64(R * 2.0)) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[ArcTan[N[(N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[(-0.25 * N[(phi2 * phi1), $MachinePrecision]), $MachinePrecision] / N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\tan^{-1}_* \frac{\sin \left(0.5 \cdot \lambda_1\right) + \frac{-0.25 \cdot \left(\phi_2 \cdot \phi_1\right)}{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0 \cdot t\_0, 0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 66.2%
associate-*r*66.2%
*-commutative66.2%
Simplified66.1%
Taylor expanded in phi2 around 0 50.5%
Taylor expanded in phi1 around 0 18.8%
associate-*r/18.8%
*-commutative18.8%
Simplified18.8%
Taylor expanded in lambda1 around inf 15.7%
unpow249.0%
sin-mult45.7%
div-inv45.7%
metadata-eval45.7%
div-inv45.7%
metadata-eval45.7%
div-inv45.7%
metadata-eval45.7%
div-inv45.7%
metadata-eval45.7%
Applied egg-rr15.7%
div-sub45.7%
+-inverses45.7%
cos-045.7%
metadata-eval45.7%
distribute-lft-out45.7%
metadata-eval45.7%
*-rgt-identity45.7%
Simplified15.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
(* R 2.0)
(atan2
(+
(* 0.5 lambda1)
(/ (* -0.25 (* phi2 phi1)) (sin (* 0.5 (- lambda1 lambda2)))))
(sqrt
(-
1.0
(fma
(* (cos phi1) (cos phi2))
(* t_0 t_0)
(pow (sin (/ (- phi1 phi2) 2.0)) 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(((0.5 * lambda1) + ((-0.25 * (phi2 * phi1)) / sin((0.5 * (lambda1 - lambda2))))), sqrt((1.0 - fma((cos(phi1) * cos(phi2)), (t_0 * t_0), pow(sin(((phi1 - phi2) / 2.0)), 2.0)))));
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(Float64(R * 2.0) * atan(Float64(Float64(0.5 * lambda1) + Float64(Float64(-0.25 * Float64(phi2 * phi1)) / sin(Float64(0.5 * Float64(lambda1 - lambda2))))), sqrt(Float64(1.0 - fma(Float64(cos(phi1) * cos(phi2)), Float64(t_0 * t_0), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[(R * 2.0), $MachinePrecision] * N[ArcTan[N[(N[(0.5 * lambda1), $MachinePrecision] + N[(N[(-0.25 * N[(phi2 * phi1), $MachinePrecision]), $MachinePrecision] / N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\left(R \cdot 2\right) \cdot \tan^{-1}_* \frac{0.5 \cdot \lambda_1 + \frac{-0.25 \cdot \left(\phi_2 \cdot \phi_1\right)}{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0 \cdot t\_0, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}
\end{array}
\end{array}
Initial program 66.2%
associate-*r*66.2%
*-commutative66.2%
Simplified66.1%
Taylor expanded in phi2 around 0 50.5%
Taylor expanded in phi1 around 0 18.8%
associate-*r/18.8%
*-commutative18.8%
Simplified18.8%
Taylor expanded in lambda1 around inf 15.7%
Taylor expanded in lambda1 around 0 11.5%
Final simplification11.5%
herbie shell --seed 2024182
(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))))))))))