
(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 23 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+
(- 1.0 t_1)
(*
t_0
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 65.3%
associate-*l*65.3%
Simplified65.3%
div-sub65.3%
sin-diff66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr66.3%
div-sub65.3%
sin-diff66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr76.3%
sin-mult76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
cos-sum76.3%
cos-276.4%
div-inv76.4%
metadata-eval76.4%
Applied egg-rr76.4%
div-sub76.4%
+-inverses76.4%
cos-076.4%
metadata-eval76.4%
associate-*r*76.4%
Simplified76.4%
Final simplification76.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (+ (* t_2 (* t_0 t_2)) t_1))
(t_4 (sqrt (- (- 1.0 t_1) (* t_0 (* t_2 t_2))))))
(if (<= (atan2 (sqrt t_3) (sqrt (- 1.0 t_3))) 0.094)
(*
R
(*
2.0
(atan2
(hypot
(* (sin (* 0.5 (- lambda1 lambda2))) (sqrt t_0))
(sin (* 0.5 (- phi1 phi2))))
t_4)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)
(* t_0 (- 0.5 (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0)))))
t_4))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (t_2 * (t_0 * t_2)) + t_1;
double t_4 = sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2))));
double tmp;
if (atan2(sqrt(t_3), sqrt((1.0 - t_3))) <= 0.094) {
tmp = R * (2.0 * atan2(hypot((sin((0.5 * (lambda1 - lambda2))) * sqrt(t_0)), sin((0.5 * (phi1 - phi2)))), t_4));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0) + (t_0 * (0.5 - (cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0))))), t_4));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (t_2 * (t_0 * t_2)) + t_1;
double t_4 = Math.sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2))));
double tmp;
if (Math.atan2(Math.sqrt(t_3), Math.sqrt((1.0 - t_3))) <= 0.094) {
tmp = R * (2.0 * Math.atan2(Math.hypot((Math.sin((0.5 * (lambda1 - lambda2))) * Math.sqrt(t_0)), Math.sin((0.5 * (phi1 - phi2)))), t_4));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0) + (t_0 * (0.5 - (Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0))))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (t_2 * (t_0 * t_2)) + t_1 t_4 = math.sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2)))) tmp = 0 if math.atan2(math.sqrt(t_3), math.sqrt((1.0 - t_3))) <= 0.094: tmp = R * (2.0 * math.atan2(math.hypot((math.sin((0.5 * (lambda1 - lambda2))) * math.sqrt(t_0)), math.sin((0.5 * (phi1 - phi2)))), t_4)) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) + (t_0 * (0.5 - (math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0))))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(t_2 * Float64(t_0 * t_2)) + t_1) t_4 = sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * Float64(t_2 * t_2)))) tmp = 0.0 if (atan(sqrt(t_3), sqrt(Float64(1.0 - t_3))) <= 0.094) tmp = Float64(R * Float64(2.0 * atan(hypot(Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(t_0)), sin(Float64(0.5 * Float64(phi1 - phi2)))), t_4))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0) + Float64(t_0 * Float64(0.5 - Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0))))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (t_2 * (t_0 * t_2)) + t_1; t_4 = sqrt(((1.0 - t_1) - (t_0 * (t_2 * t_2)))); tmp = 0.0; if (atan2(sqrt(t_3), sqrt((1.0 - t_3))) <= 0.094) tmp = R * (2.0 * atan2(hypot((sin((0.5 * (lambda1 - lambda2))) * sqrt(t_0)), sin((0.5 * (phi1 - phi2)))), t_4)); else tmp = R * (2.0 * atan2(sqrt(((((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0) + (t_0 * (0.5 - (cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0))))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[ArcTan[N[Sqrt[t$95$3], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision], 0.094], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$0], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(0.5 - N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(t\_0 \cdot t\_2\right) + t\_1\\
t_4 := \sqrt{\left(1 - t\_1\right) - t\_0 \cdot \left(t\_2 \cdot t\_2\right)}\\
\mathbf{if}\;\tan^{-1}_* \frac{\sqrt{t\_3}}{\sqrt{1 - t\_3}} \leq 0.094:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{t\_0}, \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\right)}{t\_4}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t\_0 \cdot \left(0.5 - \frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2}\right)}}{t\_4}\right)\\
\end{array}
\end{array}
if (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) < 0.094Initial program 81.7%
associate-*l*81.7%
Simplified81.7%
+-commutative81.7%
add-sqr-sqrt81.7%
unpow281.7%
hypot-define86.0%
Applied egg-rr91.4%
if 0.094 < (atan2.f64 (sqrt.f64 (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))) (sqrt.f64 (-.f64 #s(literal 1 binary64) (+.f64 (pow.f64 (sin.f64 (/.f64 (-.f64 phi1 phi2) #s(literal 2 binary64))) #s(literal 2 binary64)) (*.f64 (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))) (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64)))))))) Initial program 63.7%
associate-*l*63.7%
Simplified63.7%
div-sub63.7%
sin-diff64.8%
div-inv64.8%
metadata-eval64.8%
div-inv64.8%
metadata-eval64.8%
div-inv64.8%
metadata-eval64.8%
div-inv64.8%
metadata-eval64.8%
Applied egg-rr64.8%
sin-mult75.8%
div-inv75.8%
metadata-eval75.8%
div-inv75.8%
metadata-eval75.8%
cos-sum75.8%
cos-275.8%
div-inv75.8%
metadata-eval75.8%
Applied egg-rr64.8%
div-sub75.8%
+-inverses75.8%
cos-075.8%
metadata-eval75.8%
associate-*r*75.8%
Simplified64.8%
Final simplification67.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (- 1.0 t_0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (cos phi1) (cos phi2))))
(if (or (<= lambda2 -3.3e-5) (not (<= lambda2 0.000118)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
(sqrt
(+
t_1
(*
t_3
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_3 (* t_2 t_2))))
(sqrt (+ t_1 (* t_3 (- (/ (cos lambda1) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos(phi1) * cos(phi2);
double tmp;
if ((lambda2 <= -3.3e-5) || !(lambda2 <= 0.000118)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), sqrt((t_1 + (t_3 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_2 * t_2)))), sqrt((t_1 + (t_3 * ((cos(lambda1) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos(phi1) * cos(phi2)
if ((lambda2 <= (-3.3d-5)) .or. (.not. (lambda2 <= 0.000118d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), sqrt((t_1 + (t_3 * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_3 * (t_2 * t_2)))), sqrt((t_1 + (t_3 * ((cos(lambda1) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((lambda2 <= -3.3e-5) || !(lambda2 <= 0.000118)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), Math.sqrt((t_1 + (t_3 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * (t_2 * t_2)))), Math.sqrt((t_1 + (t_3 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = 1.0 - t_0 t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (lambda2 <= -3.3e-5) or not (lambda2 <= 0.000118): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), math.sqrt((t_1 + (t_3 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_3 * (t_2 * t_2)))), math.sqrt((t_1 + (t_3 * ((math.cos(lambda1) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((lambda2 <= -3.3e-5) || !(lambda2 <= 0.000118)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), sqrt(Float64(t_1 + Float64(t_3 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * Float64(t_2 * t_2)))), sqrt(Float64(t_1 + Float64(t_3 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = 1.0 - t_0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos(phi1) * cos(phi2); tmp = 0.0; if ((lambda2 <= -3.3e-5) || ~((lambda2 <= 0.000118))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), sqrt((t_1 + (t_3 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * (t_2 * t_2)))), sqrt((t_1 + (t_3 * ((cos(lambda1) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[lambda2, -3.3e-5], N[Not[LessEqual[lambda2, 0.000118]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$3 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$3 * N[(N[(N[Cos[lambda1], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := 1 - t\_0\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq -3.3 \cdot 10^{-5} \lor \neg \left(\lambda_2 \leq 0.000118\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{t\_1 + t\_3 \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{t\_1 + t\_3 \cdot \left(\frac{\cos \lambda_1}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < -3.3000000000000003e-5 or 1.18e-4 < lambda2 Initial program 52.6%
associate-*l*52.5%
Simplified52.6%
div-sub52.6%
sin-diff53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
Applied egg-rr53.8%
div-sub52.6%
sin-diff53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
div-inv53.8%
metadata-eval53.8%
Applied egg-rr60.8%
sin-mult60.8%
div-inv60.8%
metadata-eval60.8%
div-inv60.8%
metadata-eval60.8%
cos-sum60.8%
cos-260.8%
div-inv60.8%
metadata-eval60.8%
Applied egg-rr60.8%
div-sub60.8%
+-inverses60.8%
cos-060.8%
metadata-eval60.8%
associate-*r*60.8%
Simplified60.8%
Taylor expanded in lambda1 around 0 60.4%
if -3.3000000000000003e-5 < lambda2 < 1.18e-4Initial program 81.3%
associate-*l*81.3%
Simplified81.3%
div-sub81.3%
sin-diff81.9%
div-inv81.9%
metadata-eval81.9%
div-inv81.9%
metadata-eval81.9%
div-inv81.9%
metadata-eval81.9%
div-inv81.9%
metadata-eval81.9%
Applied egg-rr81.9%
div-sub81.3%
sin-diff81.9%
div-inv81.9%
metadata-eval81.9%
div-inv81.9%
metadata-eval81.9%
div-inv81.9%
metadata-eval81.9%
div-inv81.9%
metadata-eval81.9%
Applied egg-rr95.7%
sin-mult95.8%
div-inv95.8%
metadata-eval95.8%
div-inv95.8%
metadata-eval95.8%
cos-sum95.7%
cos-295.8%
div-inv95.8%
metadata-eval95.8%
Applied egg-rr95.8%
div-sub95.8%
+-inverses95.8%
cos-095.8%
metadata-eval95.8%
associate-*r*95.8%
Simplified95.8%
Taylor expanded in lambda2 around 0 95.8%
Final simplification76.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sqrt (+ t_0 (* t_2 (* t_3 t_3))))))
(if (<= lambda1 -5.5e-6)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
(sqrt
(+
t_1
(*
t_2
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5)))))))
(if (<= lambda1 0.00021)
(*
R
(*
2.0
(atan2 t_4 (sqrt (+ t_1 (* t_2 (- (/ (cos lambda2) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2 t_4 (sqrt (+ t_1 (* t_2 (- (/ (cos lambda1) 2.0) 0.5)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda1 <= -5.5e-6) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), sqrt((t_1 + (t_2 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else if (lambda1 <= 0.00021) {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda2) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = cos(phi1) * cos(phi2)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3))))
if (lambda1 <= (-5.5d-6)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), sqrt((t_1 + (t_2 * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
else if (lambda1 <= 0.00021d0) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda2) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.sqrt((t_0 + (t_2 * (t_3 * t_3))));
double tmp;
if (lambda1 <= -5.5e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), Math.sqrt((t_1 + (t_2 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else if (lambda1 <= 0.00021) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda2) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((t_1 + (t_2 * ((Math.cos(lambda1) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = 1.0 - t_0 t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.sqrt((t_0 + (t_2 * (t_3 * t_3)))) tmp = 0 if lambda1 <= -5.5e-6: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), math.sqrt((t_1 + (t_2 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))) elif lambda1 <= 0.00021: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 + (t_2 * ((math.cos(lambda2) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((t_1 + (t_2 * ((math.cos(lambda1) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))) tmp = 0.0 if (lambda1 <= -5.5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))); elseif (lambda1 <= 0.00021) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda2) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(lambda1) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = 1.0 - t_0; t_2 = cos(phi1) * cos(phi2); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sqrt((t_0 + (t_2 * (t_3 * t_3)))); tmp = 0.0; if (lambda1 <= -5.5e-6) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), sqrt((t_1 + (t_2 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); elseif (lambda1 <= 0.00021) tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda2) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(t_4, sqrt((t_1 + (t_2 * ((cos(lambda1) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda1, -5.5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 0.00021], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda2], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[lambda1], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := 1 - t\_0\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sqrt{t\_0 + t\_2 \cdot \left(t\_3 \cdot t\_3\right)}\\
\mathbf{if}\;\lambda_1 \leq -5.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{\sqrt{t\_1 + t\_2 \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 0.00021:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{t\_1 + t\_2 \cdot \left(\frac{\cos \lambda_2}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4}{\sqrt{t\_1 + t\_2 \cdot \left(\frac{\cos \lambda_1}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if lambda1 < -5.4999999999999999e-6Initial program 50.5%
associate-*l*50.5%
Simplified50.5%
div-sub50.5%
sin-diff51.3%
div-inv51.3%
metadata-eval51.3%
div-inv51.3%
metadata-eval51.3%
div-inv51.3%
metadata-eval51.3%
div-inv51.3%
metadata-eval51.3%
Applied egg-rr51.3%
div-sub50.5%
sin-diff51.3%
div-inv51.3%
metadata-eval51.3%
div-inv51.3%
metadata-eval51.3%
div-inv51.3%
metadata-eval51.3%
div-inv51.3%
metadata-eval51.3%
Applied egg-rr57.8%
sin-mult57.8%
div-inv57.8%
metadata-eval57.8%
div-inv57.8%
metadata-eval57.8%
cos-sum57.8%
cos-257.8%
div-inv57.8%
metadata-eval57.8%
Applied egg-rr57.8%
div-sub57.8%
+-inverses57.8%
cos-057.8%
metadata-eval57.8%
associate-*r*57.8%
Simplified57.8%
Taylor expanded in lambda2 around 0 58.2%
if -5.4999999999999999e-6 < lambda1 < 2.1000000000000001e-4Initial program 81.6%
associate-*l*81.6%
Simplified81.6%
div-sub81.6%
sin-diff82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
Applied egg-rr82.2%
div-sub81.6%
sin-diff82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
Applied egg-rr96.2%
sin-mult96.2%
div-inv96.2%
metadata-eval96.2%
div-inv96.2%
metadata-eval96.2%
cos-sum96.2%
cos-296.2%
div-inv96.2%
metadata-eval96.2%
Applied egg-rr96.2%
div-sub96.2%
+-inverses96.2%
cos-096.2%
metadata-eval96.2%
associate-*r*96.2%
Simplified96.2%
Taylor expanded in lambda1 around 0 95.9%
cos-neg95.9%
Simplified95.9%
if 2.1000000000000001e-4 < lambda1 Initial program 48.6%
associate-*l*48.7%
Simplified48.7%
div-sub48.7%
sin-diff50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
Applied egg-rr50.4%
div-sub48.7%
sin-diff50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
div-inv50.4%
metadata-eval50.4%
Applied egg-rr56.4%
sin-mult56.4%
div-inv56.4%
metadata-eval56.4%
div-inv56.4%
metadata-eval56.4%
cos-sum56.3%
cos-256.4%
div-inv56.4%
metadata-eval56.4%
Applied egg-rr56.4%
div-sub56.4%
+-inverses56.4%
cos-056.4%
metadata-eval56.4%
associate-*r*56.4%
Simplified56.4%
Taylor expanded in lambda2 around 0 56.4%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1
(sqrt
(+
(- 1.0 t_0)
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5))))))
(if (or (<= lambda1 -5.8e-8) (not (<= lambda1 1.2e-5)))
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi1) (* (cos phi2) (pow (sin (* 0.5 lambda1)) 2.0)))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = sqrt(((1.0 - t_0) + ((cos(phi1) * cos(phi2)) * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))));
double tmp;
if ((lambda1 <= -5.8e-8) || !(lambda1 <= 1.2e-5)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((0.5 * lambda1)), 2.0))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = sqrt(((1.0d0 - t_0) + ((cos(phi1) * cos(phi2)) * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))
if ((lambda1 <= (-5.8d-8)) .or. (.not. (lambda1 <= 1.2d-5))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5d0 * lambda1)) ** 2.0d0))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.sqrt(((1.0 - t_0) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))));
double tmp;
if ((lambda1 <= -5.8e-8) || !(lambda1 <= 1.2e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((0.5 * lambda1)), 2.0))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = math.sqrt(((1.0 - t_0) + ((math.cos(phi1) * math.cos(phi2)) * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))) tmp = 0 if (lambda1 <= -5.8e-8) or not (lambda1 <= 1.2e-5): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((0.5 * lambda1)), 2.0))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = sqrt(Float64(Float64(1.0 - t_0) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5)))) tmp = 0.0 if ((lambda1 <= -5.8e-8) || !(lambda1 <= 1.2e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(0.5 * lambda1)) ^ 2.0))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = sqrt(((1.0 - t_0) + ((cos(phi1) * cos(phi2)) * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))); tmp = 0.0; if ((lambda1 <= -5.8e-8) || ~((lambda1 <= 1.2e-5))) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((0.5 * lambda1)) ^ 2.0))))), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[lambda1, -5.8e-8], N[Not[LessEqual[lambda1, 1.2e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * lambda1), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := \sqrt{\left(1 - t\_0\right) + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}\\
\mathbf{if}\;\lambda_1 \leq -5.8 \cdot 10^{-8} \lor \neg \left(\lambda_1 \leq 1.2 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(0.5 \cdot \lambda_1\right)}^{2}\right)}}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{t\_1}\right)\\
\end{array}
\end{array}
if lambda1 < -5.8000000000000003e-8 or 1.2e-5 < lambda1 Initial program 49.6%
associate-*l*49.6%
Simplified49.6%
div-sub49.6%
sin-diff50.9%
div-inv50.9%
metadata-eval50.9%
div-inv50.9%
metadata-eval50.9%
div-inv50.9%
metadata-eval50.9%
div-inv50.9%
metadata-eval50.9%
Applied egg-rr50.9%
div-sub49.6%
sin-diff50.9%
div-inv50.9%
metadata-eval50.9%
div-inv50.9%
metadata-eval50.9%
div-inv50.9%
metadata-eval50.9%
div-inv50.9%
metadata-eval50.9%
Applied egg-rr57.1%
sin-mult57.1%
div-inv57.1%
metadata-eval57.1%
div-inv57.1%
metadata-eval57.1%
cos-sum57.1%
cos-257.1%
div-inv57.1%
metadata-eval57.1%
Applied egg-rr57.1%
div-sub57.1%
+-inverses57.1%
cos-057.1%
metadata-eval57.1%
associate-*r*57.1%
Simplified57.1%
Taylor expanded in lambda2 around 0 57.3%
if -5.8000000000000003e-8 < lambda1 < 1.2e-5Initial program 81.6%
associate-*l*81.6%
Simplified81.6%
div-sub81.6%
sin-diff82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
Applied egg-rr82.2%
div-sub81.6%
sin-diff82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
div-inv82.2%
metadata-eval82.2%
Applied egg-rr96.2%
sin-mult96.2%
div-inv96.2%
metadata-eval96.2%
div-inv96.2%
metadata-eval96.2%
cos-sum96.2%
cos-296.2%
div-inv96.2%
metadata-eval96.2%
Applied egg-rr96.2%
div-sub96.2%
+-inverses96.2%
cos-096.2%
metadata-eval96.2%
associate-*r*96.2%
Simplified96.2%
Taylor expanded in lambda1 around 0 94.3%
Final simplification75.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_2 (* t_1 t_2)))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_5 (* t_1 (* t_2 t_2))))
(if (<= lambda1 -3.7e-16)
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_3)) (sqrt (- 1.0 (+ t_3 t_4))))))
(if (<= lambda1 1.9e-11)
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (cos phi1) (* (cos phi2) (pow (sin (* lambda2 -0.5)) 2.0)))))
(sqrt
(+
(- 1.0 t_0)
(*
t_1
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_5)) (sqrt (- (- 1.0 t_4) t_5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * (t_1 * t_2);
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = t_1 * (t_2 * t_2);
double tmp;
if (lambda1 <= -3.7e-16) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - (t_3 + t_4)))));
} else if (lambda1 <= 1.9e-11) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * pow(sin((lambda2 * -0.5)), 2.0))))), sqrt(((1.0 - t_0) + (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_5)), sqrt(((1.0 - t_4) - t_5))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_2 * (t_1 * t_2)
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_5 = t_1 * (t_2 * t_2)
if (lambda1 <= (-3.7d-16)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0d0 - (t_3 + t_4)))))
else if (lambda1 <= 1.9d-11) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))), sqrt(((1.0d0 - t_0) + (t_1 * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_5)), sqrt(((1.0d0 - t_4) - t_5))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_2 * (t_1 * t_2);
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = t_1 * (t_2 * t_2);
double tmp;
if (lambda1 <= -3.7e-16) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_3)), Math.sqrt((1.0 - (t_3 + t_4)))));
} else if (lambda1 <= 1.9e-11) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))))), Math.sqrt(((1.0 - t_0) + (t_1 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_5)), Math.sqrt(((1.0 - t_4) - t_5))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_2 * (t_1 * t_2) t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_5 = t_1 * (t_2 * t_2) tmp = 0 if lambda1 <= -3.7e-16: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_3)), math.sqrt((1.0 - (t_3 + t_4))))) elif lambda1 <= 1.9e-11: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.pow(math.sin((lambda2 * -0.5)), 2.0))))), math.sqrt(((1.0 - t_0) + (t_1 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_5)), math.sqrt(((1.0 - t_4) - t_5)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_2 * Float64(t_1 * t_2)) t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_5 = Float64(t_1 * Float64(t_2 * t_2)) tmp = 0.0 if (lambda1 <= -3.7e-16) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_3)), sqrt(Float64(1.0 - Float64(t_3 + t_4)))))); elseif (lambda1 <= 1.9e-11) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * (sin(Float64(lambda2 * -0.5)) ^ 2.0))))), sqrt(Float64(Float64(1.0 - t_0) + Float64(t_1 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_5)), sqrt(Float64(Float64(1.0 - t_4) - t_5))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_2 * (t_1 * t_2); t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_5 = t_1 * (t_2 * t_2); tmp = 0.0; if (lambda1 <= -3.7e-16) tmp = R * (2.0 * atan2(sqrt((t_0 + t_3)), sqrt((1.0 - (t_3 + t_4))))); elseif (lambda1 <= 1.9e-11) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (cos(phi2) * (sin((lambda2 * -0.5)) ^ 2.0))))), sqrt(((1.0 - t_0) + (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + t_5)), sqrt(((1.0 - t_4) - t_5)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -3.7e-16], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + t$95$4), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda1, 1.9e-11], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$4), $MachinePrecision] - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_2 \cdot \left(t\_1 \cdot t\_2\right)\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_5 := t\_1 \cdot \left(t\_2 \cdot t\_2\right)\\
\mathbf{if}\;\lambda_1 \leq -3.7 \cdot 10^{-16}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_3}}{\sqrt{1 - \left(t\_3 + t\_4\right)}}\right)\\
\mathbf{elif}\;\lambda_1 \leq 1.9 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{\left(1 - t\_0\right) + t\_1 \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_5}}{\sqrt{\left(1 - t\_4\right) - t\_5}}\right)\\
\end{array}
\end{array}
if lambda1 < -3.7e-16Initial program 51.3%
div-sub51.2%
sin-diff52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
div-inv52.0%
metadata-eval52.0%
Applied egg-rr52.0%
if -3.7e-16 < lambda1 < 1.8999999999999999e-11Initial program 81.7%
associate-*l*81.7%
Simplified81.7%
div-sub81.7%
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%
div-sub81.7%
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-rr97.0%
sin-mult97.0%
div-inv97.0%
metadata-eval97.0%
div-inv97.0%
metadata-eval97.0%
cos-sum97.0%
cos-297.0%
div-inv97.0%
metadata-eval97.0%
Applied egg-rr97.0%
div-sub97.0%
+-inverses97.0%
cos-097.0%
metadata-eval97.0%
associate-*r*97.0%
Simplified97.0%
Taylor expanded in lambda1 around 0 96.0%
if 1.8999999999999999e-11 < lambda1 Initial program 50.6%
associate-*l*50.7%
Simplified50.6%
div-sub50.6%
sin-diff52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
div-inv52.3%
metadata-eval52.3%
Applied egg-rr52.3%
Final simplification72.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(-
(- 1.0 t_1)
(* t_0 (+ (+ 1.5 (* -0.5 (cos (- lambda1 lambda2)))) -1.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * ((1.5 + (-0.5 * cos((lambda1 - lambda2)))) + -1.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) - (t_0 * ((1.5d0 + ((-0.5d0) * cos((lambda1 - lambda2)))) + (-1.0d0)))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) - (t_0 * ((1.5 + (-0.5 * Math.cos((lambda1 - lambda2)))) + -1.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) - (t_0 * ((1.5 + (-0.5 * math.cos((lambda1 - lambda2)))) + -1.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) - Float64(t_0 * Float64(Float64(1.5 + Float64(-0.5 * cos(Float64(lambda1 - lambda2)))) + -1.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) - (t_0 * ((1.5 + (-0.5 * cos((lambda1 - lambda2)))) + -1.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - N[(t$95$0 * N[(N[(1.5 + N[(-0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + -1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) - t\_0 \cdot \left(\left(1.5 + -0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) + -1\right)}}\right)
\end{array}
\end{array}
Initial program 65.3%
associate-*l*65.3%
Simplified65.3%
div-sub65.3%
sin-diff66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr66.3%
div-sub65.3%
sin-diff66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr76.3%
sin-mult76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
cos-sum76.3%
cos-276.4%
div-inv76.4%
metadata-eval76.4%
Applied egg-rr76.4%
div-sub76.4%
+-inverses76.4%
cos-076.4%
metadata-eval76.4%
associate-*r*76.4%
Simplified76.4%
expm1-log1p-u76.3%
div-inv76.3%
associate-*l*76.3%
metadata-eval76.3%
Applied egg-rr76.3%
Simplified76.3%
Final simplification76.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 65.3%
associate-*l*65.3%
Simplified65.3%
div-sub65.3%
sin-diff66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr66.0%
Final simplification66.0%
(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
(-
(* (cos (* 0.5 phi2)) (sin (* phi1 0.5)))
(* (cos (* phi1 0.5)) (sin (* 0.5 phi2))))
2.0)
t_1))
(sqrt (- (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((pow(((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))), 2.0) + t_1)), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt(((((cos((0.5d0 * phi2)) * sin((phi1 * 0.5d0))) - (cos((phi1 * 0.5d0)) * sin((0.5d0 * phi2)))) ** 2.0d0) + t_1)), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.cos((0.5 * phi2)) * Math.sin((phi1 * 0.5))) - (Math.cos((phi1 * 0.5)) * Math.sin((0.5 * phi2)))), 2.0) + t_1)), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.cos((0.5 * phi2)) * math.sin((phi1 * 0.5))) - (math.cos((phi1 * 0.5)) * math.sin((0.5 * phi2)))), 2.0) + t_1)), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(cos(Float64(0.5 * phi2)) * sin(Float64(phi1 * 0.5))) - Float64(cos(Float64(phi1 * 0.5)) * sin(Float64(0.5 * phi2)))) ^ 2.0) + t_1)), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt(((((cos((0.5 * phi2)) * sin((phi1 * 0.5))) - (cos((phi1 * 0.5)) * sin((0.5 * phi2)))) ^ 2.0) + t_1)), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Cos[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\cos \left(0.5 \cdot \phi_2\right) \cdot \sin \left(\phi_1 \cdot 0.5\right) - \cos \left(\phi_1 \cdot 0.5\right) \cdot \sin \left(0.5 \cdot \phi_2\right)\right)}^{2} + t\_1}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 65.3%
associate-*l*65.3%
Simplified65.3%
div-sub65.3%
sin-diff66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
div-inv66.3%
metadata-eval66.3%
Applied egg-rr66.3%
Final simplification66.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(cbrt
(pow
(-
1.0
(fma
(cos phi1)
(* (cos phi2) (- 0.5 (* 0.5 (cos (- lambda1 lambda2)))))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))
3.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(cbrt(pow((1.0 - fma(cos(phi1), (cos(phi2) * (0.5 - (0.5 * cos((lambda1 - lambda2))))), pow(sin((0.5 * (phi1 - phi2))), 2.0))), 3.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(cbrt((Float64(1.0 - fma(cos(phi1), Float64(cos(phi2) * Float64(0.5 - Float64(0.5 * cos(Float64(lambda1 - lambda2))))), (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0))) ^ 3.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[Power[N[Power[N[(1.0 - N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(0.5 - N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $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{\sqrt[3]{{\left(1 - \mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \left(0.5 - 0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right), {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)\right)}^{3}}}}\right)
\end{array}
\end{array}
Initial program 65.3%
Applied egg-rr65.4%
Final simplification65.4%
(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))
(t_2 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(* R (* 2.0 (atan2 (sqrt (+ t_2 t_1)) (sqrt (- (- 1.0 t_1) 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 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_1) - t_2))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0d0 - t_1) - t_2))))
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);
double t_2 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_1)), Math.sqrt(((1.0 - t_1) - t_2))));
}
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) t_2 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_2 + t_1)), math.sqrt(((1.0 - t_1) - t_2))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_2 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_1)), sqrt(Float64(Float64(1.0 - t_1) - t_2))))) 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; t_2 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_1) - t_2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] - 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 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + t\_1}}{\sqrt{\left(1 - t\_1\right) - t\_2}}\right)
\end{array}
\end{array}
Initial program 65.3%
associate-*l*65.3%
Simplified65.3%
Final simplification65.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= phi2 -4.7e-14)
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* 0.5 phi2)) 2.0)))
(sqrt (- t_3 (* t_1 (* t_2 t_2)))))))
(if (<= phi2 7300.0)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_2)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi2) t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
t_3
(*
(cos phi2)
(pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (phi2 <= -4.7e-14) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((0.5 * phi2)), 2.0))), sqrt((t_3 - (t_1 * (t_2 * t_2))))));
} else if (phi2 <= 7300.0) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi1) * t_0) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), t_0, pow(sin((phi2 * -0.5)), 2.0))), sqrt((t_3 - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (phi2 <= -4.7e-14) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(0.5 * phi2)) ^ 2.0))), sqrt(Float64(t_3 - Float64(t_1 * Float64(t_2 * t_2))))))); elseif (phi2 <= 7300.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_0) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), t_0, (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(t_3 - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -4.7e-14], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 7300.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$2), $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[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$3 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -4.7 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}}}{\sqrt{t\_3 - t\_1 \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 7300:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_0 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{t\_3 - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -4.7000000000000002e-14Initial program 53.5%
associate-*l*53.5%
Simplified53.5%
div-sub53.5%
sin-diff55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
Applied egg-rr55.1%
Taylor expanded in phi1 around 0 55.8%
unpow255.8%
1-sub-sin55.8%
unpow255.8%
Simplified55.8%
Taylor expanded in phi1 around 0 55.4%
if -4.7000000000000002e-14 < phi2 < 7300Initial program 75.0%
Taylor expanded in phi2 around 0 75.0%
if 7300 < phi2 Initial program 57.5%
Taylor expanded in phi1 around 0 58.6%
+-commutative58.6%
associate--r+58.6%
unpow258.6%
1-sub-sin58.7%
unpow258.7%
*-commutative58.7%
sub-neg58.7%
mul-1-neg58.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in phi1 around 0 60.4%
fma-define60.4%
*-commutative60.4%
Simplified60.4%
Final simplification66.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_4 (pow (cos (* phi2 -0.5)) 2.0)))
(if (<= phi2 -4.7e-14)
(*
R
(*
2.0
(atan2
(sqrt (+ (* (cos phi2) t_0) (pow (sin (* 0.5 phi2)) 2.0)))
(sqrt (- t_4 (* t_1 (* t_2 t_2)))))))
(if (<= phi2 7300.0)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_2)) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_3))))))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi2) t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- t_4 (* (cos phi2) t_3))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((0.5 * (lambda1 - lambda2))), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_4 = pow(cos((phi2 * -0.5)), 2.0);
double tmp;
if (phi2 <= -4.7e-14) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * t_0) + pow(sin((0.5 * phi2)), 2.0))), sqrt((t_4 - (t_1 * (t_2 * t_2))))));
} else if (phi2 <= 7300.0) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_3)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), t_0, pow(sin((phi2 * -0.5)), 2.0))), sqrt((t_4 - (cos(phi2) * t_3)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_4 = cos(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (phi2 <= -4.7e-14) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * t_0) + (sin(Float64(0.5 * phi2)) ^ 2.0))), sqrt(Float64(t_4 - Float64(t_1 * Float64(t_2 * t_2))))))); elseif (phi2 <= 7300.0) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_2)) + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_3)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), t_0, (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(t_4 - Float64(cos(phi2) * t_3)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi2, -4.7e-14], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(0.5 * phi2), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 7300.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$4 - N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_4 := {\cos \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -4.7 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot t\_0 + {\sin \left(0.5 \cdot \phi_2\right)}^{2}}}{\sqrt{t\_4 - t\_1 \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 7300:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_2\right) + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, t\_0, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{t\_4 - \cos \phi_2 \cdot t\_3}}\right)\\
\end{array}
\end{array}
if phi2 < -4.7000000000000002e-14Initial program 53.5%
associate-*l*53.5%
Simplified53.5%
div-sub53.5%
sin-diff55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
div-inv55.1%
metadata-eval55.1%
Applied egg-rr55.1%
Taylor expanded in phi1 around 0 55.8%
unpow255.8%
1-sub-sin55.8%
unpow255.8%
Simplified55.8%
Taylor expanded in phi1 around 0 55.4%
if -4.7000000000000002e-14 < phi2 < 7300Initial program 75.0%
Taylor expanded in phi2 around 0 75.0%
+-commutative75.0%
associate--r+75.0%
unpow275.0%
1-sub-sin75.0%
unpow275.0%
*-commutative75.0%
Simplified75.0%
if 7300 < phi2 Initial program 57.5%
Taylor expanded in phi1 around 0 58.6%
+-commutative58.6%
associate--r+58.6%
unpow258.6%
1-sub-sin58.7%
unpow258.7%
*-commutative58.7%
sub-neg58.7%
mul-1-neg58.7%
*-commutative58.7%
Simplified58.7%
Taylor expanded in phi1 around 0 60.4%
fma-define60.4%
*-commutative60.4%
Simplified60.4%
Final simplification66.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(+
1.0
(-
(*
(cos phi1)
(* (cos phi2) (- (* 0.5 (cos (- lambda1 lambda2))) 0.5)))
(pow (sin (* 0.5 (- phi1 phi2))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
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 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos((lambda1 - lambda2))) - 0.5))) - pow(sin((0.5 * (phi1 - phi2))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
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 + ((cos(phi1) * (cos(phi2) * ((0.5d0 * cos((lambda1 - lambda2))) - 0.5d0))) - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
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.cos(phi1) * (Math.cos(phi2) * ((0.5 * Math.cos((lambda1 - lambda2))) - 0.5))) - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 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.cos(phi1) * (math.cos(phi2) * ((0.5 * math.cos((lambda1 - lambda2))) - 0.5))) - math.pow(math.sin((0.5 * (phi1 - phi2))), 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 + Float64(Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(0.5 * cos(Float64(lambda1 - lambda2))) - 0.5))) - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 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 + ((cos(phi1) * (cos(phi2) * ((0.5 * cos((lambda1 - lambda2))) - 0.5))) - (sin((0.5 * (phi1 - phi2))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, 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[(N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
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 + \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)\right) - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 65.3%
Applied egg-rr65.3%
Final simplification65.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))
(if (or (<= (- lambda1 lambda2) -1e-68)
(not (<= (- lambda1 lambda2) 5e-11)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi1) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))
t_0)))
(* R (* 2.0 (atan2 (sin (* 0.5 (- phi1 phi2))) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double tmp;
if (((lambda1 - lambda2) <= -1e-68) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))), t_0));
} else {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))
if (((lambda1 - lambda2) <= (-1d-68)) .or. (.not. ((lambda1 - lambda2) <= 5d-11))) then
tmp = r * (2.0d0 * atan2(sqrt(((cos(phi1) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))), t_0))
else
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), t_0))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))));
double tmp;
if (((lambda1 - lambda2) <= -1e-68) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi1) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), t_0));
} else {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))) tmp = 0 if ((lambda1 - lambda2) <= -1e-68) or not ((lambda1 - lambda2) <= 5e-11): tmp = R * (2.0 * math.atan2(math.sqrt(((math.cos(phi1) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), t_0)) else: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0)))) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -1e-68) || !(Float64(lambda1 - lambda2) <= 5e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi1) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), t_0))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))); tmp = 0.0; if (((lambda1 - lambda2) <= -1e-68) || ~(((lambda1 - lambda2) <= 5e-11))) tmp = R * (2.0 * atan2(sqrt(((cos(phi1) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0))), t_0)); else tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e-68], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{-68} \lor \neg \left(\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_1 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{t\_0}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{t\_0}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000007e-68 or 5.00000000000000018e-11 < (-.f64 lambda1 lambda2) Initial program 62.4%
Taylor expanded in phi1 around 0 51.1%
+-commutative51.1%
associate--r+51.1%
unpow251.1%
1-sub-sin51.1%
unpow251.1%
*-commutative51.1%
sub-neg51.1%
mul-1-neg51.1%
*-commutative51.1%
Simplified51.1%
add-log-exp50.2%
unpow250.2%
associate-*r*50.2%
add-sqr-sqrt36.3%
hypot-define36.3%
Applied egg-rr36.3%
Taylor expanded in phi2 around 0 36.4%
if -1.00000000000000007e-68 < (-.f64 lambda1 lambda2) < 5.00000000000000018e-11Initial program 78.8%
Taylor expanded in phi1 around 0 66.9%
+-commutative66.9%
associate--r+66.9%
unpow266.9%
1-sub-sin67.0%
unpow267.0%
*-commutative67.0%
sub-neg67.0%
mul-1-neg67.0%
*-commutative67.0%
Simplified67.0%
Taylor expanded in lambda2 around 0 65.2%
Taylor expanded in lambda1 around 0 44.1%
Final simplification37.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 65.3%
Taylor expanded in phi1 around 0 53.9%
+-commutative53.9%
associate--r+53.9%
unpow253.9%
1-sub-sin54.0%
unpow254.0%
*-commutative54.0%
sub-neg54.0%
mul-1-neg54.0%
*-commutative54.0%
Simplified54.0%
Taylor expanded in phi1 around 0 54.1%
Final simplification54.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(* (cos phi2) (pow (sin (* 0.5 (- lambda1 lambda2))) 2.0))
(pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt(((cos(phi2) * pow(sin((0.5 * (lambda1 - lambda2))), 2.0)) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((cos(phi2) * (sin((0.5d0 * (lambda1 - lambda2))) ** 2.0d0)) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt(((Math.cos(phi2) * Math.pow(Math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sqrt(((math.cos(phi2) * math.pow(math.sin((0.5 * (lambda1 - lambda2))), 2.0)) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(cos(phi2) * (sin(Float64(0.5 * Float64(lambda1 - lambda2))) ^ 2.0)) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((cos(phi2) * (sin((0.5 * (lambda1 - lambda2))) ^ 2.0)) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\cos \phi_2 \cdot {\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)}^{2} + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 65.3%
Taylor expanded in phi1 around 0 53.9%
+-commutative53.9%
associate--r+53.9%
unpow253.9%
1-sub-sin54.0%
unpow254.0%
*-commutative54.0%
sub-neg54.0%
mul-1-neg54.0%
*-commutative54.0%
Simplified54.0%
Taylor expanded in phi1 around 0 51.8%
Final simplification51.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (* 0.5 (- lambda1 lambda2))) (sqrt (cos phi1))))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (sin (* 0.5 (- phi1 phi2)))))
(if (<= (- lambda1 lambda2) -1e+25)
(*
R
(*
2.0
(atan2
t_0
(sqrt
(+
t_2
(*
t_1
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5)))))))
(if (<= (- lambda1 lambda2) 5e-11)
(*
R
(*
2.0
(atan2
(+
t_4
(*
0.25
(/
(* lambda1 (* (cos phi1) (* (cos phi2) (sin (* lambda2 -0.5)))))
t_4)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(* R (* 2.0 (atan2 t_0 (sqrt (- t_2 (* t_1 (* t_3 t_3)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = 1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = sin((0.5 * (phi1 - phi2)));
double tmp;
if ((lambda1 - lambda2) <= -1e+25) {
tmp = R * (2.0 * atan2(t_0, sqrt((t_2 + (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else if ((lambda1 - lambda2) <= 5e-11) {
tmp = R * (2.0 * atan2((t_4 + (0.25 * ((lambda1 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5))))) / t_4))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt((t_2 - (t_1 * (t_3 * t_3))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) * sqrt(cos(phi1))
t_1 = cos(phi1) * cos(phi2)
t_2 = 1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = sin((0.5d0 * (phi1 - phi2)))
if ((lambda1 - lambda2) <= (-1d+25)) then
tmp = r * (2.0d0 * atan2(t_0, sqrt((t_2 + (t_1 * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
else if ((lambda1 - lambda2) <= 5d-11) then
tmp = r * (2.0d0 * atan2((t_4 + (0.25d0 * ((lambda1 * (cos(phi1) * (cos(phi2) * sin((lambda2 * (-0.5d0)))))) / t_4))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt((t_2 - (t_1 * (t_3 * 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((0.5 * (lambda1 - lambda2))) * Math.sqrt(Math.cos(phi1));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = 1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.sin((0.5 * (phi1 - phi2)));
double tmp;
if ((lambda1 - lambda2) <= -1e+25) {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((t_2 + (t_1 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else if ((lambda1 - lambda2) <= 5e-11) {
tmp = R * (2.0 * Math.atan2((t_4 + (0.25 * ((lambda1 * (Math.cos(phi1) * (Math.cos(phi2) * Math.sin((lambda2 * -0.5))))) / t_4))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((t_2 - (t_1 * (t_3 * t_3))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (lambda1 - lambda2))) * math.sqrt(math.cos(phi1)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = 1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.sin((0.5 * (phi1 - phi2))) tmp = 0 if (lambda1 - lambda2) <= -1e+25: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((t_2 + (t_1 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))) elif (lambda1 - lambda2) <= 5e-11: tmp = R * (2.0 * math.atan2((t_4 + (0.25 * ((lambda1 * (math.cos(phi1) * (math.cos(phi2) * math.sin((lambda2 * -0.5))))) / t_4))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((t_2 - (t_1 * (t_3 * t_3)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(cos(phi1))) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = sin(Float64(0.5 * Float64(phi1 - phi2))) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1e+25) tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(t_2 + Float64(t_1 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))); elseif (Float64(lambda1 - lambda2) <= 5e-11) tmp = Float64(R * Float64(2.0 * atan(Float64(t_4 + Float64(0.25 * Float64(Float64(lambda1 * Float64(cos(phi1) * Float64(cos(phi2) * sin(Float64(lambda2 * -0.5))))) / t_4))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(t_2 - Float64(t_1 * Float64(t_3 * t_3))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1)); t_1 = cos(phi1) * cos(phi2); t_2 = 1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0); t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = sin((0.5 * (phi1 - phi2))); tmp = 0.0; if ((lambda1 - lambda2) <= -1e+25) tmp = R * (2.0 * atan2(t_0, sqrt((t_2 + (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); elseif ((lambda1 - lambda2) <= 5e-11) tmp = R * (2.0 * atan2((t_4 + (0.25 * ((lambda1 * (cos(phi1) * (cos(phi2) * sin((lambda2 * -0.5))))) / t_4))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_0, sqrt((t_2 - (t_1 * (t_3 * t_3)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+25], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(t$95$2 + N[(t$95$1 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e-11], N[(R * N[(2.0 * N[ArcTan[N[(t$95$4 + N[(0.25 * N[(N[(lambda1 * N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / t$95$4), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(t$95$2 - N[(t$95$1 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := 1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+25}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{t\_2 + t\_1 \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_4 + 0.25 \cdot \frac{\lambda_1 \cdot \left(\cos \phi_1 \cdot \left(\cos \phi_2 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)\right)}{t\_4}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{t\_2 - t\_1 \cdot \left(t\_3 \cdot t\_3\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000009e25Initial program 59.5%
associate-*l*59.4%
Simplified59.5%
Taylor expanded in phi1 around 0 50.1%
Taylor expanded in phi2 around 0 19.5%
sin-mult66.9%
div-inv66.9%
metadata-eval66.9%
div-inv66.9%
metadata-eval66.9%
cos-sum66.9%
cos-266.9%
div-inv66.9%
metadata-eval66.9%
Applied egg-rr19.5%
div-sub66.9%
+-inverses66.9%
cos-066.9%
metadata-eval66.9%
associate-*r*66.9%
Simplified19.5%
if -1.00000000000000009e25 < (-.f64 lambda1 lambda2) < 5.00000000000000018e-11Initial program 78.7%
Taylor expanded in phi1 around 0 64.3%
+-commutative64.3%
associate--r+64.3%
unpow264.3%
1-sub-sin64.4%
unpow264.4%
*-commutative64.4%
sub-neg64.4%
mul-1-neg64.4%
*-commutative64.4%
Simplified64.4%
Taylor expanded in lambda2 around 0 57.1%
Taylor expanded in lambda1 around 0 34.5%
if 5.00000000000000018e-11 < (-.f64 lambda1 lambda2) Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in phi1 around 0 46.1%
Taylor expanded in phi2 around 0 18.2%
Final simplification22.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin (* 0.5 (- lambda1 lambda2))) (sqrt (cos phi1))))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))))
(if (<= (- lambda1 lambda2) -1e+25)
(*
R
(*
2.0
(atan2
t_0
(sqrt
(+
t_3
(*
t_1
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5)))))))
(if (<= (- lambda1 lambda2) 5e-11)
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(* R (* 2.0 (atan2 t_0 (sqrt (- t_3 (* t_1 (* t_2 t_2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = 1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -1e+25) {
tmp = R * (2.0 * atan2(t_0, sqrt((t_3 + (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else if ((lambda1 - lambda2) <= 5e-11) {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_0, sqrt((t_3 - (t_1 * (t_2 * t_2))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2))) * sqrt(cos(phi1))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = 1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)
if ((lambda1 - lambda2) <= (-1d+25)) then
tmp = r * (2.0d0 * atan2(t_0, sqrt((t_3 + (t_1 * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
else if ((lambda1 - lambda2) <= 5d-11) then
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_0, sqrt((t_3 - (t_1 * (t_2 * t_2))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * (lambda1 - lambda2))) * Math.sqrt(Math.cos(phi1));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = 1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -1e+25) {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((t_3 + (t_1 * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else if ((lambda1 - lambda2) <= 5e-11) {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_0, Math.sqrt((t_3 - (t_1 * (t_2 * t_2))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (lambda1 - lambda2))) * math.sqrt(math.cos(phi1)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = 1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) tmp = 0 if (lambda1 - lambda2) <= -1e+25: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((t_3 + (t_1 * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))) elif (lambda1 - lambda2) <= 5e-11: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_0, math.sqrt((t_3 - (t_1 * (t_2 * t_2)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(cos(phi1))) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1e+25) tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(t_3 + Float64(t_1 * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))); elseif (Float64(lambda1 - lambda2) <= 5e-11) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_0, sqrt(Float64(t_3 - Float64(t_1 * Float64(t_2 * t_2))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1)); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = 1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0); tmp = 0.0; if ((lambda1 - lambda2) <= -1e+25) tmp = R * (2.0 * atan2(t_0, sqrt((t_3 + (t_1 * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); elseif ((lambda1 - lambda2) <= 5e-11) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_0, sqrt((t_3 - (t_1 * (t_2 * t_2)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+25], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(t$95$3 + N[(t$95$1 * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e-11], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$0 / N[Sqrt[N[(t$95$3 - N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := 1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+25}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{t\_3 + t\_1 \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)\\
\mathbf{elif}\;\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0}{\sqrt{t\_3 - t\_1 \cdot \left(t\_2 \cdot t\_2\right)}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000009e25Initial program 59.5%
associate-*l*59.4%
Simplified59.5%
Taylor expanded in phi1 around 0 50.1%
Taylor expanded in phi2 around 0 19.5%
sin-mult66.9%
div-inv66.9%
metadata-eval66.9%
div-inv66.9%
metadata-eval66.9%
cos-sum66.9%
cos-266.9%
div-inv66.9%
metadata-eval66.9%
Applied egg-rr19.5%
div-sub66.9%
+-inverses66.9%
cos-066.9%
metadata-eval66.9%
associate-*r*66.9%
Simplified19.5%
if -1.00000000000000009e25 < (-.f64 lambda1 lambda2) < 5.00000000000000018e-11Initial program 78.7%
Taylor expanded in phi1 around 0 64.3%
+-commutative64.3%
associate--r+64.3%
unpow264.3%
1-sub-sin64.4%
unpow264.4%
*-commutative64.4%
sub-neg64.4%
mul-1-neg64.4%
*-commutative64.4%
Simplified64.4%
Taylor expanded in lambda2 around 0 57.1%
Taylor expanded in lambda1 around 0 34.4%
if 5.00000000000000018e-11 < (-.f64 lambda1 lambda2) Initial program 62.1%
associate-*l*62.1%
Simplified62.1%
Taylor expanded in phi1 around 0 46.1%
Taylor expanded in phi2 around 0 18.2%
Final simplification22.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= (- lambda1 lambda2) -1e+25) (not (<= (- lambda1 lambda2) 5e-11)))
(*
R
(*
2.0
(atan2
(* (sin (* 0.5 (- lambda1 lambda2))) (sqrt (cos phi1)))
(sqrt
(+
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (* 0.5 (* 2.0 (- lambda1 lambda2)))) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (((lambda1 - lambda2) <= -1e+25) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * atan2((sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (((lambda1 - lambda2) <= (-1d+25)) .or. (.not. ((lambda1 - lambda2) <= 5d-11))) then
tmp = r * (2.0d0 * atan2((sin((0.5d0 * (lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) + ((cos(phi1) * cos(phi2)) * ((cos((0.5d0 * (2.0d0 * (lambda1 - lambda2)))) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (((lambda1 - lambda2) <= -1e+25) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * Math.atan2((Math.sin((0.5 * (lambda1 - lambda2))) * Math.sqrt(Math.cos(phi1))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if ((lambda1 - lambda2) <= -1e+25) or not ((lambda1 - lambda2) <= 5e-11): tmp = R * (2.0 * math.atan2((math.sin((0.5 * (lambda1 - lambda2))) * math.sqrt(math.cos(phi1))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -1e+25) || !(Float64(lambda1 - lambda2) <= 5e-11)) tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(0.5 * Float64(2.0 * Float64(lambda1 - lambda2)))) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (((lambda1 - lambda2) <= -1e+25) || ~(((lambda1 - lambda2) <= 5e-11))) tmp = R * (2.0 * atan2((sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) + ((cos(phi1) * cos(phi2)) * ((cos((0.5 * (2.0 * (lambda1 - lambda2)))) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+25], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(0.5 * N[(2.0 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+25} \lor \neg \left(\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(0.5 \cdot \left(2 \cdot \left(\lambda_1 - \lambda_2\right)\right)\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000009e25 or 5.00000000000000018e-11 < (-.f64 lambda1 lambda2) Initial program 60.9%
associate-*l*60.9%
Simplified60.9%
Taylor expanded in phi1 around 0 47.9%
Taylor expanded in phi2 around 0 18.8%
sin-mult70.1%
div-inv70.1%
metadata-eval70.1%
div-inv70.1%
metadata-eval70.1%
cos-sum70.1%
cos-270.1%
div-inv70.1%
metadata-eval70.1%
Applied egg-rr18.8%
div-sub70.1%
+-inverses70.1%
cos-070.1%
metadata-eval70.1%
associate-*r*70.1%
Simplified18.8%
if -1.00000000000000009e25 < (-.f64 lambda1 lambda2) < 5.00000000000000018e-11Initial program 78.7%
Taylor expanded in phi1 around 0 64.3%
+-commutative64.3%
associate--r+64.3%
unpow264.3%
1-sub-sin64.4%
unpow264.4%
*-commutative64.4%
sub-neg64.4%
mul-1-neg64.4%
*-commutative64.4%
Simplified64.4%
Taylor expanded in lambda2 around 0 57.1%
Taylor expanded in lambda1 around 0 34.4%
Final simplification22.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= (- lambda1 lambda2) -1e+25) (not (<= (- lambda1 lambda2) 5e-11)))
(*
R
(*
2.0
(atan2
(* (sin (* 0.5 (- lambda1 lambda2))) (sqrt (cos phi1)))
(sqrt
(+
1.0
(-
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))
(pow (sin (* phi2 -0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (((lambda1 - lambda2) <= -1e+25) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * atan2((sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - pow(sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (((lambda1 - lambda2) <= (-1d+25)) .or. (.not. ((lambda1 - lambda2) <= 5d-11))) then
tmp = r * (2.0d0 * atan2((sin((0.5d0 * (lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt((1.0d0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0)) - (sin((phi2 * (-0.5d0))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (((lambda1 - lambda2) <= -1e+25) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * Math.atan2((Math.sin((0.5 * (lambda1 - lambda2))) * Math.sqrt(Math.cos(phi1))), Math.sqrt((1.0 + ((Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - Math.pow(Math.sin((phi2 * -0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if ((lambda1 - lambda2) <= -1e+25) or not ((lambda1 - lambda2) <= 5e-11): tmp = R * (2.0 * math.atan2((math.sin((0.5 * (lambda1 - lambda2))) * math.sqrt(math.cos(phi1))), math.sqrt((1.0 + ((math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)) - math.pow(math.sin((phi2 * -0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -1e+25) || !(Float64(lambda1 - lambda2) <= 5e-11)) tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(0.5 * Float64(lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt(Float64(1.0 + Float64(Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5)) - (sin(Float64(phi2 * -0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (((lambda1 - lambda2) <= -1e+25) || ~(((lambda1 - lambda2) <= 5e-11))) tmp = R * (2.0 * atan2((sin((0.5 * (lambda1 - lambda2))) * sqrt(cos(phi1))), sqrt((1.0 + ((cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)) - (sin((phi2 * -0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+25], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 + N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $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[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+25} \lor \neg \left(\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{1 + \left(\cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right) - {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000009e25 or 5.00000000000000018e-11 < (-.f64 lambda1 lambda2) Initial program 60.9%
associate-*l*60.9%
Simplified60.9%
Taylor expanded in phi1 around 0 47.9%
Taylor expanded in phi2 around 0 18.8%
Taylor expanded in phi1 around 0 18.7%
*-commutative18.7%
metadata-eval18.7%
div-inv18.7%
pow218.7%
sin-mult18.7%
div-inv18.7%
metadata-eval18.7%
div-inv18.7%
metadata-eval18.7%
div-inv18.7%
metadata-eval18.7%
div-inv18.7%
metadata-eval18.7%
Applied egg-rr18.7%
div-sub18.7%
+-inverses18.7%
cos-018.7%
metadata-eval18.7%
distribute-lft-out18.7%
metadata-eval18.7%
*-rgt-identity18.7%
Simplified18.7%
if -1.00000000000000009e25 < (-.f64 lambda1 lambda2) < 5.00000000000000018e-11Initial program 78.7%
Taylor expanded in phi1 around 0 64.3%
+-commutative64.3%
associate--r+64.3%
unpow264.3%
1-sub-sin64.4%
unpow264.4%
*-commutative64.4%
sub-neg64.4%
mul-1-neg64.4%
*-commutative64.4%
Simplified64.4%
Taylor expanded in lambda2 around 0 57.1%
Taylor expanded in lambda1 around 0 34.4%
Final simplification22.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2)))))
(if (or (<= (- lambda1 lambda2) -1e+25)
(not (<= (- lambda1 lambda2) 5e-11)))
(*
R
(* 2.0 (atan2 (* t_0 (sqrt (cos phi1))) (sqrt (- 1.0 (pow t_0 2.0))))))
(*
R
(*
2.0
(atan2
(sin (* 0.5 (- phi1 phi2)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
double tmp;
if (((lambda1 - lambda2) <= -1e+25) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * atan2((t_0 * sqrt(cos(phi1))), sqrt((1.0 - pow(t_0, 2.0)))));
} else {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin((0.5d0 * (lambda1 - lambda2)))
if (((lambda1 - lambda2) <= (-1d+25)) .or. (.not. ((lambda1 - lambda2) <= 5d-11))) then
tmp = r * (2.0d0 * atan2((t_0 * sqrt(cos(phi1))), sqrt((1.0d0 - (t_0 ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * (lambda1 - lambda2)));
double tmp;
if (((lambda1 - lambda2) <= -1e+25) || !((lambda1 - lambda2) <= 5e-11)) {
tmp = R * (2.0 * Math.atan2((t_0 * Math.sqrt(Math.cos(phi1))), Math.sqrt((1.0 - Math.pow(t_0, 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (lambda1 - lambda2))) tmp = 0 if ((lambda1 - lambda2) <= -1e+25) or not ((lambda1 - lambda2) <= 5e-11): tmp = R * (2.0 * math.atan2((t_0 * math.sqrt(math.cos(phi1))), math.sqrt((1.0 - math.pow(t_0, 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) tmp = 0.0 if ((Float64(lambda1 - lambda2) <= -1e+25) || !(Float64(lambda1 - lambda2) <= 5e-11)) tmp = Float64(R * Float64(2.0 * atan(Float64(t_0 * sqrt(cos(phi1))), sqrt(Float64(1.0 - (t_0 ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))); tmp = 0.0; if (((lambda1 - lambda2) <= -1e+25) || ~(((lambda1 - lambda2) <= 5e-11))) tmp = R * (2.0 * atan2((t_0 * sqrt(cos(phi1))), sqrt((1.0 - (t_0 ^ 2.0))))); else tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1e+25], N[Not[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], 5e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[(t$95$0 * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1 \cdot 10^{+25} \lor \neg \left(\lambda_1 - \lambda_2 \leq 5 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0 \cdot \sqrt{\cos \phi_1}}{\sqrt{1 - {t\_0}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000009e25 or 5.00000000000000018e-11 < (-.f64 lambda1 lambda2) Initial program 60.9%
associate-*l*60.9%
Simplified60.9%
Taylor expanded in phi1 around 0 47.9%
Taylor expanded in phi2 around 0 18.8%
Taylor expanded in phi1 around 0 18.7%
Taylor expanded in phi2 around 0 18.5%
*-commutative18.5%
Simplified18.5%
if -1.00000000000000009e25 < (-.f64 lambda1 lambda2) < 5.00000000000000018e-11Initial program 78.7%
Taylor expanded in phi1 around 0 64.3%
+-commutative64.3%
associate--r+64.3%
unpow264.3%
1-sub-sin64.4%
unpow264.4%
*-commutative64.4%
sub-neg64.4%
mul-1-neg64.4%
*-commutative64.4%
Simplified64.4%
Taylor expanded in lambda2 around 0 57.1%
Taylor expanded in lambda1 around 0 34.4%
Final simplification22.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (* 0.5 (- lambda1 lambda2)))))
(*
R
(* 2.0 (atan2 (* t_0 (sqrt (cos phi1))) (sqrt (- 1.0 (pow t_0 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin((0.5 * (lambda1 - lambda2)));
return R * (2.0 * atan2((t_0 * sqrt(cos(phi1))), sqrt((1.0 - pow(t_0, 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin((0.5d0 * (lambda1 - lambda2)))
code = r * (2.0d0 * atan2((t_0 * sqrt(cos(phi1))), sqrt((1.0d0 - (t_0 ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin((0.5 * (lambda1 - lambda2)));
return R * (2.0 * Math.atan2((t_0 * Math.sqrt(Math.cos(phi1))), Math.sqrt((1.0 - Math.pow(t_0, 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin((0.5 * (lambda1 - lambda2))) return R * (2.0 * math.atan2((t_0 * math.sqrt(math.cos(phi1))), math.sqrt((1.0 - math.pow(t_0, 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(0.5 * Float64(lambda1 - lambda2))) return Float64(R * Float64(2.0 * atan(Float64(t_0 * sqrt(cos(phi1))), sqrt(Float64(1.0 - (t_0 ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin((0.5 * (lambda1 - lambda2))); tmp = R * (2.0 * atan2((t_0 * sqrt(cos(phi1))), sqrt((1.0 - (t_0 ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(0.5 * N[(lambda1 - lambda2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[(t$95$0 * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[t$95$0, 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(0.5 \cdot \left(\lambda_1 - \lambda_2\right)\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_0 \cdot \sqrt{\cos \phi_1}}{\sqrt{1 - {t\_0}^{2}}}\right)
\end{array}
\end{array}
Initial program 65.3%
associate-*l*65.3%
Simplified65.3%
Taylor expanded in phi1 around 0 49.3%
Taylor expanded in phi2 around 0 16.0%
Taylor expanded in phi1 around 0 15.9%
Taylor expanded in phi2 around 0 15.7%
*-commutative15.7%
Simplified15.7%
Final simplification15.7%
herbie shell --seed 2024059
(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))))))))))