
(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 29 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
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= (+ t_1 (* (cos (- lambda1 lambda2)) t_0)) 1.0)
(*
(acos
(+
t_1
(*
t_0
(fma
(cos lambda1)
(cos lambda2)
(cbrt (pow (* (sin lambda1) (sin lambda2)) 3.0))))))
R)
(* R (fabs (remainder phi1 (* 2.0 PI)))))))
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 ((t_1 + (cos((lambda1 - lambda2)) * t_0)) <= 1.0) {
tmp = acos((t_1 + (t_0 * fma(cos(lambda1), cos(lambda2), cbrt(pow((sin(lambda1) * sin(lambda2)), 3.0)))))) * R;
} else {
tmp = R * fabs(remainder(phi1, (2.0 * ((double) M_PI))));
}
return tmp;
}
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[N[(t$95$1 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 1.0], N[(N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[Power[N[Power[N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision], 3.0], $MachinePrecision], 1/3], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision], N[(R * N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $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}\;t\_1 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_0 \leq 1:\\
\;\;\;\;\cos^{-1} \left(t\_1 + t\_0 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sqrt[3]{{\left(\sin \lambda_1 \cdot \sin \lambda_2\right)}^{3}}\right)\right) \cdot R\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\end{array}
\end{array}
if (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) < 1Initial program 73.0%
cos-diff92.0%
distribute-lft-in92.0%
Applied egg-rr92.0%
distribute-lft-out92.0%
*-commutative92.0%
fma-define92.0%
Simplified92.0%
add-cbrt-cube92.0%
pow392.0%
Applied egg-rr92.0%
if 1 < (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 17.4%
acos-cos15.8%
Applied egg-rr15.8%
Final simplification92.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= (+ t_1 (* (cos (- lambda1 lambda2)) t_0)) 1.0)
(*
R
(acos
(+
t_1
(*
t_0
(+
(* (cos lambda1) (cos lambda2))
(log1p (expm1 (* (sin lambda1) (sin lambda2)))))))))
(* R (fabs (remainder phi1 (* 2.0 PI)))))))
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 ((t_1 + (cos((lambda1 - lambda2)) * t_0)) <= 1.0) {
tmp = R * acos((t_1 + (t_0 * ((cos(lambda1) * cos(lambda2)) + log1p(expm1((sin(lambda1) * sin(lambda2))))))));
} else {
tmp = R * fabs(remainder(phi1, (2.0 * ((double) M_PI))));
}
return tmp;
}
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 ((t_1 + (Math.cos((lambda1 - lambda2)) * t_0)) <= 1.0) {
tmp = R * Math.acos((t_1 + (t_0 * ((Math.cos(lambda1) * Math.cos(lambda2)) + Math.log1p(Math.expm1((Math.sin(lambda1) * Math.sin(lambda2))))))));
} else {
tmp = R * Math.abs(Math.IEEEremainder(phi1, (2.0 * Math.PI)));
}
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 (t_1 + (math.cos((lambda1 - lambda2)) * t_0)) <= 1.0: tmp = R * math.acos((t_1 + (t_0 * ((math.cos(lambda1) * math.cos(lambda2)) + math.log1p(math.expm1((math.sin(lambda1) * math.sin(lambda2)))))))) else: tmp = R * math.fabs(math.remainder(phi1, (2.0 * math.pi))) return tmp
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[N[(t$95$1 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 1.0], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[(N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision] + N[Log[1 + N[(Exp[N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]] - 1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $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}\;t\_1 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_0 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \left(\cos \lambda_1 \cdot \cos \lambda_2 + \mathsf{log1p}\left(\mathsf{expm1}\left(\sin \lambda_1 \cdot \sin \lambda_2\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\end{array}
\end{array}
if (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) < 1Initial program 73.0%
cos-diff92.0%
distribute-lft-in92.0%
Applied egg-rr92.0%
distribute-lft-out92.0%
*-commutative92.0%
fma-define92.0%
Simplified92.0%
add-cbrt-cube92.0%
pow392.0%
Applied egg-rr92.0%
Taylor expanded in lambda1 around inf 92.0%
log1p-expm1-u92.0%
Applied egg-rr92.0%
if 1 < (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 17.4%
acos-cos15.8%
Applied egg-rr15.8%
Final simplification92.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= (+ t_1 (* (cos (- lambda1 lambda2)) t_0)) 1.0)
(*
R
(acos
(+
t_1
(*
t_0
(fma (cos lambda1) (cos lambda2) (* (sin lambda1) (sin lambda2)))))))
(* R (fabs (remainder phi1 (* 2.0 PI)))))))
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 ((t_1 + (cos((lambda1 - lambda2)) * t_0)) <= 1.0) {
tmp = R * acos((t_1 + (t_0 * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * fabs(remainder(phi1, (2.0 * ((double) M_PI))));
}
return tmp;
}
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[N[(t$95$1 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 1.0], N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $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}\;t\_1 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_0 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\end{array}
\end{array}
if (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) < 1Initial program 73.0%
cos-diff92.0%
distribute-lft-in92.0%
Applied egg-rr92.0%
distribute-lft-out92.0%
*-commutative92.0%
fma-define92.0%
Simplified92.0%
if 1 < (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 17.4%
acos-cos15.8%
Applied egg-rr15.8%
Final simplification92.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= (+ t_1 (* (cos (- lambda1 lambda2)) t_0)) 1.0)
(*
R
(acos
(+
t_1
(*
t_0
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (fabs (remainder phi1 (* 2.0 PI)))))))
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 ((t_1 + (cos((lambda1 - lambda2)) * t_0)) <= 1.0) {
tmp = R * acos((t_1 + (t_0 * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * fabs(remainder(phi1, (2.0 * ((double) M_PI))));
}
return tmp;
}
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 ((t_1 + (Math.cos((lambda1 - lambda2)) * t_0)) <= 1.0) {
tmp = R * Math.acos((t_1 + (t_0 * ((Math.sin(lambda1) * Math.sin(lambda2)) + (Math.cos(lambda1) * Math.cos(lambda2))))));
} else {
tmp = R * Math.abs(Math.IEEEremainder(phi1, (2.0 * Math.PI)));
}
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 (t_1 + (math.cos((lambda1 - lambda2)) * t_0)) <= 1.0: tmp = R * math.acos((t_1 + (t_0 * ((math.sin(lambda1) * math.sin(lambda2)) + (math.cos(lambda1) * math.cos(lambda2)))))) else: tmp = R * math.fabs(math.remainder(phi1, (2.0 * math.pi))) return tmp
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[N[(t$95$1 + N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision], 1.0], N[(R * N[ArcCos[N[(t$95$1 + N[(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]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $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}\;t\_1 + \cos \left(\lambda_1 - \lambda_2\right) \cdot t\_0 \leq 1:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \left(\sin \lambda_1 \cdot \sin \lambda_2 + \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\end{array}
\end{array}
if (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) < 1Initial program 73.0%
cos-diff92.0%
+-commutative92.0%
Applied egg-rr92.0%
if 1 < (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2)))) Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 17.4%
acos-cos15.8%
Applied egg-rr15.8%
Final simplification92.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<=
(*
R
(acos
(+ (* (sin phi1) (sin phi2)) (* t_0 (* (cos phi1) (cos phi2))))))
0.0)
(* R (fabs (remainder phi1 (* 2.0 PI))))
(*
R
(acos (fma (sin phi1) (sin phi2) (* (cos phi1) (* (cos phi2) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double tmp;
if ((R * acos(((sin(phi1) * sin(phi2)) + (t_0 * (cos(phi1) * cos(phi2)))))) <= 0.0) {
tmp = R * fabs(remainder(phi1, (2.0 * ((double) M_PI))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * (cos(phi2) * t_0))));
}
return tmp;
}
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(R * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0], N[(R * N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;R \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \leq 0:\\
\;\;\;\;R \cdot \left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_0\right)\right)\right)\\
\end{array}
\end{array}
if (*.f64 (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) R) < 0.0Initial program 67.6%
Simplified67.7%
Taylor expanded in lambda2 around 0 51.3%
Taylor expanded in phi2 around 0 27.6%
*-commutative27.6%
Simplified27.6%
Taylor expanded in lambda1 around 0 15.9%
acos-cos17.6%
Applied egg-rr17.6%
if 0.0 < (*.f64 (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) R) Initial program 78.8%
Simplified78.8%
Final simplification47.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= (* R (acos (+ t_1 (* t_0 (* (cos phi1) (cos phi2)))))) 0.0)
(* R (fabs (remainder phi1 (* 2.0 PI))))
(* R (acos (fma (cos phi1) (* (cos phi2) t_0) 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 ((R * acos((t_1 + (t_0 * (cos(phi1) * cos(phi2)))))) <= 0.0) {
tmp = R * fabs(remainder(phi1, (2.0 * ((double) M_PI))));
} else {
tmp = R * acos(fma(cos(phi1), (cos(phi2) * t_0), t_1));
}
return tmp;
}
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[N[(R * N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], 0.0], N[(R * N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $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}\;R \cdot \cos^{-1} \left(t\_1 + t\_0 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \leq 0:\\
\;\;\;\;R \cdot \left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
if (*.f64 (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) R) < 0.0Initial program 67.6%
Simplified67.7%
Taylor expanded in lambda2 around 0 51.3%
Taylor expanded in phi2 around 0 27.6%
*-commutative27.6%
Simplified27.6%
Taylor expanded in lambda1 around 0 15.9%
acos-cos17.6%
Applied egg-rr17.6%
if 0.0 < (*.f64 (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) R) Initial program 78.8%
Simplified78.8%
Final simplification47.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))) (t_1 (cos (- lambda1 lambda2))))
(if (<= (acos (+ t_0 (* t_1 (* (cos phi1) (cos phi2))))) 0.0)
(* R (fabs (remainder phi1 (* 2.0 PI))))
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) 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((lambda1 - lambda2));
double tmp;
if (acos((t_0 + (t_1 * (cos(phi1) * cos(phi2))))) <= 0.0) {
tmp = R * fabs(remainder(phi1, (2.0 * ((double) M_PI))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * t_1))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = Math.cos((lambda1 - lambda2));
double tmp;
if (Math.acos((t_0 + (t_1 * (Math.cos(phi1) * Math.cos(phi2))))) <= 0.0) {
tmp = R * Math.abs(Math.IEEEremainder(phi1, (2.0 * Math.PI)));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * t_1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = math.cos((lambda1 - lambda2)) tmp = 0 if math.acos((t_0 + (t_1 * (math.cos(phi1) * math.cos(phi2))))) <= 0.0: tmp = R * math.fabs(math.remainder(phi1, (2.0 * math.pi))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * t_1)))) return tmp
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[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[ArcCos[N[(t$95$0 + N[(t$95$1 * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision], 0.0], N[(R * N[Abs[N[With[{TMP1 = phi1, TMP2 = N[(2.0 * Pi), $MachinePrecision]}, TMP1 - Round[TMP1 / TMP2] * TMP2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $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 \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\cos^{-1} \left(t\_0 + t\_1 \cdot \left(\cos \phi_1 \cdot \cos \phi_2\right)\right) \leq 0:\\
\;\;\;\;R \cdot \left|\left(\phi_1 \mathsf{rem} \left(2 \cdot \pi\right)\right)\right|\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot t\_1\right)\right)\\
\end{array}
\end{array}
if (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) < 0.0Initial program 8.8%
Simplified8.8%
Taylor expanded in lambda2 around 0 8.8%
Taylor expanded in phi2 around 0 8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in lambda1 around 0 8.8%
acos-cos39.3%
Applied egg-rr39.3%
if 0.0 < (acos.f64 (+.f64 (*.f64 (sin.f64 phi1) (sin.f64 phi2)) (*.f64 (*.f64 (cos.f64 phi1) (cos.f64 phi2)) (cos.f64 (-.f64 lambda1 lambda2))))) Initial program 78.5%
Taylor expanded in phi1 around inf 78.5%
Final simplification75.4%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* (cos phi2) (cos (- lambda1 lambda2)))))
(if (<= phi2 -6.5e-7)
(* R (acos (fma (cos phi1) t_1 t_0)))
(if (<= phi2 4.7e-7)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(fma
(sin lambda1)
(sin lambda2)
(* (cos lambda1) (cos lambda2)))))))
(* R (acos (fma (sin phi1) (sin phi2) (* (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 (phi2 <= -6.5e-7) {
tmp = R * acos(fma(cos(phi1), t_1, t_0));
} else if (phi2 <= 4.7e-7) {
tmp = R * acos((t_0 + (cos(phi1) * fma(sin(lambda1), sin(lambda2), (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (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 (phi2 <= -6.5e-7) tmp = Float64(R * acos(fma(cos(phi1), t_1, t_0))); elseif (phi2 <= 4.7e-7) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * fma(sin(lambda1), sin(lambda2), Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), 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[phi2, -6.5e-7], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 4.7e-7], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision] + N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $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_2 \leq -6.5 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t\_1, t\_0\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 4.7 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \mathsf{fma}\left(\sin \lambda_1, \sin \lambda_2, \cos \lambda_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -6.50000000000000024e-7Initial program 81.2%
Simplified81.3%
if -6.50000000000000024e-7 < phi2 < 4.7e-7Initial program 63.7%
cos-diff84.4%
distribute-lft-in84.4%
Applied egg-rr84.4%
distribute-lft-out84.4%
*-commutative84.4%
fma-define84.4%
Simplified84.4%
add-cbrt-cube84.4%
pow384.4%
Applied egg-rr84.4%
Taylor expanded in lambda1 around inf 84.4%
Taylor expanded in phi2 around 0 84.4%
+-commutative84.4%
*-commutative84.4%
fma-define84.4%
Simplified84.4%
if 4.7e-7 < phi2 Initial program 82.0%
Simplified82.1%
Final simplification83.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* (cos phi2) (cos (- lambda1 lambda2)))))
(if (<= phi2 -5e-8)
(* R (acos (fma (cos phi1) t_1 t_0)))
(if (<= phi2 1.9e-7)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(fma
(cos lambda1)
(cos lambda2)
(* (sin lambda1) (sin lambda2)))))))
(* R (acos (fma (sin phi1) (sin phi2) (* (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 (phi2 <= -5e-8) {
tmp = R * acos(fma(cos(phi1), t_1, t_0));
} else if (phi2 <= 1.9e-7) {
tmp = R * acos((t_0 + (cos(phi1) * fma(cos(lambda1), cos(lambda2), (sin(lambda1) * sin(lambda2))))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (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 (phi2 <= -5e-8) tmp = Float64(R * acos(fma(cos(phi1), t_1, t_0))); elseif (phi2 <= 1.9e-7) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * fma(cos(lambda1), cos(lambda2), Float64(sin(lambda1) * sin(lambda2))))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), 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[phi2, -5e-8], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 1.9e-7], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[lambda1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision] + N[(N[Sin[lambda1], $MachinePrecision] * N[Sin[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $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_2 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t\_1, t\_0\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 1.9 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \mathsf{fma}\left(\cos \lambda_1, \cos \lambda_2, \sin \lambda_1 \cdot \sin \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -4.9999999999999998e-8Initial program 81.2%
Simplified81.3%
if -4.9999999999999998e-8 < phi2 < 1.90000000000000007e-7Initial program 63.7%
cos-diff84.4%
distribute-lft-in84.4%
Applied egg-rr84.4%
distribute-lft-out84.4%
*-commutative84.4%
fma-define84.4%
Simplified84.4%
Taylor expanded in phi2 around 0 84.4%
fma-define84.4%
Simplified84.4%
if 1.90000000000000007e-7 < phi2 Initial program 82.0%
Simplified82.1%
Final simplification83.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1 (* (cos phi2) (cos (- lambda1 lambda2)))))
(if (<= phi2 -1e-6)
(* R (acos (fma (cos phi1) t_1 t_0)))
(if (<= phi2 3e-7)
(*
R
(acos
(+
t_0
(*
(cos phi1)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (acos (fma (sin phi1) (sin phi2) (* (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 (phi2 <= -1e-6) {
tmp = R * acos(fma(cos(phi1), t_1, t_0));
} else if (phi2 <= 3e-7) {
tmp = R * acos((t_0 + (cos(phi1) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (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 (phi2 <= -1e-6) tmp = Float64(R * acos(fma(cos(phi1), t_1, t_0))); elseif (phi2 <= 3e-7) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(Float64(sin(lambda1) * sin(lambda2)) + Float64(cos(lambda1) * cos(lambda2))))))); else tmp = Float64(R * acos(fma(sin(phi1), sin(phi2), 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[phi2, -1e-6], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1 + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 3e-7], N[(R * N[ArcCos[N[(t$95$0 + 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]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $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_2 \leq -1 \cdot 10^{-6}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t\_1, t\_0\right)\right)\\
\mathbf{elif}\;\phi_2 \leq 3 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \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(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot t\_1\right)\right)\\
\end{array}
\end{array}
if phi2 < -9.99999999999999955e-7Initial program 81.2%
Simplified81.3%
if -9.99999999999999955e-7 < phi2 < 2.9999999999999999e-7Initial program 63.7%
cos-diff84.4%
distribute-lft-in84.4%
Applied egg-rr84.4%
distribute-lft-out84.4%
*-commutative84.4%
fma-define84.4%
Simplified84.4%
Taylor expanded in phi2 around 0 84.4%
if 2.9999999999999999e-7 < phi2 Initial program 82.0%
Simplified82.1%
Final simplification83.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi2) (cos (- lambda1 lambda2)))))
(if (<= phi1 -8.2e-7)
(* R (acos (fma (cos phi1) t_0 (* (sin phi1) (sin phi2)))))
(if (<= phi1 5e-69)
(*
R
(acos
(+
(* phi1 (sin phi2))
(*
(cos phi2)
(+
(* (sin lambda1) (sin lambda2))
(* (cos lambda1) (cos lambda2)))))))
(* R (acos (fma (sin phi1) (sin phi2) (* (cos phi1) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi2) * cos((lambda1 - lambda2));
double tmp;
if (phi1 <= -8.2e-7) {
tmp = R * acos(fma(cos(phi1), t_0, (sin(phi1) * sin(phi2))));
} else if (phi1 <= 5e-69) {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * ((sin(lambda1) * sin(lambda2)) + (cos(lambda1) * cos(lambda2))))));
} else {
tmp = R * acos(fma(sin(phi1), sin(phi2), (cos(phi1) * t_0)));
}
return tmp;
}
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) tmp = 0.0 if (phi1 <= -8.2e-7) tmp = Float64(R * acos(fma(cos(phi1), t_0, Float64(sin(phi1) * sin(phi2))))); elseif (phi1 <= 5e-69) 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 * acos(fma(sin(phi1), sin(phi2), Float64(cos(phi1) * t_0)))); end return tmp end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -8.2e-7], 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], If[LessEqual[phi1, 5e-69], 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[ArcCos[N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision] + N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\\
\mathbf{if}\;\phi_1 \leq -8.2 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, t\_0, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 5 \cdot 10^{-69}:\\
\;\;\;\;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 \cos^{-1} \left(\mathsf{fma}\left(\sin \phi_1, \sin \phi_2, \cos \phi_1 \cdot t\_0\right)\right)\\
\end{array}
\end{array}
if phi1 < -8.1999999999999998e-7Initial program 75.9%
Simplified75.9%
if -8.1999999999999998e-7 < phi1 < 5.00000000000000033e-69Initial program 66.5%
Simplified66.5%
Taylor expanded in phi1 around 0 66.5%
cos-diff84.6%
+-commutative84.6%
Applied egg-rr84.6%
if 5.00000000000000033e-69 < phi1 Initial program 80.4%
Simplified80.5%
Final simplification81.0%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda1 -1.85e-7)
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda1))))))
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda1 <= -1.85e-7) {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))));
} else {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))));
}
return tmp;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (lambda1 <= (-1.85d-7)) then
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))))
else
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2)))))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda1 <= -1.85e-7) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda1 <= -1.85e-7: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda1 <= -1.85e-7) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda1 <= -1.85e-7) tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1))))); else tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda1, -1.85e-7], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_1 \leq -1.85 \cdot 10^{-7}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda1 < -1.85000000000000002e-7Initial program 60.2%
cos-diff99.1%
distribute-lft-in99.2%
Applied egg-rr99.2%
distribute-lft-out99.1%
*-commutative99.1%
fma-define99.2%
Simplified99.2%
add-cbrt-cube99.2%
pow399.2%
Applied egg-rr99.2%
Taylor expanded in lambda2 around 0 60.0%
associate-*r*60.0%
*-commutative60.0%
associate-*l*60.0%
Simplified60.0%
if -1.85000000000000002e-7 < lambda1 Initial program 77.4%
Taylor expanded in lambda1 around 0 59.5%
cos-neg59.5%
Simplified59.5%
Final simplification59.6%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(if (<= lambda2 20000000000.0)
(* R (acos (+ t_0 (* (cos phi1) (* (cos phi2) (cos lambda1))))))
(* R (acos (+ t_0 (* (cos phi1) (cos (- lambda1 lambda2)))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (lambda2 <= 20000000000.0) {
tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))));
} else {
tmp = R * acos((t_0 + (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) :: t_0
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
if (lambda2 <= 20000000000.0d0) then
tmp = r * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1)))))
else
tmp = r * acos((t_0 + (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 t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (lambda2 <= 20000000000.0) {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * Math.cos(lambda1)))));
} else {
tmp = R * Math.acos((t_0 + (Math.cos(phi1) * Math.cos((lambda1 - lambda2)))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if lambda2 <= 20000000000.0: tmp = R * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * math.cos(lambda1))))) else: tmp = R * math.acos((t_0 + (math.cos(phi1) * math.cos((lambda1 - lambda2))))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (lambda2 <= 20000000000.0) tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * cos(lambda1)))))); else tmp = Float64(R * acos(Float64(t_0 + Float64(cos(phi1) * cos(Float64(lambda1 - lambda2)))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = sin(phi1) * sin(phi2); tmp = 0.0; if (lambda2 <= 20000000000.0) tmp = R * acos((t_0 + (cos(phi1) * (cos(phi2) * cos(lambda1))))); else tmp = R * acos((t_0 + (cos(phi1) * cos((lambda1 - lambda2))))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[lambda2, 20000000000.0], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\lambda_2 \leq 20000000000:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if lambda2 < 2e10Initial program 77.1%
cos-diff90.2%
distribute-lft-in90.2%
Applied egg-rr90.2%
distribute-lft-out90.2%
*-commutative90.2%
fma-define90.2%
Simplified90.2%
add-cbrt-cube90.2%
pow390.2%
Applied egg-rr90.2%
Taylor expanded in lambda2 around 0 64.6%
associate-*r*64.6%
*-commutative64.6%
associate-*l*64.6%
Simplified64.6%
if 2e10 < lambda2 Initial program 57.2%
Taylor expanded in phi2 around 0 35.3%
*-commutative35.3%
Simplified35.3%
Final simplification58.5%
(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.2e+269)
t_0
(if (<= phi1 -0.0001)
(* R (acos (+ (* (cos phi1) t_1) (* (sin phi1) phi2))))
(if (<= phi1 2.55e-8)
(* 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.2e+269) {
tmp = t_0;
} else if (phi1 <= -0.0001) {
tmp = R * acos(((cos(phi1) * t_1) + (sin(phi1) * phi2)));
} else if (phi1 <= 2.55e-8) {
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.2d+269)) then
tmp = t_0
else if (phi1 <= (-0.0001d0)) then
tmp = r * acos(((cos(phi1) * t_1) + (sin(phi1) * phi2)))
else if (phi1 <= 2.55d-8) 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.2e+269) {
tmp = t_0;
} else if (phi1 <= -0.0001) {
tmp = R * Math.acos(((Math.cos(phi1) * t_1) + (Math.sin(phi1) * phi2)));
} else if (phi1 <= 2.55e-8) {
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.2e+269: tmp = t_0 elif phi1 <= -0.0001: tmp = R * math.acos(((math.cos(phi1) * t_1) + (math.sin(phi1) * phi2))) elif phi1 <= 2.55e-8: 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.2e+269) tmp = t_0; elseif (phi1 <= -0.0001) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * t_1) + Float64(sin(phi1) * phi2)))); elseif (phi1 <= 2.55e-8) 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.2e+269) tmp = t_0; elseif (phi1 <= -0.0001) tmp = R * acos(((cos(phi1) * t_1) + (sin(phi1) * phi2))); elseif (phi1 <= 2.55e-8) 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.2e+269], t$95$0, If[LessEqual[phi1, -0.0001], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 2.55e-8], 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.2 \cdot 10^{+269}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;\phi_1 \leq -0.0001:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_1 + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{elif}\;\phi_1 \leq 2.55 \cdot 10^{-8}:\\
\;\;\;\;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.1999999999999999e269 or 2.55e-8 < phi1 Initial program 80.1%
Simplified80.3%
Taylor expanded in lambda2 around 0 61.5%
Taylor expanded in lambda1 around 0 39.4%
if -3.1999999999999999e269 < phi1 < -1.00000000000000005e-4Initial program 77.8%
Simplified77.8%
Taylor expanded in phi2 around 0 39.5%
if -1.00000000000000005e-4 < phi1 < 2.55e-8Initial program 66.5%
Simplified66.5%
Taylor expanded in phi1 around 0 66.2%
Final simplification52.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 -0.0275)
(* R (acos (+ t_1 (* (cos phi1) (cos phi2)))))
(if (<= phi2 0.0074)
(* R (acos (+ (* (cos phi1) t_0) (* (sin phi1) phi2))))
(* R (acos (+ t_1 (* (cos phi2) t_0))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= -0.0275) {
tmp = R * acos((t_1 + (cos(phi1) * cos(phi2))));
} else if (phi2 <= 0.0074) {
tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)));
} 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((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi2 <= (-0.0275d0)) then
tmp = r * acos((t_1 + (cos(phi1) * cos(phi2))))
else if (phi2 <= 0.0074d0) then
tmp = r * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)))
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((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= -0.0275) {
tmp = R * Math.acos((t_1 + (Math.cos(phi1) * Math.cos(phi2))));
} else if (phi2 <= 0.0074) {
tmp = R * Math.acos(((Math.cos(phi1) * t_0) + (Math.sin(phi1) * phi2)));
} 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((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= -0.0275: tmp = R * math.acos((t_1 + (math.cos(phi1) * math.cos(phi2)))) elif phi2 <= 0.0074: tmp = R * math.acos(((math.cos(phi1) * t_0) + (math.sin(phi1) * phi2))) 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(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= -0.0275) tmp = Float64(R * acos(Float64(t_1 + Float64(cos(phi1) * cos(phi2))))); elseif (phi2 <= 0.0074) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * t_0) + Float64(sin(phi1) * phi2)))); 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((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= -0.0275) tmp = R * acos((t_1 + (cos(phi1) * cos(phi2)))); elseif (phi2 <= 0.0074) tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2))); 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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, -0.0275], 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.0074], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $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_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq -0.0275:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_1 \cdot \cos \phi_2\right)\\
\mathbf{elif}\;\phi_2 \leq 0.0074:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0 + \sin \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(t\_1 + \cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
if phi2 < -0.0275000000000000001Initial program 81.0%
Simplified81.0%
Taylor expanded in lambda2 around 0 60.2%
Taylor expanded in lambda1 around 0 37.8%
if -0.0275000000000000001 < phi2 < 0.0074000000000000003Initial program 64.3%
Simplified64.3%
Taylor expanded in phi2 around 0 63.8%
if 0.0074000000000000003 < phi2 Initial program 81.7%
Taylor expanded in phi1 around 0 51.8%
Final simplification54.2%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))) (t_1 (* (sin phi1) (sin phi2))))
(if (<= phi2 1380.0)
(* 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((lambda1 - lambda2));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi2 <= 1380.0) {
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((lambda1 - lambda2))
t_1 = sin(phi1) * sin(phi2)
if (phi2 <= 1380.0d0) 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((lambda1 - lambda2));
double t_1 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if (phi2 <= 1380.0) {
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((lambda1 - lambda2)) t_1 = math.sin(phi1) * math.sin(phi2) tmp = 0 if phi2 <= 1380.0: 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(lambda1 - lambda2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi2 <= 1380.0) 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((lambda1 - lambda2)); t_1 = sin(phi1) * sin(phi2); tmp = 0.0; if (phi2 <= 1380.0) 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[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi2, 1380.0], 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_1 - \lambda_2\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
\mathbf{if}\;\phi_2 \leq 1380:\\
\;\;\;\;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 < 1380Initial program 70.0%
Taylor expanded in phi2 around 0 47.4%
*-commutative47.4%
Simplified47.4%
if 1380 < phi2 Initial program 82.2%
Taylor expanded in phi1 around 0 53.4%
Final simplification48.9%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -3.1e-22)
(* R (- (/ PI 2.0) (asin (* (cos phi1) (cos lambda1)))))
(if (<= phi1 4.8e-208)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos (+ (* phi1 (sin phi2)) (* (cos phi2) (cos lambda1))))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -3.1e-22) {
tmp = R * ((((double) M_PI) / 2.0) - asin((cos(phi1) * cos(lambda1))));
} else if (phi1 <= 4.8e-208) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -3.1e-22) {
tmp = R * ((Math.PI / 2.0) - Math.asin((Math.cos(phi1) * Math.cos(lambda1))));
} else if (phi1 <= 4.8e-208) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(((phi1 * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos(lambda1))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -3.1e-22: tmp = R * ((math.pi / 2.0) - math.asin((math.cos(phi1) * math.cos(lambda1)))) elif phi1 <= 4.8e-208: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos(((phi1 * math.sin(phi2)) + (math.cos(phi2) * math.cos(lambda1)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -3.1e-22) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(Float64(cos(phi1) * cos(lambda1))))); elseif (phi1 <= 4.8e-208) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(Float64(phi1 * sin(phi2)) + Float64(cos(phi2) * cos(lambda1))))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -3.1e-22) tmp = R * ((pi / 2.0) - asin((cos(phi1) * cos(lambda1)))); elseif (phi1 <= 4.8e-208) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); else tmp = R * acos(((phi1 * sin(phi2)) + (cos(phi2) * cos(lambda1)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -3.1e-22], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4.8e-208], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-22}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 4.8 \cdot 10^{-208}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \lambda_1\right)\\
\end{array}
\end{array}
if phi1 < -3.10000000000000013e-22Initial program 73.6%
Simplified73.6%
Taylor expanded in lambda2 around 0 59.3%
Taylor expanded in phi2 around 0 39.3%
*-commutative39.3%
Simplified39.3%
acos-asin39.3%
Applied egg-rr39.3%
if -3.10000000000000013e-22 < phi1 < 4.7999999999999998e-208Initial program 68.0%
Simplified68.0%
Taylor expanded in phi1 around 0 68.0%
Taylor expanded in phi2 around 0 51.9%
if 4.7999999999999998e-208 < phi1 Initial program 76.4%
Simplified76.4%
Taylor expanded in phi1 around 0 28.5%
Taylor expanded in lambda2 around 0 24.1%
Final simplification37.1%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda1 lambda2))))
(if (<= phi1 -0.00019)
(* R (acos (+ (* (cos phi1) t_0) (* (sin phi1) phi2))))
(* 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.00019) {
tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)));
} 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.00019d0)) then
tmp = r * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2)))
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.00019) {
tmp = R * Math.acos(((Math.cos(phi1) * t_0) + (Math.sin(phi1) * phi2)));
} 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.00019: tmp = R * math.acos(((math.cos(phi1) * t_0) + (math.sin(phi1) * phi2))) 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.00019) tmp = Float64(R * acos(Float64(Float64(cos(phi1) * t_0) + Float64(sin(phi1) * phi2)))); 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.00019) tmp = R * acos(((cos(phi1) * t_0) + (sin(phi1) * phi2))); 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.00019], N[(R * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * phi2), $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.00019:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0 + \sin \phi_1 \cdot \phi_2\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 < -1.9000000000000001e-4Initial program 75.6%
Simplified75.6%
Taylor expanded in phi2 around 0 39.0%
if -1.9000000000000001e-4 < phi1 Initial program 72.0%
Simplified72.0%
Taylor expanded in phi1 around 0 45.5%
Final simplification43.7%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -0.01)
(* R (- (/ PI 2.0) (asin (* (cos phi1) (cos 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 <= -0.01) {
tmp = R * ((((double) M_PI) / 2.0) - asin((cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * sin(phi2))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.01) {
tmp = R * ((Math.PI / 2.0) - Math.asin((Math.cos(phi1) * Math.cos(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 <= -0.01: tmp = R * ((math.pi / 2.0) - math.asin((math.cos(phi1) * math.cos(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 <= -0.01) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(Float64(cos(phi1) * cos(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 <= -0.01) tmp = R * ((pi / 2.0) - asin((cos(phi1) * cos(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, -0.01], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.01:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\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 < -0.0100000000000000002Initial program 75.6%
Simplified75.6%
Taylor expanded in lambda2 around 0 61.4%
Taylor expanded in phi2 around 0 41.2%
*-commutative41.2%
Simplified41.2%
acos-asin41.2%
Applied egg-rr41.2%
if -0.0100000000000000002 < phi1 Initial program 72.0%
Simplified72.0%
Taylor expanded in phi1 around 0 45.5%
Final simplification44.3%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(if (<= phi1 -3.3e-21)
(* R (- (/ PI 2.0) (asin (* (cos phi1) (cos lambda1)))))
(if (<= phi1 1.35e-207)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos (/ (+ (cos (+ phi1 lambda1)) (cos (- phi1 lambda1))) 2.0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -3.3e-21) {
tmp = R * ((((double) M_PI) / 2.0) - asin((cos(phi1) * cos(lambda1))));
} else if (phi1 <= 1.35e-207) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos(((cos((phi1 + lambda1)) + cos((phi1 - lambda1))) / 2.0));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -3.3e-21) {
tmp = R * ((Math.PI / 2.0) - Math.asin((Math.cos(phi1) * Math.cos(lambda1))));
} else if (phi1 <= 1.35e-207) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(((Math.cos((phi1 + lambda1)) + Math.cos((phi1 - lambda1))) / 2.0));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -3.3e-21: tmp = R * ((math.pi / 2.0) - math.asin((math.cos(phi1) * math.cos(lambda1)))) elif phi1 <= 1.35e-207: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos(((math.cos((phi1 + lambda1)) + math.cos((phi1 - lambda1))) / 2.0)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -3.3e-21) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(Float64(cos(phi1) * cos(lambda1))))); elseif (phi1 <= 1.35e-207) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(Float64(Float64(cos(Float64(phi1 + lambda1)) + cos(Float64(phi1 - lambda1))) / 2.0))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (phi1 <= -3.3e-21) tmp = R * ((pi / 2.0) - asin((cos(phi1) * cos(lambda1)))); elseif (phi1 <= 1.35e-207) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); else tmp = R * acos(((cos((phi1 + lambda1)) + cos((phi1 - lambda1))) / 2.0)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -3.3e-21], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.35e-207], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[(N[Cos[N[(phi1 + lambda1), $MachinePrecision]], $MachinePrecision] + N[Cos[N[(phi1 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.3 \cdot 10^{-21}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 1.35 \cdot 10^{-207}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\frac{\cos \left(\phi_1 + \lambda_1\right) + \cos \left(\phi_1 - \lambda_1\right)}{2}\right)\\
\end{array}
\end{array}
if phi1 < -3.30000000000000009e-21Initial program 73.6%
Simplified73.6%
Taylor expanded in lambda2 around 0 59.3%
Taylor expanded in phi2 around 0 39.3%
*-commutative39.3%
Simplified39.3%
acos-asin39.3%
Applied egg-rr39.3%
if -3.30000000000000009e-21 < phi1 < 1.35e-207Initial program 68.0%
Simplified68.0%
Taylor expanded in phi1 around 0 68.0%
Taylor expanded in phi2 around 0 51.9%
if 1.35e-207 < phi1 Initial program 76.4%
Simplified76.5%
Taylor expanded in lambda2 around 0 60.8%
Taylor expanded in phi2 around 0 32.5%
*-commutative32.5%
Simplified32.5%
cos-mult25.8%
Applied egg-rr25.8%
Final simplification37.8%
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos lambda1))))
(if (<= phi1 -4.2e-21)
(* R (- (/ PI 2.0) (asin t_0)))
(if (<= phi1 1.35e-207)
(* R (acos (+ (* (cos phi2) (cos (- lambda1 lambda2))) (* phi1 phi2))))
(* R (acos t_0))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos(phi1) * cos(lambda1);
double tmp;
if (phi1 <= -4.2e-21) {
tmp = R * ((((double) M_PI) / 2.0) - asin(t_0));
} else if (phi1 <= 1.35e-207) {
tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * acos(t_0);
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos(phi1) * Math.cos(lambda1);
double tmp;
if (phi1 <= -4.2e-21) {
tmp = R * ((Math.PI / 2.0) - Math.asin(t_0));
} else if (phi1 <= 1.35e-207) {
tmp = R * Math.acos(((Math.cos(phi2) * Math.cos((lambda1 - lambda2))) + (phi1 * phi2)));
} else {
tmp = R * Math.acos(t_0);
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): t_0 = math.cos(phi1) * math.cos(lambda1) tmp = 0 if phi1 <= -4.2e-21: tmp = R * ((math.pi / 2.0) - math.asin(t_0)) elif phi1 <= 1.35e-207: tmp = R * math.acos(((math.cos(phi2) * math.cos((lambda1 - lambda2))) + (phi1 * phi2))) else: tmp = R * math.acos(t_0) return tmp
function code(R, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(lambda1)) tmp = 0.0 if (phi1 <= -4.2e-21) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(t_0))); elseif (phi1 <= 1.35e-207) tmp = Float64(R * acos(Float64(Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))) + Float64(phi1 * phi2)))); else tmp = Float64(R * acos(t_0)); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) t_0 = cos(phi1) * cos(lambda1); tmp = 0.0; if (phi1 <= -4.2e-21) tmp = R * ((pi / 2.0) - asin(t_0)); elseif (phi1 <= 1.35e-207) tmp = R * acos(((cos(phi2) * cos((lambda1 - lambda2))) + (phi1 * phi2))); else tmp = R * acos(t_0); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[phi1, -4.2e-21], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[t$95$0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 1.35e-207], N[(R * N[ArcCos[N[(N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + N[(phi1 * phi2), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[t$95$0], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \lambda_1\\
\mathbf{if}\;\phi_1 \leq -4.2 \cdot 10^{-21}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} t\_0\right)\\
\mathbf{elif}\;\phi_1 \leq 1.35 \cdot 10^{-207}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \phi_2\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} t\_0\\
\end{array}
\end{array}
if phi1 < -4.20000000000000025e-21Initial program 73.6%
Simplified73.6%
Taylor expanded in lambda2 around 0 59.3%
Taylor expanded in phi2 around 0 39.3%
*-commutative39.3%
Simplified39.3%
acos-asin39.3%
Applied egg-rr39.3%
if -4.20000000000000025e-21 < phi1 < 1.35e-207Initial program 68.0%
Simplified68.0%
Taylor expanded in phi1 around 0 68.0%
Taylor expanded in phi2 around 0 51.9%
if 1.35e-207 < phi1 Initial program 76.4%
Simplified76.5%
Taylor expanded in lambda2 around 0 60.8%
Taylor expanded in phi2 around 0 32.5%
*-commutative32.5%
Simplified32.5%
Final simplification40.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.00021) (* R (- (/ PI 2.0) (asin (* (cos phi1) (cos lambda1))))) (* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00021) {
tmp = R * ((((double) M_PI) / 2.0) - asin((cos(phi1) * cos(lambda1))));
} else {
tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2))));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00021) {
tmp = R * ((Math.PI / 2.0) - Math.asin((Math.cos(phi1) * Math.cos(lambda1))));
} else {
tmp = R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00021: tmp = R * ((math.pi / 2.0) - math.asin((math.cos(phi1) * math.cos(lambda1)))) else: tmp = R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00021) tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(Float64(cos(phi1) * cos(lambda1))))); else tmp = Float64(R * acos(Float64(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 <= -0.00021) tmp = R * ((pi / 2.0) - asin((cos(phi1) * cos(lambda1)))); else tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00021], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[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 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00021:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \left(\cos \left(\lambda_1 - \lambda_2\right) + \phi_1 \cdot \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -2.1000000000000001e-4Initial program 75.6%
Simplified75.6%
Taylor expanded in lambda2 around 0 61.4%
Taylor expanded in phi2 around 0 41.2%
*-commutative41.2%
Simplified41.2%
acos-asin41.2%
Applied egg-rr41.2%
if -2.1000000000000001e-4 < phi1 Initial program 72.0%
Simplified72.0%
Taylor expanded in phi1 around 0 45.5%
Taylor expanded in phi2 around 0 22.8%
Final simplification28.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= phi1 -0.00042) (* R (acos (* (cos phi1) (cos lambda1)))) (* R (acos (+ (cos (- lambda1 lambda2)) (* phi1 (sin phi2)))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi1 <= -0.00042) {
tmp = R * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R * acos((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 <= (-0.00042d0)) then
tmp = r * acos((cos(phi1) * cos(lambda1)))
else
tmp = r * acos((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 <= -0.00042) {
tmp = R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R * Math.acos((Math.cos((lambda1 - lambda2)) + (phi1 * Math.sin(phi2))));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if phi1 <= -0.00042: tmp = R * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R * math.acos((math.cos((lambda1 - lambda2)) + (phi1 * math.sin(phi2)))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi1 <= -0.00042) tmp = Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R * acos(Float64(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 <= -0.00042) tmp = R * acos((cos(phi1) * cos(lambda1))); else tmp = R * acos((cos((lambda1 - lambda2)) + (phi1 * sin(phi2)))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[phi1, -0.00042], N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[(N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision] + N[(phi1 * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\phi_1 \leq -0.00042:\\
\;\;\;\;R \cdot \cos^{-1} \left(\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 \sin \phi_2\right)\\
\end{array}
\end{array}
if phi1 < -4.2000000000000002e-4Initial program 75.6%
Simplified75.6%
Taylor expanded in lambda2 around 0 61.4%
Taylor expanded in phi2 around 0 41.2%
*-commutative41.2%
Simplified41.2%
if -4.2000000000000002e-4 < phi1 Initial program 72.0%
Simplified72.0%
Taylor expanded in phi1 around 0 45.5%
Taylor expanded in phi2 around 0 22.8%
Final simplification28.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (* (cos phi1) (cos lambda1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos((cos(phi1) * cos(lambda1)));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos((cos(phi1) * cos(lambda1)))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos((math.cos(phi1) * math.cos(lambda1)))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(Float64(cos(phi1) * cos(lambda1)))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos((cos(phi1) * cos(lambda1))); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)
\end{array}
Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Final simplification30.8%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -4.5e-5) (* R (acos (cos lambda1))) (* R (- (/ PI 2.0) (asin (cos phi1))))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -4.5e-5) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * ((((double) M_PI) / 2.0) - asin(cos(phi1)));
}
return tmp;
}
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -4.5e-5) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * ((Math.PI / 2.0) - Math.asin(Math.cos(phi1)));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -4.5e-5: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * ((math.pi / 2.0) - math.asin(math.cos(phi1))) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -4.5e-5) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * Float64(Float64(pi / 2.0) - asin(cos(phi1)))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -4.5e-5) tmp = R * acos(cos(lambda1)); else tmp = R * ((pi / 2.0) - asin(cos(phi1))); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -4.5e-5], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[(N[(Pi / 2.0), $MachinePrecision] - N[ArcSin[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -4.5 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \left(\frac{\pi}{2} - \sin^{-1} \cos \phi_1\right)\\
\end{array}
\end{array}
if lambda1 < -4.50000000000000028e-5Initial program 59.7%
Simplified59.8%
Taylor expanded in lambda2 around 0 60.0%
Taylor expanded in phi2 around 0 38.2%
*-commutative38.2%
Simplified38.2%
Taylor expanded in phi1 around 0 27.7%
if -4.50000000000000028e-5 < lambda1 Initial program 77.4%
Simplified77.4%
Taylor expanded in lambda2 around 0 54.0%
Taylor expanded in phi2 around 0 28.4%
*-commutative28.4%
Simplified28.4%
Taylor expanded in lambda1 around 0 19.0%
acos-asin19.0%
Applied egg-rr19.0%
Final simplification21.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (if (<= lambda1 -2.35e-5) (* R (acos (cos lambda1))) (* R (acos (cos phi1)))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -2.35e-5) {
tmp = R * acos(cos(lambda1));
} else {
tmp = R * acos(cos(phi1));
}
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 <= (-2.35d-5)) then
tmp = r * acos(cos(lambda1))
else
tmp = r * acos(cos(phi1))
end if
code = tmp
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -2.35e-5) {
tmp = R * Math.acos(Math.cos(lambda1));
} else {
tmp = R * Math.acos(Math.cos(phi1));
}
return tmp;
}
def code(R, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -2.35e-5: tmp = R * math.acos(math.cos(lambda1)) else: tmp = R * math.acos(math.cos(phi1)) return tmp
function code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -2.35e-5) tmp = Float64(R * acos(cos(lambda1))); else tmp = Float64(R * acos(cos(phi1))); end return tmp end
function tmp_2 = code(R, lambda1, lambda2, phi1, phi2) tmp = 0.0; if (lambda1 <= -2.35e-5) tmp = R * acos(cos(lambda1)); else tmp = R * acos(cos(phi1)); end tmp_2 = tmp; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := If[LessEqual[lambda1, -2.35e-5], N[(R * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -2.35 \cdot 10^{-5}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R \cdot \cos^{-1} \cos \phi_1\\
\end{array}
\end{array}
if lambda1 < -2.34999999999999986e-5Initial program 59.7%
Simplified59.8%
Taylor expanded in lambda2 around 0 60.0%
Taylor expanded in phi2 around 0 38.2%
*-commutative38.2%
Simplified38.2%
Taylor expanded in phi1 around 0 27.7%
if -2.34999999999999986e-5 < lambda1 Initial program 77.4%
Simplified77.4%
Taylor expanded in lambda2 around 0 54.0%
Taylor expanded in phi2 around 0 28.4%
*-commutative28.4%
Simplified28.4%
Taylor expanded in lambda1 around 0 19.0%
Final simplification21.2%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos (cos phi1))))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(cos(phi1));
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(cos(phi1))
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(Math.cos(phi1));
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(math.cos(phi1))
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(cos(phi1))) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(cos(phi1)); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[N[Cos[phi1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} \cos \phi_1
\end{array}
Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 17.4%
Final simplification17.4%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* R (acos 1.0)))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * acos(1.0);
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r * acos(1.0d0)
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return R * Math.acos(1.0);
}
def code(R, lambda1, lambda2, phi1, phi2): return R * math.acos(1.0)
function code(R, lambda1, lambda2, phi1, phi2) return Float64(R * acos(1.0)) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = R * acos(1.0); end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(R * N[ArcCos[1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
R \cdot \cos^{-1} 1
\end{array}
Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 17.4%
Taylor expanded in phi1 around 0 4.0%
Final simplification4.0%
(FPCore (R lambda1 lambda2 phi1 phi2) :precision binary64 (* phi1 R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi1 * 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 = phi1 * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return phi1 * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return phi1 * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(phi1 * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = phi1 * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(phi1 * R), $MachinePrecision]
\begin{array}{l}
\\
\phi_1 \cdot R
\end{array}
Initial program 73.0%
Simplified73.1%
Taylor expanded in lambda2 around 0 55.4%
Taylor expanded in phi2 around 0 30.8%
*-commutative30.8%
Simplified30.8%
Taylor expanded in lambda1 around 0 17.4%
Taylor expanded in phi1 around 0 5.4%
*-commutative5.4%
Simplified5.4%
herbie shell --seed 2024170
(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))