
(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 22 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
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(fma (sin lambda2) (sin lambda1) (* (cos lambda1) (cos lambda2)))))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * fma(sin(lambda2), sin(lambda1), (cos(lambda1) * cos(lambda2))))))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * fma(sin(lambda2), sin(lambda1), Float64(cos(lambda1) * cos(lambda2))))))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \mathsf{fma}\left(\sin \lambda_2, \sin \lambda_1, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\right)\right) \cdot R
\end{array}
Initial program 74.0%
Simplified74.0%
cos-diff95.7%
+-commutative95.7%
Applied egg-rr95.7%
*-commutative95.7%
fma-def95.7%
Applied egg-rr95.7%
Final simplification95.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(fma
(sin phi1)
(sin phi2)
(*
(cos phi1)
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1)))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\right)\right)
\end{array}
Initial program 74.0%
Simplified74.0%
cos-diff95.7%
+-commutative95.7%
Applied egg-rr95.7%
Final simplification95.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1)))
(* (cos phi1) (cos phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + (((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) * (cos(phi1) * cos(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(((sin(phi1) * sin(phi2)) + (((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) * (cos(phi1) * cos(phi2)))))
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(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda2) * Math.sin(lambda1))) * (Math.cos(phi1) * Math.cos(phi2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda2) * math.sin(lambda1))) * (math.cos(phi1) * math.cos(phi2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1))) * Float64(cos(phi1) * cos(phi2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + (((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) * (cos(phi1) * cos(phi2))))); 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[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)
\end{array}
Initial program 74.0%
cos-diff95.7%
+-commutative95.7%
Applied egg-rr95.7%
Final simplification95.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -2.6e-25)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 9.5e-9)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1))))
(* phi1 (sin phi2)))))
(*
R
(acos
(+ t_1 (+ (exp (log1p (* (* (cos phi1) (cos phi2)) t_0))) -1.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 <= -2.6e-25) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 9.5e-9) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_1 + (exp(log1p(((cos(phi1) * cos(phi2)) * t_0))) + -1.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 <= -2.6e-25) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 9.5e-9) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(exp(log1p(Float64(Float64(cos(phi1) * cos(phi2)) * t_0))) + -1.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, -2.6e-25], 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, 9.5e-9], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Exp[N[Log[1 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision] + -1.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 -2.6 \cdot 10^{-25}:\\
\;\;\;\;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 9.5 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \left(e^{\mathsf{log1p}\left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)} + -1\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.6e-25Initial program 77.4%
+-commutative77.4%
associate-*l*77.4%
fma-def77.4%
Simplified77.4%
if -2.6e-25 < phi1 < 9.5000000000000007e-9Initial program 67.2%
+-commutative67.2%
associate-*l*67.2%
fma-def67.2%
Simplified67.2%
Taylor expanded in phi1 around 0 67.2%
cos-diff91.4%
+-commutative91.4%
Applied egg-rr91.4%
if 9.5000000000000007e-9 < phi1 Initial program 80.9%
expm1-log1p-u80.7%
expm1-udef80.8%
*-commutative80.8%
Applied egg-rr80.8%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -2.6e-25)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 4e-6)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1))))
(* phi1 (sin phi2)))))
(*
R
(acos (+ t_1 (cbrt (pow (* (* (cos phi1) (cos phi2)) t_0) 3.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 <= -2.6e-25) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 4e-6) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) + (phi1 * sin(phi2))));
} else {
tmp = R * acos((t_1 + cbrt(pow(((cos(phi1) * cos(phi2)) * t_0), 3.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 <= -2.6e-25) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 4e-6) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * acos(Float64(t_1 + cbrt((Float64(Float64(cos(phi1) * cos(phi2)) * t_0) ^ 3.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, -2.6e-25], 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, 4e-6], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[Power[N[Power[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $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 -2.6 \cdot 10^{-25}:\\
\;\;\;\;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 4 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \sqrt[3]{{\left(\left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t_0\right)}^{3}}\right)\\
\end{array}
\end{array}
if phi1 < -2.6e-25Initial program 77.4%
+-commutative77.4%
associate-*l*77.4%
fma-def77.4%
Simplified77.4%
if -2.6e-25 < phi1 < 3.99999999999999982e-6Initial program 67.2%
+-commutative67.2%
associate-*l*67.2%
fma-def67.2%
Simplified67.2%
Taylor expanded in phi1 around 0 67.2%
cos-diff91.4%
+-commutative91.4%
Applied egg-rr91.4%
if 3.99999999999999982e-6 < phi1 Initial program 80.9%
add-cbrt-cube80.6%
pow380.6%
*-commutative80.6%
Applied egg-rr80.6%
Final simplification84.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -2.6e-25)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 8.5e-14)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1))))
(* phi1 (sin phi2)))))
(* 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 (phi1 <= -2.6e-25) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 8.5e-14) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) + (phi1 * sin(phi2))));
} 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 (phi1 <= -2.6e-25) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 8.5e-14) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1)))) + Float64(phi1 * sin(phi2))))); 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[phi1, -2.6e-25], 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, 8.5e-14], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $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] * 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 -2.6 \cdot 10^{-25}:\\
\;\;\;\;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 8.5 \cdot 10^{-14}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\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 t_0\right)\\
\end{array}
\end{array}
if phi1 < -2.6e-25Initial program 77.4%
+-commutative77.4%
associate-*l*77.4%
fma-def77.4%
Simplified77.4%
if -2.6e-25 < phi1 < 8.50000000000000038e-14Initial program 67.5%
+-commutative67.5%
associate-*l*67.5%
fma-def67.5%
Simplified67.5%
Taylor expanded in phi1 around 0 67.5%
cos-diff92.1%
+-commutative92.1%
Applied egg-rr92.1%
if 8.50000000000000038e-14 < phi1 Initial program 80.1%
Final simplification84.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -3.7e-9)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1))))
(* phi1 phi2))))
(*
R
(acos
(fma
(cos phi1)
(* (cos phi2) (cos (- lambda1 lambda2)))
(* (sin phi1) (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -3.7e-9) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) + (phi1 * phi2)));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * cos((lambda1 - lambda2))), (sin(phi1) * sin(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -3.7e-9) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1)))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))), Float64(sin(phi1) * sin(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -3.7e-9], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -3.7 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;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)\\
\end{array}
\end{array}
if lambda2 < -3.7e-9Initial program 54.4%
+-commutative54.4%
associate-*l*54.4%
fma-def54.4%
Simplified54.4%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in phi2 around 0 23.5%
cos-diff98.4%
+-commutative98.4%
Applied egg-rr43.1%
if -3.7e-9 < lambda2 Initial program 82.7%
+-commutative82.7%
associate-*l*82.7%
fma-def82.7%
Simplified82.7%
Final simplification70.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -3.7e-9)
(*
R
(acos
(+
(*
(cos phi2)
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1))))
(* phi1 phi2))))
(*
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) {
double tmp;
if (lambda2 <= -3.7e-9) {
tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) + (phi1 * phi2)));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - 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 <= (-3.7d-9)) then
tmp = r * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) + (phi1 * phi2)))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - 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 <= -3.7e-9) {
tmp = R * Math.acos(((Math.cos(phi2) * ((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda2) * Math.sin(lambda1)))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= -3.7e-9: tmp = R * math.acos(((math.cos(phi2) * ((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda2) * math.sin(lambda1)))) + (phi1 * phi2))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -3.7e-9) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1)))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= -3.7e-9) tmp = R * acos(((cos(phi2) * ((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1)))) + (phi1 * phi2))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -3.7e-9], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $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] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -3.7 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) + \phi_1 \cdot \phi_2\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 \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda2 < -3.7e-9Initial program 54.4%
+-commutative54.4%
associate-*l*54.4%
fma-def54.4%
Simplified54.4%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in phi2 around 0 23.5%
cos-diff98.4%
+-commutative98.4%
Applied egg-rr43.1%
if -3.7e-9 < lambda2 Initial program 82.7%
Final simplification70.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -3.7e-9)
(*
R
(acos
(+
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1)))
(* phi1 phi2))))
(if (<= lambda2 0.059)
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos lambda1) (* (cos phi1) (cos phi2))))))
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= -3.7e-9) {
tmp = R * acos((((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) + (phi1 * phi2)));
} else if (lambda2 <= 0.059) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(lambda1) * (cos(phi1) * cos(phi2)))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * cos(lambda2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -3.7e-9) tmp = Float64(R * acos(Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1))) + Float64(phi1 * phi2)))); elseif (lambda2 <= 0.059) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(lambda1) * Float64(cos(phi1) * cos(phi2)))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * cos(lambda2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -3.7e-9], N[(R * N[ArcCos[N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 0.059], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[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 -3.7 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{elif}\;\lambda_2 \leq 0.059:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \lambda_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda2 < -3.7e-9Initial program 54.4%
+-commutative54.4%
associate-*l*54.4%
fma-def54.4%
Simplified54.4%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in phi2 around 0 23.5%
Taylor expanded in phi2 around 0 17.6%
cos-neg17.6%
sub-neg17.6%
+-commutative17.6%
distribute-neg-in17.6%
remove-double-neg17.6%
sub-neg17.6%
Simplified17.6%
cos-diff32.0%
*-commutative32.0%
Applied egg-rr32.0%
if -3.7e-9 < lambda2 < 0.058999999999999997Initial program 91.6%
Taylor expanded in lambda2 around 0 91.6%
if 0.058999999999999997 < lambda2 Initial program 65.7%
Simplified65.8%
Taylor expanded in lambda1 around 0 66.1%
cos-neg66.1%
Simplified66.1%
Taylor expanded in phi2 around 0 43.5%
*-commutative43.5%
Simplified43.5%
Final simplification61.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= lambda2 -3.7e-9)
(*
R
(acos
(+
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1)))
(* phi1 phi2))))
(if (<= lambda2 0.013)
(* R (acos (+ t_1 (* (cos lambda1) t_0))))
(* R (acos (+ t_1 (* (cos lambda2) t_0))))))))
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 <= -3.7e-9) {
tmp = R * acos((((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) + (phi1 * phi2)));
} else if (lambda2 <= 0.013) {
tmp = R * acos((t_1 + (cos(lambda1) * t_0)));
} else {
tmp = R * acos((t_1 + (cos(lambda2) * 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(phi1) * cos(phi2)
t_1 = sin(phi1) * sin(phi2)
if (lambda2 <= (-3.7d-9)) then
tmp = r * acos((((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) + (phi1 * phi2)))
else if (lambda2 <= 0.013d0) then
tmp = r * acos((t_1 + (cos(lambda1) * t_0)))
else
tmp = r * acos((t_1 + (cos(lambda2) * 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(phi1) * Math.cos(phi2);
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -3.7e-9) {
tmp = R * Math.acos((((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda2) * Math.sin(lambda1))) + (phi1 * phi2)));
} else if (lambda2 <= 0.013) {
tmp = R * Math.acos((t_1 + (Math.cos(lambda1) * t_0)));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(lambda2) * t_0)));
}
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 <= -3.7e-9: tmp = R * math.acos((((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda2) * math.sin(lambda1))) + (phi1 * phi2))) elif lambda2 <= 0.013: tmp = R * math.acos((t_1 + (math.cos(lambda1) * t_0))) else: tmp = R * math.acos((t_1 + (math.cos(lambda2) * t_0))) 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 <= -3.7e-9) tmp = Float64(R * acos(Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1))) + Float64(phi1 * phi2)))); elseif (lambda2 <= 0.013) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(lambda1) * t_0)))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(lambda2) * t_0)))); 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 <= -3.7e-9) tmp = R * acos((((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) + (phi1 * phi2))); elseif (lambda2 <= 0.013) tmp = R * acos((t_1 + (cos(lambda1) * t_0))); else tmp = R * acos((t_1 + (cos(lambda2) * t_0))); 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, -3.7e-9], N[(R * N[ArcCos[N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 0.013], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[lambda1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[lambda2], $MachinePrecision] * t$95$0), $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 -3.7 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{elif}\;\lambda_2 \leq 0.013:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \lambda_1 \cdot t_0\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \lambda_2 \cdot t_0\right)\\
\end{array}
\end{array}
if lambda2 < -3.7e-9Initial program 54.4%
+-commutative54.4%
associate-*l*54.4%
fma-def54.4%
Simplified54.4%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in phi2 around 0 23.5%
Taylor expanded in phi2 around 0 17.6%
cos-neg17.6%
sub-neg17.6%
+-commutative17.6%
distribute-neg-in17.6%
remove-double-neg17.6%
sub-neg17.6%
Simplified17.6%
cos-diff32.0%
*-commutative32.0%
Applied egg-rr32.0%
if -3.7e-9 < lambda2 < 0.0129999999999999994Initial program 91.6%
Taylor expanded in lambda2 around 0 91.6%
if 0.0129999999999999994 < lambda2 Initial program 65.7%
Taylor expanded in lambda1 around 0 66.1%
cos-neg66.1%
Simplified66.1%
Final simplification67.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= lambda2 -3.7e-9)
(*
R
(acos
(+
(+ (* (cos lambda1) (cos lambda2)) (* (sin lambda2) (sin lambda1)))
(* phi1 phi2))))
(*
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) {
double tmp;
if (lambda2 <= -3.7e-9) {
tmp = R * acos((((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) + (phi1 * phi2)));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - 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 <= (-3.7d-9)) then
tmp = r * acos((((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) + (phi1 * phi2)))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - 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 <= -3.7e-9) {
tmp = R * Math.acos((((Math.cos(lambda1) * Math.cos(lambda2)) + (Math.sin(lambda2) * Math.sin(lambda1))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= -3.7e-9: tmp = R * math.acos((((math.cos(lambda1) * math.cos(lambda2)) + (math.sin(lambda2) * math.sin(lambda1))) + (phi1 * phi2))) else: tmp = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= -3.7e-9) tmp = Float64(R * acos(Float64(Float64(Float64(cos(lambda1) * cos(lambda2)) + Float64(sin(lambda2) * sin(lambda1))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= -3.7e-9) tmp = R * acos((((cos(lambda1) * cos(lambda2)) + (sin(lambda2) * sin(lambda1))) + (phi1 * phi2))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, -3.7e-9], N[(R * N[ArcCos[N[(N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $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] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -3.7 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\left(\cos \lambda_1 \cdot \cos \lambda_2 + \sin \lambda_2 \cdot \sin \lambda_1\right) + \phi_1 \cdot \phi_2\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 \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda2 < -3.7e-9Initial program 54.4%
+-commutative54.4%
associate-*l*54.4%
fma-def54.4%
Simplified54.4%
Taylor expanded in phi1 around 0 30.9%
Taylor expanded in phi2 around 0 23.5%
Taylor expanded in phi2 around 0 17.6%
cos-neg17.6%
sub-neg17.6%
+-commutative17.6%
distribute-neg-in17.6%
remove-double-neg17.6%
sub-neg17.6%
Simplified17.6%
cos-diff32.0%
*-commutative32.0%
Applied egg-rr32.0%
if -3.7e-9 < lambda2 Initial program 82.7%
Final simplification67.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(if (<= phi1 -0.14)
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) t_0))))
(if (<= phi1 0.205)
(*
R
(acos
(+
(* phi1 (sin phi2))
(* (+ 1.0 (* -0.5 (pow phi1 2.0))) (* (cos phi2) t_0)))))
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) (cos phi2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi1 <= -0.14) {
tmp = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * t_0)));
} else if (phi1 <= 0.205) {
tmp = R * acos(((phi1 * sin(phi2)) + ((1.0 + (-0.5 * pow(phi1, 2.0))) * (cos(phi2) * t_0))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * cos(phi2))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi1 <= -0.14) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 0.205) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) * Float64(cos(phi2) * t_0))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * cos(phi2))))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -0.14], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.205], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $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_2 - \lambda_1\right)\\
\mathbf{if}\;\phi_1 \leq -0.14:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.205:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(1 + -0.5 \cdot {\phi_1}^{2}\right) \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \cos \phi_2\right)\right)\\
\end{array}
\end{array}
if phi1 < -0.14000000000000001Initial program 76.0%
Taylor expanded in phi2 around 0 46.8%
sub-neg46.8%
remove-double-neg46.8%
mul-1-neg46.8%
distribute-neg-in46.8%
+-commutative46.8%
cos-neg46.8%
mul-1-neg46.8%
unsub-neg46.8%
Simplified46.8%
if -0.14000000000000001 < phi1 < 0.204999999999999988Initial program 68.4%
+-commutative68.4%
associate-*l*68.4%
fma-def68.4%
Simplified68.4%
Taylor expanded in phi1 around 0 67.9%
+-commutative67.9%
associate-+r+67.9%
Simplified67.9%
if 0.204999999999999988 < phi1 Initial program 81.4%
Simplified81.4%
Taylor expanded in lambda1 around 0 63.0%
cos-neg63.0%
Simplified63.0%
Taylor expanded in lambda2 around 0 45.1%
Final simplification56.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -0.047)
(* R (acos (+ t_1 (* (cos phi1) t_0))))
(if (<= phi1 0.145)
(*
R
(acos
(+
(* phi1 (sin phi2))
(* (+ 1.0 (* -0.5 (pow phi1 2.0))) (* (cos phi2) t_0)))))
(* R (acos (+ t_1 (* (cos phi1) (cos phi2)))))))))
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 (phi1 <= -0.047) {
tmp = R * acos((t_1 + (cos(phi1) * t_0)));
} else if (phi1 <= 0.145) {
tmp = R * acos(((phi1 * sin(phi2)) + ((1.0 + (-0.5 * pow(phi1, 2.0))) * (cos(phi2) * t_0))));
} else {
tmp = R * acos((t_1 + (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) :: t_1
real(8) :: tmp
t_0 = cos((lambda2 - lambda1))
t_1 = sin(phi1) * sin(phi2)
if (phi1 <= (-0.047d0)) then
tmp = r * acos((t_1 + (cos(phi1) * t_0)))
else if (phi1 <= 0.145d0) then
tmp = r * acos(((phi1 * sin(phi2)) + ((1.0d0 + ((-0.5d0) * (phi1 ** 2.0d0))) * (cos(phi2) * t_0))))
else
tmp = r * acos((t_1 + (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((lambda2 - lambda1));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -0.047) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * t_0)));
} else if (phi1 <= 0.145) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + ((1.0 + (-0.5 * Math.pow(phi1, 2.0))) * (Math.cos(phi2) * t_0))));
} else {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * Math.cos(phi2))));
}
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 phi1 <= -0.047: tmp = R * math.acos((t_1 + (math.cos(phi1) * t_0))) elif phi1 <= 0.145: tmp = R * math.acos(((phi1 * math.sin(phi2)) + ((1.0 + (-0.5 * math.pow(phi1, 2.0))) * (math.cos(phi2) * t_0)))) else: tmp = R * math.acos((t_1 + (math.cos(phi1) * math.cos(phi2)))) 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 (phi1 <= -0.047) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * t_0)))); elseif (phi1 <= 0.145) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(1.0 + Float64(-0.5 * (phi1 ^ 2.0))) * Float64(cos(phi2) * t_0))))); else tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * cos(phi2))))); 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 (phi1 <= -0.047) tmp = R * acos((t_1 + (cos(phi1) * t_0))); elseif (phi1 <= 0.145) tmp = R * acos(((phi1 * sin(phi2)) + ((1.0 + (-0.5 * (phi1 ^ 2.0))) * (cos(phi2) * t_0)))); else tmp = R * acos((t_1 + (cos(phi1) * cos(phi2)))); 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[phi1, -0.047], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.145], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(1.0 + N[(-0.5 * N[Power[phi1, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $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_1 \leq -0.047:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot t_0\right)\\
\mathbf{elif}\;\phi_1 \leq 0.145:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(1 + -0.5 \cdot {\phi_1}^{2}\right) \cdot \left(\cos \phi_2 \cdot t_0\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -0.047Initial program 76.0%
Taylor expanded in phi2 around 0 46.8%
sub-neg46.8%
remove-double-neg46.8%
mul-1-neg46.8%
distribute-neg-in46.8%
+-commutative46.8%
cos-neg46.8%
mul-1-neg46.8%
unsub-neg46.8%
Simplified46.8%
if -0.047 < phi1 < 0.14499999999999999Initial program 68.8%
+-commutative68.8%
associate-*l*68.8%
fma-def68.8%
Simplified68.8%
Taylor expanded in phi1 around 0 68.3%
+-commutative68.3%
associate-+r+68.3%
Simplified68.3%
if 0.14499999999999999 < phi1 Initial program 80.6%
add-sqr-sqrt39.4%
pow239.4%
*-commutative39.4%
Applied egg-rr39.4%
Taylor expanded in lambda2 around 0 33.4%
Taylor expanded in lambda1 around 0 44.7%
Final simplification56.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(* R (acos (+ (* (sin phi1) (sin phi2)) (* (cos phi1) (cos phi2))))))
(t_1 (cos (- lambda1 lambda2))))
(if (<= phi1 -3.1e+139)
t_0
(if (<= phi1 -0.00089)
(* R (acos (+ (* (sin phi1) phi2) (* (cos phi1) t_1))))
(if (<= phi1 0.06)
(* R (acos (+ (* (cos phi2) t_1) (* phi1 (sin phi2)))))
t_0)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))));
double t_1 = cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.1e+139) {
tmp = t_0;
} else if (phi1 <= -0.00089) {
tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1)));
} else if (phi1 <= 0.06) {
tmp = R * acos(((cos(phi2) * t_1) + (phi1 * sin(phi2))));
} else {
tmp = 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 = r * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2))))
t_1 = cos((lambda1 - lambda2))
if (phi1 <= (-3.1d+139)) then
tmp = t_0
else if (phi1 <= (-0.00089d0)) then
tmp = r * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1)))
else if (phi1 <= 0.06d0) then
tmp = r * acos(((cos(phi2) * t_1) + (phi1 * sin(phi2))))
else
tmp = 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 = R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(phi2))));
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -3.1e+139) {
tmp = t_0;
} else if (phi1 <= -0.00089) {
tmp = R * Math.acos(((Math.sin(phi1) * phi2) + (Math.cos(phi1) * t_1)));
} else if (phi1 <= 0.06) {
tmp = R * Math.acos(((Math.cos(phi2) * t_1) + (phi1 * Math.sin(phi2))));
} else {
tmp = t_0;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = R * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi1) * math.cos(phi2)))) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -3.1e+139: tmp = t_0 elif phi1 <= -0.00089: tmp = R * math.acos(((math.sin(phi1) * phi2) + (math.cos(phi1) * t_1))) elif phi1 <= 0.06: tmp = R * math.acos(((math.cos(phi2) * t_1) + (phi1 * math.sin(phi2)))) else: tmp = t_0 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi1) * cos(phi2))))) t_1 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if (phi1 <= -3.1e+139) tmp = t_0; elseif (phi1 <= -0.00089) tmp = Float64(R * acos(Float64(Float64(sin(phi1) * phi2) + Float64(cos(phi1) * t_1)))); elseif (phi1 <= 0.06) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * t_1) + Float64(phi1 * sin(phi2))))); else tmp = t_0; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = R * acos(((sin(phi1) * sin(phi2)) + (cos(phi1) * cos(phi2)))); t_1 = cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -3.1e+139) tmp = t_0; elseif (phi1 <= -0.00089) tmp = R * acos(((sin(phi1) * phi2) + (cos(phi1) * t_1))); elseif (phi1 <= 0.06) tmp = R * acos(((cos(phi2) * t_1) + (phi1 * sin(phi2)))); else tmp = t_0; end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = 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]}, Block[{t$95$1 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[phi1, -3.1e+139], t$95$0, If[LessEqual[phi1, -0.00089], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 0.06], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \phi_2\right)\\
t_1 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{+139}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;\phi_1 \leq -0.00089:\\
\;\;\;\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \phi_2 + \cos \phi_1 \cdot t_1\right)\\
\mathbf{elif}\;\phi_1 \leq 0.06:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot t_1 + \phi_1 \cdot \sin \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if phi1 < -3.1e139 or 0.059999999999999998 < phi1 Initial program 77.8%
add-sqr-sqrt37.3%
pow237.3%
*-commutative37.3%
Applied egg-rr37.3%
Taylor expanded in lambda2 around 0 31.6%
Taylor expanded in lambda1 around 0 43.2%
if -3.1e139 < phi1 < -8.8999999999999995e-4Initial program 79.7%
+-commutative79.7%
associate-*l*79.7%
fma-def79.7%
Simplified79.7%
Taylor expanded in phi2 around 0 47.2%
if -8.8999999999999995e-4 < phi1 < 0.059999999999999998Initial program 68.8%
+-commutative68.8%
associate-*l*68.8%
fma-def68.8%
Simplified68.8%
Taylor expanded in phi1 around 0 67.8%
Final simplification55.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -4.2e+27)
(* R (acos (+ t_1 (* (cos phi1) (cos phi2)))))
(if (<= phi2 0.175)
(* 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 <= -4.2e+27) {
tmp = R * acos((t_1 + (cos(phi1) * cos(phi2))));
} else if (phi2 <= 0.175) {
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 <= (-4.2d+27)) then
tmp = r * acos((t_1 + (cos(phi1) * cos(phi2))))
else if (phi2 <= 0.175d0) 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 <= -4.2e+27) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * Math.cos(phi2))));
} else if (phi2 <= 0.175) {
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 <= -4.2e+27: tmp = R * math.acos((t_1 + (math.cos(phi1) * math.cos(phi2)))) elif phi2 <= 0.175: 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 <= -4.2e+27) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * cos(phi2))))); elseif (phi2 <= 0.175) 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 <= -4.2e+27) tmp = R * acos((t_1 + (cos(phi1) * cos(phi2)))); elseif (phi2 <= 0.175) 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, -4.2e+27], N[(R * N[ArcCos[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 0.175], 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 -4.2 \cdot 10^{+27}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_1 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\mathbf{elif}\;\phi_2 \leq 0.175:\\
\;\;\;\;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 < -4.19999999999999989e27Initial program 79.5%
add-sqr-sqrt45.8%
pow245.8%
*-commutative45.8%
Applied egg-rr45.8%
Taylor expanded in lambda2 around 0 38.0%
Taylor expanded in lambda1 around 0 37.7%
if -4.19999999999999989e27 < phi2 < 0.17499999999999999Initial program 71.1%
Taylor expanded in phi2 around 0 68.7%
sub-neg68.7%
remove-double-neg68.7%
mul-1-neg68.7%
distribute-neg-in68.7%
+-commutative68.7%
cos-neg68.7%
mul-1-neg68.7%
unsub-neg68.7%
Simplified68.7%
if 0.17499999999999999 < phi2 Initial program 75.7%
Taylor expanded in phi1 around 0 43.3%
sub-neg43.3%
neg-mul-143.3%
neg-mul-143.3%
remove-double-neg43.3%
mul-1-neg43.3%
distribute-neg-in43.3%
+-commutative43.3%
cos-neg43.3%
mul-1-neg43.3%
unsub-neg43.3%
Simplified43.3%
Final simplification56.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= phi1 -0.0034)
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda2 lambda1))))))
(if (<= phi1 0.054)
(*
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 <= -0.0034) {
tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))));
} else if (phi1 <= 0.054) {
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 <= (-0.0034d0)) then
tmp = r * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1)))))
else if (phi1 <= 0.054d0) 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 <= -0.0034) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda2 - lambda1)))));
} else if (phi1 <= 0.054) {
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 <= -0.0034: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda2 - lambda1))))) elif phi1 <= 0.054: 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 <= -0.0034) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda2 - lambda1)))))); elseif (phi1 <= 0.054) 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 <= -0.0034) tmp = R * acos((t_0 + (cos(phi1) * cos((lambda2 - lambda1))))); elseif (phi1 <= 0.054) 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, -0.0034], 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, 0.054], 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 -0.0034:\\
\;\;\;\;R \cdot \cos^{-1} \left(t_0 + \cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 0.054:\\
\;\;\;\;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 < -0.00339999999999999981Initial program 76.0%
Taylor expanded in phi2 around 0 46.8%
sub-neg46.8%
remove-double-neg46.8%
mul-1-neg46.8%
distribute-neg-in46.8%
+-commutative46.8%
cos-neg46.8%
mul-1-neg46.8%
unsub-neg46.8%
Simplified46.8%
if -0.00339999999999999981 < phi1 < 0.0539999999999999994Initial program 68.8%
+-commutative68.8%
associate-*l*68.8%
fma-def68.8%
Simplified68.8%
Taylor expanded in phi1 around 0 67.8%
if 0.0539999999999999994 < phi1 Initial program 80.6%
add-sqr-sqrt39.4%
pow239.4%
*-commutative39.4%
Applied egg-rr39.4%
Taylor expanded in lambda2 around 0 33.4%
Taylor expanded in lambda1 around 0 44.7%
Final simplification55.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -205000000.0)
(* R (acos (cos (- lambda2 lambda1))))
(*
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 <= -205000000.0) {
tmp = R * acos(cos((lambda2 - lambda1)));
} 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 <= (-205000000.0d0)) then
tmp = r * acos(cos((lambda2 - lambda1)))
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 <= -205000000.0) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} 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 <= -205000000.0: tmp = R * math.acos(math.cos((lambda2 - lambda1))) 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 <= -205000000.0) tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); 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 <= -205000000.0) tmp = R * acos(cos((lambda2 - lambda1))); 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, -205000000.0], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $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 -205000000:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\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 < -2.05e8Initial program 75.2%
+-commutative75.2%
associate-*l*75.2%
fma-def75.2%
Simplified75.2%
Taylor expanded in phi1 around 0 4.1%
Taylor expanded in phi2 around 0 4.1%
Taylor expanded in phi2 around 0 4.1%
cos-neg4.1%
sub-neg4.1%
+-commutative4.1%
distribute-neg-in4.1%
remove-double-neg4.1%
sub-neg4.1%
Simplified4.1%
Taylor expanded in phi1 around 0 15.9%
if -2.05e8 < phi1 Initial program 73.5%
+-commutative73.5%
associate-*l*73.5%
fma-def73.5%
Simplified73.5%
Taylor expanded in phi1 around 0 43.5%
Final simplification36.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi2 0.18)
(* 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 (phi2 <= 0.18) {
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 (phi2 <= 0.18d0) 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 (phi2 <= 0.18) {
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 phi2 <= 0.18: 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 (phi2 <= 0.18) 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 (phi2 <= 0.18) 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[phi2, 0.18], 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_2 \leq 0.18:\\
\;\;\;\;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 phi2 < 0.17999999999999999Initial program 73.5%
+-commutative73.5%
associate-*l*73.5%
fma-def73.5%
Simplified73.5%
Taylor expanded in phi2 around 0 49.6%
if 0.17999999999999999 < phi2 Initial program 75.7%
+-commutative75.7%
associate-*l*75.7%
fma-def75.7%
Simplified75.7%
Taylor expanded in phi1 around 0 35.3%
Final simplification46.7%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 0.013) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos lambda1))))) (* R (acos (cos (- lambda2 lambda1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 0.013) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))));
} 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 (lambda2 <= 0.013d0) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))))
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 (lambda2 <= 0.013) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 0.013: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos(lambda1)))) else: tmp = R * math.acos(math.cos((lambda2 - lambda1))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 0.013) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(lambda1))))); 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 (lambda2 <= 0.013) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1)))); else tmp = R * acos(cos((lambda2 - lambda1))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 0.013], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 0.013:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\end{array}
\end{array}
if lambda2 < 0.0129999999999999994Initial program 76.5%
+-commutative76.5%
associate-*l*76.5%
fma-def76.5%
Simplified76.5%
Taylor expanded in phi1 around 0 34.2%
Taylor expanded in lambda2 around 0 26.1%
if 0.0129999999999999994 < lambda2 Initial program 65.7%
+-commutative65.7%
associate-*l*65.7%
fma-def65.7%
Simplified65.7%
Taylor expanded in phi1 around 0 29.9%
Taylor expanded in phi2 around 0 23.6%
Taylor expanded in phi2 around 0 21.2%
cos-neg21.2%
sub-neg21.2%
+-commutative21.2%
distribute-neg-in21.2%
remove-double-neg21.2%
sub-neg21.2%
Simplified21.2%
Taylor expanded in phi1 around 0 31.9%
Final simplification27.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (or (<= phi1 -7.5e-85) (not (<= phi1 7.2e-118))) (* R (acos (cos (- lambda2 lambda1)))) (* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -7.5e-85) || !(phi1 <= 7.2e-118)) {
tmp = R * acos(cos((lambda2 - lambda1)));
} else {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (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 <= (-7.5d-85)) .or. (.not. (phi1 <= 7.2d-118))) then
tmp = r * acos(cos((lambda2 - lambda1)))
else
tmp = r * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (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 <= -7.5e-85) || !(phi1 <= 7.2e-118)) {
tmp = R * Math.acos(Math.cos((lambda2 - lambda1)));
} else {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -7.5e-85) or not (phi1 <= 7.2e-118): tmp = R * math.acos(math.cos((lambda2 - lambda1))) else: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -7.5e-85) || !(phi1 <= 7.2e-118)) tmp = Float64(R * acos(cos(Float64(lambda2 - lambda1)))); else tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((phi1 <= -7.5e-85) || ~((phi1 <= 7.2e-118))) tmp = R * acos(cos((lambda2 - lambda1))); else tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[phi1, -7.5e-85], N[Not[LessEqual[phi1, 7.2e-118]], $MachinePrecision]], N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 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]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -7.5 \cdot 10^{-85} \lor \neg \left(\phi_1 \leq 7.2 \cdot 10^{-118}\right):\\
\;\;\;\;R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -7.5000000000000003e-85 or 7.2000000000000004e-118 < phi1 Initial program 77.6%
+-commutative77.6%
associate-*l*77.6%
fma-def77.6%
Simplified77.6%
Taylor expanded in phi1 around 0 17.5%
Taylor expanded in phi2 around 0 12.4%
Taylor expanded in phi2 around 0 11.1%
cos-neg11.1%
sub-neg11.1%
+-commutative11.1%
distribute-neg-in11.1%
remove-double-neg11.1%
sub-neg11.1%
Simplified11.1%
Taylor expanded in phi1 around 0 21.9%
if -7.5000000000000003e-85 < phi1 < 7.2000000000000004e-118Initial program 66.3%
+-commutative66.3%
associate-*l*66.3%
fma-def66.3%
Simplified66.3%
Taylor expanded in phi1 around 0 66.3%
Taylor expanded in phi2 around 0 58.2%
Final simplification33.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos (- lambda2 lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos((lambda2 - 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(cos((lambda2 - lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos((lambda2 - lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos((lambda2 - lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(Float64(lambda2 - lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos((lambda2 - lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)
\end{array}
Initial program 74.0%
+-commutative74.0%
associate-*l*74.0%
fma-def74.0%
Simplified74.0%
Taylor expanded in phi1 around 0 33.2%
Taylor expanded in phi2 around 0 27.1%
Taylor expanded in phi2 around 0 20.0%
cos-neg20.0%
sub-neg20.0%
+-commutative20.0%
distribute-neg-in20.0%
remove-double-neg20.0%
sub-neg20.0%
Simplified20.0%
Taylor expanded in phi1 around 0 28.0%
Final simplification28.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 74.0%
+-commutative74.0%
associate-*l*74.0%
fma-def74.0%
Simplified74.0%
Taylor expanded in phi1 around 0 33.2%
Taylor expanded in phi2 around 0 27.1%
Taylor expanded in phi2 around 0 20.0%
cos-neg20.0%
sub-neg20.0%
+-commutative20.0%
distribute-neg-in20.0%
remove-double-neg20.0%
sub-neg20.0%
Simplified20.0%
Taylor expanded in phi1 around inf 9.9%
Final simplification9.9%
herbie shell --seed 2023322
(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))