
(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 25 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
(* (cos phi1) (cos phi2))
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))
(* (sin phi1) (sin phi2))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(fma((cos(phi1) * cos(phi2)), fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))), (sin(phi1) * sin(phi2)))) * R;
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(fma(Float64(cos(phi1) * cos(phi2)), fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))), Float64(sin(phi1) * sin(phi2)))) * R) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right), \sin \phi_1 \cdot \sin \phi_2\right)\right) \cdot R
\end{array}
Initial program 76.1%
cos-diff95.9%
Applied egg-rr95.9%
cos-neg95.9%
*-commutative95.9%
fma-define95.9%
cos-neg95.9%
Simplified95.9%
Taylor expanded in phi1 around 0 95.8%
associate-*r*95.9%
fma-define95.8%
fma-define95.9%
Simplified95.9%
Final simplification95.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(fma (cos lambda2) (cos lambda1) (* (sin lambda1) (sin lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), (sin(lambda1) * sin(lambda2))))));
}
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * fma(cos(lambda2), cos(lambda1), Float64(sin(lambda1) * sin(lambda2))))))) end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \mathsf{fma}\left(\cos \lambda_2, \cos \lambda_1, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)
\end{array}
Initial program 76.1%
cos-diff95.9%
Applied egg-rr95.9%
cos-neg95.9%
*-commutative95.9%
fma-define95.9%
cos-neg95.9%
Simplified95.9%
Final simplification95.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(*
(* (cos phi1) (cos phi2))
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[(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]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)
\end{array}
Initial program 76.1%
cos-diff55.6%
+-commutative55.6%
Applied egg-rr95.9%
Final simplification95.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2)))
(t_1 (* (sin phi1) (sin phi2)))
(t_2 (* (cos phi1) (cos phi2))))
(if (<= phi1 -2850000000.0)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 0.0013)
(*
R
(acos
(+
(*
t_2
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))
(* phi1 (sin phi2)))))
(* R (- (* PI 0.5) (asin (fma t_0 t_2 t_1))))))))
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 t_2 = cos(phi1) * cos(phi2);
double tmp;
if (phi1 <= -2850000000.0) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 0.0013) {
tmp = R * acos(((t_2 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))) + (phi1 * sin(phi2))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin(fma(t_0, t_2, t_1)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (phi1 <= -2850000000.0) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 0.0013) tmp = Float64(R * acos(Float64(Float64(t_2 * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))) + Float64(phi1 * sin(phi2))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(fma(t_0, t_2, t_1)))); 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]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2850000000.0], 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, 0.0013], N[(R * N[ArcCos[N[(N[(t$95$2 * 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[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 * t$95$2 + t$95$1), $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\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
\mathbf{if}\;\phi_1 \leq -2850000000:\\
\;\;\;\;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 0.0013:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_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 \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(t\_0, t\_2, t\_1\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.85e9Initial program 83.0%
Simplified83.1%
if -2.85e9 < phi1 < 0.0012999999999999999Initial program 72.9%
Taylor expanded in phi1 around 0 72.9%
cos-diff92.5%
+-commutative92.5%
Applied egg-rr92.5%
if 0.0012999999999999999 < phi1 Initial program 76.2%
acos-asin76.1%
sub-neg76.1%
div-inv76.1%
metadata-eval76.1%
+-commutative76.1%
*-commutative76.1%
fma-define76.1%
Applied egg-rr76.1%
sub-neg76.1%
Simplified76.1%
Final simplification85.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* (cos phi2) (cos (- lambda1 lambda2)))))
(if (<= phi1 -6.1e-6)
(* R (acos (fma (cos phi1) t_1 t_0)))
(if (<= phi1 8.5e-7)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (- (* PI 0.5) (asin (+ t_0 (* (cos phi1) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi2) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -6.1e-6) {
tmp = R * acos(fma(cos(phi1), t_1, t_0));
} else if (phi1 <= 8.5e-7) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_0 + (cos(phi1) * t_1))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -6.1e-6) tmp = Float64(R * acos(fma(cos(phi1), t_1, t_0))); elseif (phi1 <= 8.5e-7) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_0 + Float64(cos(phi1) * t_1))))); end return 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[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -6.1e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 8.5e-7], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + 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[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -6.1 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t\_1, t\_0\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 8.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \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 \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_0 + \cos \phi_1 \cdot t\_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -6.10000000000000004e-6Initial program 83.3%
Simplified83.4%
if -6.10000000000000004e-6 < phi1 < 8.50000000000000014e-7Initial program 72.7%
cos-diff92.4%
Applied egg-rr92.4%
cos-neg92.4%
*-commutative92.4%
fma-define92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
associate-*r*92.4%
fma-define92.4%
fma-define92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
if 8.50000000000000014e-7 < phi1 Initial program 76.2%
acos-asin76.1%
sub-neg76.1%
div-inv76.1%
metadata-eval76.1%
+-commutative76.1%
*-commutative76.1%
fma-define76.1%
Applied egg-rr76.1%
sub-neg76.1%
Simplified76.1%
Taylor expanded in lambda1 around 0 76.0%
Final simplification85.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -6.6e-6)
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))
(if (<= phi1 2.3e-7)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (- (* PI 0.5) (asin (fma t_0 (* (cos phi1) (cos phi2)) t_1))))))))
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.6e-6) {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
} else if (phi1 <= 2.3e-7) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin(fma(t_0, (cos(phi1) * cos(phi2)), t_1)));
}
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.6e-6) tmp = Float64(R * acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))); elseif (phi1 <= 2.3e-7) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(fma(t_0, Float64(cos(phi1) * cos(phi2)), t_1)))); 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.6e-6], 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, 2.3e-7], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + 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[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] + t$95$1), $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.6 \cdot 10^{-6}:\\
\;\;\;\;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 2.3 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \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 \left(\pi \cdot 0.5 - \sin^{-1} \left(\mathsf{fma}\left(t\_0, \cos \phi_1 \cdot \cos \phi_2, t\_1\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -6.60000000000000034e-6Initial program 83.3%
Simplified83.4%
if -6.60000000000000034e-6 < phi1 < 2.29999999999999995e-7Initial program 72.7%
cos-diff92.4%
Applied egg-rr92.4%
cos-neg92.4%
*-commutative92.4%
fma-define92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
associate-*r*92.4%
fma-define92.4%
fma-define92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
if 2.29999999999999995e-7 < phi1 Initial program 76.2%
acos-asin76.1%
sub-neg76.1%
div-inv76.1%
metadata-eval76.1%
+-commutative76.1%
*-commutative76.1%
fma-define76.1%
Applied egg-rr76.1%
sub-neg76.1%
Simplified76.1%
Final simplification85.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -9.5e-10)
(* R (acos (+ t_1 (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= phi1 2.1e-8)
(*
R
(acos
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(*
R
(- (* PI 0.5) (asin (+ 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 <= -9.5e-10) {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 2.1e-8) {
tmp = R * acos((cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin((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 <= -9.5e-10) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); elseif (phi1 <= 2.1e-8) tmp = Float64(R * acos(Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_1 + Float64(cos(phi1) * Float64(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.5e-10], 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], If[LessEqual[phi1, 2.1e-8], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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 -9.5 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 2.1 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -9.50000000000000028e-10Initial program 83.3%
if -9.50000000000000028e-10 < phi1 < 2.09999999999999994e-8Initial program 72.7%
cos-diff92.4%
Applied egg-rr92.4%
cos-neg92.4%
*-commutative92.4%
fma-define92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
associate-*r*92.4%
fma-define92.4%
fma-define92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
fma-define92.5%
Simplified92.5%
if 2.09999999999999994e-8 < phi1 Initial program 76.2%
acos-asin76.1%
sub-neg76.1%
div-inv76.1%
metadata-eval76.1%
+-commutative76.1%
*-commutative76.1%
fma-define76.1%
Applied egg-rr76.1%
sub-neg76.1%
Simplified76.1%
Taylor expanded in lambda1 around 0 76.0%
Final simplification85.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* (cos phi2) (cos (- lambda1 lambda2)))))
(if (<= phi1 -2.9e-7)
(* R (acos (fma (cos phi1) t_1 t_0)))
(if (<= phi1 2.8e-10)
(*
R
(acos
(*
(cos phi2)
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2))))))
(* R (- (* PI 0.5) (asin (+ t_0 (* (cos phi1) t_1)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = cos(phi2) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -2.9e-7) {
tmp = R * acos(fma(cos(phi1), t_1, t_0));
} else if (phi1 <= 2.8e-10) {
tmp = R * acos((cos(phi2) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2)))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_0 + (cos(phi1) * t_1))));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -2.9e-7) tmp = Float64(R * acos(fma(cos(phi1), t_1, t_0))); elseif (phi1 <= 2.8e-10) tmp = Float64(R * acos(Float64(cos(phi2) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2)))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_0 + Float64(cos(phi1) * t_1))))); end return 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[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -2.9e-7], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.8e-10], N[(R * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2.9 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t\_1, t\_0\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 2.8 \cdot 10^{-10}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_0 + \cos \phi_1 \cdot t\_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -2.8999999999999998e-7Initial program 83.3%
Simplified83.4%
if -2.8999999999999998e-7 < phi1 < 2.80000000000000015e-10Initial program 72.7%
cos-diff92.4%
Applied egg-rr92.4%
cos-neg92.4%
*-commutative92.4%
fma-define92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
associate-*r*92.4%
fma-define92.4%
fma-define92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
fma-define92.5%
Simplified92.5%
if 2.80000000000000015e-10 < phi1 Initial program 76.2%
acos-asin76.1%
sub-neg76.1%
div-inv76.1%
metadata-eval76.1%
+-commutative76.1%
*-commutative76.1%
fma-define76.1%
Applied egg-rr76.1%
sub-neg76.1%
Simplified76.1%
Taylor expanded in lambda1 around 0 76.0%
Final simplification85.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi1 -3.6e-9)
(* R (acos (+ t_1 (* (* (cos phi1) (cos phi2)) t_0))))
(if (<= phi1 2e-11)
(*
R
(acos
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2))))))
(*
R
(- (* PI 0.5) (asin (+ 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 <= -3.6e-9) {
tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0)));
} else if (phi1 <= 2e-11) {
tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * ((((double) M_PI) * 0.5) - asin((t_1 + (cos(phi1) * (cos(phi2) * t_0)))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi1 <= -3.6e-9) {
tmp = R * Math.acos((t_1 + ((Math.cos(phi1) * Math.cos(phi2)) * t_0)));
} else if (phi1 <= 2e-11) {
tmp = R * Math.acos((Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else {
tmp = R * ((Math.PI * 0.5) - Math.asin((t_1 + (Math.cos(phi1) * (Math.cos(phi2) * t_0)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi1 <= -3.6e-9: tmp = R * math.acos((t_1 + ((math.cos(phi1) * math.cos(phi2)) * t_0))) elif phi1 <= 2e-11: tmp = R * math.acos((math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) else: tmp = R * ((math.pi * 0.5) - math.asin((t_1 + (math.cos(phi1) * (math.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 <= -3.6e-9) tmp = Float64(R * acos(Float64(t_1 + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); elseif (phi1 <= 2e-11) tmp = Float64(R * acos(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * Float64(Float64(pi * 0.5) - asin(Float64(t_1 + Float64(cos(phi1) * Float64(cos(phi2) * t_0)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi1 <= -3.6e-9) tmp = R * acos((t_1 + ((cos(phi1) * cos(phi2)) * t_0))); elseif (phi1 <= 2e-11) tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * ((pi * 0.5) - asin((t_1 + (cos(phi1) * (cos(phi2) * t_0))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -3.6e-9], 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], If[LessEqual[phi1, 2e-11], 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], N[(R * N[(N[(Pi * 0.5), $MachinePrecision] - N[ArcSin[N[(t$95$1 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $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 -3.6 \cdot 10^{-9}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 2 \cdot 10^{-11}:\\
\;\;\;\;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)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\pi \cdot 0.5 - \sin^{-1} \left(t\_1 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\\
\end{array}
\end{array}
if phi1 < -3.6e-9Initial program 83.3%
if -3.6e-9 < phi1 < 1.99999999999999988e-11Initial program 72.7%
cos-diff92.4%
Applied egg-rr92.4%
cos-neg92.4%
*-commutative92.4%
fma-define92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
associate-*r*92.4%
fma-define92.4%
fma-define92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
if 1.99999999999999988e-11 < phi1 Initial program 76.2%
acos-asin76.1%
sub-neg76.1%
div-inv76.1%
metadata-eval76.1%
+-commutative76.1%
*-commutative76.1%
fma-define76.1%
Applied egg-rr76.1%
sub-neg76.1%
Simplified76.1%
Taylor expanded in lambda1 around 0 76.0%
Final simplification85.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2)))
(t_1
(*
R
(acos
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(t_2 (* (sin phi1) (sin phi2))))
(if (<= lambda2 -0.000185)
t_1
(if (<= lambda2 1.3e-5)
(* R (acos (+ t_2 (* t_0 (cos lambda1)))))
(if (<= lambda2 8e+207)
(* R (acos (+ t_2 (* t_0 (cos lambda2)))))
t_1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(phi2);
double t_1 = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
double t_2 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= -0.000185) {
tmp = t_1;
} else if (lambda2 <= 1.3e-5) {
tmp = R * acos((t_2 + (t_0 * cos(lambda1))));
} else if (lambda2 <= 8e+207) {
tmp = R * acos((t_2 + (t_0 * cos(lambda2))));
} else {
tmp = t_1;
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = cos(phi1) * cos(phi2)
t_1 = r * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
t_2 = sin(phi1) * sin(phi2)
if (lambda2 <= (-0.000185d0)) then
tmp = t_1
else if (lambda2 <= 1.3d-5) then
tmp = r * acos((t_2 + (t_0 * cos(lambda1))))
else if (lambda2 <= 8d+207) then
tmp = r * acos((t_2 + (t_0 * cos(lambda2))))
else
tmp = t_1
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(phi2);
double t_1 = R * Math.acos((Math.cos(phi2) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
double t_2 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= -0.000185) {
tmp = t_1;
} else if (lambda2 <= 1.3e-5) {
tmp = R * Math.acos((t_2 + (t_0 * Math.cos(lambda1))));
} else if (lambda2 <= 8e+207) {
tmp = R * Math.acos((t_2 + (t_0 * Math.cos(lambda2))));
} else {
tmp = t_1;
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(phi2) t_1 = R * math.acos((math.cos(phi2) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) t_2 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= -0.000185: tmp = t_1 elif lambda2 <= 1.3e-5: tmp = R * math.acos((t_2 + (t_0 * math.cos(lambda1)))) elif lambda2 <= 8e+207: tmp = R * math.acos((t_2 + (t_0 * math.cos(lambda2)))) else: tmp = t_1 return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(R * acos(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))) t_2 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= -0.000185) tmp = t_1; elseif (lambda2 <= 1.3e-5) tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * cos(lambda1))))); elseif (lambda2 <= 8e+207) tmp = Float64(R * acos(Float64(t_2 + Float64(t_0 * cos(lambda2))))); else tmp = t_1; end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(phi2); t_1 = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); t_2 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= -0.000185) tmp = t_1; elseif (lambda2 <= 1.3e-5) tmp = R * acos((t_2 + (t_0 * cos(lambda1)))); elseif (lambda2 <= 8e+207) tmp = R * acos((t_2 + (t_0 * cos(lambda2)))); else tmp = t_1; 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[(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]}, Block[{t$95$2 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, -0.000185], t$95$1, If[LessEqual[lambda2, 1.3e-5], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 8e+207], N[(R * N[ArcCos[N[(t$95$2 + N[(t$95$0 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_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)\right)\\
t_2 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq -0.000185:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;\lambda_2 \leq 1.3 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\lambda_2 \leq 8 \cdot 10^{+207}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_2 + t\_0 \cdot \cos \lambda_2\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if lambda2 < -1.85e-4 or 8.0000000000000003e207 < lambda2 Initial program 59.0%
cos-diff99.0%
Applied egg-rr99.0%
cos-neg99.0%
*-commutative99.0%
fma-define99.1%
cos-neg99.1%
Simplified99.1%
Taylor expanded in phi1 around 0 99.0%
associate-*r*99.0%
fma-define99.0%
fma-define99.1%
Simplified99.1%
Taylor expanded in phi1 around 0 54.8%
if -1.85e-4 < lambda2 < 1.29999999999999992e-5Initial program 91.7%
Taylor expanded in lambda2 around 0 91.7%
if 1.29999999999999992e-5 < lambda2 < 8.0000000000000003e207Initial program 65.3%
Taylor expanded in lambda1 around 0 64.4%
cos-neg40.0%
Simplified64.4%
Final simplification74.5%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= phi1 -1.08e-8) (not (<= phi1 2.05e-10)))
(*
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 <= -1.08e-8) || !(phi1 <= 2.05e-10)) {
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 <= (-1.08d-8)) .or. (.not. (phi1 <= 2.05d-10))) 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 <= -1.08e-8) || !(phi1 <= 2.05e-10)) {
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 <= -1.08e-8) or not (phi1 <= 2.05e-10): 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 <= -1.08e-8) || !(phi1 <= 2.05e-10)) 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 <= -1.08e-8) || ~((phi1 <= 2.05e-10))) 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, -1.08e-8], N[Not[LessEqual[phi1, 2.05e-10]], $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 -1.08 \cdot 10^{-8} \lor \neg \left(\phi_1 \leq 2.05 \cdot 10^{-10}\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 < -1.0800000000000001e-8 or 2.0499999999999999e-10 < phi1 Initial program 79.4%
if -1.0800000000000001e-8 < phi1 < 2.0499999999999999e-10Initial program 72.7%
cos-diff92.4%
Applied egg-rr92.4%
cos-neg92.4%
*-commutative92.4%
fma-define92.5%
cos-neg92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
associate-*r*92.4%
fma-define92.4%
fma-define92.5%
Simplified92.5%
Taylor expanded in phi1 around 0 92.4%
Final simplification85.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (or (<= lambda2 -0.000185) (not (<= lambda2 2.45e-11)))
(*
R
(acos
(*
(cos phi2)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda1)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -0.000185) || !(lambda2 <= 2.45e-11)) {
tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((lambda2 <= (-0.000185d0)) .or. (.not. (lambda2 <= 2.45d-11))) then
tmp = r * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else
tmp = r * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((lambda2 <= -0.000185) || !(lambda2 <= 2.45e-11)) {
tmp = R * Math.acos((Math.cos(phi2) * ((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(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if (lambda2 <= -0.000185) or not (lambda2 <= 2.45e-11): tmp = R * math.acos((math.cos(phi2) * ((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(phi1) * math.cos(phi2)) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((lambda2 <= -0.000185) || !(lambda2 <= 2.45e-11)) tmp = Float64(R * acos(Float64(cos(phi2) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2)))))); else tmp = Float64(R * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if ((lambda2 <= -0.000185) || ~((lambda2 <= 2.45e-11))) tmp = R * acos((cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[Or[LessEqual[lambda2, -0.000185], N[Not[LessEqual[lambda2, 2.45e-11]], $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], N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -0.000185 \lor \neg \left(\lambda_2 \leq 2.45 \cdot 10^{-11}\right):\\
\;\;\;\;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)\\
\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 \lambda_1\right)\\
\end{array}
\end{array}
if lambda2 < -1.85e-4 or 2.4499999999999999e-11 < lambda2 Initial program 60.7%
cos-diff99.1%
Applied egg-rr99.1%
cos-neg99.1%
*-commutative99.1%
fma-define99.1%
cos-neg99.1%
Simplified99.1%
Taylor expanded in phi1 around 0 99.1%
associate-*r*99.1%
fma-define99.1%
fma-define99.1%
Simplified99.1%
Taylor expanded in phi1 around 0 60.1%
if -1.85e-4 < lambda2 < 2.4499999999999999e-11Initial program 92.3%
Taylor expanded in lambda2 around 0 92.3%
Final simplification75.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (or (<= phi1 -2850000000.0) (not (<= phi1 4e-16)))
(* R (acos (fma (cos phi1) t_0 (* (sin phi1) (sin phi2)))))
(* R (acos (+ (* phi1 (sin phi2)) (* (* (cos phi1) (cos phi2)) t_0)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((phi1 <= -2850000000.0) || !(phi1 <= 4e-16)) {
tmp = R * acos(fma(cos(phi1), t_0, (sin(phi1) * sin(phi2))));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + ((cos(phi1) * cos(phi2)) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda1 - lambda2)) tmp = 0.0 if ((phi1 <= -2850000000.0) || !(phi1 <= 4e-16)) tmp = Float64(R * acos(fma(cos(phi1), t_0, Float64(sin(phi1) * sin(phi2))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[Or[LessEqual[phi1, -2850000000.0], N[Not[LessEqual[phi1, 4e-16]], $MachinePrecision]], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -2850000000 \lor \neg \left(\phi_1 \leq 4 \cdot 10^{-16}\right):\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t\_0, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if phi1 < -2.85e9 or 3.9999999999999999e-16 < phi1 Initial program 79.4%
Simplified79.4%
Taylor expanded in phi2 around 0 45.3%
if -2.85e9 < phi1 < 3.9999999999999999e-16Initial program 72.7%
Taylor expanded in phi1 around 0 72.7%
Final simplification58.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi2 0.0019)
(*
R
(acos
(*
(cos phi1)
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2))))))
(*
R
(acos
(+
(* 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 (phi2 <= 0.0019) {
tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))));
} else {
tmp = R * acos(((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 (phi2 <= 0.0019d0) then
tmp = r * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2)))))
else
tmp = r * acos(((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 (phi2 <= 0.0019) {
tmp = R * Math.acos((Math.cos(phi1) * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2)))));
} else {
tmp = R * Math.acos(((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 phi2 <= 0.0019: tmp = R * math.acos((math.cos(phi1) * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2))))) else: tmp = R * math.acos(((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 (phi2 <= 0.0019) 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(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 (phi2 <= 0.0019) tmp = R * acos((cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))); else tmp = R * acos(((phi1 * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi2, 0.0019], 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[(phi1 * 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}\;\phi_2 \leq 0.0019:\\
\;\;\;\;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(\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 phi2 < 0.0019Initial program 77.6%
cos-diff94.7%
Applied egg-rr94.7%
cos-neg94.7%
*-commutative94.7%
fma-define94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in phi1 around 0 94.7%
associate-*r*94.7%
fma-define94.7%
fma-define94.7%
Simplified94.7%
Taylor expanded in phi2 around 0 64.7%
if 0.0019 < phi2 Initial program 71.9%
Taylor expanded in phi1 around 0 38.5%
Final simplification57.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (sin lambda1) (sin lambda2)) (* (cos lambda1) (cos lambda2)))))
(if (<= phi2 5.6e-5)
(* 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 <= 5.6e-5) {
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 <= 5.6d-5) 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 <= 5.6e-5) {
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 <= 5.6e-5: 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 <= 5.6e-5) 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 <= 5.6e-5) 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, 5.6e-5], 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 5.6 \cdot 10^{-5}:\\
\;\;\;\;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 < 5.59999999999999992e-5Initial program 77.6%
cos-diff94.7%
Applied egg-rr94.7%
cos-neg94.7%
*-commutative94.7%
fma-define94.7%
cos-neg94.7%
Simplified94.7%
Taylor expanded in phi1 around 0 94.7%
associate-*r*94.7%
fma-define94.7%
fma-define94.7%
Simplified94.7%
Taylor expanded in phi2 around 0 64.7%
if 5.59999999999999992e-5 < phi2 Initial program 71.9%
cos-diff99.2%
Applied egg-rr99.2%
cos-neg99.2%
*-commutative99.2%
fma-define99.2%
cos-neg99.2%
Simplified99.2%
Taylor expanded in phi1 around 0 99.1%
associate-*r*99.2%
fma-define99.1%
fma-define99.2%
Simplified99.2%
Taylor expanded in phi1 around 0 62.3%
Final simplification64.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
(if (<= phi1 -4e+32)
(* R (acos (+ t_0 (* phi2 (sin phi1)))))
(* R (acos (+ (* phi1 (sin phi2)) t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -4e+32) {
tmp = R * acos((t_0 + (phi2 * sin(phi1))));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + t_0));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))
if (phi1 <= (-4d+32)) then
tmp = r * acos((t_0 + (phi2 * sin(phi1))))
else
tmp = r * acos(((phi1 * sin(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(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -4e+32) {
tmp = R * Math.acos((t_0 + (phi2 * Math.sin(phi1))));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + t_0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)) tmp = 0 if phi1 <= -4e+32: tmp = R * math.acos((t_0 + (phi2 * math.sin(phi1)))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + t_0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -4e+32) tmp = Float64(R * acos(Float64(t_0 + Float64(phi2 * sin(phi1))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + t_0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = (cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)); tmp = 0.0; if (phi1 <= -4e+32) tmp = R * acos((t_0 + (phi2 * sin(phi1)))); else tmp = R * acos(((phi1 * sin(phi2)) + t_0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4e+32], N[(R * N[ArcCos[N[(t$95$0 + N[(phi2 * N[Sin[phi1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -4 \cdot 10^{+32}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \phi_2 \cdot \sin \phi_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + t\_0\right)\\
\end{array}
\end{array}
if phi1 < -4.00000000000000021e32Initial program 83.2%
Taylor expanded in phi2 around 0 33.9%
if -4.00000000000000021e32 < phi1 Initial program 74.2%
Taylor expanded in phi1 around 0 51.8%
Final simplification48.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R
(acos
(+
(* phi1 (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((phi1 * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((phi1 * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 76.1%
Taylor expanded in phi1 around 0 44.1%
Final simplification44.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.035)
(* R (acos (+ (* 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 <= -0.035) {
tmp = R * acos(((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 <= (-0.035d0)) then
tmp = r * acos(((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 <= -0.035) {
tmp = R * Math.acos(((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 <= -0.035: tmp = R * math.acos(((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 <= -0.035) tmp = Float64(R * acos(Float64(Float64(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 <= -0.035) tmp = R * acos(((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, -0.035], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(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 -0.035:\\
\;\;\;\;R \cdot \cos^{-1} \left(\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 < -0.035000000000000003Initial program 83.3%
Taylor expanded in phi1 around 0 17.4%
Taylor expanded in phi2 around 0 17.4%
Taylor expanded in phi2 around 0 17.4%
if -0.035000000000000003 < phi1 Initial program 74.0%
Taylor expanded in phi1 around 0 52.1%
Taylor expanded in phi1 around 0 47.5%
Final simplification40.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -1.76e-15) (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos (- lambda1 lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -1.76e-15) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * 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 (lambda1 <= (-1.76d-15)) then
tmp = r * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * 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 (lambda1 <= -1.76e-15) {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -1.76e-15: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -1.76e-15) tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -1.76e-15) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -1.76e-15], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -1.76 \cdot 10^{-15}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -1.76e-15Initial program 62.5%
Taylor expanded in phi1 around 0 31.9%
Taylor expanded in phi2 around 0 25.3%
Taylor expanded in lambda2 around 0 25.0%
if -1.76e-15 < lambda1 Initial program 80.6%
Taylor expanded in phi1 around 0 48.1%
Taylor expanded in phi2 around 0 29.5%
Taylor expanded in phi2 around 0 27.6%
Final simplification26.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* phi1 (sin phi2))))
(if (<= lambda2 7.7e-7)
(* R (acos (+ t_0 (* (cos phi1) (cos lambda1)))))
(* R (acos (+ t_0 (* (cos phi1) (cos lambda2))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * sin(phi2);
double tmp;
if (lambda2 <= 7.7e-7) {
tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = phi1 * sin(phi2)
if (lambda2 <= 7.7d-7) then
tmp = r * acos((t_0 + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((t_0 + (cos(phi1) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = phi1 * Math.sin(phi2);
double tmp;
if (lambda2 <= 7.7e-7) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = phi1 * math.sin(phi2) tmp = 0 if lambda2 <= 7.7e-7: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(phi1 * sin(phi2)) tmp = 0.0 if (lambda2 <= 7.7e-7) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = phi1 * sin(phi2); tmp = 0.0; if (lambda2 <= 7.7e-7) tmp = R * acos((t_0 + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((t_0 + (cos(phi1) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 7.7e-7], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 7.7 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 7.7000000000000004e-7Initial program 79.4%
Taylor expanded in phi1 around 0 42.6%
Taylor expanded in phi2 around 0 26.1%
Taylor expanded in lambda2 around 0 19.5%
if 7.7000000000000004e-7 < lambda2 Initial program 61.6%
Taylor expanded in phi1 around 0 50.7%
Taylor expanded in phi2 around 0 38.6%
Taylor expanded in lambda1 around 0 37.9%
cos-neg37.9%
Simplified37.9%
Final simplification22.9%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 (sin phi2)) (* (cos phi1) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi1) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi1) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 76.1%
Taylor expanded in phi1 around 0 44.1%
Taylor expanded in phi2 around 0 28.4%
Final simplification28.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.00013) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 phi2))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00013) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((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 <= (-0.00013d0)) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos((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 <= -0.00013) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * phi2)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00013: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * phi2))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00013) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(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 <= -0.00013) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * phi2))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00013], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00013:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -1.29999999999999989e-4Initial program 83.3%
Taylor expanded in phi1 around 0 17.4%
Taylor expanded in phi2 around 0 17.4%
Taylor expanded in phi2 around 0 17.4%
Taylor expanded in lambda2 around 0 10.4%
*-commutative10.4%
Simplified10.4%
if -1.29999999999999989e-4 < phi1 Initial program 74.0%
Taylor expanded in phi1 around 0 52.1%
Taylor expanded in phi2 around 0 31.7%
Taylor expanded in phi2 around 0 29.3%
Taylor expanded in phi1 around 0 24.8%
Final simplification21.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda2 2.45e-11) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda1))))) (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.45e-11) {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda2))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (lambda2 <= 2.45d-11) then
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1))))
else
tmp = r * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda2))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda2 <= 2.45e-11) {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos(lambda2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda2 <= 2.45e-11: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos(lambda2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda2 <= 2.45e-11) tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(lambda2))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda2 <= 2.45e-11) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda1)))); else tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos(lambda2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda2, 2.45e-11], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_2 \leq 2.45 \cdot 10^{-11}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda2 < 2.4499999999999999e-11Initial program 79.6%
Taylor expanded in phi1 around 0 42.8%
Taylor expanded in phi2 around 0 26.3%
Taylor expanded in phi2 around 0 24.6%
Taylor expanded in lambda2 around 0 18.5%
*-commutative18.5%
Simplified18.5%
if 2.4499999999999999e-11 < lambda2 Initial program 61.5%
Taylor expanded in phi1 around 0 49.8%
Taylor expanded in phi2 around 0 37.5%
Taylor expanded in phi2 around 0 35.1%
Taylor expanded in lambda1 around 0 34.5%
cos-neg34.5%
Simplified34.5%
Final simplification21.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (* phi1 phi2) (* (cos phi1) (cos (- lambda1 lambda2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2)))));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2)))))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(((phi1 * phi2) + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(((phi1 * phi2) + (math.cos(phi1) * math.cos((lambda1 - lambda2)))))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(Float64(phi1 * phi2) + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(((phi1 * phi2) + (cos(phi1) * cos((lambda1 - lambda2))))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[(phi1 * phi2), $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\phi_1 \cdot \phi_2 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)
\end{array}
Initial program 76.1%
Taylor expanded in phi1 around 0 44.1%
Taylor expanded in phi2 around 0 28.4%
Taylor expanded in phi2 around 0 26.6%
Final simplification26.6%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 phi2)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos((lambda1 - lambda2)) + (phi1 * phi2)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos((cos((lambda1 - lambda2)) + (phi1 * phi2)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * phi2)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * phi2)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(Float64(lambda1 - lambda2)) + Float64(phi1 * phi2)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * phi2))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)
\end{array}
Initial program 76.1%
Taylor expanded in phi1 around 0 44.1%
Taylor expanded in phi2 around 0 28.4%
Taylor expanded in phi2 around 0 26.6%
Taylor expanded in phi1 around 0 20.1%
Final simplification20.1%
herbie shell --seed 2024115
(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))