
(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 23 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))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(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)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(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.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(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[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $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 \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right) \cdot R
\end{array}
Initial program 73.9%
cos-diff92.7%
+-commutative92.7%
Applied egg-rr92.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -9.8e-8)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 1.0)
(*
R
(acos
(+
t_1
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(*
R
(acos (+ (pow (cbrt t_1) 3.0) (* (* (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 (phi1 <= -9.8e-8) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 1.0) {
tmp = R * acos((t_1 + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos((pow(cbrt(t_1), 3.0) + ((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 (phi1 <= -9.8e-8) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 1.0) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(Float64((cbrt(t_1) ^ 3.0) + 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[phi1, -9.8e-8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.0], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Power[N[Power[t$95$1, 1/3], $MachinePrecision], 3.0], $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)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -9.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left({\left(\sqrt[3]{t\_1}\right)}^{3} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -9.8000000000000004e-8Initial program 88.3%
*-commutative88.3%
*-commutative88.3%
+-commutative88.3%
*-commutative88.3%
associate-*l*88.2%
*-commutative88.2%
fma-define88.4%
Simplified88.4%
if -9.8000000000000004e-8 < phi1 < 1Initial program 67.0%
cos-diff87.1%
+-commutative87.1%
Applied egg-rr87.1%
add-log-exp87.1%
Applied egg-rr87.1%
Taylor expanded in phi1 around 0 87.1%
if 1 < phi1 Initial program 73.8%
add-cube-cbrt73.9%
pow373.8%
Applied egg-rr73.8%
Final simplification84.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -9.6e-8)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 1.0)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* phi1 (sin phi2)))))
(*
R
(acos (+ (pow (cbrt t_1) 3.0) (* (* (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 (phi1 <= -9.6e-8) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 1.0) {
tmp = R * acos(((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((pow(cbrt(t_1), 3.0) + ((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 (phi1 <= -9.6e-8) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 1.0) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64((cbrt(t_1) ^ 3.0) + 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[phi1, -9.6e-8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.0], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Power[N[Power[t$95$1, 1/3], $MachinePrecision], 3.0], $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)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -9.6 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left({\left(\sqrt[3]{t\_1}\right)}^{3} + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -9.59999999999999994e-8Initial program 88.3%
*-commutative88.3%
*-commutative88.3%
+-commutative88.3%
*-commutative88.3%
associate-*l*88.2%
*-commutative88.2%
fma-define88.4%
Simplified88.4%
if -9.59999999999999994e-8 < phi1 < 1Initial program 67.0%
*-commutative67.0%
*-commutative67.0%
+-commutative67.0%
*-commutative67.0%
associate-*l*67.0%
*-commutative67.0%
fma-define67.0%
Simplified67.0%
Taylor expanded in phi1 around 0 67.0%
cos-diff87.1%
+-commutative87.1%
Applied egg-rr87.1%
if 1 < phi1 Initial program 73.8%
add-cube-cbrt73.9%
pow373.8%
Applied egg-rr73.8%
Final simplification84.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -6.5e-8)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 1.0)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* phi1 (sin phi2)))))
(*
R
(acos (+ t_1 (* (* (cos phi1) (cos phi2)) (log1p (expm1 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 (phi1 <= -6.5e-8) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 1.0) {
tmp = R * acos(((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * log1p(expm1(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 (phi1 <= -6.5e-8) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 1.0) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * log1p(expm1(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[phi1, -6.5e-8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.0], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Log[1 + N[(Exp[t$95$0] - 1), $MachinePrecision]], $MachinePrecision]), $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_1 \leq -6.5 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{log1p}\left(\mathsf{expm1}\left(t\_0\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -6.49999999999999997e-8Initial program 88.3%
*-commutative88.3%
*-commutative88.3%
+-commutative88.3%
*-commutative88.3%
associate-*l*88.2%
*-commutative88.2%
fma-define88.4%
Simplified88.4%
if -6.49999999999999997e-8 < phi1 < 1Initial program 67.0%
*-commutative67.0%
*-commutative67.0%
+-commutative67.0%
*-commutative67.0%
associate-*l*67.0%
*-commutative67.0%
fma-define67.0%
Simplified67.0%
Taylor expanded in phi1 around 0 67.0%
cos-diff87.1%
+-commutative87.1%
Applied egg-rr87.1%
if 1 < phi1 Initial program 73.8%
log1p-expm1-u73.8%
Applied egg-rr73.8%
Final simplification84.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -9.1e-8) (not (<= phi1 1.0)))
(*
R
(acos
(fma
(cos phi1)
(* (cos phi2) (cos (- lambda1 lambda2)))
(* (sin phi1) (sin phi2)))))
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -9.1e-8) || !(phi1 <= 1.0)) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * cos((lambda1 - lambda2))), (sin(phi1) * sin(phi2))));
} else {
tmp = R * acos(((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -9.1e-8) || !(phi1 <= 1.0)) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))), Float64(sin(phi1) * sin(phi2))))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(phi1 * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -9.1e-8], N[Not[LessEqual[phi1, 1.0]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -9.1 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 1\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -9.09999999999999943e-8 or 1 < phi1 Initial program 81.6%
*-commutative81.6%
*-commutative81.6%
+-commutative81.6%
*-commutative81.6%
associate-*l*81.6%
*-commutative81.6%
fma-define81.7%
Simplified81.7%
if -9.09999999999999943e-8 < phi1 < 1Initial program 67.0%
*-commutative67.0%
*-commutative67.0%
+-commutative67.0%
*-commutative67.0%
associate-*l*67.0%
*-commutative67.0%
fma-define67.0%
Simplified67.0%
Taylor expanded in phi1 around 0 67.0%
cos-diff87.1%
+-commutative87.1%
Applied egg-rr87.1%
Final simplification84.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -3.8e-16) (not (<= phi1 8.5e-8)))
(*
R
(acos
(fma
(cos phi1)
(* (cos phi2) (cos (- lambda1 lambda2)))
(* (sin phi1) (sin phi2)))))
(*
R
(acos
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3.8e-16) || !(phi1 <= 8.5e-8)) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * cos((lambda1 - lambda2))), (sin(phi1) * sin(phi2))));
} else {
tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -3.8e-16) || !(phi1 <= 8.5e-8)) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))), Float64(sin(phi1) * sin(phi2))))); else tmp = Float64(R * acos(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -3.8e-16], N[Not[LessEqual[phi1, 8.5e-8]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.8 \cdot 10^{-16} \lor \neg \left(\phi_1 \leq 8.5 \cdot 10^{-8}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -3.80000000000000012e-16 or 8.49999999999999935e-8 < phi1 Initial program 82.1%
*-commutative82.1%
*-commutative82.1%
+-commutative82.1%
*-commutative82.1%
associate-*l*82.1%
*-commutative82.1%
fma-define82.1%
Simplified82.1%
if -3.80000000000000012e-16 < phi1 < 8.49999999999999935e-8Initial program 66.2%
cos-diff86.8%
+-commutative86.8%
Applied egg-rr86.8%
log1p-expm1-u86.8%
log1p-undefine86.8%
Applied egg-rr86.8%
Taylor expanded in phi1 around 0 86.6%
Final simplification84.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi1 -7.6e+123)
(* R (acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos lambda1)))))
(if (<= phi1 -9.8e-8)
(* R (acos (* (cos phi1) t_1)))
(if (<= phi1 1.0)
(* R (acos (* (cos phi2) t_1)))
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda2)))))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi1 <= -7.6e+123) {
tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
} else if (phi1 <= -9.8e-8) {
tmp = R * acos((cos(phi1) * t_1));
} else if (phi1 <= 1.0) {
tmp = R * acos((cos(phi2) * t_1));
} else {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * 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 = sin(phi1) * sin(phi2)
t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi1 <= (-7.6d+123)) then
tmp = r * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
else if (phi1 <= (-9.8d-8)) then
tmp = r * acos((cos(phi1) * t_1))
else if (phi1 <= 1.0d0) then
tmp = r * acos((cos(phi2) * t_1))
else
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * 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.sin(phi1) * Math.sin(phi2);
double t_1 = (Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi1 <= -7.6e+123) {
tmp = R * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else if (phi1 <= -9.8e-8) {
tmp = R * Math.acos((Math.cos(phi1) * t_1));
} else if (phi1 <= 1.0) {
tmp = R * Math.acos((Math.cos(phi2) * t_1));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi1 <= -7.6e+123: tmp = R * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) elif phi1 <= -9.8e-8: tmp = R * math.acos((math.cos(phi1) * t_1)) elif phi1 <= 1.0: tmp = R * math.acos((math.cos(phi2) * t_1)) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi1 <= -7.6e+123) tmp = Float64(R * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); elseif (phi1 <= -9.8e-8) tmp = Float64(R * acos(Float64(cos(phi1) * t_1))); elseif (phi1 <= 1.0) tmp = Float64(R * acos(Float64(cos(phi2) * t_1))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); t_1 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi1 <= -7.6e+123) tmp = R * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); elseif (phi1 <= -9.8e-8) tmp = R * acos((cos(phi1) * t_1)); elseif (phi1 <= 1.0) tmp = R * acos((cos(phi2) * t_1)); else tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -7.6e+123], N[(R * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, -9.8e-8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.0], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_1 \leq -7.6 \cdot 10^{+123}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\phi_1 \leq -9.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_1\right)\\
\mathbf{elif}\;\phi_1 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.59999999999999989e123Initial program 87.8%
Taylor expanded in lambda2 around 0 72.5%
if -7.59999999999999989e123 < phi1 < -9.8000000000000004e-8Initial program 88.9%
cos-diff99.5%
+-commutative99.5%
Applied egg-rr99.5%
log1p-expm1-u99.5%
log1p-undefine99.4%
Applied egg-rr99.4%
Taylor expanded in phi2 around 0 59.2%
if -9.8000000000000004e-8 < phi1 < 1Initial program 67.0%
cos-diff87.1%
+-commutative87.1%
Applied egg-rr87.1%
log1p-expm1-u87.1%
log1p-undefine87.1%
Applied egg-rr87.1%
Taylor expanded in phi1 around 0 86.9%
if 1 < phi1 Initial program 73.8%
Taylor expanded in lambda1 around 0 56.1%
*-commutative56.1%
cos-neg56.1%
Simplified56.1%
Final simplification75.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -3.8e-16) (not (<= phi1 1e-8)))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2))))))
(*
R
(acos
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3.8e-16) || !(phi1 <= 1e-8)) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
} else {
tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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 ((phi1 <= (-3.8d-16)) .or. (.not. (phi1 <= 1d-8))) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
else
tmp = r * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * 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 ((phi1 <= -3.8e-16) || !(phi1 <= 1e-8)) {
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((Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -3.8e-16) or not (phi1 <= 1e-8): 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((math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -3.8e-16) || !(phi1 <= 1e-8)) 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(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -3.8e-16) || ~((phi1 <= 1e-8))) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); else tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -3.8e-16], N[Not[LessEqual[phi1, 1e-8]], $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[Cos[phi2], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.8 \cdot 10^{-16} \lor \neg \left(\phi_1 \leq 10^{-8}\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(\cos \phi_2 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -3.80000000000000012e-16 or 1e-8 < phi1 Initial program 82.1%
if -3.80000000000000012e-16 < phi1 < 1e-8Initial program 66.2%
cos-diff86.8%
+-commutative86.8%
Applied egg-rr86.8%
log1p-expm1-u86.8%
log1p-undefine86.8%
Applied egg-rr86.8%
Taylor expanded in phi1 around 0 86.6%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi2 -8.8e-7)
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi1) (* (cos phi2) (cos lambda2))))))
(if (<= phi2 0.00023)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi2 <= -8.8e-7) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
} else if (phi2 <= 0.00023) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((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 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi2 <= (-8.8d-7)) then
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
else if (phi2 <= 0.00023d0) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi2 <= -8.8e-7) {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
} else if (phi2 <= 0.00023) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi2 <= -8.8e-7: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) elif phi2 <= 0.00023: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi2 <= -8.8e-7) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); elseif (phi2 <= 0.00023) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi2 <= -8.8e-7) tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * (cos(phi2) * cos(lambda2))))); elseif (phi2 <= 0.00023) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((cos(phi2) * t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -8.8e-7], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.00023], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_2 \leq -8.8 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 0.00023:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < -8.8000000000000004e-7Initial program 80.8%
Taylor expanded in lambda1 around 0 57.5%
*-commutative57.5%
cos-neg57.5%
Simplified57.5%
if -8.8000000000000004e-7 < phi2 < 2.3000000000000001e-4Initial program 69.0%
cos-diff87.2%
+-commutative87.2%
Applied egg-rr87.2%
log1p-expm1-u87.2%
log1p-undefine87.2%
Applied egg-rr87.2%
Taylor expanded in phi2 around 0 86.3%
if 2.3000000000000001e-4 < phi2 Initial program 77.8%
cos-diff98.9%
+-commutative98.9%
Applied egg-rr98.9%
log1p-expm1-u98.9%
log1p-undefine98.9%
Applied egg-rr98.9%
Taylor expanded in phi1 around 0 58.3%
Final simplification73.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi2 0.00021)
(* R (acos (* (cos phi1) t_0)))
(* R (acos (* (cos phi2) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2));
double tmp;
if (phi2 <= 0.00021) {
tmp = R * acos((cos(phi1) * t_0));
} else {
tmp = R * acos((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 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))
if (phi2 <= 0.00021d0) then
tmp = r * acos((cos(phi1) * t_0))
else
tmp = r * acos((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.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2));
double tmp;
if (phi2 <= 0.00021) {
tmp = R * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R * Math.acos((Math.cos(phi2) * t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)) tmp = 0 if phi2 <= 0.00021: tmp = R * math.acos((math.cos(phi1) * t_0)) else: tmp = R * math.acos((math.cos(phi2) * t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))) tmp = 0.0 if (phi2 <= 0.00021) tmp = Float64(R * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R * acos(Float64(cos(phi2) * t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)); tmp = 0.0; if (phi2 <= 0.00021) tmp = R * acos((cos(phi1) * t_0)); else tmp = R * acos((cos(phi2) * t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.00021], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\\
\mathbf{if}\;\phi_2 \leq 0.00021:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 2.1000000000000001e-4Initial program 72.7%
cos-diff90.9%
+-commutative90.9%
Applied egg-rr90.9%
log1p-expm1-u90.9%
log1p-undefine90.9%
Applied egg-rr90.9%
Taylor expanded in phi2 around 0 65.1%
if 2.1000000000000001e-4 < phi2 Initial program 77.8%
cos-diff98.9%
+-commutative98.9%
Applied egg-rr98.9%
log1p-expm1-u98.9%
log1p-undefine98.9%
Applied egg-rr98.9%
Taylor expanded in phi1 around 0 58.3%
Final simplification63.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.00096)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* (cos phi2) (cos (- lambda2 lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00096) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda2 - 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 <= 0.00096d0) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda2 - 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 <= 0.00096) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda2 - lambda1)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.00096: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda2 - lambda1))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00096) tmp = Float64(R * acos(Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda2 - lambda1)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.00096) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda2 - lambda1))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.00096], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $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}\;\phi_2 \leq 0.00096:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi2 < 9.60000000000000024e-4Initial program 72.7%
cos-diff90.9%
+-commutative90.9%
Applied egg-rr90.9%
log1p-expm1-u90.9%
log1p-undefine90.9%
Applied egg-rr90.9%
Taylor expanded in phi2 around 0 65.1%
if 9.60000000000000024e-4 < phi2 Initial program 77.8%
Taylor expanded in phi1 around 0 47.1%
sub-neg47.1%
neg-mul-147.1%
neg-mul-147.1%
remove-double-neg47.1%
mul-1-neg47.1%
distribute-neg-in47.1%
+-commutative47.1%
cos-neg47.1%
mul-1-neg47.1%
unsub-neg47.1%
Simplified47.1%
Final simplification61.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi1 -9.8e-8)
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1))))))
(if (<= phi1 1.7e-24)
(*
R
(acos
(+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 (sin phi2)))))
(* R (acos (+ t_0 (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -9.8e-8) {
tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))));
} else if (phi1 <= 1.7e-24) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * cos(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 = sin(phi1) * sin(phi2)
if (phi1 <= (-9.8d-8)) then
tmp = r * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))
else if (phi1 <= 1.7d-24) then
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
else
tmp = r * acos((t_0 + (cos(phi1) * cos(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.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -9.8e-8) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (phi1 <= 1.7e-24) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -9.8e-8: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) elif phi1 <= 1.7e-24: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -9.8e-8) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); elseif (phi1 <= 1.7e-24) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -9.8e-8) tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))); elseif (phi1 <= 1.7e-24) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); else tmp = R * acos((t_0 + (cos(phi1) * cos(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -9.8e-8], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.7e-24], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_1 \leq -9.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.7 \cdot 10^{-24}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -9.8000000000000004e-8Initial program 88.3%
Taylor expanded in phi2 around 0 56.4%
sub-neg56.4%
remove-double-neg56.4%
mul-1-neg56.4%
distribute-neg-in56.4%
+-commutative56.4%
cos-neg56.4%
mul-1-neg56.4%
unsub-neg56.4%
Simplified56.4%
if -9.8000000000000004e-8 < phi1 < 1.69999999999999996e-24Initial program 67.8%
*-commutative67.8%
*-commutative67.8%
+-commutative67.8%
*-commutative67.8%
associate-*l*67.8%
*-commutative67.8%
fma-define67.8%
Simplified67.8%
Taylor expanded in phi1 around 0 67.8%
if 1.69999999999999996e-24 < phi1 Initial program 71.4%
Simplified71.4%
Taylor expanded in lambda1 around 0 54.9%
cos-neg54.9%
Simplified54.9%
Taylor expanded in lambda2 around 0 38.2%
Final simplification58.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -9.8e-8)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(if (<= phi1 1.7e-24)
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2)))))
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -9.8e-8) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else if (phi1 <= 1.7e-24) {
tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(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((lambda1 - lambda2))
if (phi1 <= (-9.8d-8)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else if (phi1 <= 1.7d-24) then
tmp = r * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(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((lambda1 - lambda2));
double tmp;
if (phi1 <= -9.8e-8) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 1.7e-24) {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -9.8e-8: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) elif phi1 <= 1.7e-24: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -9.8e-8) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 1.7e-24) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -9.8e-8) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); elseif (phi1 <= 1.7e-24) tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2)))); 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, -9.8e-8], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.7e-24], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -9.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 1.7 \cdot 10^{-24}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -9.8000000000000004e-8Initial program 88.3%
*-commutative88.3%
*-commutative88.3%
+-commutative88.3%
*-commutative88.3%
associate-*l*88.2%
*-commutative88.2%
fma-define88.4%
Simplified88.4%
Taylor expanded in phi2 around 0 47.5%
if -9.8000000000000004e-8 < phi1 < 1.69999999999999996e-24Initial program 67.8%
*-commutative67.8%
*-commutative67.8%
+-commutative67.8%
*-commutative67.8%
associate-*l*67.8%
*-commutative67.8%
fma-define67.8%
Simplified67.8%
Taylor expanded in phi1 around 0 67.8%
if 1.69999999999999996e-24 < phi1 Initial program 71.4%
Simplified71.4%
Taylor expanded in lambda1 around 0 54.9%
cos-neg54.9%
Simplified54.9%
Taylor expanded in lambda2 around 0 38.2%
Final simplification55.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 0.00102)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(* R (acos (+ t_1 (* (cos phi2) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= 0.00102) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(phi2) * t_0)));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = sin(phi1) * sin(phi2)
if (phi2 <= 0.00102d0) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else
tmp = r * acos((t_1 + (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((lambda2 - lambda1));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= 0.00102) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi2) * t_0)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= 0.00102: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(phi2) * t_0))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= 0.00102) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi2) * t_0)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda2 - lambda1)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= 0.00102) tmp = R * acos((t_1 + (cos(phi1) * t_0))); else tmp = R * acos((t_1 + (cos(phi2) * t_0))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 0.00102], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + 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)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq 0.00102:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < 0.00102Initial program 72.7%
Taylor expanded in phi2 around 0 52.8%
sub-neg52.8%
remove-double-neg52.8%
mul-1-neg52.8%
distribute-neg-in52.8%
+-commutative52.8%
cos-neg52.8%
mul-1-neg52.8%
unsub-neg52.8%
Simplified52.8%
if 0.00102 < phi2 Initial program 77.8%
Taylor expanded in phi1 around 0 47.1%
sub-neg47.1%
neg-mul-147.1%
neg-mul-147.1%
remove-double-neg47.1%
mul-1-neg47.1%
distribute-neg-in47.1%
+-commutative47.1%
cos-neg47.1%
mul-1-neg47.1%
unsub-neg47.1%
Simplified47.1%
Final simplification51.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -9.8e-8)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_0))))
(* R (acos (+ (* (cos phi2) t_0) (* phi1 (sin phi2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -9.8e-8) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)));
} else {
tmp = R * acos(((cos(phi2) * 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((lambda1 - lambda2))
if (phi1 <= (-9.8d-8)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0)))
else
tmp = r * acos(((cos(phi2) * 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((lambda1 - lambda2));
double tmp;
if (phi1 <= -9.8e-8) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_0)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * t_0) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -9.8e-8: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_0))) else: tmp = R * math.acos(((math.cos(phi2) * t_0) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -9.8e-8) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_0)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_0) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -9.8e-8) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_0))); else tmp = R * acos(((cos(phi2) * t_0) + (phi1 * sin(phi2)))); 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, -9.8e-8], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -9.8 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0 + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -9.8000000000000004e-8Initial program 88.3%
*-commutative88.3%
*-commutative88.3%
+-commutative88.3%
*-commutative88.3%
associate-*l*88.2%
*-commutative88.2%
fma-define88.4%
Simplified88.4%
Taylor expanded in phi2 around 0 47.5%
if -9.8000000000000004e-8 < phi1 Initial program 68.9%
*-commutative68.9%
*-commutative68.9%
+-commutative68.9%
*-commutative68.9%
associate-*l*69.0%
*-commutative69.0%
fma-define68.9%
Simplified68.9%
Taylor expanded in phi1 around 0 49.4%
Final simplification48.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -7500000000000.0)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) (cos lambda2)))))
(*
R
(acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos(lambda2))));
} else {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (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) :: tmp
if (phi1 <= (-7500000000000.0d0)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * cos(lambda2))))
else
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * Math.cos(lambda2))));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -7500000000000.0: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * math.cos(lambda2)))) else: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * cos(lambda2))))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * sin(phi2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -7500000000000.0) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos(lambda2)))); else tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7500000000000.0], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $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 -7500000000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 88.3%
Simplified88.3%
Taylor expanded in lambda1 around 0 65.2%
cos-neg65.2%
Simplified65.2%
Taylor expanded in phi2 around 0 34.9%
if -7.5e12 < phi1 Initial program 68.9%
*-commutative68.9%
*-commutative68.9%
+-commutative68.9%
*-commutative68.9%
associate-*l*69.0%
*-commutative69.0%
fma-define68.9%
Simplified68.9%
Taylor expanded in phi1 around 0 49.4%
Final simplification45.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -7500000000000.0)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) (cos lambda2)))))
(if (<= phi1 6.8e-52)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos (expm1 (log1p (cos (- phi1 phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * cos(lambda2))));
} else if (phi1 <= 6.8e-52) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos(expm1(log1p(cos((phi1 - phi2)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * Math.cos(lambda2))));
} else if (phi1 <= 6.8e-52) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(Math.expm1(Math.log1p(Math.cos((phi1 - phi2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -7500000000000.0: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * math.cos(lambda2)))) elif phi1 <= 6.8e-52: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos(math.expm1(math.log1p(math.cos((phi1 - phi2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * cos(lambda2))))); elseif (phi1 <= 6.8e-52) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(expm1(log1p(cos(Float64(phi1 - phi2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7500000000000.0], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 6.8e-52], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(Exp[N[Log[1 + N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7500000000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\mathbf{elif}\;\phi_1 \leq 6.8 \cdot 10^{-52}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\phi_1 - \phi_2\right)\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 88.3%
Simplified88.3%
Taylor expanded in lambda1 around 0 65.2%
cos-neg65.2%
Simplified65.2%
Taylor expanded in phi2 around 0 34.9%
if -7.5e12 < phi1 < 6.80000000000000035e-52Initial program 69.2%
*-commutative69.2%
*-commutative69.2%
+-commutative69.2%
*-commutative69.2%
associate-*l*69.2%
*-commutative69.2%
fma-define69.2%
Simplified69.2%
Taylor expanded in phi1 around 0 69.2%
Taylor expanded in phi2 around 0 48.6%
if 6.80000000000000035e-52 < phi1 Initial program 68.5%
Simplified68.5%
Taylor expanded in lambda1 around 0 53.3%
cos-neg53.3%
Simplified53.3%
Taylor expanded in lambda2 around 0 37.9%
fma-define37.9%
Simplified37.9%
expm1-log1p-u37.6%
expm1-undefine37.7%
fma-undefine37.7%
cos-diff26.4%
Applied egg-rr26.4%
expm1-define26.4%
Simplified26.4%
Final simplification39.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -7500000000000.0)
(* R (acos (cos phi1)))
(if (<= phi1 8e-51)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos (expm1 (log1p (cos (- phi1 phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * acos(cos(phi1));
} else if (phi1 <= 8e-51) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos(expm1(log1p(cos((phi1 - phi2)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * Math.acos(Math.cos(phi1));
} else if (phi1 <= 8e-51) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(Math.expm1(Math.log1p(Math.cos((phi1 - phi2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -7500000000000.0: tmp = R * math.acos(math.cos(phi1)) elif phi1 <= 8e-51: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos(math.expm1(math.log1p(math.cos((phi1 - phi2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * acos(cos(phi1))); elseif (phi1 <= 8e-51) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(expm1(log1p(cos(Float64(phi1 - phi2)))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7500000000000.0], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 8e-51], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(Exp[N[Log[1 + N[Cos[N[(phi1 - phi2), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7500000000000:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\mathbf{elif}\;\phi_1 \leq 8 \cdot 10^{-51}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{expm1}\left(\mathsf{log1p}\left(\cos \left(\phi_1 - \phi_2\right)\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 88.3%
Simplified88.3%
Taylor expanded in lambda1 around 0 65.2%
cos-neg65.2%
Simplified65.2%
Taylor expanded in lambda2 around 0 45.2%
fma-define45.3%
Simplified45.3%
Taylor expanded in phi2 around 0 33.8%
if -7.5e12 < phi1 < 8.0000000000000001e-51Initial program 69.2%
*-commutative69.2%
*-commutative69.2%
+-commutative69.2%
*-commutative69.2%
associate-*l*69.2%
*-commutative69.2%
fma-define69.2%
Simplified69.2%
Taylor expanded in phi1 around 0 69.2%
Taylor expanded in phi2 around 0 48.6%
if 8.0000000000000001e-51 < phi1 Initial program 68.5%
Simplified68.5%
Taylor expanded in lambda1 around 0 53.3%
cos-neg53.3%
Simplified53.3%
Taylor expanded in lambda2 around 0 37.9%
fma-define37.9%
Simplified37.9%
expm1-log1p-u37.6%
expm1-undefine37.7%
fma-undefine37.7%
cos-diff26.4%
Applied egg-rr26.4%
expm1-define26.4%
Simplified26.4%
Final simplification39.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -7500000000000.0)
(* R (acos (cos phi1)))
(if (<= phi1 1.1e-50)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos (cos phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * acos(cos(phi1));
} else if (phi1 <= 1.1e-50) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos(cos(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 (phi1 <= (-7500000000000.0d0)) then
tmp = r * acos(cos(phi1))
else if (phi1 <= 1.1d-50) then
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)))
else
tmp = r * acos(cos(phi2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * Math.acos(Math.cos(phi1));
} else if (phi1 <= 1.1e-50) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(Math.cos(phi2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -7500000000000.0: tmp = R * math.acos(math.cos(phi1)) elif phi1 <= 1.1e-50: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos(math.cos(phi2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * acos(cos(phi1))); elseif (phi1 <= 1.1e-50) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(cos(phi2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -7500000000000.0) tmp = R * acos(cos(phi1)); elseif (phi1 <= 1.1e-50) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); else tmp = R * acos(cos(phi2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7500000000000.0], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.1e-50], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7500000000000:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\mathbf{elif}\;\phi_1 \leq 1.1 \cdot 10^{-50}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_2\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 88.3%
Simplified88.3%
Taylor expanded in lambda1 around 0 65.2%
cos-neg65.2%
Simplified65.2%
Taylor expanded in lambda2 around 0 45.2%
fma-define45.3%
Simplified45.3%
Taylor expanded in phi2 around 0 33.8%
if -7.5e12 < phi1 < 1.0999999999999999e-50Initial program 69.2%
*-commutative69.2%
*-commutative69.2%
+-commutative69.2%
*-commutative69.2%
associate-*l*69.2%
*-commutative69.2%
fma-define69.2%
Simplified69.2%
Taylor expanded in phi1 around 0 69.2%
Taylor expanded in phi2 around 0 48.6%
if 1.0999999999999999e-50 < phi1 Initial program 68.5%
Simplified68.5%
Taylor expanded in lambda1 around 0 53.3%
cos-neg53.3%
Simplified53.3%
Taylor expanded in lambda2 around 0 37.9%
fma-define37.9%
Simplified37.9%
Taylor expanded in phi1 around 0 13.9%
Final simplification36.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -7500000000000.0) (* R (acos (cos phi1))) (* R (acos (cos (- lambda2 lambda1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * acos(cos(phi1));
} else {
tmp = R * acos(cos((lambda2 - 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 (phi1 <= (-7500000000000.0d0)) then
tmp = r * acos(cos(phi1))
else
tmp = r * acos(cos((lambda2 - lambda1)))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -7500000000000.0) {
tmp = R * Math.acos(Math.cos(phi1));
} else {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -7500000000000.0: tmp = R * math.acos(math.cos(phi1)) else: tmp = R * math.acos(math.cos((lambda2 - lambda1))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -7500000000000.0) tmp = Float64(R * acos(cos(phi1))); else tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -7500000000000.0) tmp = R * acos(cos(phi1)); else tmp = R * acos(cos((lambda2 - lambda1))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -7500000000000.0], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7500000000000:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\end{array}
\end{array}
if phi1 < -7.5e12Initial program 88.3%
Simplified88.3%
Taylor expanded in lambda1 around 0 65.2%
cos-neg65.2%
Simplified65.2%
Taylor expanded in lambda2 around 0 45.2%
fma-define45.3%
Simplified45.3%
Taylor expanded in phi2 around 0 33.8%
if -7.5e12 < phi1 Initial program 68.9%
*-commutative68.9%
*-commutative68.9%
+-commutative68.9%
*-commutative68.9%
associate-*l*69.0%
*-commutative69.0%
fma-define68.9%
Simplified68.9%
Taylor expanded in phi1 around 0 49.4%
Taylor expanded in phi2 around 0 28.9%
sub-neg28.9%
remove-double-neg28.9%
mul-1-neg28.9%
distribute-neg-in28.9%
+-commutative28.9%
cos-neg28.9%
mul-1-neg28.9%
sub-neg28.9%
Simplified28.9%
Taylor expanded in phi2 around 0 26.1%
Taylor expanded in phi1 around 0 31.9%
Final simplification32.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi2 0.00046) (* R (acos (cos phi1))) (* R (acos (cos phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00046) {
tmp = R * acos(cos(phi1));
} else {
tmp = R * acos(cos(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 (phi2 <= 0.00046d0) then
tmp = r * acos(cos(phi1))
else
tmp = r * acos(cos(phi2))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00046) {
tmp = R * Math.acos(Math.cos(phi1));
} else {
tmp = R * Math.acos(Math.cos(phi2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.00046: tmp = R * math.acos(math.cos(phi1)) else: tmp = R * math.acos(math.cos(phi2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00046) tmp = Float64(R * acos(cos(phi1))); else tmp = Float64(R * acos(cos(phi2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi2 <= 0.00046) tmp = R * acos(cos(phi1)); else tmp = R * acos(cos(phi2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.00046], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[phi2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.00046:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_2\\
\end{array}
\end{array}
if phi2 < 4.6000000000000001e-4Initial program 72.7%
Simplified72.7%
Taylor expanded in lambda1 around 0 50.0%
cos-neg50.0%
Simplified50.0%
Taylor expanded in lambda2 around 0 27.7%
fma-define27.7%
Simplified27.7%
Taylor expanded in phi2 around 0 18.3%
if 4.6000000000000001e-4 < phi2 Initial program 77.8%
Simplified77.8%
Taylor expanded in lambda1 around 0 60.1%
cos-neg60.1%
Simplified60.1%
Taylor expanded in lambda2 around 0 43.3%
fma-define43.4%
Simplified43.4%
Taylor expanded in phi1 around 0 28.9%
Final simplification20.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -1.15e-8) (* R (acos (cos phi1))) (* R (acos (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -1.15e-8) {
tmp = R * acos(cos(phi1));
} else {
tmp = R * acos((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 (phi1 <= (-1.15d-8)) then
tmp = r * acos(cos(phi1))
else
tmp = r * acos((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 (phi1 <= -1.15e-8) {
tmp = R * Math.acos(Math.cos(phi1));
} else {
tmp = R * Math.acos((phi1 * phi2));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -1.15e-8: tmp = R * math.acos(math.cos(phi1)) else: tmp = R * math.acos((phi1 * phi2)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -1.15e-8) tmp = Float64(R * acos(cos(phi1))); else tmp = Float64(R * acos(Float64(phi1 * phi2))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -1.15e-8) tmp = R * acos(cos(phi1)); else tmp = R * acos((phi1 * phi2)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -1.15e-8], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(phi1 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -1.15 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -1.15e-8Initial program 88.3%
Simplified88.3%
Taylor expanded in lambda1 around 0 65.2%
cos-neg65.2%
Simplified65.2%
Taylor expanded in lambda2 around 0 45.2%
fma-define45.3%
Simplified45.3%
Taylor expanded in phi2 around 0 33.8%
if -1.15e-8 < phi1 Initial program 68.9%
*-commutative68.9%
*-commutative68.9%
+-commutative68.9%
*-commutative68.9%
associate-*l*69.0%
*-commutative69.0%
fma-define68.9%
Simplified68.9%
Taylor expanded in phi1 around 0 49.4%
Taylor expanded in phi2 around 0 28.9%
sub-neg28.9%
remove-double-neg28.9%
mul-1-neg28.9%
distribute-neg-in28.9%
+-commutative28.9%
cos-neg28.9%
mul-1-neg28.9%
sub-neg28.9%
Simplified28.9%
Taylor expanded in phi2 around 0 26.1%
Taylor expanded in phi1 around inf 11.3%
Final simplification17.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* phi1 phi2))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((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((phi1 * phi2))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((phi1 * phi2));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((phi1 * phi2))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(phi1 * phi2))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((phi1 * phi2)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(phi1 * phi2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2\right)
\end{array}
Initial program 73.9%
*-commutative73.9%
*-commutative73.9%
+-commutative73.9%
*-commutative73.9%
associate-*l*73.9%
*-commutative73.9%
fma-define73.9%
Simplified73.9%
Taylor expanded in phi1 around 0 37.7%
Taylor expanded in phi2 around 0 22.4%
sub-neg22.4%
remove-double-neg22.4%
mul-1-neg22.4%
distribute-neg-in22.4%
+-commutative22.4%
cos-neg22.4%
mul-1-neg22.4%
sub-neg22.4%
Simplified22.4%
Taylor expanded in phi2 around 0 20.3%
Taylor expanded in phi1 around inf 9.6%
Final simplification9.6%
herbie shell --seed 2024121
(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))