
(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 22 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) t_0))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0);
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0)
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * t_0) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * t_0); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) \cdot t\_0\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1}}{\sqrt{1 - t\_1}}\right)
\end{array}
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+
(- 1.0 t_1)
(*
t_0
(-
(/
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda1) (sin lambda2)))
2.0)
0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda1) * Math.sin(lambda2))) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda1) * math.sin(lambda2))) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda1) * sin(lambda2))) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((((cos(lambda1) * cos(lambda2)) + (sin(lambda1) * sin(lambda2))) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \left(\frac{\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_1 \cdot \sin \lambda_2}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr60.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr77.5%
sin-mult77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
cos-sum77.6%
cos-277.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr77.6%
div-sub77.6%
+-inverses77.6%
+-inverses77.6%
+-inverses77.6%
cos-077.6%
metadata-eval77.6%
*-commutative77.6%
Simplified77.6%
associate-*r*77.6%
metadata-eval77.6%
*-un-lft-identity77.6%
cos-diff78.2%
Applied egg-rr78.2%
Final simplification78.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (* (- lambda1 lambda2) 0.5))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_0 (* t_2 t_2)))
(t_4
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_5 (- 1.0 t_4)))
(if (or (<= t_2 -0.115) (not (<= t_2 5e-13)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_3 (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- t_5 t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_4 (* (cos phi1) (pow (sin t_1) 2.0))))
(sqrt (+ t_5 (* t_0 (- (/ (cos (* 2.0 t_1)) 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 = (lambda1 - lambda2) * 0.5;
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_5 = 1.0 - t_4;
double tmp;
if ((t_2 <= -0.115) || !(t_2 <= 5e-13)) {
tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((t_5 - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi1) * pow(sin(t_1), 2.0)))), sqrt((t_5 + (t_0 * ((cos((2.0 * t_1)) / 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) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = (lambda1 - lambda2) * 0.5d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_0 * (t_2 * t_2)
t_4 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_5 = 1.0d0 - t_4
if ((t_2 <= (-0.115d0)) .or. (.not. (t_2 <= 5d-13))) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((t_5 - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_4 + (cos(phi1) * (sin(t_1) ** 2.0d0)))), sqrt((t_5 + (t_0 * ((cos((2.0d0 * t_1)) / 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.cos(phi1) * Math.cos(phi2);
double t_1 = (lambda1 - lambda2) * 0.5;
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_5 = 1.0 - t_4;
double tmp;
if ((t_2 <= -0.115) || !(t_2 <= 5e-13)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((t_5 - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_4 + (Math.cos(phi1) * Math.pow(Math.sin(t_1), 2.0)))), Math.sqrt((t_5 + (t_0 * ((Math.cos((2.0 * t_1)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = (lambda1 - lambda2) * 0.5 t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_0 * (t_2 * t_2) t_4 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_5 = 1.0 - t_4 tmp = 0 if (t_2 <= -0.115) or not (t_2 <= 5e-13): tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((t_5 - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_4 + (math.cos(phi1) * math.pow(math.sin(t_1), 2.0)))), math.sqrt((t_5 + (t_0 * ((math.cos((2.0 * t_1)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(lambda1 - lambda2) * 0.5) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_0 * Float64(t_2 * t_2)) t_4 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_5 = Float64(1.0 - t_4) tmp = 0.0 if ((t_2 <= -0.115) || !(t_2 <= 5e-13)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(t_5 - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_4 + Float64(cos(phi1) * (sin(t_1) ^ 2.0)))), sqrt(Float64(t_5 + Float64(t_0 * Float64(Float64(cos(Float64(2.0 * t_1)) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = (lambda1 - lambda2) * 0.5; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_0 * (t_2 * t_2); t_4 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_5 = 1.0 - t_4; tmp = 0.0; if ((t_2 <= -0.115) || ~((t_2 <= 5e-13))) tmp = R * (2.0 * atan2(sqrt((t_3 + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((t_5 - t_3)))); else tmp = R * (2.0 * atan2(sqrt((t_4 + (cos(phi1) * (sin(t_1) ^ 2.0)))), sqrt((t_5 + (t_0 * ((cos((2.0 * t_1)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(1.0 - t$95$4), $MachinePrecision]}, If[Or[LessEqual[t$95$2, -0.115], N[Not[LessEqual[t$95$2, 5e-13]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$5 - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$4 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[t$95$1], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$5 + N[(t$95$0 * N[(N[(N[Cos[N[(2.0 * t$95$1), $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(\lambda_1 - \lambda_2\right) \cdot 0.5\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_0 \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_5 := 1 - t\_4\\
\mathbf{if}\;t\_2 \leq -0.115 \lor \neg \left(t\_2 \leq 5 \cdot 10^{-13}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{t\_5 - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_4 + \cos \phi_1 \cdot {\sin t\_1}^{2}}}{\sqrt{t\_5 + t\_0 \cdot \left(\frac{\cos \left(2 \cdot t\_1\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < -0.115000000000000005 or 4.9999999999999999e-13 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 54.3%
associate-*l*54.3%
Simplified54.3%
div-sub54.3%
sin-diff55.3%
Applied egg-rr55.3%
unpow255.3%
sin-mult55.4%
div-inv55.4%
metadata-eval55.4%
div-inv55.4%
metadata-eval55.4%
div-inv55.4%
metadata-eval55.4%
div-inv55.4%
metadata-eval55.4%
Applied egg-rr55.4%
div-sub55.4%
+-inverses55.4%
cos-055.4%
metadata-eval55.4%
distribute-lft-out55.4%
metadata-eval55.4%
*-rgt-identity55.4%
Simplified55.4%
if -0.115000000000000005 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 4.9999999999999999e-13Initial program 74.2%
associate-*l*74.2%
Simplified74.2%
div-sub74.2%
sin-diff75.0%
Applied egg-rr75.0%
div-sub74.2%
sin-diff75.0%
Applied egg-rr97.5%
sin-mult97.5%
div-inv97.5%
metadata-eval97.5%
div-inv97.5%
metadata-eval97.5%
cos-sum97.5%
cos-297.5%
div-inv97.5%
metadata-eval97.5%
Applied egg-rr97.5%
div-sub97.5%
+-inverses97.5%
+-inverses97.5%
+-inverses97.5%
cos-097.5%
metadata-eval97.5%
*-commutative97.5%
Simplified97.5%
Taylor expanded in phi2 around 0 95.7%
Final simplification65.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_0 (* t_2 t_2))))
(sqrt
(+
(- 1.0 t_1)
(*
t_0
(- (/ (cos (* 2.0 (* (- lambda1 lambda2) 0.5))) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = cos(phi1) * cos(phi2)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0d0 - t_1) + (t_0 * ((cos((2.0d0 * ((lambda1 - lambda2) * 0.5d0))) / 2.0d0) - 0.5d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_1) + (t_0 * ((Math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((t_1 + (t_0 * (t_2 * t_2)))), math.sqrt(((1.0 - t_1) + (t_0 * ((math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_0 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_0 * Float64(Float64(cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5))) / 2.0) - 0.5))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt((t_1 + (t_0 * (t_2 * t_2)))), sqrt(((1.0 - t_1) + (t_0 * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[(t$95$0 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_0 \cdot \left(t\_2 \cdot t\_2\right)}}{\sqrt{\left(1 - t\_1\right) + t\_0 \cdot \left(\frac{\cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr60.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr77.5%
sin-mult77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
cos-sum77.6%
cos-277.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr77.6%
div-sub77.6%
+-inverses77.6%
+-inverses77.6%
+-inverses77.6%
cos-077.6%
metadata-eval77.6%
*-commutative77.6%
Simplified77.6%
Final simplification77.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (- lambda1 lambda2) 0.5)))
(if (<= phi2 -0.014)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi2) (pow (sin t_4) 2.0))))
(sqrt (+ t_1 (* t_2 (- (/ (cos (* 2.0 t_4)) 2.0) 0.5)))))))
(if (<= phi2 4.5e-6)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_3 (* t_2 t_3))))
(sqrt
(-
1.0
(+
(*
(cos phi1)
(pow
(fma
(sin (/ lambda1 2.0))
(cos (/ lambda2 2.0))
(* (sin (/ lambda2 2.0)) (- (cos (/ lambda1 2.0)))))
2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_3))))
(sqrt
(+
t_1
(* (cos phi2) (- (* 0.5 (cos (- lambda1 lambda2))) 0.5)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = (lambda1 - lambda2) * 0.5;
double tmp;
if (phi2 <= -0.014) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * pow(sin(t_4), 2.0)))), sqrt((t_1 + (t_2 * ((cos((2.0 * t_4)) / 2.0) - 0.5))))));
} else if (phi2 <= 4.5e-6) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_3 * (t_2 * t_3)))), sqrt((1.0 - ((cos(phi1) * pow(fma(sin((lambda1 / 2.0)), cos((lambda2 / 2.0)), (sin((lambda2 / 2.0)) * -cos((lambda1 / 2.0)))), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_3)))), sqrt((t_1 + (cos(phi2) * ((0.5 * cos((lambda1 - lambda2))) - 0.5))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(Float64(lambda1 - lambda2) * 0.5) tmp = 0.0 if (phi2 <= -0.014) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * (sin(t_4) ^ 2.0)))), sqrt(Float64(t_1 + Float64(t_2 * Float64(Float64(cos(Float64(2.0 * t_4)) / 2.0) - 0.5))))))); elseif (phi2 <= 4.5e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_3 * Float64(t_2 * t_3)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (fma(sin(Float64(lambda1 / 2.0)), cos(Float64(lambda2 / 2.0)), Float64(sin(Float64(lambda2 / 2.0)) * Float64(-cos(Float64(lambda1 / 2.0))))) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_3)))), sqrt(Float64(t_1 + Float64(cos(phi2) * Float64(Float64(0.5 * cos(Float64(lambda1 - lambda2))) - 0.5))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(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[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, If[LessEqual[phi2, -0.014], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[t$95$4], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$2 * N[(N[(N[Cos[N[(2.0 * t$95$4), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.5e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$3 * N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[(N[Sin[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[N[(lambda2 / 2.0), $MachinePrecision]], $MachinePrecision] * (-N[Cos[N[(lambda1 / 2.0), $MachinePrecision]], $MachinePrecision])), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := 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 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
\mathbf{if}\;\phi_2 \leq -0.014:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_2 \cdot {\sin t\_4}^{2}}}{\sqrt{t\_1 + t\_2 \cdot \left(\frac{\cos \left(2 \cdot t\_4\right)}{2} - 0.5\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 4.5 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_3 \cdot \left(t\_2 \cdot t\_3\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\left(\mathsf{fma}\left(\sin \left(\frac{\lambda_1}{2}\right), \cos \left(\frac{\lambda_2}{2}\right), \sin \left(\frac{\lambda_2}{2}\right) \cdot \left(-\cos \left(\frac{\lambda_1}{2}\right)\right)\right)\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_3 \cdot t\_3\right)}}{\sqrt{t\_1 + \cos \phi_2 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -0.0140000000000000003Initial program 43.5%
associate-*l*43.5%
Simplified43.5%
div-sub43.5%
sin-diff45.8%
Applied egg-rr45.8%
div-sub43.5%
sin-diff45.8%
Applied egg-rr80.4%
sin-mult80.5%
div-inv80.5%
metadata-eval80.5%
div-inv80.5%
metadata-eval80.5%
cos-sum80.4%
cos-280.5%
div-inv80.5%
metadata-eval80.5%
Applied egg-rr80.5%
div-sub80.5%
+-inverses80.5%
+-inverses80.5%
+-inverses80.5%
cos-080.5%
metadata-eval80.5%
*-commutative80.5%
Simplified80.5%
Taylor expanded in phi1 around 0 55.1%
if -0.0140000000000000003 < phi2 < 4.50000000000000011e-6Initial program 76.2%
Taylor expanded in phi2 around 0 76.2%
*-commutative76.2%
metadata-eval76.2%
div-inv76.2%
div-sub76.2%
sin-diff77.0%
Applied egg-rr77.0%
fmm-def77.0%
*-commutative77.0%
distribute-rgt-neg-in77.0%
Simplified77.0%
if 4.50000000000000011e-6 < phi2 Initial program 46.3%
associate-*l*46.3%
Simplified46.4%
div-sub46.4%
sin-diff47.5%
Applied egg-rr47.5%
div-sub46.4%
sin-diff47.5%
Applied egg-rr76.1%
sin-mult76.1%
div-inv76.1%
metadata-eval76.1%
div-inv76.1%
metadata-eval76.1%
cos-sum76.2%
cos-276.1%
div-inv76.1%
metadata-eval76.1%
Applied egg-rr76.1%
div-sub76.1%
+-inverses76.1%
+-inverses76.1%
+-inverses76.1%
cos-076.1%
metadata-eval76.1%
*-commutative76.1%
Simplified76.1%
Taylor expanded in phi1 around 0 56.6%
Final simplification65.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
(t_1 (- 1.0 t_0))
(t_2 (* (- lambda1 lambda2) 0.5))
(t_3 (* (cos phi1) (cos phi2)))
(t_4 (sin (/ (- lambda1 lambda2) 2.0)))
(t_5 (* t_3 (* t_4 t_4))))
(if (<= phi1 -3.7e+18)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* (cos phi1) (pow (sin t_2) 2.0))))
(sqrt (+ t_1 (* t_3 (- (/ (cos (* 2.0 t_2)) 2.0) 0.5)))))))
(if (<= phi1 2.05e-40)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_5)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 t_5))
(sqrt
(+
t_1
(* (cos phi1) (- (* 0.5 (cos (- lambda1 lambda2))) 0.5)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = (lambda1 - lambda2) * 0.5;
double t_3 = cos(phi1) * cos(phi2);
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_3 * (t_4 * t_4);
double tmp;
if (phi1 <= -3.7e+18) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * pow(sin(t_2), 2.0)))), sqrt((t_1 + (t_3 * ((cos((2.0 * t_2)) / 2.0) - 0.5))))));
} else if (phi1 <= 2.05e-40) {
tmp = R * (2.0 * atan2(sqrt((t_5 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_5))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_5)), sqrt((t_1 + (cos(phi1) * ((0.5 * cos((lambda1 - lambda2))) - 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) :: t_5
real(8) :: tmp
t_0 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
t_1 = 1.0d0 - t_0
t_2 = (lambda1 - lambda2) * 0.5d0
t_3 = cos(phi1) * cos(phi2)
t_4 = sin(((lambda1 - lambda2) / 2.0d0))
t_5 = t_3 * (t_4 * t_4)
if (phi1 <= (-3.7d+18)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi1) * (sin(t_2) ** 2.0d0)))), sqrt((t_1 + (t_3 * ((cos((2.0d0 * t_2)) / 2.0d0) - 0.5d0))))))
else if (phi1 <= 2.05d-40) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_5))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_5)), sqrt((t_1 + (cos(phi1) * ((0.5d0 * cos((lambda1 - lambda2))) - 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.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
double t_1 = 1.0 - t_0;
double t_2 = (lambda1 - lambda2) * 0.5;
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double t_4 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_5 = t_3 * (t_4 * t_4);
double tmp;
if (phi1 <= -3.7e+18) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi1) * Math.pow(Math.sin(t_2), 2.0)))), Math.sqrt((t_1 + (t_3 * ((Math.cos((2.0 * t_2)) / 2.0) - 0.5))))));
} else if (phi1 <= 2.05e-40) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_5))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_5)), Math.sqrt((t_1 + (Math.cos(phi1) * ((0.5 * Math.cos((lambda1 - lambda2))) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) t_1 = 1.0 - t_0 t_2 = (lambda1 - lambda2) * 0.5 t_3 = math.cos(phi1) * math.cos(phi2) t_4 = math.sin(((lambda1 - lambda2) / 2.0)) t_5 = t_3 * (t_4 * t_4) tmp = 0 if phi1 <= -3.7e+18: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi1) * math.pow(math.sin(t_2), 2.0)))), math.sqrt((t_1 + (t_3 * ((math.cos((2.0 * t_2)) / 2.0) - 0.5)))))) elif phi1 <= 2.05e-40: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_5)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_5)), math.sqrt((t_1 + (math.cos(phi1) * ((0.5 * math.cos((lambda1 - lambda2))) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 t_1 = Float64(1.0 - t_0) t_2 = Float64(Float64(lambda1 - lambda2) * 0.5) t_3 = Float64(cos(phi1) * cos(phi2)) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_5 = Float64(t_3 * Float64(t_4 * t_4)) tmp = 0.0 if (phi1 <= -3.7e+18) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi1) * (sin(t_2) ^ 2.0)))), sqrt(Float64(t_1 + Float64(t_3 * Float64(Float64(cos(Float64(2.0 * t_2)) / 2.0) - 0.5))))))); elseif (phi1 <= 2.05e-40) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_5))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_5)), sqrt(Float64(t_1 + Float64(cos(phi1) * Float64(Float64(0.5 * cos(Float64(lambda1 - lambda2))) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; t_1 = 1.0 - t_0; t_2 = (lambda1 - lambda2) * 0.5; t_3 = cos(phi1) * cos(phi2); t_4 = sin(((lambda1 - lambda2) / 2.0)); t_5 = t_3 * (t_4 * t_4); tmp = 0.0; if (phi1 <= -3.7e+18) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi1) * (sin(t_2) ^ 2.0)))), sqrt((t_1 + (t_3 * ((cos((2.0 * t_2)) / 2.0) - 0.5)))))); elseif (phi1 <= 2.05e-40) tmp = R * (2.0 * atan2(sqrt((t_5 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_5)))); else tmp = R * (2.0 * atan2(sqrt((t_0 + t_5)), sqrt((t_1 + (cos(phi1) * ((0.5 * cos((lambda1 - lambda2))) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(1.0 - t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[(t$95$3 * N[(t$95$4 * t$95$4), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.7e+18], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[t$95$2], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 + N[(t$95$3 * N[(N[(N[Cos[N[(2.0 * t$95$2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.05e-40], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$5), $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[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(0.5 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
t_1 := 1 - t\_0\\
t_2 := \left(\lambda_1 - \lambda_2\right) \cdot 0.5\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_5 := t\_3 \cdot \left(t\_4 \cdot t\_4\right)\\
\mathbf{if}\;\phi_1 \leq -3.7 \cdot 10^{+18}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + \cos \phi_1 \cdot {\sin t\_2}^{2}}}{\sqrt{t\_1 + t\_3 \cdot \left(\frac{\cos \left(2 \cdot t\_2\right)}{2} - 0.5\right)}}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.05 \cdot 10^{-40}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t\_5}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_5}}{\sqrt{t\_1 + \cos \phi_1 \cdot \left(0.5 \cdot \cos \left(\lambda_1 - \lambda_2\right) - 0.5\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3.7e18Initial program 47.3%
associate-*l*47.3%
Simplified47.4%
div-sub47.4%
sin-diff48.9%
Applied egg-rr48.9%
div-sub47.4%
sin-diff48.9%
Applied egg-rr76.4%
sin-mult76.4%
div-inv76.4%
metadata-eval76.4%
div-inv76.4%
metadata-eval76.4%
cos-sum76.4%
cos-276.4%
div-inv76.4%
metadata-eval76.4%
Applied egg-rr76.4%
div-sub76.4%
+-inverses76.4%
+-inverses76.4%
+-inverses76.4%
cos-076.4%
metadata-eval76.4%
*-commutative76.4%
Simplified76.4%
Taylor expanded in phi2 around 0 58.7%
if -3.7e18 < phi1 < 2.04999999999999981e-40Initial program 74.3%
associate-*l*74.3%
Simplified74.3%
Taylor expanded in phi1 around 0 74.3%
unpow274.3%
1-sub-sin74.4%
unpow274.4%
Simplified74.4%
if 2.04999999999999981e-40 < phi1 Initial program 43.6%
associate-*l*43.6%
Simplified43.6%
div-sub43.6%
sin-diff45.6%
Applied egg-rr45.6%
div-sub43.6%
sin-diff45.6%
Applied egg-rr82.8%
sin-mult82.8%
div-inv82.8%
metadata-eval82.8%
div-inv82.8%
metadata-eval82.8%
cos-sum82.8%
cos-282.8%
div-inv82.8%
metadata-eval82.8%
Applied egg-rr82.8%
div-sub82.8%
+-inverses82.8%
+-inverses82.8%
+-inverses82.8%
cos-082.8%
metadata-eval82.8%
*-commutative82.8%
Simplified82.8%
Taylor expanded in phi2 around 0 55.9%
Final simplification65.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(*
(* (cos phi1) (cos phi2))
(- (/ (cos (* 2.0 (* (- lambda1 lambda2) 0.5))) 2.0) 0.5)))
(t_1
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)))
(* R (* 2.0 (atan2 (sqrt (- t_1 t_0)) (sqrt (+ (- 1.0 t_1) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * cos(phi2)) * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5);
double t_1 = pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0);
return R * (2.0 * atan2(sqrt((t_1 - t_0)), sqrt(((1.0 - t_1) + t_0))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = (cos(phi1) * cos(phi2)) * ((cos((2.0d0 * ((lambda1 - lambda2) * 0.5d0))) / 2.0d0) - 0.5d0)
t_1 = ((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_1 - t_0)), sqrt(((1.0d0 - t_1) + t_0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.cos(phi2)) * ((Math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5);
double t_1 = Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 - t_0)), Math.sqrt(((1.0 - t_1) + t_0))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.cos(phi2)) * ((math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5) t_1 = math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_1 - t_0)), math.sqrt(((1.0 - t_1) + t_0))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5))) / 2.0) - 0.5)) t_1 = Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 - t_0)), sqrt(Float64(Float64(1.0 - t_1) + t_0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * cos(phi2)) * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5); t_1 = ((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_1 - t_0)), sqrt(((1.0 - t_1) + t_0)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 - t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\frac{\cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}{2} - 0.5\right)\\
t_1 := {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 - t\_0}}{\sqrt{\left(1 - t\_1\right) + t\_0}}\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr60.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr77.5%
sin-mult77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
cos-sum77.6%
cos-277.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr77.6%
div-sub77.6%
+-inverses77.6%
+-inverses77.6%
+-inverses77.6%
cos-077.6%
metadata-eval77.6%
*-commutative77.6%
Simplified77.6%
sin-mult77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
cos-sum77.6%
cos-277.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr76.7%
div-sub77.6%
+-inverses77.6%
+-inverses77.6%
+-inverses77.6%
cos-077.6%
metadata-eval77.6%
*-commutative77.6%
Simplified76.7%
Final simplification76.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt
(-
(-
1.0
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0))
t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
return R * (2.0 * atan2(sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt(((1.0 - pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
code = r * (2.0d0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0))), sqrt(((1.0d0 - (((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0)) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0))), Math.sqrt(((1.0 - Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0)) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))), math.sqrt(((1.0 - math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0)) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(Float64(1.0 - (Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0)) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); tmp = R * (2.0 * atan2(sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(((1.0 - (((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0)) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}}{\sqrt{\left(1 - {\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2}\right) - t\_1}}\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr60.2%
Final simplification60.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow
(-
(* (sin (/ phi1 2.0)) (cos (/ phi2 2.0)))
(* (cos (/ phi1 2.0)) (sin (/ phi2 2.0))))
2.0)
(* t_0 (* t_1 t_1))))
(sqrt
(-
(- 1.0 (pow (sin (* 0.5 (- phi1 phi2))) 2.0))
(* t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt((pow(((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - pow(sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((((sin((phi1 / 2.0d0)) * cos((phi2 / 2.0d0))) - (cos((phi1 / 2.0d0)) * sin((phi2 / 2.0d0)))) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0d0 - (sin((0.5d0 * (phi1 - phi2))) ** 2.0d0)) - (t_0 * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(((Math.sin((phi1 / 2.0)) * Math.cos((phi2 / 2.0))) - (Math.cos((phi1 / 2.0)) * Math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt(((1.0 - Math.pow(Math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt((math.pow(((math.sin((phi1 / 2.0)) * math.cos((phi2 / 2.0))) - (math.cos((phi1 / 2.0)) * math.sin((phi2 / 2.0)))), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt(((1.0 - math.pow(math.sin((0.5 * (phi1 - phi2))), 2.0)) - (t_0 * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64((Float64(Float64(sin(Float64(phi1 / 2.0)) * cos(Float64(phi2 / 2.0))) - Float64(cos(Float64(phi1 / 2.0)) * sin(Float64(phi2 / 2.0)))) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64(Float64(1.0 - (sin(Float64(0.5 * Float64(phi1 - phi2))) ^ 2.0)) - Float64(t_0 * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((((sin((phi1 / 2.0)) * cos((phi2 / 2.0))) - (cos((phi1 / 2.0)) * sin((phi2 / 2.0)))) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((1.0 - (sin((0.5 * (phi1 - phi2))) ^ 2.0)) - (t_0 * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[(N[(N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Cos[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] - N[(N[Cos[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision] * N[Sin[N[(phi2 / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - N[Power[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] - N[(t$95$0 * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\left(\sin \left(\frac{\phi_1}{2}\right) \cdot \cos \left(\frac{\phi_2}{2}\right) - \cos \left(\frac{\phi_1}{2}\right) \cdot \sin \left(\frac{\phi_2}{2}\right)\right)}^{2} + t\_0 \cdot \left(t\_1 \cdot t\_1\right)}}{\sqrt{\left(1 - {\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}^{2}\right) - t\_0 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr60.2%
div-sub59.2%
sin-diff60.2%
Applied egg-rr77.5%
cancel-sign-sub-inv77.5%
sin-diff60.0%
div-sub60.0%
div-inv60.0%
metadata-eval60.0%
pow260.0%
div-inv60.0%
metadata-eval60.0%
*-commutative60.0%
Applied egg-rr60.0%
Final simplification60.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(if (or (<= phi1 -3.4e-29) (not (<= phi1 2.05e-40)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_2 t_0)) (pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* t_2 (* t_0 t_0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi1 <= -3.4e-29) || !(phi1 <= 2.05e-40)) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_2 * t_0)) + pow(sin((phi1 / 2.0)), 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * t_1))), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_2 * (t_0 * t_0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
if ((phi1 <= (-3.4d-29)) .or. (.not. (phi1 <= 2.05d-40))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_2 * t_0)) + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * t_1))), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - (t_2 * (t_0 * 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.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((phi1 <= -3.4e-29) || !(phi1 <= 2.05e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_2 * t_0)) + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * t_1))), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_2 * (t_0 * t_0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if (phi1 <= -3.4e-29) or not (phi1 <= 2.05e-40): tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_2 * t_0)) + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * t_1))), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - (t_2 * (t_0 * t_0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi1 <= -3.4e-29) || !(phi1 <= 2.05e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_2 * t_0)) + (sin(Float64(phi1 / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * t_1))), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(t_2 * Float64(t_0 * t_0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = cos(phi1) * cos(phi2); tmp = 0.0; if ((phi1 <= -3.4e-29) || ~((phi1 <= 2.05e-40))) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_2 * t_0)) + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * t_1))), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - (t_2 * (t_0 * t_0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -3.4e-29], N[Not[LessEqual[phi1, 2.05e-40]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $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[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -3.4 \cdot 10^{-29} \lor \neg \left(\phi_1 \leq 2.05 \cdot 10^{-40}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_2 \cdot t\_0\right) + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot t\_1}}{\sqrt{\left(1 - {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right) - t\_2 \cdot \left(t\_0 \cdot t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3.39999999999999972e-29 or 2.04999999999999981e-40 < phi1 Initial program 45.7%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi1 around inf 46.0%
if -3.39999999999999972e-29 < phi1 < 2.04999999999999981e-40Initial program 75.5%
associate-*l*75.5%
Simplified75.5%
Taylor expanded in phi1 around 0 75.5%
Taylor expanded in phi1 around 0 75.5%
Final simplification59.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* phi2 -0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_4 (* (cos phi1) (cos phi2)))
(t_5 (* t_4 (* t_2 t_2)))
(t_6 (sqrt (- 1.0 (+ t_1 (* (cos phi2) t_3))))))
(if (<= phi2 -0.000202)
(* R (* 2.0 (atan2 (sqrt (+ t_0 (* t_2 (* t_4 t_2)))) t_6)))
(if (<= phi2 0.000195)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 t_0))
(sqrt (- 1.0 (+ (* (cos phi1) t_3) (pow (sin (* phi1 0.5)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_5 t_1)) t_6)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(sin((phi2 * -0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = cos(phi1) * cos(phi2);
double t_5 = t_4 * (t_2 * t_2);
double t_6 = sqrt((1.0 - (t_1 + (cos(phi2) * t_3))));
double tmp;
if (phi2 <= -0.000202) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_4 * t_2)))), t_6));
} else if (phi2 <= 0.000195) {
tmp = R * (2.0 * atan2(sqrt((t_5 + t_0)), sqrt((1.0 - ((cos(phi1) * t_3) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_5 + t_1)), t_6));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: t_6
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_4 = cos(phi1) * cos(phi2)
t_5 = t_4 * (t_2 * t_2)
t_6 = sqrt((1.0d0 - (t_1 + (cos(phi2) * t_3))))
if (phi2 <= (-0.000202d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_4 * t_2)))), t_6))
else if (phi2 <= 0.000195d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + t_0)), sqrt((1.0d0 - ((cos(phi1) * t_3) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_5 + t_1)), t_6))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = Math.cos(phi1) * Math.cos(phi2);
double t_5 = t_4 * (t_2 * t_2);
double t_6 = Math.sqrt((1.0 - (t_1 + (Math.cos(phi2) * t_3))));
double tmp;
if (phi2 <= -0.000202) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_4 * t_2)))), t_6));
} else if (phi2 <= 0.000195) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + t_0)), Math.sqrt((1.0 - ((Math.cos(phi1) * t_3) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + t_1)), t_6));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_4 = math.cos(phi1) * math.cos(phi2) t_5 = t_4 * (t_2 * t_2) t_6 = math.sqrt((1.0 - (t_1 + (math.cos(phi2) * t_3)))) tmp = 0 if phi2 <= -0.000202: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_4 * t_2)))), t_6)) elif phi2 <= 0.000195: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + t_0)), math.sqrt((1.0 - ((math.cos(phi1) * t_3) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + t_1)), t_6)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_4 = Float64(cos(phi1) * cos(phi2)) t_5 = Float64(t_4 * Float64(t_2 * t_2)) t_6 = sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi2) * t_3)))) tmp = 0.0 if (phi2 <= -0.000202) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_4 * t_2)))), t_6))); elseif (phi2 <= 0.000195) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + t_0)), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_3) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + t_1)), t_6))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin((phi2 * -0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_4 = cos(phi1) * cos(phi2); t_5 = t_4 * (t_2 * t_2); t_6 = sqrt((1.0 - (t_1 + (cos(phi2) * t_3)))); tmp = 0.0; if (phi2 <= -0.000202) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_4 * t_2)))), t_6)); elseif (phi2 <= 0.000195) tmp = R * (2.0 * atan2(sqrt((t_5 + t_0)), sqrt((1.0 - ((cos(phi1) * t_3) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_5 + t_1)), t_6)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(phi2 * -0.5), $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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$6 = N[Sqrt[N[(1.0 - N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.000202], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$4 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.000195], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + t$95$1), $MachinePrecision]], $MachinePrecision] / t$95$6], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_4 := \cos \phi_1 \cdot \cos \phi_2\\
t_5 := t\_4 \cdot \left(t\_2 \cdot t\_2\right)\\
t_6 := \sqrt{1 - \left(t\_1 + \cos \phi_2 \cdot t\_3\right)}\\
\mathbf{if}\;\phi_2 \leq -0.000202:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 + t\_2 \cdot \left(t\_4 \cdot t\_2\right)}}{t\_6}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.000195:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + t\_0}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_5 + t\_1}}{t\_6}\right)\\
\end{array}
\end{array}
if phi2 < -2.02000000000000004e-4Initial program 43.1%
Taylor expanded in phi1 around 0 44.4%
if -2.02000000000000004e-4 < phi2 < 1.94999999999999996e-4Initial program 76.7%
associate-*l*76.7%
Simplified76.7%
div-sub76.7%
sin-diff76.8%
Applied egg-rr76.8%
Taylor expanded in phi2 around 0 76.5%
if 1.94999999999999996e-4 < phi2 Initial program 45.5%
associate-*l*45.5%
Simplified45.6%
Taylor expanded in phi1 around 0 45.0%
Taylor expanded in phi1 around 0 45.4%
Final simplification59.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_3 (* (cos phi2) t_2))
(t_4 (pow (sin (* phi2 -0.5)) 2.0))
(t_5 (sqrt (+ t_1 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))
(if (<= phi2 -4.1e-5)
(*
R
(* 2.0 (atan2 t_5 (sqrt (- 1.0 (+ (pow (sin (* phi2 0.5)) 2.0) t_3))))))
(if (<= phi2 0.000232)
(*
R
(*
2.0
(atan2
t_5
(sqrt (- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_1 t_4)) (sqrt (- 1.0 (+ t_4 t_3))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = cos(phi2) * t_2;
double t_4 = pow(sin((phi2 * -0.5)), 2.0);
double t_5 = sqrt((t_1 + pow(sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (phi2 <= -4.1e-5) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - (pow(sin((phi2 * 0.5)), 2.0) + t_3)))));
} else if (phi2 <= 0.000232) {
tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt((1.0 - (t_4 + 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) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_3 = cos(phi2) * t_2
t_4 = sin((phi2 * (-0.5d0))) ** 2.0d0
t_5 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)))
if (phi2 <= (-4.1d-5)) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - ((sin((phi2 * 0.5d0)) ** 2.0d0) + t_3)))))
else if (phi2 <= 0.000232d0) then
tmp = r * (2.0d0 * atan2(t_5, sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + t_4)), sqrt((1.0d0 - (t_4 + t_3)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = Math.cos(phi2) * t_2;
double t_4 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double t_5 = Math.sqrt((t_1 + Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)));
double tmp;
if (phi2 <= -4.1e-5) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - (Math.pow(Math.sin((phi2 * 0.5)), 2.0) + t_3)))));
} else if (phi2 <= 0.000232) {
tmp = R * (2.0 * Math.atan2(t_5, Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + t_4)), Math.sqrt((1.0 - (t_4 + t_3)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_3 = math.cos(phi2) * t_2 t_4 = math.pow(math.sin((phi2 * -0.5)), 2.0) t_5 = math.sqrt((t_1 + math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0))) tmp = 0 if phi2 <= -4.1e-5: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - (math.pow(math.sin((phi2 * 0.5)), 2.0) + t_3))))) elif phi2 <= 0.000232: tmp = R * (2.0 * math.atan2(t_5, math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + t_4)), math.sqrt((1.0 - (t_4 + t_3))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_3 = Float64(cos(phi2) * t_2) t_4 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_5 = sqrt(Float64(t_1 + (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))) tmp = 0.0 if (phi2 <= -4.1e-5) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - Float64((sin(Float64(phi2 * 0.5)) ^ 2.0) + t_3)))))); elseif (phi2 <= 0.000232) tmp = Float64(R * Float64(2.0 * atan(t_5, sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + t_4)), sqrt(Float64(1.0 - Float64(t_4 + t_3)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_3 = cos(phi2) * t_2; t_4 = sin((phi2 * -0.5)) ^ 2.0; t_5 = sqrt((t_1 + (sin(((phi1 - phi2) / 2.0)) ^ 2.0))); tmp = 0.0; if (phi2 <= -4.1e-5) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - ((sin((phi2 * 0.5)) ^ 2.0) + t_3))))); elseif (phi2 <= 0.000232) tmp = R * (2.0 * atan2(t_5, sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + t_4)), sqrt((1.0 - (t_4 + t_3))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -4.1e-5], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi2 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.000232], N[(R * N[(2.0 * N[ArcTan[t$95$5 / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + t$95$4), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$4 + t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t\_0 \cdot t\_0\right)\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := \cos \phi_2 \cdot t\_2\\
t_4 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_5 := \sqrt{t\_1 + {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}}\\
\mathbf{if}\;\phi_2 \leq -4.1 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - \left({\sin \left(\phi_2 \cdot 0.5\right)}^{2} + t\_3\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 0.000232:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_5}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 + t\_4}}{\sqrt{1 - \left(t\_4 + t\_3\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -4.10000000000000005e-5Initial program 43.1%
associate-*l*43.1%
Simplified43.1%
div-sub43.1%
sin-diff45.4%
Applied egg-rr45.4%
Taylor expanded in phi1 around 0 44.3%
if -4.10000000000000005e-5 < phi2 < 2.32e-4Initial program 76.7%
associate-*l*76.7%
Simplified76.7%
div-sub76.7%
sin-diff76.8%
Applied egg-rr76.8%
Taylor expanded in phi2 around 0 76.5%
if 2.32e-4 < phi2 Initial program 45.5%
associate-*l*45.5%
Simplified45.6%
Taylor expanded in phi1 around 0 45.0%
Taylor expanded in phi1 around 0 45.4%
Final simplification59.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* t_0 (* t_2 t_2)))
(t_4 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_5
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0))))))
(if (<= phi1 -3.4e-29)
(* R (* 2.0 (atan2 (sqrt (+ t_3 t_4)) t_5)))
(if (<= phi1 2.05e-40)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))
(sqrt (- (- 1.0 t_4) t_3)))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_2)) (pow (sin (/ phi1 2.0)) 2.0)))
t_5)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))));
double tmp;
if (phi1 <= -3.4e-29) {
tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), t_5));
} else if (phi1 <= 2.05e-40) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * t_1))), sqrt(((1.0 - t_4) - t_3))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_2)) + pow(sin((phi1 / 2.0)), 2.0))), t_5));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = t_0 * (t_2 * t_2)
t_4 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_5 = sqrt((1.0d0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5d0)) ** 2.0d0))))
if (phi1 <= (-3.4d-29)) then
tmp = r * (2.0d0 * atan2(sqrt((t_3 + t_4)), t_5))
else if (phi1 <= 2.05d-40) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * t_1))), sqrt(((1.0d0 - t_4) - t_3))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_2)) + (sin((phi1 / 2.0d0)) ** 2.0d0))), t_5))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = t_0 * (t_2 * t_2);
double t_4 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_5 = Math.sqrt((1.0 - ((Math.cos(phi1) * t_1) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))));
double tmp;
if (phi1 <= -3.4e-29) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_3 + t_4)), t_5));
} else if (phi1 <= 2.05e-40) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * t_1))), Math.sqrt(((1.0 - t_4) - t_3))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_2)) + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), t_5));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = t_0 * (t_2 * t_2) t_4 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_5 = math.sqrt((1.0 - ((math.cos(phi1) * t_1) + math.pow(math.sin((phi1 * 0.5)), 2.0)))) tmp = 0 if phi1 <= -3.4e-29: tmp = R * (2.0 * math.atan2(math.sqrt((t_3 + t_4)), t_5)) elif phi1 <= 2.05e-40: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * t_1))), math.sqrt(((1.0 - t_4) - t_3)))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_2)) + math.pow(math.sin((phi1 / 2.0)), 2.0))), t_5)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(t_0 * Float64(t_2 * t_2)) t_4 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_5 = sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))) tmp = 0.0 if (phi1 <= -3.4e-29) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_3 + t_4)), t_5))); elseif (phi1 <= 2.05e-40) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * t_1))), sqrt(Float64(Float64(1.0 - t_4) - t_3))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_2)) + (sin(Float64(phi1 / 2.0)) ^ 2.0))), t_5))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = t_0 * (t_2 * t_2); t_4 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_5 = sqrt((1.0 - ((cos(phi1) * t_1) + (sin((phi1 * 0.5)) ^ 2.0)))); tmp = 0.0; if (phi1 <= -3.4e-29) tmp = R * (2.0 * atan2(sqrt((t_3 + t_4)), t_5)); elseif (phi1 <= 2.05e-40) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * t_1))), sqrt(((1.0 - t_4) - t_3)))); else tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_2)) + (sin((phi1 / 2.0)) ^ 2.0))), t_5)); 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[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(t$95$0 * N[(t$95$2 * 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[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.4e-29], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$3 + t$95$4), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.05e-40], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$4), $MachinePrecision] - t$95$3), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$2), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := t\_0 \cdot \left(t\_2 \cdot t\_2\right)\\
t_4 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_5 := \sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}\\
\mathbf{if}\;\phi_1 \leq -3.4 \cdot 10^{-29}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_3 + t\_4}}{t\_5}\right)\\
\mathbf{elif}\;\phi_1 \leq 2.05 \cdot 10^{-40}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot t\_1}}{\sqrt{\left(1 - t\_4\right) - t\_3}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_0 \cdot t\_2\right) + {\sin \left(\frac{\phi_1}{2}\right)}^{2}}}{t\_5}\right)\\
\end{array}
\end{array}
if phi1 < -3.39999999999999972e-29Initial program 48.0%
associate-*l*48.0%
Simplified48.1%
div-sub48.1%
sin-diff49.5%
Applied egg-rr49.5%
Taylor expanded in phi2 around 0 47.6%
if -3.39999999999999972e-29 < phi1 < 2.04999999999999981e-40Initial program 75.5%
associate-*l*75.5%
Simplified75.5%
Taylor expanded in phi1 around 0 75.5%
Taylor expanded in phi1 around 0 75.5%
if 2.04999999999999981e-40 < phi1 Initial program 43.6%
Taylor expanded in phi2 around 0 44.4%
Taylor expanded in phi1 around inf 44.6%
Final simplification59.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))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_0 t_0)) t_1))
(sqrt
(+
(- 1.0 t_1)
(*
t_2
(- (/ (cos (* 2.0 (* (- lambda1 lambda2) 0.5))) 2.0) 0.5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
return R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 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 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_2 = cos(phi1) * cos(phi2)
code = r * (2.0d0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0d0 - t_1) + (t_2 * ((cos((2.0d0 * ((lambda1 - lambda2) * 0.5d0))) / 2.0d0) - 0.5d0))))))
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);
return R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), Math.sqrt(((1.0 - t_1) + (t_2 * ((Math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5))))));
}
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) return R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_0 * t_0)) + t_1)), math.sqrt(((1.0 - t_1) + (t_2 * ((math.cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5))))))
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(cos(phi1) * cos(phi2)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_0 * t_0)) + t_1)), sqrt(Float64(Float64(1.0 - t_1) + Float64(t_2 * Float64(Float64(cos(Float64(2.0 * Float64(Float64(lambda1 - lambda2) * 0.5))) / 2.0) - 0.5))))))) 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); tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_0 * t_0)) + t_1)), sqrt(((1.0 - t_1) + (t_2 * ((cos((2.0 * ((lambda1 - lambda2) * 0.5))) / 2.0) - 0.5)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$1), $MachinePrecision] + N[(t$95$2 * N[(N[(N[Cos[N[(2.0 * N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_0 \cdot t\_0\right) + t\_1}}{\sqrt{\left(1 - t\_1\right) + t\_2 \cdot \left(\frac{\cos \left(2 \cdot \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)}{2} - 0.5\right)}}\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
sin-mult77.6%
div-inv77.6%
metadata-eval77.6%
div-inv77.6%
metadata-eval77.6%
cos-sum77.6%
cos-277.6%
div-inv77.6%
metadata-eval77.6%
Applied egg-rr59.3%
div-sub77.6%
+-inverses77.6%
+-inverses77.6%
+-inverses77.6%
cos-077.6%
metadata-eval77.6%
*-commutative77.6%
Simplified59.3%
Final simplification59.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (pow (sin (* phi2 -0.5)) 2.0)))
(if (or (<= phi1 -3.4e-29) (not (<= phi1 2.05e-40)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_2 (* t_1 t_2)) (pow (sin (/ phi1 2.0)) 2.0)))
(sqrt (- 1.0 (+ (* (cos phi1) t_0) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_2)) t_3))
(sqrt (- 1.0 (+ t_3 (* (cos phi2) t_0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = pow(sin((phi2 * -0.5)), 2.0);
double tmp;
if ((phi1 <= -3.4e-29) || !(phi1 <= 2.05e-40)) {
tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + pow(sin((phi1 / 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(((t_1 * (t_2 * t_2)) + t_3)), sqrt((1.0 - (t_3 + (cos(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) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin((phi2 * (-0.5d0))) ** 2.0d0
if ((phi1 <= (-3.4d-29)) .or. (.not. (phi1 <= 2.05d-40))) then
tmp = r * (2.0d0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + (sin((phi1 / 2.0d0)) ** 2.0d0))), sqrt((1.0d0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + t_3)), sqrt((1.0d0 - (t_3 + (cos(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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double tmp;
if ((phi1 <= -3.4e-29) || !(phi1 <= 2.05e-40)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_2 * (t_1 * t_2)) + Math.pow(Math.sin((phi1 / 2.0)), 2.0))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_0) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_2)) + t_3)), Math.sqrt((1.0 - (t_3 + (Math.cos(phi2) * t_0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.pow(math.sin((phi2 * -0.5)), 2.0) tmp = 0 if (phi1 <= -3.4e-29) or not (phi1 <= 2.05e-40): tmp = R * (2.0 * math.atan2(math.sqrt(((t_2 * (t_1 * t_2)) + math.pow(math.sin((phi1 / 2.0)), 2.0))), math.sqrt((1.0 - ((math.cos(phi1) * t_0) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_2)) + t_3)), math.sqrt((1.0 - (t_3 + (math.cos(phi2) * t_0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if ((phi1 <= -3.4e-29) || !(phi1 <= 2.05e-40)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_2 * Float64(t_1 * t_2)) + (sin(Float64(phi1 / 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(Float64(Float64(t_1 * Float64(t_2 * t_2)) + t_3)), sqrt(Float64(1.0 - Float64(t_3 + Float64(cos(phi2) * t_0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if ((phi1 <= -3.4e-29) || ~((phi1 <= 2.05e-40))) tmp = R * (2.0 * atan2(sqrt(((t_2 * (t_1 * t_2)) + (sin((phi1 / 2.0)) ^ 2.0))), sqrt((1.0 - ((cos(phi1) * t_0) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_2)) + t_3)), sqrt((1.0 - (t_3 + (cos(phi2) * t_0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * 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[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -3.4e-29], N[Not[LessEqual[phi1, 2.05e-40]], $MachinePrecision]], 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[(phi1 / 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[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision] + t$95$3), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$3 + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -3.4 \cdot 10^{-29} \lor \neg \left(\phi_1 \leq 2.05 \cdot 10^{-40}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 \cdot \left(t\_1 \cdot t\_2\right) + {\sin \left(\frac{\phi_1}{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{t\_1 \cdot \left(t\_2 \cdot t\_2\right) + t\_3}}{\sqrt{1 - \left(t\_3 + \cos \phi_2 \cdot t\_0\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -3.39999999999999972e-29 or 2.04999999999999981e-40 < phi1 Initial program 45.7%
Taylor expanded in phi2 around 0 45.9%
Taylor expanded in phi1 around inf 46.0%
if -3.39999999999999972e-29 < phi1 < 2.04999999999999981e-40Initial program 75.5%
associate-*l*75.5%
Simplified75.5%
Taylor expanded in phi1 around 0 75.5%
Taylor expanded in phi1 around 0 75.5%
Final simplification59.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (* t_0 (* t_1 t_0)))
(t_3 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_4
(sqrt (- 1.0 (+ (* (cos phi1) t_3) (pow (sin (* phi1 0.5)) 2.0)))))
(t_5 (pow (sin (* phi2 -0.5)) 2.0)))
(if (<= phi1 -4.2)
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (- 0.5 (/ (cos (* phi1 (- 1.0 (/ phi2 phi1)))) 2.0))))
t_4)))
(if (<= phi1 3.8e-21)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_0 t_0)) t_5))
(sqrt (- 1.0 (+ t_5 (* (cos phi2) t_3)))))))
(* R (* 2.0 (atan2 (sqrt (+ t_2 (- 0.5 (/ (cos phi1) 2.0)))) t_4)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = t_0 * (t_1 * t_0);
double t_3 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = sqrt((1.0 - ((cos(phi1) * t_3) + pow(sin((phi1 * 0.5)), 2.0))));
double t_5 = pow(sin((phi2 * -0.5)), 2.0);
double tmp;
if (phi1 <= -4.2) {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 * (1.0 - (phi2 / phi1)))) / 2.0)))), t_4));
} else if (phi1 <= 3.8e-21) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + t_5)), sqrt((1.0 - (t_5 + (cos(phi2) * t_3))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos(phi1) / 2.0)))), t_4));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = t_0 * (t_1 * t_0)
t_3 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_4 = sqrt((1.0d0 - ((cos(phi1) * t_3) + (sin((phi1 * 0.5d0)) ** 2.0d0))))
t_5 = sin((phi2 * (-0.5d0))) ** 2.0d0
if (phi1 <= (-4.2d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos((phi1 * (1.0d0 - (phi2 / phi1)))) / 2.0d0)))), t_4))
else if (phi1 <= 3.8d-21) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + t_5)), sqrt((1.0d0 - (t_5 + (cos(phi2) * t_3))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (0.5d0 - (cos(phi1) / 2.0d0)))), t_4))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = t_0 * (t_1 * t_0);
double t_3 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_4 = Math.sqrt((1.0 - ((Math.cos(phi1) * t_3) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))));
double t_5 = Math.pow(Math.sin((phi2 * -0.5)), 2.0);
double tmp;
if (phi1 <= -4.2) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos((phi1 * (1.0 - (phi2 / phi1)))) / 2.0)))), t_4));
} else if (phi1 <= 3.8e-21) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_0 * t_0)) + t_5)), Math.sqrt((1.0 - (t_5 + (Math.cos(phi2) * t_3))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (0.5 - (Math.cos(phi1) / 2.0)))), t_4));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = t_0 * (t_1 * t_0) t_3 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_4 = math.sqrt((1.0 - ((math.cos(phi1) * t_3) + math.pow(math.sin((phi1 * 0.5)), 2.0)))) t_5 = math.pow(math.sin((phi2 * -0.5)), 2.0) tmp = 0 if phi1 <= -4.2: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos((phi1 * (1.0 - (phi2 / phi1)))) / 2.0)))), t_4)) elif phi1 <= 3.8e-21: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_0 * t_0)) + t_5)), math.sqrt((1.0 - (t_5 + (math.cos(phi2) * t_3)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (0.5 - (math.cos(phi1) / 2.0)))), t_4)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = Float64(t_0 * Float64(t_1 * t_0)) t_3 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_4 = sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_3) + (sin(Float64(phi1 * 0.5)) ^ 2.0)))) t_5 = sin(Float64(phi2 * -0.5)) ^ 2.0 tmp = 0.0 if (phi1 <= -4.2) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(Float64(phi1 * Float64(1.0 - Float64(phi2 / phi1)))) / 2.0)))), t_4))); elseif (phi1 <= 3.8e-21) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_0 * t_0)) + t_5)), sqrt(Float64(1.0 - Float64(t_5 + Float64(cos(phi2) * t_3))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(0.5 - Float64(cos(phi1) / 2.0)))), t_4))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = t_0 * (t_1 * t_0); t_3 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_4 = sqrt((1.0 - ((cos(phi1) * t_3) + (sin((phi1 * 0.5)) ^ 2.0)))); t_5 = sin((phi2 * -0.5)) ^ 2.0; tmp = 0.0; if (phi1 <= -4.2) tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos((phi1 * (1.0 - (phi2 / phi1)))) / 2.0)))), t_4)); elseif (phi1 <= 3.8e-21) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_0 * t_0)) + t_5)), sqrt((1.0 - (t_5 + (cos(phi2) * t_3)))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (0.5 - (cos(phi1) / 2.0)))), t_4)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$3), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$5 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[phi1, -4.2], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[N[(phi1 * N[(1.0 - N[(phi2 / phi1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 3.8e-21], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] + t$95$5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$5 + N[(N[Cos[phi2], $MachinePrecision] * t$95$3), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(0.5 - N[(N[Cos[phi1], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$4], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := t\_0 \cdot \left(t\_1 \cdot t\_0\right)\\
t_3 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_4 := \sqrt{1 - \left(\cos \phi_1 \cdot t\_3 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}\\
t_5 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -4.2:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \left(\phi_1 \cdot \left(1 - \frac{\phi_2}{\phi_1}\right)\right)}{2}\right)}}{t\_4}\right)\\
\mathbf{elif}\;\phi_1 \leq 3.8 \cdot 10^{-21}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_0 \cdot t\_0\right) + t\_5}}{\sqrt{1 - \left(t\_5 + \cos \phi_2 \cdot t\_3\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_2 + \left(0.5 - \frac{\cos \phi_1}{2}\right)}}{t\_4}\right)\\
\end{array}
\end{array}
if phi1 < -4.20000000000000018Initial program 46.8%
Taylor expanded in phi2 around 0 46.4%
unpow248.4%
sin-mult48.4%
div-inv48.4%
metadata-eval48.4%
div-inv48.4%
metadata-eval48.4%
div-inv48.4%
metadata-eval48.4%
div-inv48.4%
metadata-eval48.4%
Applied egg-rr46.3%
div-sub48.4%
+-inverses48.4%
cos-048.4%
metadata-eval48.4%
distribute-lft-out48.4%
metadata-eval48.4%
*-rgt-identity48.4%
Simplified46.3%
Taylor expanded in phi1 around inf 46.4%
mul-1-neg46.4%
unsub-neg46.4%
Simplified46.4%
if -4.20000000000000018 < phi1 < 3.7999999999999998e-21Initial program 75.3%
associate-*l*75.3%
Simplified75.3%
Taylor expanded in phi1 around 0 73.1%
Taylor expanded in phi1 around 0 73.1%
if 3.7999999999999998e-21 < phi1 Initial program 41.2%
Taylor expanded in phi2 around 0 42.0%
unpow243.3%
sin-mult43.3%
div-inv43.3%
metadata-eval43.3%
div-inv43.3%
metadata-eval43.3%
div-inv43.3%
metadata-eval43.3%
div-inv43.3%
metadata-eval43.3%
Applied egg-rr42.0%
div-sub43.3%
+-inverses43.3%
cos-043.3%
metadata-eval43.3%
distribute-lft-out43.3%
metadata-eval43.3%
*-rgt-identity43.3%
Simplified42.0%
Taylor expanded in phi2 around 0 42.3%
Final simplification58.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3 (sqrt (+ t_0 (* t_2 (pow (sin (* lambda2 -0.5)) 2.0)))))
(t_4 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_5 (* (cos phi2) t_4)))
(if (<= phi2 -8e-5)
(*
R
(* 2.0 (atan2 t_3 (sqrt (- 1.0 (+ (pow (sin (* phi2 -0.5)) 2.0) t_5))))))
(if (<= phi2 1.12e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_1 (* t_2 t_1)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_4) (pow (sin (* phi1 0.5)) 2.0)))))))
(* R (* 2.0 (atan2 t_3 (sqrt (- (- 1.0 t_0) t_5)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sqrt((t_0 + (t_2 * pow(sin((lambda2 * -0.5)), 2.0))));
double t_4 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_5 = cos(phi2) * t_4;
double tmp;
if (phi2 <= -8e-5) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (pow(sin((phi2 * -0.5)), 2.0) + t_5)))));
} else if (phi2 <= 1.12e-5) {
tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_4) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_0) - t_5))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
t_3 = sqrt((t_0 + (t_2 * (sin((lambda2 * (-0.5d0))) ** 2.0d0))))
t_4 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_5 = cos(phi2) * t_4
if (phi2 <= (-8d-5)) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - ((sin((phi2 * (-0.5d0))) ** 2.0d0) + t_5)))))
else if (phi2 <= 1.12d-5) then
tmp = r * (2.0d0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * t_4) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt(((1.0d0 - t_0) - 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.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double t_3 = Math.sqrt((t_0 + (t_2 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0))));
double t_4 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_5 = Math.cos(phi2) * t_4;
double tmp;
if (phi2 <= -8e-5) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (Math.pow(Math.sin((phi2 * -0.5)), 2.0) + t_5)))));
} else if (phi2 <= 1.12e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_1 * (t_2 * t_1)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_4) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt(((1.0 - t_0) - t_5))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sqrt((t_0 + (t_2 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))) t_4 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_5 = math.cos(phi2) * t_4 tmp = 0 if phi2 <= -8e-5: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (math.pow(math.sin((phi2 * -0.5)), 2.0) + t_5))))) elif phi2 <= 1.12e-5: tmp = R * (2.0 * math.atan2(math.sqrt(((t_1 * (t_2 * t_1)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_4) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt(((1.0 - t_0) - t_5)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sqrt(Float64(t_0 + Float64(t_2 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))) t_4 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_5 = Float64(cos(phi2) * t_4) tmp = 0.0 if (phi2 <= -8e-5) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + t_5)))))); elseif (phi2 <= 1.12e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_1 * Float64(t_2 * t_1)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_4) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(Float64(1.0 - t_0) - t_5))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); t_3 = sqrt((t_0 + (t_2 * (sin((lambda2 * -0.5)) ^ 2.0)))); t_4 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_5 = cos(phi2) * t_4; tmp = 0.0; if (phi2 <= -8e-5) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((sin((phi2 * -0.5)) ^ 2.0) + t_5))))); elseif (phi2 <= 1.12e-5) tmp = R * (2.0 * atan2(sqrt(((t_1 * (t_2 * t_1)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_4) + (sin((phi1 * 0.5)) ^ 2.0)))))); else tmp = R * (2.0 * atan2(t_3, sqrt(((1.0 - t_0) - t_5)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$5 = N[(N[Cos[phi2], $MachinePrecision] * t$95$4), $MachinePrecision]}, If[LessEqual[phi2, -8e-5], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.12e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$4), $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[t$95$3 / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - t$95$5), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := \sqrt{t\_0 + t\_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}\\
t_4 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_5 := \cos \phi_2 \cdot t\_4\\
\mathbf{if}\;\phi_2 \leq -8 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{1 - \left({\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t\_5\right)}}\right)\\
\mathbf{elif}\;\phi_2 \leq 1.12 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_1 \cdot \left(t\_2 \cdot t\_1\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_4 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t\_3}{\sqrt{\left(1 - t\_0\right) - t\_5}}\right)\\
\end{array}
\end{array}
if phi2 < -8.00000000000000065e-5Initial program 43.1%
associate-*l*43.1%
Simplified43.1%
Taylor expanded in lambda1 around 0 36.6%
Taylor expanded in phi1 around 0 37.8%
if -8.00000000000000065e-5 < phi2 < 1.11999999999999995e-5Initial program 76.7%
Taylor expanded in phi2 around 0 76.7%
unpow276.8%
sin-mult70.6%
div-inv70.6%
metadata-eval70.6%
div-inv70.6%
metadata-eval70.6%
div-inv70.6%
metadata-eval70.6%
div-inv70.6%
metadata-eval70.6%
Applied egg-rr70.5%
div-sub70.6%
+-inverses70.6%
cos-070.6%
metadata-eval70.6%
distribute-lft-out70.6%
metadata-eval70.6%
*-rgt-identity70.6%
Simplified70.5%
if 1.11999999999999995e-5 < phi2 Initial program 46.3%
associate-*l*46.3%
Simplified46.4%
Taylor expanded in lambda1 around 0 40.0%
Taylor expanded in phi1 around 0 39.2%
Final simplification53.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi2 -0.0002) (not (<= phi2 2.6e-59)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- 1.0 (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) t_2)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_1 t_0)) (- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(- 1.0 (+ (* (cos phi1) t_2) (pow (sin (* phi1 0.5)) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -0.0002) || !(phi2 <= 2.6e-59)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt((1.0 - (pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * t_2))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_2) + pow(sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if ((phi2 <= (-0.0002d0)) .or. (.not. (phi2 <= 2.6d-59))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt((1.0d0 - ((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * t_2))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi2 <= -0.0002) || !(phi2 <= 2.6e-59)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt((1.0 - (Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * t_2))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * t_2) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi2 <= -0.0002) or not (phi2 <= 2.6e-59): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt((1.0 - (math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * t_2)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * t_2) + math.pow(math.sin((phi1 * 0.5)), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi2 <= -0.0002) || !(phi2 <= 2.6e-59)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64(1.0 - Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * t_2))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_2) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; tmp = 0.0; if ((phi2 <= -0.0002) || ~((phi2 <= 2.6e-59))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt((1.0 - ((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * t_2)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_2) + (sin((phi1 * 0.5)) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0002], N[Not[LessEqual[phi2, 2.6e-59]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -0.0002 \lor \neg \left(\phi_2 \leq 2.6 \cdot 10^{-59}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t\_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - \left({\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot t\_2\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_1 \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_2 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -2.0000000000000001e-4 or 2.59999999999999998e-59 < phi2 Initial program 44.9%
associate-*l*44.9%
Simplified44.9%
Taylor expanded in lambda1 around 0 38.7%
Taylor expanded in phi1 around 0 38.3%
if -2.0000000000000001e-4 < phi2 < 2.59999999999999998e-59Initial program 77.9%
Taylor expanded in phi2 around 0 77.9%
unpow277.9%
sin-mult72.3%
div-inv72.3%
metadata-eval72.3%
div-inv72.3%
metadata-eval72.3%
div-inv72.3%
metadata-eval72.3%
div-inv72.3%
metadata-eval72.3%
Applied egg-rr72.2%
div-sub72.3%
+-inverses72.3%
cos-072.3%
metadata-eval72.3%
distribute-lft-out72.3%
metadata-eval72.3%
*-rgt-identity72.3%
Simplified72.2%
Final simplification53.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi1) (cos phi2))))
(if (or (<= phi1 -3.7e+18) (not (<= phi1 3.8e-21)))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_2 t_0)) (- 0.5 (/ (cos phi1) 2.0))))
(sqrt (- 1.0 (+ (* (cos phi1) t_1) (pow (sin (* phi1 0.5)) 2.0)))))))
(*
(atan2
(sqrt (fma t_2 (* t_0 t_0) (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (* (cos phi2) t_1))))
(* R 2.0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if ((phi1 <= -3.7e+18) || !(phi1 <= 3.8e-21)) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_2 * t_0)) + (0.5 - (cos(phi1) / 2.0)))), sqrt((1.0 - ((cos(phi1) * t_1) + pow(sin((phi1 * 0.5)), 2.0))))));
} else {
tmp = atan2(sqrt(fma(t_2, (t_0 * t_0), pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (cos(phi2) * t_1)))) * (R * 2.0);
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if ((phi1 <= -3.7e+18) || !(phi1 <= 3.8e-21)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_2 * t_0)) + Float64(0.5 - Float64(cos(phi1) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * t_1) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))); else tmp = Float64(atan(sqrt(fma(t_2, Float64(t_0 * t_0), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(cos(phi2) * t_1)))) * Float64(R * 2.0)); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -3.7e+18], N[Not[LessEqual[phi1, 3.8e-21]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$2 * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[phi1], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[ArcTan[N[Sqrt[N[(t$95$2 * N[(t$95$0 * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -3.7 \cdot 10^{+18} \lor \neg \left(\phi_1 \leq 3.8 \cdot 10^{-21}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(t\_2 \cdot t\_0\right) + \left(0.5 - \frac{\cos \phi_1}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot t\_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(t\_2, t\_0 \cdot t\_0, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \cos \phi_2 \cdot t\_1}} \cdot \left(R \cdot 2\right)\\
\end{array}
\end{array}
if phi1 < -3.7e18 or 3.7999999999999998e-21 < phi1 Initial program 44.0%
Taylor expanded in phi2 around 0 44.2%
unpow245.9%
sin-mult45.9%
div-inv45.9%
metadata-eval45.9%
div-inv45.9%
metadata-eval45.9%
div-inv45.9%
metadata-eval45.9%
div-inv45.9%
metadata-eval45.9%
Applied egg-rr44.2%
div-sub45.9%
+-inverses45.9%
cos-045.9%
metadata-eval45.9%
distribute-lft-out45.9%
metadata-eval45.9%
*-rgt-identity45.9%
Simplified44.2%
Taylor expanded in phi2 around 0 44.3%
if -3.7e18 < phi1 < 3.7999999999999998e-21Initial program 74.9%
associate-*r*74.9%
*-commutative74.9%
Simplified74.8%
Taylor expanded in phi1 around inf 47.5%
Taylor expanded in phi1 around 0 47.7%
Final simplification46.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))
(- 0.5 (/ (cos (- phi1 phi2)) 2.0))))
(sqrt
(-
1.0
(+
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(pow (sin (* phi1 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)) + pow(sin((phi1 * 0.5)), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5d0 - (cos((phi1 - phi2)) / 2.0d0)))), sqrt((1.0d0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
return R * (2.0 * Math.atan2(Math.sqrt(((t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)) + (0.5 - (Math.cos((phi1 - phi2)) / 2.0)))), Math.sqrt((1.0 - ((Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sqrt(((t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) + (0.5 - (math.cos((phi1 - phi2)) / 2.0)))), math.sqrt((1.0 - ((math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) + Float64(0.5 - Float64(cos(Float64(phi1 - phi2)) / 2.0)))), sqrt(Float64(1.0 - Float64(Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sqrt(((t_0 * ((cos(phi1) * cos(phi2)) * t_0)) + (0.5 - (cos((phi1 - phi2)) / 2.0)))), sqrt((1.0 - ((cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)) + (sin((phi1 * 0.5)) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision] + N[(0.5 - N[(N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t\_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right) + \left(0.5 - \frac{\cos \left(\phi_1 - \phi_2\right)}{2}\right)}}{\sqrt{1 - \left(\cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2} + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}\right)}}\right)
\end{array}
\end{array}
Initial program 59.2%
Taylor expanded in phi2 around 0 46.0%
unpow260.2%
sin-mult57.4%
div-inv57.4%
metadata-eval57.4%
div-inv57.4%
metadata-eval57.4%
div-inv57.4%
metadata-eval57.4%
div-inv57.4%
metadata-eval57.4%
Applied egg-rr43.1%
div-sub57.4%
+-inverses57.4%
cos-057.4%
metadata-eval57.4%
distribute-lft-out57.4%
metadata-eval57.4%
*-rgt-identity57.4%
Simplified43.1%
Final simplification43.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
(atan2
(sqrt
(fma
(* (cos phi1) (cos phi2))
(* t_0 t_0)
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(sqrt (- 1.0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))))
(* R 2.0))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
return atan2(sqrt(fma((cos(phi1) * cos(phi2)), (t_0 * t_0), pow(sin(((phi1 - phi2) / 2.0)), 2.0))), sqrt((1.0 - (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0))))) * (R * 2.0);
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(atan(sqrt(fma(Float64(cos(phi1) * cos(phi2)), Float64(t_0 * t_0), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))), sqrt(Float64(1.0 - Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0))))) * Float64(R * 2.0)) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, N[(N[ArcTan[N[Sqrt[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] * N[(R * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0 \cdot t\_0, {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}{\sqrt{1 - \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}} \cdot \left(R \cdot 2\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*r*59.2%
*-commutative59.2%
Simplified59.2%
Taylor expanded in phi1 around inf 45.1%
Taylor expanded in phi1 around 0 34.0%
Final simplification34.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) (* t_0 t_0))))))
(if (<= t_0 1e-44)
(* R (* 2.0 (atan2 (sin (* 0.5 (- phi1 phi2))) t_1)))
(* R (* 2.0 (atan2 (sin (* (- lambda1 lambda2) 0.5)) t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))));
double tmp;
if (t_0 <= 1e-44) {
tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), t_1));
} else {
tmp = R * (2.0 * atan2(sin(((lambda1 - lambda2) * 0.5)), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))
if (t_0 <= 1d-44) then
tmp = r * (2.0d0 * atan2(sin((0.5d0 * (phi1 - phi2))), t_1))
else
tmp = r * (2.0d0 * atan2(sin(((lambda1 - lambda2) * 0.5d0)), 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.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))));
double tmp;
if (t_0 <= 1e-44) {
tmp = R * (2.0 * Math.atan2(Math.sin((0.5 * (phi1 - phi2))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sin(((lambda1 - lambda2) * 0.5)), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0)))) tmp = 0 if t_0 <= 1e-44: tmp = R * (2.0 * math.atan2(math.sin((0.5 * (phi1 - phi2))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sin(((lambda1 - lambda2) * 0.5)), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)))) tmp = 0.0 if (t_0 <= 1e-44) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(0.5 * Float64(phi1 - phi2))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0)))); tmp = 0.0; if (t_0 <= 1e-44) tmp = R * (2.0 * atan2(sin((0.5 * (phi1 - phi2))), t_1)); else tmp = R * (2.0 * atan2(sin(((lambda1 - lambda2) * 0.5)), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[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[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 1e-44], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(0.5 * N[(phi1 - phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_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(t\_0 \cdot t\_0\right)}\\
\mathbf{if}\;t\_0 \leq 10^{-44}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(0.5 \cdot \left(\phi_1 - \phi_2\right)\right)}{t\_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}{t\_1}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) < 9.99999999999999953e-45Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
Taylor expanded in lambda1 around 0 48.2%
Taylor expanded in lambda2 around 0 22.2%
if 9.99999999999999953e-45 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) #s(literal 2 binary64))) Initial program 59.2%
associate-*l*59.1%
Simplified59.2%
Taylor expanded in phi1 around 0 44.5%
Taylor expanded in phi2 around 0 30.8%
Taylor expanded in phi1 around 0 36.4%
Final simplification27.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(*
R
(*
2.0
(atan2
(sin (* (- lambda1 lambda2) 0.5))
(sqrt
(-
(- 1.0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(* (* (cos phi1) (cos phi2)) (* t_0 t_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(sin(((lambda1 - lambda2) * 0.5)), sqrt(((1.0 - pow(sin(((phi1 - phi2) / 2.0)), 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
code = r * (2.0d0 * atan2(sin(((lambda1 - lambda2) * 0.5d0)), sqrt(((1.0d0 - (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_0))))))
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.sin(((lambda1 - lambda2) * 0.5)), Math.sqrt(((1.0 - Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) return R * (2.0 * math.atan2(math.sin(((lambda1 - lambda2) * 0.5)), math.sqrt(((1.0 - math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0)) - ((math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) return Float64(R * Float64(2.0 * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), sqrt(Float64(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0)) - Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = R * (2.0 * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt(((1.0 - (sin(((phi1 - phi2) / 2.0)) ^ 2.0)) - ((cos(phi1) * cos(phi2)) * (t_0 * t_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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $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[(t$95$0 * t$95$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{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}{\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(t\_0 \cdot t\_0\right)}}\right)
\end{array}
\end{array}
Initial program 59.2%
associate-*l*59.2%
Simplified59.2%
Taylor expanded in phi1 around 0 42.7%
Taylor expanded in phi2 around 0 14.0%
Taylor expanded in phi1 around 0 16.9%
Final simplification16.9%
herbie shell --seed 2024156
(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))))))))))