
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
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 = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 27 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
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 = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (sin lambda1) (sin lambda2) (* (cos lambda2) (cos lambda1))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(sin(lambda1), sin(lambda2), (cos(lambda2) * cos(lambda1)))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(sin(lambda1), sin(lambda2), Float64(cos(lambda2) * cos(lambda1)))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_2 \cdot \cos \lambda_1\right)\right) \cdot R
\end{array}
Initial program 73.8%
cos-diff94.7%
Applied egg-rr94.7%
+-commutative94.7%
fma-define94.7%
cos-neg94.7%
*-commutative94.7%
cos-neg94.7%
Simplified94.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1 (fma (sin phi1) (sin phi2) (* t_0 (cos (- lambda1 lambda2))))))
(if (<= phi1 -0.0028)
(* R (exp (log (acos t_1))))
(if (<= phi1 4.3e-32)
(*
R
(acos
(+
(*
t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(* R (- (/ PI 2.0) (cbrt (pow (asin t_1) 3.0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = fma(sin(phi1), sin(phi2), (t_0 * cos((lambda1 - lambda2))));
double tmp;
if (phi1 <= -0.0028) {
tmp = R * exp(log(acos(t_1)));
} else if (phi1 <= 4.3e-32) {
tmp = R * acos(((t_0 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * ((((double) M_PI) / 2.0) - cbrt(pow(asin(t_1), 3.0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = fma(sin(phi1), sin(phi2), Float64(t_0 * cos(Float64(lambda1 - lambda2)))) tmp = 0.0 if (phi1 <= -0.0028) tmp = Float64(R * exp(log(acos(t_1)))); elseif (phi1 <= 4.3e-32) tmp = Float64(R * acos(Float64(Float64(t_0 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * Float64(Float64(pi / 2.0) - cbrt((asin(t_1) ^ 3.0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0028], N[(R * N[Exp[N[Log[N[ArcCos[t$95$1], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4.3e-32], N[(R * N[ArcCos[N[(N[(t$95$0 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[Power[N[Power[N[ArcSin[t$95$1], $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{if}\;\phi_1 \leq -0.0028:\\
\;\;\;\;R \cdot e^{\log \cos^{-1} t\_1}\\
\mathbf{elif}\;\phi_1 \leq 4.3 \cdot 10^{-32}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sqrt[3]{{\sin^{-1} t\_1}^{3}}\right)\\
\end{array}
\end{array}
if phi1 < -0.00279999999999999997Initial program 78.4%
cos-diff99.0%
+-commutative99.0%
Applied egg-rr99.0%
add-cbrt-cube99.0%
pow399.0%
Applied egg-rr99.0%
Applied egg-rr78.5%
if -0.00279999999999999997 < phi1 < 4.2999999999999999e-32Initial program 64.6%
Taylor expanded in phi1 around 0 64.6%
cos-diff88.8%
+-commutative88.8%
Applied egg-rr88.8%
if 4.2999999999999999e-32 < phi1 Initial program 81.9%
cos-diff99.1%
Applied egg-rr99.1%
+-commutative99.1%
fma-define99.1%
cos-neg99.1%
*-commutative99.1%
cos-neg99.1%
Simplified99.1%
acos-asin99.0%
fma-define99.0%
associate-*l*99.0%
Applied egg-rr99.0%
Taylor expanded in phi1 around 0 99.0%
add-cbrt-cube98.7%
pow398.7%
Applied egg-rr81.6%
Final simplification83.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.00045)
(* R (exp (log (acos (fma (sin phi1) (sin phi2) (* t_0 t_1))))))
(if (<= phi1 1e-32)
(*
R
(acos
(+
(*
t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(*
R
(log
(exp
(acos
(fma
(sin phi1)
(sin phi2)
(* (cos phi1) (* (cos phi2) t_1)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.00045) {
tmp = R * exp(log(acos(fma(sin(phi1), sin(phi2), (t_0 * t_1)))));
} else if (phi1 <= 1e-32) {
tmp = R * acos(((t_0 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * log(exp(acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_1))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.00045) tmp = Float64(R * exp(log(acos(fma(sin(phi1), sin(phi2), Float64(t_0 * t_1)))))); elseif (phi1 <= 1e-32) tmp = Float64(R * acos(Float64(Float64(t_0 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * log(exp(acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_1))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.00045], N[(R * N[Exp[N[Log[N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1e-32], N[(R * N[ArcCos[N[(N[(t$95$0 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Log[N[Exp[N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.00045:\\
\;\;\;\;R \cdot e^{\log \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t\_0 \cdot t\_1\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 10^{-32}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)\right)\right)}\right)\\
\end{array}
\end{array}
if phi1 < -4.4999999999999999e-4Initial program 78.4%
cos-diff99.0%
+-commutative99.0%
Applied egg-rr99.0%
add-cbrt-cube99.0%
pow399.0%
Applied egg-rr99.0%
Applied egg-rr78.5%
if -4.4999999999999999e-4 < phi1 < 1.00000000000000006e-32Initial program 64.3%
Taylor expanded in phi1 around 0 64.3%
cos-diff88.7%
+-commutative88.7%
Applied egg-rr88.7%
if 1.00000000000000006e-32 < phi1 Initial program 82.1%
expm1-log1p-u82.1%
expm1-undefine82.1%
Applied egg-rr82.1%
add-log-exp82.1%
fma-define82.1%
expm1-define82.1%
expm1-log1p-u82.1%
associate-*l*82.1%
Applied egg-rr82.1%
Final simplification84.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.000205)
(* R (exp (log (acos (fma (sin phi1) (sin phi2) (* t_0 t_1))))))
(if (<= phi1 1e-32)
(*
R
(acos
(+
(*
t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(* R (log (exp (acos (fma t_1 t_0 (* (sin phi1) (sin phi2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -0.000205) {
tmp = R * exp(log(acos(fma(sin(phi1), sin(phi2), (t_0 * t_1)))));
} else if (phi1 <= 1e-32) {
tmp = R * acos(((t_0 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * log(exp(acos(fma(t_1, t_0, (sin(phi1) * sin(phi2))))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -0.000205) tmp = Float64(R * exp(log(acos(fma(sin(phi1), sin(phi2), Float64(t_0 * t_1)))))); elseif (phi1 <= 1e-32) tmp = Float64(R * acos(Float64(Float64(t_0 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * log(exp(acos(fma(t_1, t_0, Float64(sin(phi1) * sin(phi2))))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.000205], N[(R * N[Exp[N[Log[N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(t$95$0 * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1e-32], N[(R * N[ArcCos[N[(N[(t$95$0 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Log[N[Exp[N[ArcCos[N[(t$95$1 * t$95$0 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -0.000205:\\
\;\;\;\;R \cdot e^{\log \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, t\_0 \cdot t\_1\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 10^{-32}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(t\_1, t\_0, \sin \phi_1 \cdot \sin \phi_2\right)\right)}\right)\\
\end{array}
\end{array}
if phi1 < -2.05e-4Initial program 78.4%
cos-diff99.0%
+-commutative99.0%
Applied egg-rr99.0%
add-cbrt-cube99.0%
pow399.0%
Applied egg-rr99.0%
Applied egg-rr78.5%
if -2.05e-4 < phi1 < 1.00000000000000006e-32Initial program 64.3%
Taylor expanded in phi1 around 0 64.3%
cos-diff88.7%
+-commutative88.7%
Applied egg-rr88.7%
if 1.00000000000000006e-32 < phi1 Initial program 82.1%
Simplified82.1%
add-log-exp82.1%
fma-undefine82.1%
associate-*r*82.1%
+-commutative82.1%
*-commutative82.1%
fma-define82.1%
Applied egg-rr82.1%
Final simplification84.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(acos (fma (cos (- lambda1 lambda2)) t_0 (* (sin phi1) (sin phi2))))))
(if (<= phi1 -0.0066)
(* R (exp (log t_1)))
(if (<= phi1 1e-32)
(*
R
(acos
(+
(*
t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(* R (log (exp t_1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = acos(fma(cos((lambda1 - lambda2)), t_0, (sin(phi1) * sin(phi2))));
double tmp;
if (phi1 <= -0.0066) {
tmp = R * exp(log(t_1));
} else if (phi1 <= 1e-32) {
tmp = R * acos(((t_0 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * log(exp(t_1));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = acos(fma(cos(Float64(lambda1 - lambda2)), t_0, Float64(sin(phi1) * sin(phi2)))) tmp = 0.0 if (phi1 <= -0.0066) tmp = Float64(R * exp(log(t_1))); elseif (phi1 <= 1e-32) tmp = Float64(R * acos(Float64(Float64(t_0 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * log(exp(t_1))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.0066], N[(R * N[Exp[N[Log[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1e-32], N[(R * N[ArcCos[N[(N[(t$95$0 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Log[N[Exp[t$95$1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \cos^{-1} \left(\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), t\_0, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\mathbf{if}\;\phi_1 \leq -0.0066:\\
\;\;\;\;R \cdot e^{\log t\_1}\\
\mathbf{elif}\;\phi_1 \leq 10^{-32}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \log \left(e^{t\_1}\right)\\
\end{array}
\end{array}
if phi1 < -0.0066Initial program 78.4%
Simplified78.4%
add-exp-log78.5%
fma-undefine78.4%
associate-*r*78.5%
+-commutative78.5%
*-commutative78.5%
fma-define78.5%
Applied egg-rr78.5%
if -0.0066 < phi1 < 1.00000000000000006e-32Initial program 64.3%
Taylor expanded in phi1 around 0 64.3%
cos-diff88.7%
+-commutative88.7%
Applied egg-rr88.7%
if 1.00000000000000006e-32 < phi1 Initial program 82.1%
Simplified82.1%
add-log-exp82.1%
fma-undefine82.1%
associate-*r*82.1%
+-commutative82.1%
*-commutative82.1%
fma-define82.1%
Applied egg-rr82.1%
Final simplification84.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
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 * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)
\end{array}
Initial program 73.8%
cos-diff94.7%
+-commutative94.7%
Applied egg-rr94.7%
Final simplification94.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -0.0002)
(* R (exp (log (acos (fma (cos (- lambda1 lambda2)) t_0 t_1)))))
(if (<= phi1 1e-32)
(*
R
(acos
(+
(*
t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(*
R
(-
(* PI 0.5)
(asin
(fma (cos phi2) (* (cos phi1) (cos (- lambda2 lambda1))) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -0.0002) {
tmp = R * exp(log(acos(fma(cos((lambda1 - lambda2)), t_0, t_1))));
} else if (phi1 <= 1e-32) {
tmp = R * acos(((t_0 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin(fma(cos(phi2), (cos(phi1) * cos((lambda2 - lambda1))), t_1)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -0.0002) tmp = Float64(R * exp(log(acos(fma(cos(Float64(lambda1 - lambda2)), t_0, t_1))))); elseif (phi1 <= 1e-32) tmp = Float64(R * acos(Float64(Float64(t_0 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(fma(cos(phi2), Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))), t_1)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0002], N[(R * N[Exp[N[Log[N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1e-32], N[(R * N[ArcCos[N[(N[(t$95$0 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.0002:\\
\;\;\;\;R \cdot e^{\log \cos^{-1} \left(\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), t\_0, t\_1\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 10^{-32}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\cos \phi_2, \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right), t\_1\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.0000000000000001e-4Initial program 78.4%
Simplified78.4%
add-exp-log78.5%
fma-undefine78.4%
associate-*r*78.5%
+-commutative78.5%
*-commutative78.5%
fma-define78.5%
Applied egg-rr78.5%
if -2.0000000000000001e-4 < phi1 < 1.00000000000000006e-32Initial program 64.3%
Taylor expanded in phi1 around 0 64.3%
cos-diff88.7%
+-commutative88.7%
Applied egg-rr88.7%
if 1.00000000000000006e-32 < phi1 Initial program 82.1%
Simplified82.1%
acos-asin82.0%
fma-undefine82.0%
associate-*r*82.0%
sub-neg82.0%
div-inv82.0%
metadata-eval82.0%
+-commutative82.0%
*-commutative82.0%
fma-define82.0%
Applied egg-rr82.0%
sub-neg82.0%
fma-undefine82.0%
associate-*r*82.0%
*-commutative82.0%
*-commutative82.0%
fma-define82.0%
Simplified82.0%
Final simplification84.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -0.0026)
(* R (acos (fma (cos (- lambda1 lambda2)) t_0 t_1)))
(if (<= phi1 1e-32)
(*
R
(acos
(+
(*
t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda2) (cos lambda1))))
(* phi1 (sin phi2)))))
(*
R
(-
(* PI 0.5)
(asin
(fma (cos phi2) (* (cos phi1) (cos (- lambda2 lambda1))) t_1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -0.0026) {
tmp = R * acos(fma(cos((lambda1 - lambda2)), t_0, t_1));
} else if (phi1 <= 1e-32) {
tmp = R * acos(((t_0 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin(fma(cos(phi2), (cos(phi1) * cos((lambda2 - lambda1))), t_1)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -0.0026) tmp = Float64(R * acos(fma(cos(Float64(lambda1 - lambda2)), t_0, t_1))); elseif (phi1 <= 1e-32) tmp = Float64(R * acos(Float64(Float64(t_0 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(fma(cos(phi2), Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))), t_1)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -0.0026], N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1e-32], N[(R * N[ArcCos[N[(N[(t$95$0 * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -0.0026:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \left(\lambda_1 - \lambda_2\right), t\_0, t\_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 10^{-32}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(\cos \phi_2, \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right), t\_1\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -0.0025999999999999999Initial program 78.4%
Simplified78.4%
*-commutative78.4%
fma-undefine78.4%
associate-*r*78.4%
+-commutative78.4%
*-commutative78.4%
fma-define78.4%
Applied egg-rr78.4%
if -0.0025999999999999999 < phi1 < 1.00000000000000006e-32Initial program 64.3%
Taylor expanded in phi1 around 0 64.3%
cos-diff88.7%
+-commutative88.7%
Applied egg-rr88.7%
if 1.00000000000000006e-32 < phi1 Initial program 82.1%
Simplified82.1%
acos-asin82.0%
fma-undefine82.0%
associate-*r*82.0%
sub-neg82.0%
div-inv82.0%
metadata-eval82.0%
+-commutative82.0%
*-commutative82.0%
fma-define82.0%
Applied egg-rr82.0%
sub-neg82.0%
fma-undefine82.0%
associate-*r*82.0%
*-commutative82.0%
*-commutative82.0%
fma-define82.0%
Simplified82.0%
Final simplification84.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -1.15e-5)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))
(if (<= phi2 7e-6)
(*
R
(acos
(+
t_1
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(* R (acos (+ t_1 (* (* (cos phi1) (cos phi2)) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -1.15e-5) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
} else if (phi2 <= 7e-6) {
tmp = R * acos((t_1 + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -1.15e-5) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); elseif (phi2 <= 7e-6) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -1.15e-5], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 7e-6], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -1.15 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 7 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < -1.15e-5Initial program 78.1%
Simplified78.2%
if -1.15e-5 < phi2 < 6.99999999999999989e-6Initial program 70.9%
cos-diff90.2%
Applied egg-rr90.2%
+-commutative90.2%
fma-define90.2%
cos-neg90.2%
*-commutative90.2%
cos-neg90.2%
Simplified90.2%
Taylor expanded in phi2 around 0 90.1%
if 6.99999999999999989e-6 < phi2 Initial program 74.8%
Final simplification83.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 -1.05e-203)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0)))))
(if (<= phi2 8e-136)
(*
R
(acos
(+
(* phi1 phi2)
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi2 <= -1.05e-203) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
} else if (phi2 <= 8e-136) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi2 <= -1.05e-203) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * t_0))))); elseif (phi2 <= 8e-136) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, -1.05e-203], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 8e-136], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_2 \leq -1.05 \cdot 10^{-203}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 8 \cdot 10^{-136}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < -1.05000000000000001e-203Initial program 75.4%
Simplified75.5%
if -1.05000000000000001e-203 < phi2 < 8.00000000000000001e-136Initial program 70.7%
Taylor expanded in phi1 around 0 60.3%
Taylor expanded in phi2 around 0 60.3%
Taylor expanded in phi2 around 0 60.3%
cos-diff92.1%
+-commutative92.1%
Applied egg-rr76.7%
if 8.00000000000000001e-136 < phi2 Initial program 74.1%
Final simplification75.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi2 -1.06e-203) (not (<= phi2 1.45e-136)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(+
(* phi1 phi2)
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda2) (cos lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.06e-203) || !(phi2 <= 1.45e-136)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi2 <= (-1.06d-203)) .or. (.not. (phi2 <= 1.45d-136))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1))))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi2 <= -1.06e-203) || !(phi2 <= 1.45e-136)) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda2) * Math.cos(lambda1))))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi2 <= -1.06e-203) or not (phi2 <= 1.45e-136): tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda2) * math.cos(lambda1)))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi2 <= -1.06e-203) || !(phi2 <= 1.45e-136)) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda2) * cos(lambda1))))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi2 <= -1.06e-203) || ~((phi2 <= 1.45e-136))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = R * acos(((phi1 * phi2) + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda2) * cos(lambda1)))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi2, -1.06e-203], N[Not[LessEqual[phi2, 1.45e-136]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq -1.06 \cdot 10^{-203} \lor \neg \left(\phi_2 \leq 1.45 \cdot 10^{-136}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_2 \cdot \cos \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -1.0599999999999999e-203 or 1.44999999999999997e-136 < phi2 Initial program 74.8%
if -1.0599999999999999e-203 < phi2 < 1.44999999999999997e-136Initial program 70.7%
Taylor expanded in phi1 around 0 60.3%
Taylor expanded in phi2 around 0 60.3%
Taylor expanded in phi2 around 0 60.3%
cos-diff92.1%
+-commutative92.1%
Applied egg-rr76.7%
Final simplification75.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= lambda2 0.025)
(* R (acos (+ t_1 (* t_0 (cos lambda1)))))
(* R (acos (+ t_1 (* t_0 (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= 0.025) {
tmp = R * acos((t_1 + (t_0 * cos(lambda1))));
} else {
tmp = R * acos((t_1 + (t_0 * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = sin(phi1) * sin(phi2)
if (lambda2 <= 0.025d0) then
tmp = r * acos((t_1 + (t_0 * cos(lambda1))))
else
tmp = r * acos((t_1 + (t_0 * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= 0.025) {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 0.025: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda1)))) else: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= 0.025) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 0.025) tmp = R * acos((t_1 + (t_0 * cos(lambda1)))); else tmp = R * acos((t_1 + (t_0 * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 0.025], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 0.025:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 0.025000000000000001Initial program 78.6%
Taylor expanded in lambda2 around 0 65.5%
if 0.025000000000000001 < lambda2 Initial program 59.6%
Taylor expanded in lambda1 around 0 59.7%
cos-neg59.7%
Simplified59.7%
Final simplification64.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 0.025)
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda1)))))
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi2) (cos (- lambda2 lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 0.025) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi2) * cos((lambda2 - lambda1)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 0.025) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi2) * cos(Float64(lambda2 - lambda1)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 0.025], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 0.025:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)\\
\end{array}
\end{array}
if lambda2 < 0.025000000000000001Initial program 78.6%
Taylor expanded in lambda2 around 0 65.5%
if 0.025000000000000001 < lambda2 Initial program 59.6%
Simplified59.6%
Taylor expanded in phi1 around 0 36.3%
sub-neg36.3%
remove-double-neg36.3%
mul-1-neg36.3%
distribute-neg-in36.3%
+-commutative36.3%
cos-neg36.3%
mul-1-neg36.3%
unsub-neg36.3%
Simplified36.3%
Final simplification58.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi2 5.6e-24)
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) t_0))))
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 5.6e-24) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * t_0)));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi2) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 5.6e-24) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi2) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi2, 5.6e-24], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_2 \leq 5.6 \cdot 10^{-24}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot t\_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_2 \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if phi2 < 5.6000000000000003e-24Initial program 74.0%
Simplified74.0%
Taylor expanded in phi2 around 0 51.5%
sub-neg51.5%
remove-double-neg51.5%
mul-1-neg51.5%
distribute-neg-in51.5%
+-commutative51.5%
cos-neg51.5%
mul-1-neg51.5%
unsub-neg51.5%
Simplified51.5%
if 5.6000000000000003e-24 < phi2 Initial program 73.3%
Simplified73.2%
Taylor expanded in phi1 around 0 40.8%
sub-neg40.8%
remove-double-neg40.8%
mul-1-neg40.8%
distribute-neg-in40.8%
+-commutative40.8%
cos-neg40.8%
mul-1-neg40.8%
unsub-neg40.8%
Simplified40.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -850000000.0)
(*
R
(acos
(fma (sin phi1) (sin phi2) (* (cos phi1) (cos (- lambda2 lambda1))))))
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))
(* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -850000000.0) {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * cos((lambda2 - lambda1)))));
} else {
tmp = R * acos((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -850000000.0) tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); else tmp = Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -850000000.0], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -850000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -8.5e8Initial program 78.6%
Simplified78.7%
Taylor expanded in phi2 around 0 42.4%
sub-neg42.4%
remove-double-neg42.4%
mul-1-neg42.4%
distribute-neg-in42.4%
+-commutative42.4%
cos-neg42.4%
mul-1-neg42.4%
unsub-neg42.4%
Simplified42.4%
if -8.5e8 < phi1 Initial program 72.4%
Taylor expanded in phi1 around 0 43.9%
Final simplification43.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 73.8%
Final simplification73.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= phi1 -2e+33)
(* R (acos (+ t_0 (* (sin phi1) phi2))))
(* R (acos (+ t_0 (* phi1 (sin phi2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2e+33) {
tmp = R * acos((t_0 + (sin(phi1) * phi2)));
} else {
tmp = R * acos((t_0 + (phi1 * sin(phi2))));
}
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 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
if (phi1 <= (-2d+33)) then
tmp = r * acos((t_0 + (sin(phi1) * phi2)))
else
tmp = r * acos((t_0 + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2e+33) {
tmp = R * Math.acos((t_0 + (Math.sin(phi1) * phi2)));
} else {
tmp = R * Math.acos((t_0 + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -2e+33: tmp = R * math.acos((t_0 + (math.sin(phi1) * phi2))) else: tmp = R * math.acos((t_0 + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -2e+33) tmp = Float64(R * acos(Float64(t_0 + Float64(sin(phi1) * phi2)))); else tmp = Float64(R * acos(Float64(t_0 + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -2e+33) tmp = R * acos((t_0 + (sin(phi1) * phi2))); else tmp = R * acos((t_0 + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2e+33], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2 \cdot 10^{+33}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -1.9999999999999999e33Initial program 78.7%
Taylor expanded in phi2 around 0 32.3%
if -1.9999999999999999e33 < phi1 Initial program 72.5%
Taylor expanded in phi1 around 0 44.3%
Final simplification41.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* phi1 (sin phi2))))
(if (<= lambda1 -1.2e-7)
(* R (acos (+ t_1 (* t_0 (cos lambda1)))))
(* R (acos (+ t_1 (* t_0 (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = phi1 * sin(phi2);
double tmp;
if (lambda1 <= -1.2e-7) {
tmp = R * acos((t_1 + (t_0 * cos(lambda1))));
} else {
tmp = R * acos((t_1 + (t_0 * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = phi1 * sin(phi2)
if (lambda1 <= (-1.2d-7)) then
tmp = r * acos((t_1 + (t_0 * cos(lambda1))))
else
tmp = r * acos((t_1 + (t_0 * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = phi1 * Math.sin(phi2);
double tmp;
if (lambda1 <= -1.2e-7) {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_1 + (t_0 * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = phi1 * math.sin(phi2) tmp = 0 if lambda1 <= -1.2e-7: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda1)))) else: tmp = R * math.acos((t_1 + (t_0 * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda1 <= -1.2e-7) tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(t_0 * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = phi1 * sin(phi2); tmp = 0.0; if (lambda1 <= -1.2e-7) tmp = R * acos((t_1 + (t_0 * cos(lambda1)))); else tmp = R * acos((t_1 + (t_0 * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.2e-7], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -1.19999999999999989e-7Initial program 61.4%
Taylor expanded in phi1 around 0 30.6%
Taylor expanded in lambda2 around 0 30.6%
if -1.19999999999999989e-7 < lambda1 Initial program 78.1%
Taylor expanded in phi1 around 0 41.1%
Taylor expanded in lambda1 around 0 32.8%
cos-neg64.5%
Simplified32.8%
Final simplification32.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))
(* phi1 (sin phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
}
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 * acos((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)
\end{array}
Initial program 73.8%
Taylor expanded in phi1 around 0 38.4%
Final simplification38.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -10.2)
(* R (acos (+ (* phi1 phi2) (* (cos phi1) t_0))))
(* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -10.2) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * t_0)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = cos((lambda1 - lambda2))
if (phi1 <= (-10.2d0)) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * t_0)))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -10.2) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -10.2: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * t_0))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -10.2) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -10.2) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * t_0))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -10.2], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -10.2:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -10.199999999999999Initial program 78.0%
Taylor expanded in phi1 around 0 18.7%
Taylor expanded in phi2 around 0 18.7%
Taylor expanded in phi2 around 0 18.7%
if -10.199999999999999 < phi1 Initial program 72.5%
Taylor expanded in phi1 around 0 44.3%
Taylor expanded in phi1 around 0 38.4%
Final simplification33.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda2 1.1e-17)
(* R (acos (+ t_0 (* (cos phi1) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda2 <= 1.1e-17) {
tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * cos(lambda2))));
}
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 = phi1 * sin(phi2)
if (lambda2 <= 1.1d-17) then
tmp = r * acos((t_0 + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((t_0 + (cos(phi1) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * Math.sin(phi2);
double tmp;
if (lambda2 <= 1.1e-17) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda2 <= 1.1e-17: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda2 <= 1.1e-17) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda2 <= 1.1e-17) tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((t_0 + (cos(phi1) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 1.1e-17], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 1.1 \cdot 10^{-17}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 1.1e-17Initial program 78.6%
Taylor expanded in phi1 around 0 41.0%
Taylor expanded in phi2 around 0 30.9%
Taylor expanded in lambda2 around 0 24.0%
if 1.1e-17 < lambda2 Initial program 59.6%
Taylor expanded in phi1 around 0 30.6%
Taylor expanded in phi2 around 0 21.9%
Taylor expanded in lambda1 around 0 21.9%
cos-neg59.7%
Simplified21.9%
Final simplification23.5%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 1.3e+52) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos (- lambda1 lambda2)))))) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi1) (cos lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.3e+52) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos(lambda1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 1.3d+52) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2)))))
else
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.3e+52) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.3e+52: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos((lambda1 - lambda2))))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.3e+52) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi1) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 1.3e+52) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2))))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 1.3e+52], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.3 \cdot 10^{+52}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi2 < 1.3e52Initial program 73.5%
Taylor expanded in phi1 around 0 39.4%
Taylor expanded in phi2 around 0 33.5%
Taylor expanded in phi2 around 0 32.7%
if 1.3e52 < phi2 Initial program 75.1%
Taylor expanded in phi1 around 0 34.1%
Taylor expanded in phi2 around 0 7.9%
Taylor expanded in lambda2 around 0 6.4%
Final simplification27.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi1) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 73.8%
Taylor expanded in phi1 around 0 38.4%
Taylor expanded in phi2 around 0 28.6%
Final simplification28.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 1.1e-17) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 1.1e-17) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 1.1d-17) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 1.1e-17) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 1.1e-17: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 1.1e-17) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 1.1e-17) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 1.1e-17], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 1.1 \cdot 10^{-17}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 1.1e-17Initial program 78.6%
Taylor expanded in phi1 around 0 41.0%
Taylor expanded in phi2 around 0 30.9%
Taylor expanded in phi2 around 0 29.3%
Taylor expanded in lambda2 around 0 22.4%
*-commutative22.4%
Simplified22.4%
if 1.1e-17 < lambda2 Initial program 59.6%
Taylor expanded in phi1 around 0 30.6%
Taylor expanded in phi2 around 0 21.9%
Taylor expanded in phi2 around 0 19.2%
Taylor expanded in lambda1 around 0 19.2%
cos-neg19.2%
Simplified19.2%
Final simplification21.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 2e-27) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2e-27) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 2d-27) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2e-27) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((Math.cos((lambda2 - lambda1)) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 2e-27: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 2e-27) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 2e-27) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 2e-27], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 2 \cdot 10^{-27}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if lambda2 < 2.0000000000000001e-27Initial program 78.5%
Taylor expanded in phi1 around 0 40.7%
Taylor expanded in phi2 around 0 30.5%
Taylor expanded in phi2 around 0 28.9%
Taylor expanded in lambda2 around 0 22.0%
*-commutative22.0%
Simplified22.0%
if 2.0000000000000001e-27 < lambda2 Initial program 60.2%
Taylor expanded in phi1 around 0 31.6%
Taylor expanded in phi2 around 0 23.0%
Taylor expanded in phi2 around 0 20.4%
Taylor expanded in phi1 around 0 16.7%
sub-neg16.7%
remove-double-neg16.7%
mul-1-neg16.7%
distribute-neg-in16.7%
+-commutative16.7%
cos-neg16.7%
mul-1-neg16.7%
sub-neg16.7%
Simplified16.7%
Final simplification20.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 73.8%
Taylor expanded in phi1 around 0 38.4%
Taylor expanded in phi2 around 0 28.6%
Taylor expanded in phi2 around 0 26.7%
Final simplification26.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos (- lambda2 lambda1)) (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)));
}
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 * acos((cos((lambda2 - lambda1)) + (phi1 * phi2)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos((lambda2 - lambda1)) + (phi1 * phi2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos((lambda2 - lambda1)) + (phi1 * phi2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(Float64(lambda2 - lambda1)) + Float64(phi1 * phi2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos((lambda2 - lambda1)) + (phi1 * phi2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \left(\lambda_2 - \lambda_1\right) + \phi_1 \cdot \phi_2\right)
\end{array}
Initial program 73.8%
Taylor expanded in phi1 around 0 38.4%
Taylor expanded in phi2 around 0 28.6%
Taylor expanded in phi2 around 0 26.7%
Taylor expanded in phi1 around 0 19.0%
sub-neg19.0%
remove-double-neg19.0%
mul-1-neg19.0%
distribute-neg-in19.0%
+-commutative19.0%
cos-neg19.0%
mul-1-neg19.0%
sub-neg19.0%
Simplified19.0%
Final simplification19.0%
herbie shell --seed 2024096
(FPCore (R lambda1 lambda2 phi1 phi2)
:name "Spherical law of cosines"
:precision binary64
(* (acos (+ (* (sin phi1) (sin phi2)) (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))) R))