
(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 26 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 (sin (/ (- lambda1 lambda2) 2.0))))
(if (or (<= phi2 -1150000.0) (not (<= phi2 18000.0)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_1))))
(sqrt
(+
(pow (cos (* phi1 0.5)) 2.0)
(* t_0 (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -1150000.0) || !(phi2 <= 18000.0)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if ((phi2 <= (-1150000.0d0)) .or. (.not. (phi2 <= 18000.0d0))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * (t_1 * t_1)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) + (t_0 * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((phi2 <= -1150000.0) || !(phi2 <= 18000.0)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) + (t_0 * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (phi2 <= -1150000.0) or not (phi2 <= 18000.0): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_1)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) + (t_0 * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if ((phi2 <= -1150000.0) || !(phi2 <= 18000.0)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_1)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 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 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((phi2 <= -1150000.0) || ~((phi2 <= 18000.0))) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_1 * t_1)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) + (t_0 * ((cos((lambda1 - lambda2)) / 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[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -1150000.0], N[Not[LessEqual[phi2, 18000.0]], $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] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -1150000 \lor \neg \left(\phi_2 \leq 18000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_1\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} + t_0 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if phi2 < -1.15e6 or 18000 < phi2 Initial program 45.5%
Taylor expanded in phi1 around 0 45.9%
associate--r+45.9%
unpow245.9%
1-sub-sin46.0%
unpow246.0%
*-commutative46.0%
sub-neg46.0%
mul-1-neg46.0%
+-commutative46.0%
*-commutative46.0%
Simplified46.0%
Taylor expanded in phi1 around 0 45.5%
Taylor expanded in phi1 around 0 47.3%
if -1.15e6 < phi2 < 18000Initial program 80.2%
associate-*l*80.2%
Simplified80.2%
Taylor expanded in phi2 around 0 80.2%
unpow280.2%
1-sub-sin80.3%
unpow280.3%
Simplified80.3%
sin-mult80.4%
div-inv80.4%
metadata-eval80.4%
div-inv80.4%
metadata-eval80.4%
cos-sum80.3%
cos-280.4%
div-inv80.4%
metadata-eval80.4%
Applied egg-rr80.4%
div-sub80.4%
+-inverses80.4%
cos-080.4%
metadata-eval80.4%
*-commutative80.4%
associate-*r*80.4%
metadata-eval80.4%
*-lft-identity80.4%
Simplified80.4%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) t_0))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_0 t_1)))
(sqrt
(-
1.0
(+
t_2
(* t_1 (log1p (expm1 (sin (* (- lambda1 lambda2) 0.5)))))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * t_0;
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_0 * t_1))), sqrt((1.0 - (t_2 + (t_1 * log1p(expm1(sin(((lambda1 - lambda2) * 0.5))))))))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * t_0;
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_0 * t_1))), Math.sqrt((1.0 - (t_2 + (t_1 * Math.log1p(Math.expm1(Math.sin(((lambda1 - lambda2) * 0.5))))))))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * t_0 t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_0 * t_1))), math.sqrt((1.0 - (t_2 + (t_1 * math.log1p(math.expm1(math.sin(((lambda1 - lambda2) * 0.5))))))))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * t_0) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_0 * t_1))), sqrt(Float64(1.0 - Float64(t_2 + Float64(t_1 * log1p(expm1(sin(Float64(Float64(lambda1 - lambda2) * 0.5))))))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(t$95$1 * N[Log[1 + N[(Exp[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_0 \cdot t_1}}{\sqrt{1 - \left(t_2 + t_1 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)\right)\right)}}\right)
\end{array}
\end{array}
Initial program 63.0%
log1p-expm1-u63.0%
div-inv63.0%
metadata-eval63.0%
Applied egg-rr63.0%
Final simplification63.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (log1p (expm1 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))
(sqrt (- 1.0 (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
return R * (2.0 * atan2(sqrt((t_1 + log1p(expm1(pow(sin(((phi1 - phi2) * 0.5)), 2.0))))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
return R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.log1p(Math.expm1(Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0))))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) return R * (2.0 * math.atan2(math.sqrt((t_1 + math.log1p(math.expm1(math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + log1p(expm1((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Log[1 + N[(Exp[N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + \mathsf{log1p}\left(\mathsf{expm1}\left({\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)\right)}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1\right)}}\right)
\end{array}
\end{array}
Initial program 63.0%
log1p-expm1-u63.0%
div-inv63.0%
metadata-eval63.0%
Applied egg-rr63.0%
Final simplification63.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) t_0))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_1 (log1p (expm1 (sin (* (- lambda1 lambda2) 0.5)))))))
(sqrt (- 1.0 (+ t_2 (* t_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;
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + (t_1 * log1p(expm1(sin(((lambda1 - lambda2) * 0.5))))))), sqrt((1.0 - (t_2 + (t_0 * t_1))))));
}
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;
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_1 * Math.log1p(Math.expm1(Math.sin(((lambda1 - lambda2) * 0.5))))))), Math.sqrt((1.0 - (t_2 + (t_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_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + (t_1 * math.log1p(math.expm1(math.sin(((lambda1 - lambda2) * 0.5))))))), math.sqrt((1.0 - (t_2 + (t_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)) * t_0) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_1 * log1p(expm1(sin(Float64(Float64(lambda1 - lambda2) * 0.5))))))), sqrt(Float64(1.0 - Float64(t_2 + Float64(t_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] * t$95$0), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$1 * N[Log[1 + N[(Exp[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_1 \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)\right)\right)}}{\sqrt{1 - \left(t_2 + t_0 \cdot t_1\right)}}\right)
\end{array}
\end{array}
Initial program 63.0%
log1p-expm1-u63.0%
div-inv63.0%
metadata-eval63.0%
Applied egg-rr63.0%
Final simplification63.0%
(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 (* t_2 t_1))
(t_4 (sqrt (+ t_0 (* t_1 t_3)))))
(if (<= lambda2 0.0265)
(*
R
(* 2.0 (atan2 t_4 (sqrt (- 1.0 (+ t_0 (* t_3 (sin (* lambda1 0.5)))))))))
(*
R
(*
2.0
(atan2
t_4
(sqrt
(-
1.0
(+
(* t_2 (pow (sin (* lambda2 -0.5)) 2.0))
(pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))))))
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 = t_2 * t_1;
double t_4 = sqrt((t_0 + (t_1 * t_3)));
double tmp;
if (lambda2 <= 0.0265) {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_0 + (t_3 * sin((lambda1 * 0.5))))))));
} else {
tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((t_2 * pow(sin((lambda2 * -0.5)), 2.0)) + pow(sin(((phi1 - phi2) * 0.5)), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
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 = t_2 * t_1
t_4 = sqrt((t_0 + (t_1 * t_3)))
if (lambda2 <= 0.0265d0) then
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - (t_0 + (t_3 * sin((lambda1 * 0.5d0))))))))
else
tmp = r * (2.0d0 * atan2(t_4, sqrt((1.0d0 - ((t_2 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)) + (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.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 = t_2 * t_1;
double t_4 = Math.sqrt((t_0 + (t_1 * t_3)));
double tmp;
if (lambda2 <= 0.0265) {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - (t_0 + (t_3 * Math.sin((lambda1 * 0.5))))))));
} else {
tmp = R * (2.0 * Math.atan2(t_4, Math.sqrt((1.0 - ((t_2 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)) + Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0))))));
}
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 = t_2 * t_1 t_4 = math.sqrt((t_0 + (t_1 * t_3))) tmp = 0 if lambda2 <= 0.0265: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - (t_0 + (t_3 * math.sin((lambda1 * 0.5)))))))) else: tmp = R * (2.0 * math.atan2(t_4, math.sqrt((1.0 - ((t_2 * math.pow(math.sin((lambda2 * -0.5)), 2.0)) + math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0)))))) 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 = Float64(t_2 * t_1) t_4 = sqrt(Float64(t_0 + Float64(t_1 * t_3))) tmp = 0.0 if (lambda2 <= 0.0265) tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(t_0 + Float64(t_3 * sin(Float64(lambda1 * 0.5))))))))); else tmp = Float64(R * Float64(2.0 * atan(t_4, sqrt(Float64(1.0 - Float64(Float64(t_2 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)) + (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0))))))); 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 = t_2 * t_1; t_4 = sqrt((t_0 + (t_1 * t_3))); tmp = 0.0; if (lambda2 <= 0.0265) tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - (t_0 + (t_3 * sin((lambda1 * 0.5)))))))); else tmp = R * (2.0 * atan2(t_4, sqrt((1.0 - ((t_2 * (sin((lambda2 * -0.5)) ^ 2.0)) + (sin(((phi1 - phi2) * 0.5)) ^ 2.0)))))); 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[(t$95$2 * t$95$1), $MachinePrecision]}, Block[{t$95$4 = N[Sqrt[N[(t$95$0 + N[(t$95$1 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 0.0265], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$3 * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$4 / N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
t_3 := t_2 \cdot t_1\\
t_4 := \sqrt{t_0 + t_1 \cdot t_3}\\
\mathbf{if}\;\lambda_2 \leq 0.0265:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{1 - \left(t_0 + t_3 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_4}{\sqrt{1 - \left(t_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2} + {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 0.0264999999999999993Initial program 68.1%
Taylor expanded in lambda2 around 0 60.4%
if 0.0264999999999999993 < lambda2 Initial program 48.1%
Taylor expanded in lambda1 around 0 48.3%
Final simplification57.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) (* t_0 t_0)))
(t_2 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))
(* R (* 2.0 (atan2 (sqrt (+ t_2 t_1)) (sqrt (- (- 1.0 t_2) t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0);
double t_2 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_2) - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0)
t_2 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
code = r * (2.0d0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0d0 - t_2) - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * (t_0 * t_0);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
return R * (2.0 * Math.atan2(Math.sqrt((t_2 + t_1)), Math.sqrt(((1.0 - t_2) - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * (t_0 * t_0) t_2 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) return R * (2.0 * math.atan2(math.sqrt((t_2 + t_1)), math.sqrt(((1.0 - t_2) - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * Float64(t_0 * t_0)) t_2 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 return Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + t_1)), sqrt(Float64(Float64(1.0 - t_2) - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * (t_0 * t_0); t_2 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; tmp = R * (2.0 * atan2(sqrt((t_2 + t_1)), sqrt(((1.0 - t_2) - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(t_0 \cdot t_0\right)\\
t_2 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_1}}{\sqrt{\left(1 - t_2\right) - t_1}}\right)
\end{array}
\end{array}
Initial program 63.0%
associate-*l*63.0%
Simplified63.0%
Final simplification63.0%
(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_0 (* (* (cos phi1) (cos phi2)) t_0)))))
(* R (* 2.0 (atan2 (sqrt t_1) (sqrt (- 1.0 t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0));
return R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))
code = r * (2.0d0 * atan2(sqrt(t_1), sqrt((1.0d0 - t_1))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0));
return R * (2.0 * Math.atan2(Math.sqrt(t_1), Math.sqrt((1.0 - t_1))));
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)) return R * (2.0 * math.atan2(math.sqrt(t_1), math.sqrt((1.0 - t_1))))
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) return Float64(R * Float64(2.0 * atan(sqrt(t_1), sqrt(Float64(1.0 - t_1))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)); tmp = R * (2.0 * atan2(sqrt(t_1), sqrt((1.0 - t_1)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R * N[(2.0 * N[ArcTan[N[Sqrt[t$95$1], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1}}{\sqrt{1 - t_1}}\right)
\end{array}
\end{array}
Initial program 63.0%
Final simplification63.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (sin (* lambda2 -0.5)))
(t_2 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(t_3 (sin (/ (- lambda1 lambda2) 2.0)))
(t_4 (* (cos phi1) (cos phi2)))
(t_5 (* t_4 t_3)))
(if (<= lambda2 0.0265)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_3 t_5)))
(sqrt
(-
1.0
(+
t_2
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_5 t_1)))
(sqrt (- (- 1.0 t_2) (* t_4 (pow t_1 2.0))))))))))
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((lambda2 * -0.5));
double t_2 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double t_3 = sin(((lambda1 - lambda2) / 2.0));
double t_4 = cos(phi1) * cos(phi2);
double t_5 = t_4 * t_3;
double tmp;
if (lambda2 <= 0.0265) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * t_5))), sqrt((1.0 - (t_2 + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_5 * t_1))), sqrt(((1.0 - t_2) - (t_4 * pow(t_1, 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: t_4
real(8) :: t_5
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin((lambda2 * (-0.5d0)))
t_2 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_3 = sin(((lambda1 - lambda2) / 2.0d0))
t_4 = cos(phi1) * cos(phi2)
t_5 = t_4 * t_3
if (lambda2 <= 0.0265d0) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_3 * t_5))), sqrt((1.0d0 - (t_2 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_5 * t_1))), sqrt(((1.0d0 - t_2) - (t_4 * (t_1 ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin((lambda2 * -0.5));
double t_2 = Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0);
double t_3 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_4 = Math.cos(phi1) * Math.cos(phi2);
double t_5 = t_4 * t_3;
double tmp;
if (lambda2 <= 0.0265) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * t_5))), Math.sqrt((1.0 - (t_2 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_5 * t_1))), Math.sqrt(((1.0 - t_2) - (t_4 * Math.pow(t_1, 2.0))))));
}
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((lambda2 * -0.5)) t_2 = math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) t_3 = math.sin(((lambda1 - lambda2) / 2.0)) t_4 = math.cos(phi1) * math.cos(phi2) t_5 = t_4 * t_3 tmp = 0 if lambda2 <= 0.0265: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_3 * t_5))), math.sqrt((1.0 - (t_2 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_5 * t_1))), math.sqrt(((1.0 - t_2) - (t_4 * math.pow(t_1, 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(lambda2 * -0.5)) t_2 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_3 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_4 = Float64(cos(phi1) * cos(phi2)) t_5 = Float64(t_4 * t_3) tmp = 0.0 if (lambda2 <= 0.0265) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * t_5))), sqrt(Float64(1.0 - Float64(t_2 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_5 * t_1))), sqrt(Float64(Float64(1.0 - t_2) - Float64(t_4 * (t_1 ^ 2.0))))))); 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((lambda2 * -0.5)); t_2 = sin(((phi1 - phi2) * 0.5)) ^ 2.0; t_3 = sin(((lambda1 - lambda2) / 2.0)); t_4 = cos(phi1) * cos(phi2); t_5 = t_4 * t_3; tmp = 0.0; if (lambda2 <= 0.0265) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * t_5))), sqrt((1.0 - (t_2 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_5 * t_1))), sqrt(((1.0 - t_2) - (t_4 * (t_1 ^ 2.0)))))); 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[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$4 * t$95$3), $MachinePrecision]}, If[LessEqual[lambda2, 0.0265], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * t$95$5), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$2 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$5 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$2), $MachinePrecision] - N[(t$95$4 * N[Power[t$95$1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := \sin \left(\lambda_2 \cdot -0.5\right)\\
t_2 := {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\\
t_3 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_4 := \cos \phi_1 \cdot \cos \phi_2\\
t_5 := t_4 \cdot t_3\\
\mathbf{if}\;\lambda_2 \leq 0.0265:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot t_5}}{\sqrt{1 - \left(t_2 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_5 \cdot t_1}}{\sqrt{\left(1 - t_2\right) - t_4 \cdot {t_1}^{2}}}\right)\\
\end{array}
\end{array}
if lambda2 < 0.0264999999999999993Initial program 68.1%
Taylor expanded in lambda2 around 0 60.6%
if 0.0264999999999999993 < lambda2 Initial program 48.1%
Taylor expanded in lambda1 around 0 47.2%
Taylor expanded in lambda1 around 0 47.1%
associate--r+47.1%
Simplified47.1%
Final simplification57.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0)))
(t_2 (* (cos phi1) (cos phi2)))
(t_3
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_1 (* t_2 t_1))))))
(if (<= lambda2 0.0265)
(*
R
(*
2.0
(atan2
t_3
(sqrt
(-
1.0
(+
t_0
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
t_3
(sqrt (- 1.0 (+ (* t_2 (pow (sin (* lambda2 -0.5)) 2.0)) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double t_2 = cos(phi1) * cos(phi2);
double t_3 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_1))));
double tmp;
if (lambda2 <= 0.0265) {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((t_2 * pow(sin((lambda2 * -0.5)), 2.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) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = cos(phi1) * cos(phi2)
t_3 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * (t_2 * t_1))))
if (lambda2 <= 0.0265d0) then
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - (t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(t_3, sqrt((1.0d0 - ((t_2 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)) + t_0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 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((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_1))));
double tmp;
if (lambda2 <= 0.0265) {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - (t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * Math.atan2(t_3, Math.sqrt((1.0 - ((t_2 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)) + t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) t_2 = math.cos(phi1) * math.cos(phi2) t_3 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * (t_2 * t_1)))) tmp = 0 if lambda2 <= 0.0265: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - (t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0)))))))) else: tmp = R * (2.0 * math.atan2(t_3, math.sqrt((1.0 - ((t_2 * math.pow(math.sin((lambda2 * -0.5)), 2.0)) + t_0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_2 = Float64(cos(phi1) * cos(phi2)) t_3 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(t_2 * t_1)))) tmp = 0.0 if (lambda2 <= 0.0265) tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(t_3, sqrt(Float64(1.0 - Float64(Float64(t_2 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)) + t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) * 0.5)) ^ 2.0; t_1 = sin(((lambda1 - lambda2) / 2.0)); t_2 = cos(phi1) * cos(phi2); t_3 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * (t_2 * t_1)))); tmp = 0.0; if (lambda2 <= 0.0265) tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - (t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(t_3, sqrt((1.0 - ((t_2 * (sin((lambda2 * -0.5)) ^ 2.0)) + t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $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[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(t$95$2 * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 0.0265], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$3 / N[Sqrt[N[(1.0 - N[(N[(t$95$2 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\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{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(t_2 \cdot t_1\right)}\\
\mathbf{if}\;\lambda_2 \leq 0.0265:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_3}{\sqrt{1 - \left(t_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2} + t_0\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 0.0264999999999999993Initial program 68.1%
Taylor expanded in lambda2 around 0 60.6%
if 0.0264999999999999993 < lambda2 Initial program 48.1%
Taylor expanded in lambda1 around 0 48.3%
Final simplification57.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (* (cos phi1) (cos phi2)) t_2)))
(if (or (<= phi1 -0.000116) (not (<= phi1 0.0021)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_3 (sin (* lambda2 -0.5)))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 t_3)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = (cos(phi1) * cos(phi2)) * t_2;
double tmp;
if ((phi1 <= -0.000116) || !(phi1 <= 0.0021)) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * sin((lambda2 * -0.5))))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * t_3))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = (cos(phi1) * cos(phi2)) * t_2
if ((phi1 <= (-0.000116d0)) .or. (.not. (phi1 <= 0.0021d0))) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_3 * sin((lambda2 * (-0.5d0)))))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * t_3))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double tmp;
if ((phi1 <= -0.000116) || !(phi1 <= 0.0021)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_3 * Math.sin((lambda2 * -0.5))))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * t_3))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_2 tmp = 0 if (phi1 <= -0.000116) or not (phi1 <= 0.0021): tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_3 * math.sin((lambda2 * -0.5))))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * t_3))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) tmp = 0.0 if ((phi1 <= -0.000116) || !(phi1 <= 0.0021)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_3 * sin(Float64(lambda2 * -0.5))))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * t_3))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = (cos(phi1) * cos(phi2)) * t_2; tmp = 0.0; if ((phi1 <= -0.000116) || ~((phi1 <= 0.0021))) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_3 * sin((lambda2 * -0.5))))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * t_3))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, If[Or[LessEqual[phi1, -0.000116], N[Not[LessEqual[phi1, 0.0021]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$3 * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\\
\mathbf{if}\;\phi_1 \leq -0.000116 \lor \neg \left(\phi_1 \leq 0.0021\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_3 \cdot \sin \left(\lambda_2 \cdot -0.5\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot t_3}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi1 < -1.16e-4 or 0.00209999999999999987 < phi1 Initial program 47.5%
Taylor expanded in lambda1 around 0 39.0%
Taylor expanded in phi2 around 0 39.5%
associate--r+39.5%
unpow239.5%
1-sub-sin39.6%
unpow239.6%
*-commutative39.6%
*-commutative39.6%
unpow239.6%
associate-*r*39.6%
Simplified39.6%
if -1.16e-4 < phi1 < 0.00209999999999999987Initial program 82.3%
Taylor expanded in phi1 around 0 82.3%
associate--r+82.3%
unpow282.3%
1-sub-sin82.4%
unpow282.4%
*-commutative82.4%
sub-neg82.4%
mul-1-neg82.4%
+-commutative82.4%
*-commutative82.4%
Simplified82.4%
Final simplification58.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))
(if (or (<= phi2 -1150000.0) (not (<= phi2 2.9e-18)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_1))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = pow(sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -1150000.0) || !(phi2 <= 2.9e-18)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0
if ((phi2 <= (-1150000.0d0)) .or. (.not. (phi2 <= 2.9d-18))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_1)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * t_1)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0);
double tmp;
if ((phi2 <= -1150000.0) || !(phi2 <= 2.9e-18)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_1)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * t_1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0) tmp = 0 if (phi2 <= -1150000.0) or not (phi2 <= 2.9e-18): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_1))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * t_1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0 tmp = 0.0 if ((phi2 <= -1150000.0) || !(phi2 <= 2.9e-18)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = sin((-0.5 * (lambda2 - lambda1))) ^ 2.0; tmp = 0.0; if ((phi2 <= -1150000.0) || ~((phi2 <= 2.9e-18))) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_1))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * t_1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi2, -1150000.0], N[Not[LessEqual[phi2, 2.9e-18]], $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] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}\\
\mathbf{if}\;\phi_2 \leq -1150000 \lor \neg \left(\phi_2 \leq 2.9 \cdot 10^{-18}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_1}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot t_1}}\right)\\
\end{array}
\end{array}
if phi2 < -1.15e6 or 2.9e-18 < phi2 Initial program 45.7%
Taylor expanded in phi1 around 0 46.1%
associate--r+46.2%
unpow246.2%
1-sub-sin46.2%
unpow246.2%
*-commutative46.2%
sub-neg46.2%
mul-1-neg46.2%
+-commutative46.2%
*-commutative46.2%
Simplified46.2%
Taylor expanded in phi1 around 0 45.8%
Taylor expanded in phi1 around 0 47.5%
if -1.15e6 < phi2 < 2.9e-18Initial program 80.6%
Taylor expanded in phi2 around 0 80.6%
associate--r+57.1%
unpow257.1%
1-sub-sin57.3%
unpow257.3%
*-commutative57.3%
*-commutative57.3%
unpow257.3%
associate-*r*57.3%
Simplified80.7%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (* (cos phi1) (cos phi2)) t_0)))
(if (or (<= phi1 -1.1e-34) (not (<= phi1 2.05e-7)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (sin (* lambda2 -0.5)))))
(sqrt
(-
(pow (cos (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 t_1) (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = (cos(phi1) * cos(phi2)) * t_0;
double tmp;
if ((phi1 <= -1.1e-34) || !(phi1 <= 2.05e-7)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * sin((lambda2 * -0.5))))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = (cos(phi1) * cos(phi2)) * t_0
if ((phi1 <= (-1.1d-34)) .or. (.not. (phi1 <= 2.05d-7))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * sin((lambda2 * (-0.5d0)))))), sqrt(((cos((phi1 * 0.5d0)) ** 2.0d0) - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * t_1) + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = (Math.cos(phi1) * Math.cos(phi2)) * t_0;
double tmp;
if ((phi1 <= -1.1e-34) || !(phi1 <= 2.05e-7)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * Math.sin((lambda2 * -0.5))))), Math.sqrt((Math.pow(Math.cos((phi1 * 0.5)), 2.0) - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * t_1) + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = (math.cos(phi1) * math.cos(phi2)) * t_0 tmp = 0 if (phi1 <= -1.1e-34) or not (phi1 <= 2.05e-7): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * math.sin((lambda2 * -0.5))))), math.sqrt((math.pow(math.cos((phi1 * 0.5)), 2.0) - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * t_1) + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) + (math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(Float64(cos(phi1) * cos(phi2)) * t_0) tmp = 0.0 if ((phi1 <= -1.1e-34) || !(phi1 <= 2.05e-7)) 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))))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * t_1) + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = (cos(phi1) * cos(phi2)) * t_0; tmp = 0.0; if ((phi1 <= -1.1e-34) || ~((phi1 <= 2.05e-7))) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * sin((lambda2 * -0.5))))), sqrt(((cos((phi1 * 0.5)) ^ 2.0) - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((t_0 * t_1) + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]}, If[Or[LessEqual[phi1, -1.1e-34], N[Not[LessEqual[phi1, 2.05e-7]], $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[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * t$95$1), $MachinePrecision] + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\\
\mathbf{if}\;\phi_1 \leq -1.1 \cdot 10^{-34} \lor \neg \left(\phi_1 \leq 2.05 \cdot 10^{-7}\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)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2} - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\end{array}
\end{array}
if phi1 < -1.0999999999999999e-34 or 2.05e-7 < phi1 Initial program 49.9%
Taylor expanded in lambda1 around 0 40.2%
Taylor expanded in phi2 around 0 40.2%
associate--r+40.2%
unpow240.2%
1-sub-sin40.3%
unpow240.3%
*-commutative40.3%
*-commutative40.3%
unpow240.3%
associate-*r*40.3%
Simplified40.3%
if -1.0999999999999999e-34 < phi1 < 2.05e-7Initial program 81.8%
Taylor expanded in phi1 around 0 81.8%
associate--r+81.8%
unpow281.8%
1-sub-sin81.9%
unpow281.9%
*-commutative81.9%
sub-neg81.9%
mul-1-neg81.9%
+-commutative81.9%
*-commutative81.9%
Simplified81.9%
Taylor expanded in phi1 around 0 77.6%
unpow277.6%
sin-mult77.6%
Applied egg-rr77.6%
div-sub77.6%
+-inverses77.6%
cos-077.6%
Simplified77.6%
Final simplification55.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (cos (* phi1 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (sin (* lambda2 -0.5)))
(t_4 (* (* (cos phi1) (cos phi2)) t_2))
(t_5 (* t_2 t_4)))
(if (<= phi1 -1.1e-34)
(*
R
(*
2.0
(atan2 (sqrt (+ t_0 t_5)) (sqrt (- t_1 (* (cos phi1) (pow t_3 2.0)))))))
(if (<= phi1 1.2e-7)
(*
R
(*
2.0
(atan2
(sqrt (+ t_5 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt
(+
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (- (/ (cos (- lambda1 lambda2)) 2.0) 0.5)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_4 t_3)))
(sqrt
(-
t_1
(*
(cos phi1)
(pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = pow(cos((phi1 * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = sin((lambda2 * -0.5));
double t_4 = (cos(phi1) * cos(phi2)) * t_2;
double t_5 = t_2 * t_4;
double tmp;
if (phi1 <= -1.1e-34) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_5)), sqrt((t_1 - (cos(phi1) * pow(t_3, 2.0))))));
} else if (phi1 <= 1.2e-7) {
tmp = R * (2.0 * atan2(sqrt((t_5 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_4 * t_3))), sqrt((t_1 - (cos(phi1) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: 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 = cos((phi1 * 0.5d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = sin((lambda2 * (-0.5d0)))
t_4 = (cos(phi1) * cos(phi2)) * t_2
t_5 = t_2 * t_4
if (phi1 <= (-1.1d-34)) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + t_5)), sqrt((t_1 - (cos(phi1) * (t_3 ** 2.0d0))))))
else if (phi1 <= 1.2d-7) then
tmp = r * (2.0d0 * atan2(sqrt((t_5 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0d0) - 0.5d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_4 * t_3))), sqrt((t_1 - (cos(phi1) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.cos((phi1 * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.sin((lambda2 * -0.5));
double t_4 = (Math.cos(phi1) * Math.cos(phi2)) * t_2;
double t_5 = t_2 * t_4;
double tmp;
if (phi1 <= -1.1e-34) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + t_5)), Math.sqrt((t_1 - (Math.cos(phi1) * Math.pow(t_3, 2.0))))));
} else if (phi1 <= 1.2e-7) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_5 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * ((Math.cos((lambda1 - lambda2)) / 2.0) - 0.5))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_4 * t_3))), Math.sqrt((t_1 - (Math.cos(phi1) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
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.cos((phi1 * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.sin((lambda2 * -0.5)) t_4 = (math.cos(phi1) * math.cos(phi2)) * t_2 t_5 = t_2 * t_4 tmp = 0 if phi1 <= -1.1e-34: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + t_5)), math.sqrt((t_1 - (math.cos(phi1) * math.pow(t_3, 2.0)))))) elif phi1 <= 1.2e-7: tmp = R * (2.0 * math.atan2(math.sqrt((t_5 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) + (math.cos(phi2) * ((math.cos((lambda1 - lambda2)) / 2.0) - 0.5)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_4 * t_3))), math.sqrt((t_1 - (math.cos(phi1) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0 t_1 = cos(Float64(phi1 * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = sin(Float64(lambda2 * -0.5)) t_4 = Float64(Float64(cos(phi1) * cos(phi2)) * t_2) t_5 = Float64(t_2 * t_4) tmp = 0.0 if (phi1 <= -1.1e-34) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_5)), sqrt(Float64(t_1 - Float64(cos(phi1) * (t_3 ^ 2.0))))))); elseif (phi1 <= 1.2e-7) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_5 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * Float64(Float64(cos(Float64(lambda1 - lambda2)) / 2.0) - 0.5))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_4 * t_3))), sqrt(Float64(t_1 - Float64(cos(phi1) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) / 2.0)) ^ 2.0; t_1 = cos((phi1 * 0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = sin((lambda2 * -0.5)); t_4 = (cos(phi1) * cos(phi2)) * t_2; t_5 = t_2 * t_4; tmp = 0.0; if (phi1 <= -1.1e-34) tmp = R * (2.0 * atan2(sqrt((t_0 + t_5)), sqrt((t_1 - (cos(phi1) * (t_3 ^ 2.0)))))); elseif (phi1 <= 1.2e-7) tmp = R * (2.0 * atan2(sqrt((t_5 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * ((cos((lambda1 - lambda2)) / 2.0) - 0.5)))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_4 * t_3))), sqrt((t_1 - (cos(phi1) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); 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[Cos[N[(phi1 * 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[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$2), $MachinePrecision]}, Block[{t$95$5 = N[(t$95$2 * t$95$4), $MachinePrecision]}, If[LessEqual[phi1, -1.1e-34], 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[Power[t$95$3, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.2e-7], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$5 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] / 2.0), $MachinePrecision] - 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$4 * t$95$3), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(t$95$1 - N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\\
t_1 := {\cos \left(\phi_1 \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \sin \left(\lambda_2 \cdot -0.5\right)\\
t_4 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_2\\
t_5 := t_2 \cdot t_4\\
\mathbf{if}\;\phi_1 \leq -1.1 \cdot 10^{-34}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_5}}{\sqrt{t_1 - \cos \phi_1 \cdot {t_3}^{2}}}\right)\\
\mathbf{elif}\;\phi_1 \leq 1.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_5 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot \left(\frac{\cos \left(\lambda_1 - \lambda_2\right)}{2} - 0.5\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_4 \cdot t_3}}{\sqrt{t_1 - \cos \phi_1 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -1.0999999999999999e-34Initial program 54.4%
Taylor expanded in lambda1 around 0 42.2%
+-commutative42.2%
*-commutative42.2%
fma-def42.2%
sub-neg42.2%
mul-1-neg42.2%
+-commutative42.2%
*-commutative42.2%
Simplified42.2%
Taylor expanded in phi2 around 0 42.3%
+-commutative42.3%
associate--r+42.3%
unpow242.3%
1-sub-sin42.4%
unpow242.4%
*-commutative42.4%
Simplified42.4%
if -1.0999999999999999e-34 < phi1 < 1.19999999999999989e-7Initial program 81.8%
Taylor expanded in phi1 around 0 81.8%
associate--r+81.8%
unpow281.8%
1-sub-sin81.9%
unpow281.9%
*-commutative81.9%
sub-neg81.9%
mul-1-neg81.9%
+-commutative81.9%
*-commutative81.9%
Simplified81.9%
Taylor expanded in phi1 around 0 77.6%
unpow277.6%
sin-mult77.6%
Applied egg-rr77.6%
div-sub77.6%
+-inverses77.6%
cos-077.6%
Simplified77.6%
if 1.19999999999999989e-7 < phi1 Initial program 44.4%
Taylor expanded in lambda1 around 0 37.7%
Taylor expanded in phi2 around 0 37.8%
associate--r+37.8%
unpow237.8%
1-sub-sin37.9%
unpow237.9%
*-commutative37.9%
*-commutative37.9%
unpow237.9%
associate-*r*37.9%
Simplified37.9%
Final simplification55.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= (- lambda1 lambda2) -0.0001)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt
(pow
(pow (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 2.0)) 3.0)
0.3333333333333333))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((lambda1 - lambda2) <= -0.0001) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(pow(pow((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 2.0)), 3.0), 0.3333333333333333))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if ((lambda1 - lambda2) <= (-0.0001d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((((1.0d0 - (sin(((-0.5d0) * (phi2 - phi1))) ** 2.0d0)) ** 3.0d0) ** 0.3333333333333333d0))))
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 tmp;
if ((lambda1 - lambda2) <= -0.0001) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt(Math.pow(Math.pow((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0)), 3.0), 0.3333333333333333))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (lambda1 - lambda2) <= -0.0001: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt(math.pow(math.pow((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 2.0)), 3.0), 0.3333333333333333)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -0.0001) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(((Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)) ^ 3.0) ^ 0.3333333333333333))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((lambda1 - lambda2) <= -0.0001) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 2.0)) ^ 3.0) ^ 0.3333333333333333)))); 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]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.0001], 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] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Power[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 0.3333333333333333], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.0001:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\left({\left(1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}\right)}^{3}\right)}^{0.3333333333333333}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000005e-4Initial program 56.7%
Taylor expanded in phi1 around 0 46.4%
associate--r+46.4%
unpow246.4%
1-sub-sin46.4%
unpow246.4%
*-commutative46.4%
sub-neg46.4%
mul-1-neg46.4%
+-commutative46.4%
*-commutative46.4%
Simplified46.4%
Taylor expanded in phi1 around 0 42.3%
Taylor expanded in phi1 around 0 46.1%
if -1.00000000000000005e-4 < (-.f64 lambda1 lambda2) Initial program 67.3%
Taylor expanded in lambda1 around 0 55.8%
+-commutative55.8%
*-commutative55.8%
fma-def55.8%
sub-neg55.8%
mul-1-neg55.8%
+-commutative55.8%
*-commutative55.8%
Simplified55.8%
Taylor expanded in lambda2 around 0 46.5%
add-cbrt-cube46.5%
pow1/346.5%
pow346.5%
Applied egg-rr46.5%
Final simplification46.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= (- lambda1 lambda2) -0.0001)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((lambda1 - lambda2) <= -0.0001) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 2.0)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if ((lambda1 - lambda2) <= (-0.0001d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - (sin(((-0.5d0) * (phi2 - phi1))) ** 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 tmp;
if ((lambda1 - lambda2) <= -0.0001) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (lambda1 - lambda2) <= -0.0001: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -0.0001) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((lambda1 - lambda2) <= -0.0001) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 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]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.0001], 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] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.0001:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.00000000000000005e-4Initial program 56.7%
Taylor expanded in phi1 around 0 46.4%
associate--r+46.4%
unpow246.4%
1-sub-sin46.4%
unpow246.4%
*-commutative46.4%
sub-neg46.4%
mul-1-neg46.4%
+-commutative46.4%
*-commutative46.4%
Simplified46.4%
Taylor expanded in phi1 around 0 42.3%
Taylor expanded in phi1 around 0 46.1%
if -1.00000000000000005e-4 < (-.f64 lambda1 lambda2) Initial program 67.3%
Taylor expanded in lambda1 around 0 55.8%
+-commutative55.8%
*-commutative55.8%
fma-def55.8%
sub-neg55.8%
mul-1-neg55.8%
+-commutative55.8%
*-commutative55.8%
Simplified55.8%
Taylor expanded in lambda2 around 0 46.5%
Final simplification46.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2))))
(if (<= (- lambda1 lambda2) -4000000.0)
(*
R
(*
2.0
(atan2
(hypot
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt t_1))
(sin (* phi2 -0.5)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) (* t_0 (* t_1 t_0))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 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 tmp;
if ((lambda1 - lambda2) <= -4000000.0) {
tmp = R * (2.0 * atan2(hypot((sin(((lambda1 - lambda2) * 0.5)) * sqrt(t_1)), sin((phi2 * -0.5))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), sqrt((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 2.0)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if ((lambda1 - lambda2) <= -4000000.0) {
tmp = R * (2.0 * Math.atan2(Math.hypot((Math.sin(((lambda1 - lambda2) * 0.5)) * Math.sqrt(t_1)), Math.sin((phi2 * -0.5))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 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) tmp = 0 if (lambda1 - lambda2) <= -4000000.0: tmp = R * (2.0 * math.atan2(math.hypot((math.sin(((lambda1 - lambda2) * 0.5)) * math.sqrt(t_1)), math.sin((phi2 * -0.5))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * (t_1 * t_0)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 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)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -4000000.0) tmp = Float64(R * Float64(2.0 * atan(hypot(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(t_1)), sin(Float64(phi2 * -0.5))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(t_1 * t_0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 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); tmp = 0.0; if ((lambda1 - lambda2) <= -4000000.0) tmp = R * (2.0 * atan2(hypot((sin(((lambda1 - lambda2) * 0.5)) * sqrt(t_1)), sin((phi2 * -0.5))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * (t_1 * t_0)))), sqrt((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 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]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -4000000.0], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[t$95$1], $MachinePrecision]), $MachinePrecision] ^ 2 + N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -4000000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\mathsf{hypot}\left(\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{t_1}, \sin \left(\phi_2 \cdot -0.5\right)\right)}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(t_1 \cdot t_0\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -4e6Initial program 55.2%
Taylor expanded in phi1 around 0 44.5%
associate--r+44.5%
unpow244.5%
1-sub-sin44.5%
unpow244.5%
*-commutative44.5%
sub-neg44.5%
mul-1-neg44.5%
+-commutative44.5%
*-commutative44.5%
Simplified44.5%
Taylor expanded in phi1 around 0 40.3%
+-commutative40.3%
add-sqr-sqrt30.7%
unpow230.7%
hypot-def30.7%
Applied egg-rr30.7%
if -4e6 < (-.f64 lambda1 lambda2) Initial program 67.9%
Taylor expanded in lambda1 around 0 55.6%
+-commutative55.6%
*-commutative55.6%
fma-def55.7%
sub-neg55.7%
mul-1-neg55.7%
+-commutative55.7%
*-commutative55.7%
Simplified55.7%
Taylor expanded in lambda2 around 0 46.3%
Final simplification40.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_0 0.05)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 2.0))))))
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_0 <= 0.05d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0d0 - (sin(((-0.5d0) * (phi2 - phi1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2((sin(((lambda1 - lambda2) * 0.5d0)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2((Math.sin(((lambda1 - lambda2) * 0.5)) * Math.sqrt(Math.cos(phi1))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 0.05: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 2.0))))) else: tmp = R * (2.0 * math.atan2((math.sin(((lambda1 - lambda2) * 0.5)) * math.sqrt(math.cos(phi1))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 0.05) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_0 <= 0.05) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 2.0))))); else tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.050000000000000003Initial program 64.9%
Taylor expanded in lambda1 around 0 54.6%
+-commutative54.6%
*-commutative54.6%
fma-def54.6%
sub-neg54.6%
mul-1-neg54.6%
+-commutative54.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in lambda2 around 0 45.4%
if 0.050000000000000003 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 59.4%
Taylor expanded in phi1 around 0 47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.7%
unpow247.7%
*-commutative47.7%
sub-neg47.7%
mul-1-neg47.7%
+-commutative47.7%
*-commutative47.7%
Simplified47.7%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in phi2 around 0 34.0%
Final simplification41.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_0 0.05)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) (sin (* lambda2 -0.5)))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 2.0))))))
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * sin((lambda2 * -0.5))))), sqrt((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_0 <= 0.05d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * sin((lambda2 * (-0.5d0)))))), sqrt((1.0d0 - (sin(((-0.5d0) * (phi2 - phi1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2((sin(((lambda1 - lambda2) * 0.5d0)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * Math.sin((lambda2 * -0.5))))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2((Math.sin(((lambda1 - lambda2) * 0.5)) * Math.sqrt(Math.cos(phi1))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 0.05: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * math.sin((lambda2 * -0.5))))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 2.0))))) else: tmp = R * (2.0 * math.atan2((math.sin(((lambda1 - lambda2) * 0.5)) * math.sqrt(math.cos(phi1))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 0.05) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * sin(Float64(lambda2 * -0.5))))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_0 <= 0.05) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * sin((lambda2 * -0.5))))), sqrt((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 2.0))))); else tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\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 \sin \left(\lambda_2 \cdot -0.5\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.050000000000000003Initial program 64.9%
Taylor expanded in lambda1 around 0 54.6%
+-commutative54.6%
*-commutative54.6%
fma-def54.6%
sub-neg54.6%
mul-1-neg54.6%
+-commutative54.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in lambda2 around 0 45.4%
Taylor expanded in lambda1 around 0 43.0%
if 0.050000000000000003 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 59.4%
Taylor expanded in phi1 around 0 47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.7%
unpow247.7%
*-commutative47.7%
sub-neg47.7%
mul-1-neg47.7%
+-commutative47.7%
*-commutative47.7%
Simplified47.7%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in phi2 around 0 34.0%
Final simplification39.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_0 0.05)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* (* (* (cos phi1) (cos phi2)) t_0) (sin (* lambda1 0.5)))))
(sqrt (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 2.0))))))
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * sin((lambda1 * 0.5))))), sqrt((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_0 <= 0.05d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (((cos(phi1) * cos(phi2)) * t_0) * sin((lambda1 * 0.5d0))))), sqrt((1.0d0 - (sin(((-0.5d0) * (phi2 - phi1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2((sin(((lambda1 - lambda2) * 0.5d0)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((Math.cos(phi1) * Math.cos(phi2)) * t_0) * Math.sin((lambda1 * 0.5))))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2((Math.sin(((lambda1 - lambda2) * 0.5)) * Math.sqrt(Math.cos(phi1))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 0.05: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (((math.cos(phi1) * math.cos(phi2)) * t_0) * math.sin((lambda1 * 0.5))))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 2.0))))) else: tmp = R * (2.0 * math.atan2((math.sin(((lambda1 - lambda2) * 0.5)) * math.sqrt(math.cos(phi1))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 0.05) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * t_0) * sin(Float64(lambda1 * 0.5))))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_0 <= 0.05) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (((cos(phi1) * cos(phi2)) * t_0) * sin((lambda1 * 0.5))))), sqrt((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 2.0))))); else tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\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 \sin \left(\lambda_1 \cdot 0.5\right)}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.050000000000000003Initial program 64.9%
Taylor expanded in lambda1 around 0 54.6%
+-commutative54.6%
*-commutative54.6%
fma-def54.6%
sub-neg54.6%
mul-1-neg54.6%
+-commutative54.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in lambda2 around 0 45.4%
Taylor expanded in lambda2 around 0 44.5%
if 0.050000000000000003 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 59.4%
Taylor expanded in phi1 around 0 47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.7%
unpow247.7%
*-commutative47.7%
sub-neg47.7%
mul-1-neg47.7%
+-commutative47.7%
*-commutative47.7%
Simplified47.7%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in phi2 around 0 34.0%
Final simplification40.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_0 0.05)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(sqrt (pow (cos (* phi1 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt(pow(cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
if (t_0 <= 0.05d0) then
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2((sin(((lambda1 - lambda2) * 0.5d0)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.05) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0)))), Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2((Math.sin(((lambda1 - lambda2) * 0.5)) * Math.sqrt(Math.cos(phi1))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if t_0 <= 0.05: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))), math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2((math.sin(((lambda1 - lambda2) * 0.5)) * math.sqrt(math.cos(phi1))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 0.05) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (t_0 <= 0.05) tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))), sqrt((cos((phi1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.05], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.05:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.050000000000000003Initial program 64.9%
Taylor expanded in lambda1 around 0 54.6%
+-commutative54.6%
*-commutative54.6%
fma-def54.6%
sub-neg54.6%
mul-1-neg54.6%
+-commutative54.6%
*-commutative54.6%
Simplified54.6%
Taylor expanded in lambda2 around 0 45.4%
Taylor expanded in phi2 around 0 36.5%
unpow236.5%
1-sub-sin36.6%
unpow236.6%
Simplified36.6%
if 0.050000000000000003 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 59.4%
Taylor expanded in phi1 around 0 47.7%
associate--r+47.7%
unpow247.7%
1-sub-sin47.7%
unpow247.7%
*-commutative47.7%
sub-neg47.7%
mul-1-neg47.7%
+-commutative47.7%
*-commutative47.7%
Simplified47.7%
Taylor expanded in phi1 around 0 45.4%
Taylor expanded in phi2 around 0 34.0%
Final simplification35.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0))))
(if (or (<= phi1 -230000000000.0) (not (<= phi1 9e-11)))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (pow (cos (* phi2 -0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double tmp;
if ((phi1 <= -230000000000.0) || !(phi1 <= 9e-11)) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt(pow(cos((phi2 * -0.5)), 2.0))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
if ((phi1 <= (-230000000000.0d0)) .or. (.not. (phi1 <= 9d-11))) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (phi2 - phi1))) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((cos((phi2 * (-0.5d0))) ** 2.0d0))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((phi1 <= -230000000000.0) || !(phi1 <= 9e-11)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), Math.sqrt(Math.pow(Math.cos((phi2 * -0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) tmp = 0 if (phi1 <= -230000000000.0) or not (phi1 <= 9e-11): tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), math.sqrt(math.pow(math.cos((phi2 * -0.5)), 2.0)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) tmp = 0.0 if ((phi1 <= -230000000000.0) || !(phi1 <= 9e-11)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((cos(Float64(phi2 * -0.5)) ^ 2.0))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = 0.0; if ((phi1 <= -230000000000.0) || ~((phi1 <= 9e-11))) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((cos((phi2 * -0.5)) ^ 2.0)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[phi1, -230000000000.0], N[Not[LessEqual[phi1, 9e-11]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
\mathbf{if}\;\phi_1 \leq -230000000000 \lor \neg \left(\phi_1 \leq 9 \cdot 10^{-11}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -2.3e11 or 8.9999999999999999e-11 < phi1 Initial program 47.9%
Taylor expanded in lambda1 around 0 39.1%
+-commutative39.1%
*-commutative39.1%
fma-def39.1%
sub-neg39.1%
mul-1-neg39.1%
+-commutative39.1%
*-commutative39.1%
Simplified39.1%
Taylor expanded in lambda2 around 0 31.8%
Taylor expanded in phi2 around 0 32.2%
if -2.3e11 < phi1 < 8.9999999999999999e-11Initial program 81.2%
Taylor expanded in lambda1 around 0 61.0%
+-commutative61.0%
*-commutative61.0%
fma-def61.1%
sub-neg61.1%
mul-1-neg61.1%
+-commutative61.1%
*-commutative61.1%
Simplified61.1%
Taylor expanded in lambda2 around 0 42.8%
Taylor expanded in phi1 around 0 42.8%
unpow242.8%
1-sub-sin42.9%
unpow242.9%
*-commutative42.9%
Simplified42.9%
Final simplification37.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* t_0 (* (* (cos phi1) (cos phi2)) t_0)))
(t_2 (sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))))
(if (<= phi2 -0.00037)
(* R (* 2.0 (atan2 t_2 (sqrt (pow (cos (* phi2 -0.5)) 2.0)))))
(if (<= phi2 18000.0)
(* R (* 2.0 (atan2 t_2 (sqrt (pow (cos (* phi1 0.5)) 2.0)))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* -0.5 (- phi2 phi1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0);
double t_2 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1));
double tmp;
if (phi2 <= -0.00037) {
tmp = R * (2.0 * atan2(t_2, sqrt(pow(cos((phi2 * -0.5)), 2.0))));
} else if (phi2 <= 18000.0) {
tmp = R * (2.0 * atan2(t_2, sqrt(pow(cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi2 * -0.5)), 2.0))), sqrt((1.0 - pow(sin((-0.5 * (phi2 - phi1))), 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 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
t_2 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1))
if (phi2 <= (-0.00037d0)) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((cos((phi2 * (-0.5d0))) ** 2.0d0))))
else if (phi2 <= 18000.0d0) then
tmp = r * (2.0d0 * atan2(t_2, sqrt((cos((phi1 * 0.5d0)) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi2 * (-0.5d0))) ** 2.0d0))), sqrt((1.0d0 - (sin(((-0.5d0) * (phi2 - phi1))) ** 2.0d0)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double t_2 = Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1));
double tmp;
if (phi2 <= -0.00037) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt(Math.pow(Math.cos((phi2 * -0.5)), 2.0))));
} else if (phi2 <= 18000.0) {
tmp = R * (2.0 * Math.atan2(t_2, Math.sqrt(Math.pow(Math.cos((phi1 * 0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_1 + Math.pow(Math.sin((phi2 * -0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin((-0.5 * (phi2 - phi1))), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0) t_2 = math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)) tmp = 0 if phi2 <= -0.00037: tmp = R * (2.0 * math.atan2(t_2, math.sqrt(math.pow(math.cos((phi2 * -0.5)), 2.0)))) elif phi2 <= 18000.0: tmp = R * (2.0 * math.atan2(t_2, math.sqrt(math.pow(math.cos((phi1 * 0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_1 + math.pow(math.sin((phi2 * -0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin((-0.5 * (phi2 - phi1))), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) t_2 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)) tmp = 0.0 if (phi2 <= -0.00037) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt((cos(Float64(phi2 * -0.5)) ^ 2.0))))); elseif (phi2 <= 18000.0) tmp = Float64(R * Float64(2.0 * atan(t_2, sqrt((cos(Float64(phi1 * 0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(-0.5 * Float64(phi2 - phi1))) ^ 2.0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); t_2 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)); tmp = 0.0; if (phi2 <= -0.00037) tmp = R * (2.0 * atan2(t_2, sqrt((cos((phi2 * -0.5)) ^ 2.0)))); elseif (phi2 <= 18000.0) tmp = R * (2.0 * atan2(t_2, sqrt((cos((phi1 * 0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi2 * -0.5)) ^ 2.0))), sqrt((1.0 - (sin((-0.5 * (phi2 - phi1))) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -0.00037], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 18000.0], N[(R * N[(2.0 * N[ArcTan[t$95$2 / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$1 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(-0.5 * N[(phi2 - phi1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)\\
t_2 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1}\\
\mathbf{if}\;\phi_2 \leq -0.00037:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{elif}\;\phi_2 \leq 18000:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_2}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(-0.5 \cdot \left(\phi_2 - \phi_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -3.6999999999999999e-4Initial program 50.4%
Taylor expanded in lambda1 around 0 38.6%
+-commutative38.6%
*-commutative38.6%
fma-def38.6%
sub-neg38.6%
mul-1-neg38.6%
+-commutative38.6%
*-commutative38.6%
Simplified38.6%
Taylor expanded in lambda2 around 0 34.3%
Taylor expanded in phi1 around 0 34.4%
unpow234.4%
1-sub-sin34.5%
unpow234.5%
*-commutative34.5%
Simplified34.5%
if -3.6999999999999999e-4 < phi2 < 18000Initial program 81.2%
Taylor expanded in lambda1 around 0 61.6%
+-commutative61.6%
*-commutative61.6%
fma-def61.6%
sub-neg61.6%
mul-1-neg61.6%
+-commutative61.6%
*-commutative61.6%
Simplified61.6%
Taylor expanded in lambda2 around 0 42.9%
Taylor expanded in phi2 around 0 42.9%
unpow242.9%
1-sub-sin43.0%
unpow243.0%
Simplified43.0%
if 18000 < phi2 Initial program 38.4%
Taylor expanded in lambda1 around 0 34.3%
+-commutative34.3%
*-commutative34.3%
fma-def34.3%
sub-neg34.3%
mul-1-neg34.3%
+-commutative34.3%
*-commutative34.3%
Simplified34.3%
Taylor expanded in lambda2 around 0 26.3%
Taylor expanded in phi1 around 0 27.0%
Final simplification37.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_0 (* (* (cos phi1) (cos phi2)) t_0))))))
(if (or (<= phi2 -0.0035) (not (<= phi2 18000.0)))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* phi2 -0.5)) 2.0)))))
(* R (* 2.0 (atan2 t_1 (sqrt (pow (cos (* 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 = sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))));
double tmp;
if ((phi2 <= -0.0035) || !(phi2 <= 18000.0)) {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((phi2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * atan2(t_1, sqrt(pow(cos((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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0))))
if ((phi2 <= (-0.0035d0)) .or. (.not. (phi2 <= 18000.0d0))) then
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((phi2 * (-0.5d0))) ** 2.0d0))))
else
tmp = r * (2.0d0 * atan2(t_1, sqrt((cos((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.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0))));
double tmp;
if ((phi2 <= -0.0035) || !(phi2 <= 18000.0)) {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((phi2 * -0.5)), 2.0))));
} else {
tmp = R * (2.0 * Math.atan2(t_1, Math.sqrt(Math.pow(Math.cos((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.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_0 * ((math.cos(phi1) * math.cos(phi2)) * t_0)))) tmp = 0 if (phi2 <= -0.0035) or not (phi2 <= 18000.0): tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((phi2 * -0.5)), 2.0)))) else: tmp = R * (2.0 * math.atan2(t_1, math.sqrt(math.pow(math.cos((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 = sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))) tmp = 0.0 if ((phi2 <= -0.0035) || !(phi2 <= 18000.0)) tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(Float64(phi2 * -0.5)) ^ 2.0))))); else tmp = Float64(R * Float64(2.0 * atan(t_1, sqrt((cos(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 = sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_0 * ((cos(phi1) * cos(phi2)) * t_0)))); tmp = 0.0; if ((phi2 <= -0.0035) || ~((phi2 <= 18000.0))) tmp = R * (2.0 * atan2(t_1, sqrt((cos((phi2 * -0.5)) ^ 2.0)))); else tmp = R * (2.0 * atan2(t_1, sqrt((cos((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[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$0 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi2, -0.0035], N[Not[LessEqual[phi2, 18000.0]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[t$95$1 / N[Sqrt[N[Power[N[Cos[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_0 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}\\
\mathbf{if}\;\phi_2 \leq -0.0035 \lor \neg \left(\phi_2 \leq 18000\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{t_1}{\sqrt{{\cos \left(\phi_1 \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -0.00350000000000000007 or 18000 < phi2 Initial program 45.1%
Taylor expanded in lambda1 around 0 36.7%
+-commutative36.7%
*-commutative36.7%
fma-def36.7%
sub-neg36.7%
mul-1-neg36.7%
+-commutative36.7%
*-commutative36.7%
Simplified36.7%
Taylor expanded in lambda2 around 0 30.8%
Taylor expanded in phi1 around 0 30.8%
unpow230.8%
1-sub-sin30.9%
unpow230.9%
*-commutative30.9%
Simplified30.9%
if -0.00350000000000000007 < phi2 < 18000Initial program 81.2%
Taylor expanded in lambda1 around 0 61.6%
+-commutative61.6%
*-commutative61.6%
fma-def61.6%
sub-neg61.6%
mul-1-neg61.6%
+-commutative61.6%
*-commutative61.6%
Simplified61.6%
Taylor expanded in lambda2 around 0 42.9%
Taylor expanded in phi2 around 0 42.9%
unpow242.9%
1-sub-sin43.0%
unpow243.0%
Simplified43.0%
Final simplification36.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= t_0 0.035)
(*
R
(*
2.0
(atan2
(sin (* phi2 -0.5))
(sqrt
(-
1.0
(fma
(cos phi2)
(* t_0 (* (cos phi1) (sin (* lambda1 0.5))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (t_0 <= 0.035) {
tmp = R * (2.0 * atan2(sin((phi2 * -0.5)), sqrt((1.0 - fma(cos(phi2), (t_0 * (cos(phi1) * sin((lambda1 * 0.5)))), pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (t_0 <= 0.035) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(phi2 * -0.5)), sqrt(Float64(1.0 - fma(cos(phi2), Float64(t_0 * Float64(cos(phi1) * sin(Float64(lambda1 * 0.5)))), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t$95$0, 0.035], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda1 * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;t_0 \leq 0.035:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_2 \cdot -0.5\right)}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2, t_0 \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right), {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) < 0.035000000000000003Initial program 64.7%
Simplified64.7%
Taylor expanded in phi1 around 0 38.0%
Taylor expanded in lambda2 around 0 32.7%
+-commutative32.7%
associate-*r*32.7%
fma-def32.7%
Simplified32.7%
Taylor expanded in lambda1 around 0 13.5%
*-commutative13.5%
Simplified13.5%
Taylor expanded in lambda2 around 0 13.5%
if 0.035000000000000003 < (sin.f64 (/.f64 (-.f64 lambda1 lambda2) 2)) Initial program 59.8%
Taylor expanded in phi1 around 0 47.4%
associate--r+47.4%
unpow247.4%
1-sub-sin47.5%
unpow247.5%
*-commutative47.5%
sub-neg47.5%
mul-1-neg47.5%
+-commutative47.5%
*-commutative47.5%
Simplified47.5%
Taylor expanded in phi1 around 0 45.0%
Taylor expanded in phi2 around 0 33.8%
Final simplification20.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -0.00035) (not (<= phi2 1.9e+20)))
(*
R
(*
2.0
(atan2
(sin (* phi2 -0.5))
(sqrt
(-
1.0
(fma
(cos phi2)
(*
(sin (/ (- lambda1 lambda2) 2.0))
(* (cos phi1) (sin (* lambda2 -0.5))))
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)))))))
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -0.00035) || !(phi2 <= 1.9e+20)) {
tmp = R * (2.0 * atan2(sin((phi2 * -0.5)), sqrt((1.0 - fma(cos(phi2), (sin(((lambda1 - lambda2) / 2.0)) * (cos(phi1) * sin((lambda2 * -0.5)))), pow(sin(((phi1 - phi2) / 2.0)), 2.0))))));
} else {
tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -0.00035) || !(phi2 <= 1.9e+20)) tmp = Float64(R * Float64(2.0 * atan(sin(Float64(phi2 * -0.5)), sqrt(Float64(1.0 - fma(cos(phi2), Float64(sin(Float64(Float64(lambda1 - lambda2) / 2.0)) * Float64(cos(phi1) * sin(Float64(lambda2 * -0.5)))), (sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0))))))); else tmp = Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -0.00035], N[Not[LessEqual[phi2, 1.9e+20]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.00035 \lor \neg \left(\phi_2 \leq 1.9 \cdot 10^{+20}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\phi_2 \cdot -0.5\right)}{\sqrt{1 - \mathsf{fma}\left(\cos \phi_2, \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right) \cdot \left(\cos \phi_1 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right), {\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2}\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi2 < -3.49999999999999996e-4 or 1.9e20 < phi2 Initial program 44.3%
Simplified44.2%
Taylor expanded in phi1 around 0 43.7%
Taylor expanded in lambda2 around 0 38.7%
+-commutative38.7%
associate-*r*38.7%
fma-def38.6%
Simplified38.6%
Taylor expanded in lambda1 around 0 18.1%
*-commutative18.1%
Simplified18.1%
Taylor expanded in lambda1 around 0 17.8%
if -3.49999999999999996e-4 < phi2 < 1.9e20Initial program 81.4%
Taylor expanded in phi1 around 0 51.0%
associate--r+51.0%
unpow251.0%
1-sub-sin51.0%
unpow251.0%
*-commutative51.0%
sub-neg51.0%
mul-1-neg51.0%
+-commutative51.0%
*-commutative51.0%
Simplified51.0%
Taylor expanded in phi1 around 0 37.2%
Taylor expanded in phi2 around 0 20.9%
Final simplification19.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(* (sin (* (- lambda1 lambda2) 0.5)) (sqrt (cos phi1)))
(sqrt
(-
(pow (cos (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* -0.5 (- lambda2 lambda1))) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * pow(sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2((sin(((lambda1 - lambda2) * 0.5d0)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * (sin(((-0.5d0) * (lambda2 - lambda1))) ** 2.0d0))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2((Math.sin(((lambda1 - lambda2) * 0.5)) * Math.sqrt(Math.cos(phi1))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * Math.pow(Math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2((math.sin(((lambda1 - lambda2) * 0.5)) * math.sqrt(math.cos(phi1))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * math.pow(math.sin((-0.5 * (lambda2 - lambda1))), 2.0))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(Float64(sin(Float64(Float64(lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * (sin(Float64(-0.5 * Float64(lambda2 - lambda1))) ^ 2.0))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2((sin(((lambda1 - lambda2) * 0.5)) * sqrt(cos(phi1))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * (sin((-0.5 * (lambda2 - lambda1))) ^ 2.0)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[(N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] * N[Sqrt[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(-0.5 * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right) \cdot \sqrt{\cos \phi_1}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot {\sin \left(-0.5 \cdot \left(\lambda_2 - \lambda_1\right)\right)}^{2}}}\right)
\end{array}
Initial program 63.0%
Taylor expanded in phi1 around 0 47.9%
associate--r+47.9%
unpow247.9%
1-sub-sin48.0%
unpow248.0%
*-commutative48.0%
sub-neg48.0%
mul-1-neg48.0%
+-commutative48.0%
*-commutative48.0%
Simplified48.0%
Taylor expanded in phi1 around 0 40.7%
Taylor expanded in phi2 around 0 13.8%
Final simplification13.8%
herbie shell --seed 2023214
(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))))))))))