
(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 17 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 (pow (sin (* phi2 -0.5)) 2.0))
(t_1 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_2 (* (cos phi2) t_1))
(t_3 (sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_2)))
(t_4 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= phi2 -3.9)
(* R (* 2.0 (atan2 (sqrt (+ t_0 t_2)) t_3)))
(if (<= phi2 2e-5)
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_4 (* (* (cos phi1) (cos phi2)) t_4))))
(sqrt (- (pow (cos (* phi1 0.5)) 2.0) (* (cos phi1) t_1))))))
(* R (* 2.0 (atan2 (sqrt (fma (cos phi2) t_1 t_0)) t_3)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin((phi2 * -0.5)), 2.0);
double t_1 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_2 = cos(phi2) * t_1;
double t_3 = sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_2));
double t_4 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (phi2 <= -3.9) {
tmp = R * (2.0 * atan2(sqrt((t_0 + t_2)), t_3));
} else if (phi2 <= 2e-5) {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_4 * ((cos(phi1) * cos(phi2)) * t_4)))), sqrt((pow(cos((phi1 * 0.5)), 2.0) - (cos(phi1) * t_1)))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), t_1, t_0)), t_3));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(phi2 * -0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_2 = Float64(cos(phi2) * t_1) t_3 = sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_2)) t_4 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (phi2 <= -3.9) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + t_2)), t_3))); elseif (phi2 <= 2e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_4 * Float64(Float64(cos(phi1) * cos(phi2)) * t_4)))), sqrt(Float64((cos(Float64(phi1 * 0.5)) ^ 2.0) - Float64(cos(phi1) * t_1)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), t_1, t_0)), t_3))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]}, Block[{t$95$3 = N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$4 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -3.9], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + t$95$2), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 2e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$4 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$4), $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[(N[Cos[phi2], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision] / t$95$3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\\
t_1 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \cos \phi_2 \cdot t_1\\
t_3 := \sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_2}\\
t_4 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\phi_2 \leq -3.9:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2}}{t_3}\right)\\
\mathbf{elif}\;\phi_2 \leq 2 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_4 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_4\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{\mathsf{fma}\left(\cos \phi_2, t_1, t_0\right)}}{t_3}\right)\\
\end{array}
\end{array}
if phi2 < -3.89999999999999991Initial program 43.1%
Taylor expanded in phi1 around 0 44.1%
associate--r+44.1%
unpow244.1%
1-sub-sin44.2%
unpow244.2%
Simplified44.2%
Taylor expanded in phi1 around 0 45.5%
if -3.89999999999999991 < phi2 < 2.00000000000000016e-5Initial program 78.9%
Taylor expanded in phi2 around 0 78.8%
associate--r+78.8%
unpow278.8%
1-sub-sin78.8%
unpow278.8%
*-commutative78.8%
Simplified78.8%
if 2.00000000000000016e-5 < phi2 Initial program 41.3%
Taylor expanded in phi1 around 0 43.1%
associate--r+43.2%
unpow243.2%
1-sub-sin43.3%
unpow243.3%
Simplified43.3%
Taylor expanded in phi1 around 0 44.4%
+-commutative44.4%
fma-def44.4%
Simplified44.4%
Final simplification62.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= lambda2 5.7e-5)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 (* t_2 t_2))))
(sqrt (- (- 1.0 t_0) (* t_1 (* t_2 (sin (* lambda1 0.5)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_1 t_2))))
(sqrt
(-
1.0
(+
(pow (sin (* (- phi1 phi2) 0.5)) 2.0)
(* t_1 (pow (sin (* lambda2 -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 = cos(phi1) * cos(phi2);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 5.7e-5) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_2)))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * sin((lambda1 * 0.5))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - (pow(sin(((phi1 - phi2) * 0.5)), 2.0) + (t_1 * pow(sin((lambda2 * -0.5)), 2.0)))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
if (lambda2 <= 5.7d-5) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_2)))), sqrt(((1.0d0 - t_0) - (t_1 * (t_2 * sin((lambda1 * 0.5d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_1 * t_2)))), sqrt((1.0d0 - ((sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0) + (t_1 * (sin((lambda2 * (-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.cos(phi1) * Math.cos(phi2);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if (lambda2 <= 5.7e-5) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * (t_2 * t_2)))), Math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * Math.sin((lambda1 * 0.5))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_1 * t_2)))), Math.sqrt((1.0 - (Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0) + (t_1 * Math.pow(Math.sin((lambda2 * -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.cos(phi1) * math.cos(phi2) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if lambda2 <= 5.7e-5: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * (t_2 * t_2)))), math.sqrt(((1.0 - t_0) - (t_1 * (t_2 * math.sin((lambda1 * 0.5)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_1 * t_2)))), math.sqrt((1.0 - (math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) + (t_1 * math.pow(math.sin((lambda2 * -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 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (lambda2 <= 5.7e-5) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * Float64(t_2 * t_2)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(t_1 * Float64(t_2 * sin(Float64(lambda1 * 0.5))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_1 * t_2)))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0) + Float64(t_1 * (sin(Float64(lambda2 * -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 = cos(phi1) * cos(phi2); t_2 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if (lambda2 <= 5.7e-5) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * (t_2 * t_2)))), sqrt(((1.0 - t_0) - (t_1 * (t_2 * sin((lambda1 * 0.5)))))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_1 * t_2)))), sqrt((1.0 - ((sin(((phi1 - phi2) * 0.5)) ^ 2.0) + (t_1 * (sin((lambda2 * -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[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 5.7e-5], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$1 * N[(t$95$2 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(t$95$1 * N[(t$95$2 * N[Sin[N[(lambda1 * 0.5), $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$2 * N[(t$95$1 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $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 \phi_1 \cdot \cos \phi_2\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_2 \leq 5.7 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot \left(t_2 \cdot t_2\right)}}{\sqrt{\left(1 - t_0\right) - t_1 \cdot \left(t_2 \cdot \sin \left(\lambda_1 \cdot 0.5\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_1 \cdot t_2\right)}}{\sqrt{1 - \left({\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2} + t_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 5.7000000000000003e-5Initial program 64.2%
associate-*l*64.2%
Simplified64.2%
Taylor expanded in lambda2 around 0 56.1%
if 5.7000000000000003e-5 < lambda2 Initial program 49.1%
Taylor expanded in lambda1 around 0 49.0%
Final simplification54.6%
(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 60.9%
associate-*l*60.9%
Simplified60.9%
Final simplification60.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (/ (- phi1 phi2) 2.0)) 2.0))
(t_1 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))
(t_2 (sin (/ (- lambda1 lambda2) 2.0)))
(t_3 (* (cos phi1) (cos phi2))))
(if (<= lambda2 4.8e-6)
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_2 (* t_3 t_2))))
(sqrt
(-
1.0
(+
t_1
(* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (* t_3 (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- (- 1.0 t_0) (* t_3 (* t_2 t_2))))))))))
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(((phi1 - phi2) * 0.5)), 2.0);
double t_2 = sin(((lambda1 - lambda2) / 2.0));
double t_3 = cos(phi1) * cos(phi2);
double tmp;
if (lambda2 <= 4.8e-6) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0 - (t_1 + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt(((1.0 - t_0) - (t_3 * (t_2 * t_2))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_2 = sin(((lambda1 - lambda2) / 2.0d0))
t_3 = cos(phi1) * cos(phi2)
if (lambda2 <= 4.8d-6) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0d0 - (t_1 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (t_3 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt(((1.0d0 - t_0) - (t_3 * (t_2 * t_2))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0);
double t_2 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_3 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (lambda2 <= 4.8e-6) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_2 * (t_3 * t_2)))), Math.sqrt((1.0 - (t_1 + (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_1 + (t_3 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt(((1.0 - t_0) - (t_3 * (t_2 * t_2))))));
}
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(((phi1 - phi2) * 0.5)), 2.0) t_2 = math.sin(((lambda1 - lambda2) / 2.0)) t_3 = math.cos(phi1) * math.cos(phi2) tmp = 0 if lambda2 <= 4.8e-6: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_2 * (t_3 * t_2)))), math.sqrt((1.0 - (t_1 + (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_1 + (t_3 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt(((1.0 - t_0) - (t_3 * (t_2 * t_2)))))) 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(phi1 - phi2) * 0.5)) ^ 2.0 t_2 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_3 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (lambda2 <= 4.8e-6) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_2 * Float64(t_3 * t_2)))), sqrt(Float64(1.0 - Float64(t_1 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + Float64(t_3 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64(Float64(1.0 - t_0) - Float64(t_3 * Float64(t_2 * t_2))))))); 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(((phi1 - phi2) * 0.5)) ^ 2.0; t_2 = sin(((lambda1 - lambda2) / 2.0)); t_3 = cos(phi1) * cos(phi2); tmp = 0.0; if (lambda2 <= 4.8e-6) tmp = R * (2.0 * atan2(sqrt((t_0 + (t_2 * (t_3 * t_2)))), sqrt((1.0 - (t_1 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0)))))))); else tmp = R * (2.0 * atan2(sqrt((t_1 + (t_3 * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt(((1.0 - t_0) - (t_3 * (t_2 * t_2)))))); 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[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$2 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$3 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 4.8e-6], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(t$95$2 * N[(t$95$3 * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$1 + 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$1 + N[(t$95$3 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[(1.0 - t$95$0), $MachinePrecision] - N[(t$95$3 * N[(t$95$2 * t$95$2), $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(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\\
t_2 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_3 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\lambda_2 \leq 4.8 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_2 \cdot \left(t_3 \cdot t_2\right)}}{\sqrt{1 - \left(t_1 + \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_1 + t_3 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{\left(1 - t_0\right) - t_3 \cdot \left(t_2 \cdot t_2\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 4.7999999999999998e-6Initial program 64.2%
Taylor expanded in lambda2 around 0 56.5%
if 4.7999999999999998e-6 < lambda2 Initial program 49.1%
associate-*l*49.1%
Simplified49.0%
Taylor expanded in lambda1 around 0 49.3%
Final simplification54.9%
(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 1e-5)
(*
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_0 (* t_2 (pow (sin (* lambda2 -0.5)) 2.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 <= 1e-5) {
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_0 + (t_2 * pow(sin((lambda2 * -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) :: 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 <= 1d-5) 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_0 + (t_2 * (sin((lambda2 * (-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) * 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 <= 1e-5) {
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_0 + (t_2 * Math.pow(Math.sin((lambda2 * -0.5)), 2.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 <= 1e-5: 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_0 + (t_2 * math.pow(math.sin((lambda2 * -0.5)), 2.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 <= 1e-5) 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(t_0 + Float64(t_2 * (sin(Float64(lambda2 * -0.5)) ^ 2.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 <= 1e-5) 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_0 + (t_2 * (sin((lambda2 * -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] * 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, 1e-5], 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[(t$95$0 + N[(t$95$2 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $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 10^{-5}:\\
\;\;\;\;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_0 + t_2 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}\right)}}\right)\\
\end{array}
\end{array}
if lambda2 < 1.00000000000000008e-5Initial program 64.2%
Taylor expanded in lambda2 around 0 56.5%
if 1.00000000000000008e-5 < lambda2 Initial program 49.1%
Taylor expanded in lambda1 around 0 49.0%
Final simplification54.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi1 -8e-8) (not (<= phi1 2.6e-23)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi1 0.5)) 2.0) (* (cos phi1) t_0)))
(sqrt
(-
1.0
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(*
(* (* (cos phi1) (cos phi2)) (sin (/ (- lambda1 lambda2) 2.0)))
(sin (* lambda2 -0.5)))))))))
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi2) t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -8e-8) || !(phi1 <= 2.6e-23)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * t_0))), sqrt((1.0 - (pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (((cos(phi1) * cos(phi2)) * sin(((lambda1 - lambda2) / 2.0))) * sin((lambda2 * -0.5))))))));
} else {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), t_0, pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi1 <= -8e-8) || !(phi1 <= 2.6e-23)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * t_0))), sqrt(Float64(1.0 - Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(Float64(Float64(cos(phi1) * cos(phi2)) * sin(Float64(Float64(lambda1 - lambda2) / 2.0))) * sin(Float64(lambda2 * -0.5))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), t_0, (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -8e-8], N[Not[LessEqual[phi1, 2.6e-23]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -8 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 2.6 \cdot 10^{-23}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot t_0}}{\sqrt{1 - \left({\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\right) \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, t_0, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_0}}\right)\\
\end{array}
\end{array}
if phi1 < -8.0000000000000002e-8 or 2.6e-23 < phi1 Initial program 47.2%
Taylor expanded in lambda1 around 0 37.9%
Taylor expanded in phi2 around 0 39.0%
if -8.0000000000000002e-8 < phi1 < 2.6e-23Initial program 79.8%
Taylor expanded in phi1 around 0 79.8%
associate--r+79.8%
unpow279.8%
1-sub-sin79.9%
unpow279.9%
Simplified79.9%
Taylor expanded in phi1 around 0 79.1%
+-commutative79.1%
fma-def79.1%
Simplified79.1%
Final simplification55.8%
(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 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_3 (* (* (cos phi1) (cos phi2)) t_1)))
(if (or (<= phi1 -2200.0) (not (<= phi1 1.55e-5)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi1 0.5)) 2.0) (* (cos phi1) t_2)))
(sqrt (- 1.0 (+ t_0 (* t_3 (sin (* lambda2 -0.5)))))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_0 (* t_1 t_3)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_2)))))))))
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 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = (cos(phi1) * cos(phi2)) * t_1;
double tmp;
if ((phi1 <= -2200.0) || !(phi1 <= 1.55e-5)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * t_2))), sqrt((1.0 - (t_0 + (t_3 * sin((lambda2 * -0.5))))))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_0 = sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
t_2 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
t_3 = (cos(phi1) * cos(phi2)) * t_1
if ((phi1 <= (-2200.0d0)) .or. (.not. (phi1 <= 1.55d-5))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * t_2))), sqrt((1.0d0 - (t_0 + (t_3 * sin((lambda2 * (-0.5d0)))))))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - (cos(phi2) * t_2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_2 = Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_3 = (Math.cos(phi1) * Math.cos(phi2)) * t_1;
double tmp;
if ((phi1 <= -2200.0) || !(phi1 <= 1.55e-5)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * t_2))), Math.sqrt((1.0 - (t_0 + (t_3 * Math.sin((lambda2 * -0.5))))))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (t_1 * t_3))), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - (Math.cos(phi2) * t_2)))));
}
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.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_3 = (math.cos(phi1) * math.cos(phi2)) * t_1 tmp = 0 if (phi1 <= -2200.0) or not (phi1 <= 1.55e-5): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * t_2))), math.sqrt((1.0 - (t_0 + (t_3 * math.sin((lambda2 * -0.5)))))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (t_1 * t_3))), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - (math.cos(phi2) * t_2))))) 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 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_3 = Float64(Float64(cos(phi1) * cos(phi2)) * t_1) tmp = 0.0 if ((phi1 <= -2200.0) || !(phi1 <= 1.55e-5)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * t_2))), sqrt(Float64(1.0 - Float64(t_0 + Float64(t_3 * sin(Float64(lambda2 * -0.5))))))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(t_1 * t_3))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_2)))))); 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 = sin(((lambda1 - lambda2) * 0.5)) ^ 2.0; t_3 = (cos(phi1) * cos(phi2)) * t_1; tmp = 0.0; if ((phi1 <= -2200.0) || ~((phi1 <= 1.55e-5))) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * t_2))), sqrt((1.0 - (t_0 + (t_3 * sin((lambda2 * -0.5)))))))); else tmp = R * (2.0 * atan2(sqrt((t_0 + (t_1 * t_3))), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - (cos(phi2) * t_2))))); 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[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$3 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]}, If[Or[LessEqual[phi1, -2200.0], N[Not[LessEqual[phi1, 1.55e-5]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[(t$95$0 + N[(t$95$3 * N[Sin[N[(lambda2 * -0.5), $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$1 * 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$2), $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 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_3 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\\
\mathbf{if}\;\phi_1 \leq -2200 \lor \neg \left(\phi_1 \leq 1.55 \cdot 10^{-5}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot t_2}}{\sqrt{1 - \left(t_0 + t_3 \cdot \sin \left(\lambda_2 \cdot -0.5\right)\right)}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + t_1 \cdot t_3}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_2}}\right)\\
\end{array}
\end{array}
if phi1 < -2200 or 1.55000000000000007e-5 < phi1 Initial program 45.8%
Taylor expanded in lambda1 around 0 36.9%
Taylor expanded in phi2 around 0 38.2%
if -2200 < phi1 < 1.55000000000000007e-5Initial program 79.6%
Taylor expanded in phi1 around 0 79.0%
associate--r+79.1%
unpow279.1%
1-sub-sin79.1%
unpow279.1%
Simplified79.1%
Final simplification56.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= (- lambda1 lambda2) -0.002)
(*
R
(*
2.0
(atan2
(sqrt (fma (cos phi2) t_0 (pow (sin (* phi2 -0.5)) 2.0)))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) (* (cos phi2) t_0))))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(sqrt (- 1.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(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((lambda1 - lambda2) <= -0.002) {
tmp = R * (2.0 * atan2(sqrt(fma(cos(phi2), t_0, pow(sin((phi2 * -0.5)), 2.0))), sqrt((pow(cos((phi2 * -0.5)), 2.0) - (cos(phi2) * t_0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0 t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -0.002) tmp = Float64(R * Float64(2.0 * atan(sqrt(fma(cos(phi2), t_0, (sin(Float64(phi2 * -0.5)) ^ 2.0))), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - Float64(cos(phi2) * t_0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.002], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(t$95$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.002:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{\mathsf{fma}\left(\cos \phi_2, t_0, {\sin \left(\phi_2 \cdot -0.5\right)}^{2}\right)}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - \cos \phi_2 \cdot t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -2e-3Initial program 58.1%
Taylor expanded in phi1 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.8%
unpow243.8%
Simplified43.8%
Taylor expanded in phi1 around 0 43.4%
+-commutative43.4%
fma-def43.4%
Simplified43.4%
if -2e-3 < (-.f64 lambda1 lambda2) Initial program 62.4%
Taylor expanded in lambda1 around 0 52.5%
Taylor expanded in lambda2 around 0 43.4%
Final simplification43.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(t_1 (sin (/ (- lambda1 lambda2) 2.0))))
(if (<= (- lambda1 lambda2) -0.002)
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) t_0))
(sqrt (- (pow (cos (* phi2 -0.5)) 2.0) t_0)))))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (/ (- phi1 phi2) 2.0)) 2.0)
(* t_1 (* (* (cos phi1) (cos phi2)) t_1))))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((lambda1 - lambda2) <= -0.002) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + t_0)), sqrt((pow(cos((phi2 * -0.5)), 2.0) - t_0))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.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) :: tmp
t_0 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)
t_1 = sin(((lambda1 - lambda2) / 2.0d0))
if ((lambda1 - lambda2) <= (-0.002d0)) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + t_0)), sqrt(((cos((phi2 * (-0.5d0))) ** 2.0d0) - t_0))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.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.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double t_1 = Math.sin(((lambda1 - lambda2) / 2.0));
double tmp;
if ((lambda1 - lambda2) <= -0.002) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + t_0)), Math.sqrt((Math.pow(Math.cos((phi2 * -0.5)), 2.0) - t_0))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((Math.cos(phi1) * Math.cos(phi2)) * t_1)))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi2) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) t_1 = math.sin(((lambda1 - lambda2) / 2.0)) tmp = 0 if (lambda1 - lambda2) <= -0.002: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + t_0)), math.sqrt((math.pow(math.cos((phi2 * -0.5)), 2.0) - t_0)))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin(((phi1 - phi2) / 2.0)), 2.0) + (t_1 * ((math.cos(phi1) * math.cos(phi2)) * t_1)))), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)) t_1 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -0.002) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + t_0)), sqrt(Float64((cos(Float64(phi2 * -0.5)) ^ 2.0) - t_0))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + Float64(t_1 * Float64(Float64(cos(phi1) * cos(phi2)) * t_1)))), sqrt(Float64(1.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 = cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0); t_1 = sin(((lambda1 - lambda2) / 2.0)); tmp = 0.0; if ((lambda1 - lambda2) <= -0.002) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + t_0)), sqrt(((cos((phi2 * -0.5)) ^ 2.0) - t_0)))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + (t_1 * ((cos(phi1) * cos(phi2)) * t_1)))), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.002], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(N[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] - t$95$0), $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$1 * N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
t_1 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.002:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + t_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2} - t_0}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\frac{\phi_1 - \phi_2}{2}\right)}^{2} + t_1 \cdot \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_1\right)}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -2e-3Initial program 58.1%
Taylor expanded in phi1 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.8%
unpow243.8%
Simplified43.8%
Taylor expanded in phi1 around 0 43.4%
if -2e-3 < (-.f64 lambda1 lambda2) Initial program 62.4%
Taylor expanded in lambda1 around 0 52.5%
Taylor expanded in lambda2 around 0 43.4%
Final simplification43.4%
(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 (<= (- lambda1 lambda2) -0.002)
(*
R
(*
2.0
(atan2
(sqrt (+ t_1 (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (/ (- phi1 phi2) 2.0)) 2.0) t_1))
(sqrt (- 1.0 (pow (sin (* (- phi1 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 ((lambda1 - lambda2) <= -0.002) {
tmp = R * (2.0 * atan2(sqrt((t_1 + pow(sin((phi1 * 0.5)), 2.0))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin(((phi1 - phi2) / 2.0)), 2.0) + t_1)), sqrt((1.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) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0)
if ((lambda1 - lambda2) <= (-0.002d0)) then
tmp = r * (2.0d0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0d0)) ** 2.0d0) + t_1)), sqrt((1.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.sin(((lambda1 - lambda2) / 2.0));
double t_1 = t_0 * ((Math.cos(phi1) * Math.cos(phi2)) * t_0);
double tmp;
if ((lambda1 - lambda2) <= -0.002) {
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(((lambda1 - lambda2) * 0.5)), 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((1.0 - Math.pow(Math.sin(((phi1 - 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 (lambda1 - lambda2) <= -0.002: 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(((lambda1 - lambda2) * 0.5)), 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((1.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(lambda1 - lambda2) / 2.0)) t_1 = Float64(t_0 * Float64(Float64(cos(phi1) * cos(phi2)) * t_0)) tmp = 0.0 if (Float64(lambda1 - lambda2) <= -0.002) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_1 + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(Float64(phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt(Float64(1.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(((lambda1 - lambda2) / 2.0)); t_1 = t_0 * ((cos(phi1) * cos(phi2)) * t_0); tmp = 0.0; if ((lambda1 - lambda2) <= -0.002) tmp = R * (2.0 * atan2(sqrt((t_1 + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin(((phi1 - phi2) / 2.0)) ^ 2.0) + t_1)), sqrt((1.0 - (sin(((phi1 - 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[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -0.002], 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[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $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[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $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)\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -0.002:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_1 + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\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{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -2e-3Initial program 58.1%
Taylor expanded in phi1 around 0 43.7%
associate--r+43.7%
unpow243.7%
1-sub-sin43.8%
unpow243.8%
Simplified43.8%
Taylor expanded in phi2 around 0 30.7%
Taylor expanded in phi2 around 0 30.5%
if -2e-3 < (-.f64 lambda1 lambda2) Initial program 62.4%
Taylor expanded in lambda1 around 0 52.5%
Taylor expanded in lambda2 around 0 43.4%
Final simplification38.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (sin (/ (- lambda1 lambda2) 2.0)))
(t_1 (* (cos phi1) (cos phi2)))
(t_2 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))
(if (<= (- lambda1 lambda2) -1.24e-45)
(*
R
(*
2.0
(atan2
(sqrt (+ (* t_0 (* t_1 t_0)) (pow (sin (* phi1 0.5)) 2.0)))
(sqrt (- 1.0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ t_2 (* t_1 (pow (sin (* lambda2 -0.5)) 2.0))))
(sqrt (- 1.0 t_2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(((lambda1 - lambda2) / 2.0));
double t_1 = cos(phi1) * cos(phi2);
double t_2 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -1.24e-45) {
tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + pow(sin((phi1 * 0.5)), 2.0))), sqrt((1.0 - pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((t_2 + (t_1 * pow(sin((lambda2 * -0.5)), 2.0)))), sqrt((1.0 - t_2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(((lambda1 - lambda2) / 2.0d0))
t_1 = cos(phi1) * cos(phi2)
t_2 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
if ((lambda1 - lambda2) <= (-1.24d-45)) then
tmp = r * (2.0d0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (sin((phi1 * 0.5d0)) ** 2.0d0))), sqrt((1.0d0 - (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt((t_2 + (t_1 * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), sqrt((1.0d0 - t_2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(((lambda1 - lambda2) / 2.0));
double t_1 = Math.cos(phi1) * Math.cos(phi2);
double t_2 = Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0);
double tmp;
if ((lambda1 - lambda2) <= -1.24e-45) {
tmp = R * (2.0 * Math.atan2(Math.sqrt(((t_0 * (t_1 * t_0)) + Math.pow(Math.sin((phi1 * 0.5)), 2.0))), Math.sqrt((1.0 - Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_2 + (t_1 * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), Math.sqrt((1.0 - t_2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(((lambda1 - lambda2) / 2.0)) t_1 = math.cos(phi1) * math.cos(phi2) t_2 = math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) tmp = 0 if (lambda1 - lambda2) <= -1.24e-45: tmp = R * (2.0 * math.atan2(math.sqrt(((t_0 * (t_1 * t_0)) + math.pow(math.sin((phi1 * 0.5)), 2.0))), math.sqrt((1.0 - math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_2 + (t_1 * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), math.sqrt((1.0 - t_2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(lambda1 - lambda2) / 2.0)) t_1 = Float64(cos(phi1) * cos(phi2)) t_2 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 tmp = 0.0 if (Float64(lambda1 - lambda2) <= -1.24e-45) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(Float64(t_0 * Float64(t_1 * t_0)) + (sin(Float64(phi1 * 0.5)) ^ 2.0))), sqrt(Float64(1.0 - (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_2 + Float64(t_1 * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), sqrt(Float64(1.0 - t_2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((lambda1 - lambda2) / 2.0)); t_1 = cos(phi1) * cos(phi2); t_2 = sin(((phi1 - phi2) * 0.5)) ^ 2.0; tmp = 0.0; if ((lambda1 - lambda2) <= -1.24e-45) tmp = R * (2.0 * atan2(sqrt(((t_0 * (t_1 * t_0)) + (sin((phi1 * 0.5)) ^ 2.0))), sqrt((1.0 - (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt((t_2 + (t_1 * (sin((lambda2 * -0.5)) ^ 2.0)))), sqrt((1.0 - t_2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[LessEqual[N[(lambda1 - lambda2), $MachinePrecision], -1.24e-45], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[(t$95$0 * N[(t$95$1 * t$95$0), $MachinePrecision]), $MachinePrecision] + 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[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$2 + N[(t$95$1 * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - t$95$2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \left(\frac{\lambda_1 - \lambda_2}{2}\right)\\
t_1 := \cos \phi_1 \cdot \cos \phi_2\\
t_2 := {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\lambda_1 - \lambda_2 \leq -1.24 \cdot 10^{-45}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 \cdot \left(t_1 \cdot t_0\right) + {\sin \left(\phi_1 \cdot 0.5\right)}^{2}}}{\sqrt{1 - {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_2 + t_1 \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{\sqrt{1 - t_2}}\right)\\
\end{array}
\end{array}
if (-.f64 lambda1 lambda2) < -1.24e-45Initial program 59.4%
Taylor expanded in phi1 around 0 45.7%
associate--r+45.8%
unpow245.8%
1-sub-sin45.8%
unpow245.8%
Simplified45.8%
Taylor expanded in phi2 around 0 33.0%
Taylor expanded in phi2 around 0 32.9%
if -1.24e-45 < (-.f64 lambda1 lambda2) Initial program 61.7%
Taylor expanded in lambda1 around 0 51.5%
Taylor expanded in lambda2 around 0 42.1%
Taylor expanded in lambda1 around 0 39.5%
Final simplification36.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)) (t_1 (sqrt (- 1.0 t_0))))
(if (<= lambda2 1.25e-52)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi1 0.5)) 2.0)
(* (cos phi1) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
t_1))))))
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 = sqrt((1.0 - t_0));
double tmp;
if (lambda2 <= 1.25e-52) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_1 = sqrt((1.0d0 - t_0))
if (lambda2 <= 1.25d-52) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0);
double t_1 = Math.sqrt((1.0 - t_0));
double tmp;
if (lambda2 <= 1.25e-52) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) t_1 = math.sqrt((1.0 - t_0)) tmp = 0 if lambda2 <= 1.25e-52: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_1 = sqrt(Float64(1.0 - t_0)) tmp = 0.0 if (lambda2 <= 1.25e-52) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * (sin(Float64(Float64(lambda1 - lambda2) * 0.5)) ^ 2.0)))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) * 0.5)) ^ 2.0; t_1 = sqrt((1.0 - t_0)); tmp = 0.0; if (lambda2 <= 1.25e-52) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0))))), t_1)); else tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 1.25e-52], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[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] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Power[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $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 := \sqrt{1 - t_0}\\
\mathbf{if}\;\lambda_2 \leq 1.25 \cdot 10^{-52}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot {\sin \left(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}}}{t_1}\right)\\
\end{array}
\end{array}
if lambda2 < 1.25e-52Initial program 63.8%
Taylor expanded in lambda1 around 0 46.5%
Taylor expanded in lambda2 around 0 38.7%
Taylor expanded in lambda2 around 0 36.9%
if 1.25e-52 < lambda2 Initial program 51.8%
Taylor expanded in lambda1 around 0 50.0%
Taylor expanded in lambda2 around 0 25.8%
Taylor expanded in phi2 around 0 26.3%
Final simplification34.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)) (t_1 (sqrt (- 1.0 t_0))))
(if (<= lambda2 5.9e-80)
(*
R
(*
2.0
(atan2
(sqrt
(+ t_0 (* (cos phi2) (* (cos phi1) (pow (sin (* lambda1 0.5)) 2.0)))))
t_1)))
(*
R
(*
2.0
(atan2
(sqrt
(+
t_0
(* (* (cos phi1) (cos phi2)) (pow (sin (* lambda2 -0.5)) 2.0))))
t_1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((phi1 - phi2) * 0.5)), 2.0);
double t_1 = sqrt((1.0 - t_0));
double tmp;
if (lambda2 <= 5.9e-80) {
tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * pow(sin((lambda1 * 0.5)), 2.0))))), t_1));
} else {
tmp = R * (2.0 * atan2(sqrt((t_0 + ((cos(phi1) * cos(phi2)) * pow(sin((lambda2 * -0.5)), 2.0)))), t_1));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0
t_1 = sqrt((1.0d0 - t_0))
if (lambda2 <= 5.9d-80) then
tmp = r * (2.0d0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5d0)) ** 2.0d0))))), t_1))
else
tmp = r * (2.0d0 * atan2(sqrt((t_0 + ((cos(phi1) * cos(phi2)) * (sin((lambda2 * (-0.5d0))) ** 2.0d0)))), t_1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0);
double t_1 = Math.sqrt((1.0 - t_0));
double tmp;
if (lambda2 <= 5.9e-80) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.pow(Math.sin((lambda1 * 0.5)), 2.0))))), t_1));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.pow(Math.sin((lambda2 * -0.5)), 2.0)))), t_1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0) t_1 = math.sqrt((1.0 - t_0)) tmp = 0 if lambda2 <= 5.9e-80: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.pow(math.sin((lambda1 * 0.5)), 2.0))))), t_1)) else: tmp = R * (2.0 * math.atan2(math.sqrt((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.pow(math.sin((lambda2 * -0.5)), 2.0)))), t_1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0 t_1 = sqrt(Float64(1.0 - t_0)) tmp = 0.0 if (lambda2 <= 5.9e-80) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * (sin(Float64(lambda1 * 0.5)) ^ 2.0))))), t_1))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * (sin(Float64(lambda2 * -0.5)) ^ 2.0)))), t_1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(((phi1 - phi2) * 0.5)) ^ 2.0; t_1 = sqrt((1.0 - t_0)); tmp = 0.0; if (lambda2 <= 5.9e-80) tmp = R * (2.0 * atan2(sqrt((t_0 + (cos(phi2) * (cos(phi1) * (sin((lambda1 * 0.5)) ^ 2.0))))), t_1)); else tmp = R * (2.0 * atan2(sqrt((t_0 + ((cos(phi1) * cos(phi2)) * (sin((lambda2 * -0.5)) ^ 2.0)))), t_1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, Block[{t$95$1 = N[Sqrt[N[(1.0 - t$95$0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[lambda2, 5.9e-80], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[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] / t$95$1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Power[N[Sin[N[(lambda2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / t$95$1], $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 := \sqrt{1 - t_0}\\
\mathbf{if}\;\lambda_2 \leq 5.9 \cdot 10^{-80}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot {\sin \left(\lambda_1 \cdot 0.5\right)}^{2}\right)}}{t_1}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{t_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot {\sin \left(\lambda_2 \cdot -0.5\right)}^{2}}}{t_1}\right)\\
\end{array}
\end{array}
if lambda2 < 5.9000000000000001e-80Initial program 64.0%
Taylor expanded in lambda1 around 0 46.3%
Taylor expanded in lambda2 around 0 38.4%
Taylor expanded in lambda2 around 0 36.5%
if 5.9000000000000001e-80 < lambda2 Initial program 52.0%
Taylor expanded in lambda1 around 0 50.3%
Taylor expanded in lambda2 around 0 27.5%
Taylor expanded in lambda1 around 0 28.1%
Final simplification34.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0)))
(if (or (<= phi1 -2.65e-8) (not (<= phi1 1.2e-65)))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi1 0.5)) 2.0) (* (cos phi1) t_0)))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0))))))
(*
R
(*
2.0
(atan2
(sqrt (+ (pow (sin (* phi2 -0.5)) 2.0) (* (cos phi2) t_0)))
(sqrt (pow (cos (* phi2 -0.5)) 2.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = pow(sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -2.65e-8) || !(phi1 <= 1.2e-65)) {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi1 * 0.5)), 2.0) + (cos(phi1) * t_0))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * t_0))), 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) :: tmp
t_0 = sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0
if ((phi1 <= (-2.65d-8)) .or. (.not. (phi1 <= 1.2d-65))) then
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi1 * 0.5d0)) ** 2.0d0) + (cos(phi1) * t_0))), sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))))
else
tmp = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * t_0))), 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.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0);
double tmp;
if ((phi1 <= -2.65e-8) || !(phi1 <= 1.2e-65)) {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi1 * 0.5)), 2.0) + (Math.cos(phi1) * t_0))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
} else {
tmp = R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * t_0))), Math.sqrt(Math.pow(Math.cos((phi2 * -0.5)), 2.0))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.pow(math.sin(((lambda1 - lambda2) * 0.5)), 2.0) tmp = 0 if (phi1 <= -2.65e-8) or not (phi1 <= 1.2e-65): tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi1 * 0.5)), 2.0) + (math.cos(phi1) * t_0))), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0))))) else: tmp = R * (2.0 * math.atan2(math.sqrt((math.pow(math.sin((phi2 * -0.5)), 2.0) + (math.cos(phi2) * t_0))), 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) * 0.5)) ^ 2.0 tmp = 0.0 if ((phi1 <= -2.65e-8) || !(phi1 <= 1.2e-65)) tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi1 * 0.5)) ^ 2.0) + Float64(cos(phi1) * t_0))), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))); else tmp = Float64(R * Float64(2.0 * atan(sqrt(Float64((sin(Float64(phi2 * -0.5)) ^ 2.0) + Float64(cos(phi2) * t_0))), 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) * 0.5)) ^ 2.0; tmp = 0.0; if ((phi1 <= -2.65e-8) || ~((phi1 <= 1.2e-65))) tmp = R * (2.0 * atan2(sqrt(((sin((phi1 * 0.5)) ^ 2.0) + (cos(phi1) * t_0))), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))))); else tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * t_0))), sqrt((cos((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[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]}, If[Or[LessEqual[phi1, -2.65e-8], N[Not[LessEqual[phi1, 1.2e-65]], $MachinePrecision]], N[(R * N[(2.0 * N[ArcTan[N[Sqrt[N[(N[Power[N[Sin[N[(phi1 * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $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[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $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(\left(\lambda_1 - \lambda_2\right) \cdot 0.5\right)}^{2}\\
\mathbf{if}\;\phi_1 \leq -2.65 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 1.2 \cdot 10^{-65}\right):\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_1 \cdot 0.5\right)}^{2} + \cos \phi_1 \cdot t_0}}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(2 \cdot \tan^{-1}_* \frac{\sqrt{{\sin \left(\phi_2 \cdot -0.5\right)}^{2} + \cos \phi_2 \cdot t_0}}{\sqrt{{\cos \left(\phi_2 \cdot -0.5\right)}^{2}}}\right)\\
\end{array}
\end{array}
if phi1 < -2.6499999999999999e-8 or 1.2000000000000001e-65 < phi1 Initial program 48.7%
Taylor expanded in lambda1 around 0 38.4%
Taylor expanded in lambda2 around 0 29.9%
Taylor expanded in phi2 around 0 31.0%
if -2.6499999999999999e-8 < phi1 < 1.2000000000000001e-65Initial program 79.5%
Taylor expanded in lambda1 around 0 61.2%
Taylor expanded in lambda2 around 0 44.2%
Taylor expanded in phi1 around 0 44.2%
Taylor expanded in phi1 around 0 44.2%
*-commutative44.2%
unpow244.2%
1-sub-sin44.2%
unpow244.2%
*-commutative44.2%
Simplified44.2%
Final simplification36.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sqrt
(+
(pow (sin (* phi2 -0.5)) 2.0)
(* (cos phi2) (pow (sin (* (- lambda1 lambda2) 0.5)) 2.0))))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 2.0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * atan2(sqrt((pow(sin((phi2 * -0.5)), 2.0) + (cos(phi2) * pow(sin(((lambda1 - lambda2) * 0.5)), 2.0)))), sqrt((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 2.0d0)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((phi2 * -0.5)), 2.0) + (Math.cos(phi2) * Math.pow(Math.sin(((lambda1 - lambda2) * 0.5)), 2.0)))), Math.sqrt((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return 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((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return 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(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sqrt(((sin((phi2 * -0.5)) ^ 2.0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5)) ^ 2.0)))), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := 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[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
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{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 60.9%
Taylor expanded in lambda1 around 0 47.4%
Taylor expanded in lambda2 around 0 35.5%
Taylor expanded in phi1 around 0 28.9%
Final simplification28.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
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))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return 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))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sqrt(((sin((phi2 * (-0.5d0))) ** 2.0d0) + (cos(phi2) * (sin(((lambda1 - lambda2) * 0.5d0)) ** 2.0d0)))), sqrt((cos((phi2 * (-0.5d0))) ** 2.0d0))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * (2.0 * Math.atan2(Math.sqrt((Math.pow(Math.sin((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))));
}
def code(R, lambda1, lambda2, phi1, phi2): return 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))))
function code(R, lambda1, lambda2, phi1, phi2) return 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((cos(Float64(phi2 * -0.5)) ^ 2.0))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) 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)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := 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[Power[N[Cos[N[(phi2 * -0.5), $MachinePrecision]], $MachinePrecision], 2.0], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
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}}}\right)
\end{array}
Initial program 60.9%
Taylor expanded in lambda1 around 0 47.4%
Taylor expanded in lambda2 around 0 35.5%
Taylor expanded in phi1 around 0 28.9%
Taylor expanded in phi1 around 0 28.9%
*-commutative28.9%
unpow228.9%
1-sub-sin28.9%
unpow228.9%
*-commutative28.9%
Simplified28.9%
Final simplification28.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(*
2.0
(atan2
(sin (* (- lambda1 lambda2) 0.5))
(sqrt (- 1.0 (pow (sin (* (- phi1 phi2) 0.5)) 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((1.0 - pow(sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * (2.0d0 * atan2(sin(((lambda1 - lambda2) * 0.5d0)), sqrt((1.0d0 - (sin(((phi1 - phi2) * 0.5d0)) ** 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((1.0 - Math.pow(Math.sin(((phi1 - phi2) * 0.5)), 2.0)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * (2.0 * math.atan2(math.sin(((lambda1 - lambda2) * 0.5)), math.sqrt((1.0 - math.pow(math.sin(((phi1 - phi2) * 0.5)), 2.0)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * Float64(2.0 * atan(sin(Float64(Float64(lambda1 - lambda2) * 0.5)), sqrt(Float64(1.0 - (sin(Float64(Float64(phi1 - phi2) * 0.5)) ^ 2.0)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * (2.0 * atan2(sin(((lambda1 - lambda2) * 0.5)), sqrt((1.0 - (sin(((phi1 - phi2) * 0.5)) ^ 2.0))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[(2.0 * N[ArcTan[N[Sin[N[(N[(lambda1 - lambda2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision] / N[Sqrt[N[(1.0 - N[Power[N[Sin[N[(N[(phi1 - phi2), $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision], 2.0], $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)}{\sqrt{1 - {\sin \left(\left(\phi_1 - \phi_2\right) \cdot 0.5\right)}^{2}}}\right)
\end{array}
Initial program 60.9%
Taylor expanded in lambda1 around 0 47.4%
Taylor expanded in lambda2 around 0 35.5%
Taylor expanded in phi1 around 0 28.9%
Taylor expanded in phi2 around 0 12.7%
Final simplification12.7%
herbie shell --seed 2023230
(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))))))))))