
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 27 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (R lambda1 lambda2 phi1 phi2)
:precision binary64
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R))
double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R;
}
real(8) function code(r, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r
end function
public static double code(double R, double lambda1, double lambda2, double phi1, double phi2) {
return Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R;
}
def code(R, lambda1, lambda2, phi1, phi2): return math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R
function code(R, lambda1, lambda2, phi1, phi2) return Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R) end
function tmp = code(R, lambda1, lambda2, phi1, phi2) tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R; end
code[R_, lambda1_, lambda2_, phi1_, phi2_] := N[(N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R), $MachinePrecision]
\begin{array}{l}
\\
\cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R
\end{array}
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (cos phi1) (cos phi2))) (t_1 (* (sin phi1) (sin phi2))))
(*
R_s
(if (<= (* (acos (+ t_1 (* t_0 (cos (- lambda1 lambda2))))) R_m) 0.0)
(* R_m (- lambda2 lambda1))
(*
R_m
(acos
(fma
t_0
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1)))
t_1)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, 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 ((acos((t_1 + (t_0 * cos((lambda1 - lambda2))))) * R_m) <= 0.0) {
tmp = R_m * (lambda2 - lambda1);
} else {
tmp = R_m * acos(fma(t_0, ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))), t_1));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = Float64(cos(phi1) * cos(phi2)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (Float64(acos(Float64(t_1 + Float64(t_0 * cos(Float64(lambda1 - lambda2))))) * R_m) <= 0.0) tmp = Float64(R_m * Float64(lambda2 - lambda1)); else tmp = Float64(R_m * acos(fma(t_0, Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1))), t_1))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, 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]}, N[(R$95$s * If[LessEqual[N[(N[ArcCos[N[(t$95$1 + N[(t$95$0 * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R$95$m), $MachinePrecision], 0.0], N[(R$95$m * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(t$95$0 * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \phi_1 \cdot \cos \phi_2\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\cos^{-1} \left(t\_1 + t\_0 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\_m \leq 0:\\
\;\;\;\;R\_m \cdot \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(t\_0, \cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1, t\_1\right)\right)\\
\end{array}
\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 69.7%
Simplified69.8%
Taylor expanded in phi2 around 0 44.0%
Taylor expanded in phi1 around 0 26.4%
Taylor expanded in R around 0 6.1%
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 74.3%
Simplified74.4%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
Final simplification51.5%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(*
R_s
(if (<=
(*
(acos
(+ t_0 (* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R_m)
0.0)
(* R_m (- lambda2 lambda1))
(*
R_m
(acos
(+
t_0
(*
(cos phi1)
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda2) (sin lambda1))))))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if ((acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R_m) <= 0.0) {
tmp = R_m * (lambda2 - lambda1);
} else {
tmp = R_m * acos((t_0 + (cos(phi1) * (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))))));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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 ((acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r_m) <= 0.0d0) then
tmp = r_m * (lambda2 - lambda1)
else
tmp = r_m * acos((t_0 + (cos(phi1) * (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))))))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double tmp;
if ((Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R_m) <= 0.0) {
tmp = R_m * (lambda2 - lambda1);
} else {
tmp = R_m * Math.acos((t_0 + (Math.cos(phi1) * (Math.cos(phi2) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1)))))));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) tmp = 0 if (math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R_m) <= 0.0: tmp = R_m * (lambda2 - lambda1) else: tmp = R_m * math.acos((t_0 + (math.cos(phi1) * (math.cos(phi2) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1))))))) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (Float64(acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R_m) <= 0.0) tmp = Float64(R_m * Float64(lambda2 - lambda1)); else tmp = Float64(R_m * acos(Float64(t_0 + Float64(cos(phi1) * Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = sin(phi1) * sin(phi2);
tmp = 0.0;
if ((acos((t_0 + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R_m) <= 0.0)
tmp = R_m * (lambda2 - lambda1);
else
tmp = R_m * acos((t_0 + (cos(phi1) * (cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))))));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[N[(N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * R$95$m), $MachinePrecision], 0.0], N[(R$95$m * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \left(\lambda_1 - \lambda_2\right)\right) \cdot R\_m \leq 0:\\
\;\;\;\;R\_m \cdot \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(t\_0 + \cos \phi_1 \cdot \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\right)\\
\end{array}
\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 69.7%
Simplified69.8%
Taylor expanded in phi2 around 0 44.0%
Taylor expanded in phi1 around 0 26.4%
Taylor expanded in R around 0 6.1%
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 74.3%
Simplified74.4%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
Taylor expanded in phi1 around 0 99.0%
Final simplification51.5%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(*
R_s
(if (<= phi1 -2.7e-5)
(* R_m (log (exp (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))
(if (<= phi1 4e-31)
(*
R_m
(acos
(fma
(cos phi2)
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1)))
t_1)))
(* R_m (acos (fma (* (cos phi1) (cos phi2)) t_0 t_1))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -2.7e-5) {
tmp = R_m * log(exp(acos(fma(cos(phi1), (cos(phi2) * t_0), t_1))));
} else if (phi1 <= 4e-31) {
tmp = R_m * acos(fma(cos(phi2), ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))), t_1));
} else {
tmp = R_m * acos(fma((cos(phi1) * cos(phi2)), t_0, t_1));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -2.7e-5) tmp = Float64(R_m * log(exp(acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))))); elseif (phi1 <= 4e-31) tmp = Float64(R_m * acos(fma(cos(phi2), Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1))), t_1))); else tmp = Float64(R_m * acos(fma(Float64(cos(phi1) * cos(phi2)), t_0, t_1))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi1, -2.7e-5], N[(R$95$m * N[Log[N[Exp[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4e-31], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_1 \leq -2.7 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)}\right)\\
\mathbf{elif}\;\phi_1 \leq 4 \cdot 10^{-31}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2, \cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1, t\_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
\end{array}
if phi1 < -2.6999999999999999e-5Initial program 78.0%
Simplified78.0%
add-log-exp78.0%
cos-diff99.3%
*-commutative99.3%
*-commutative99.3%
cos-diff78.0%
fma-define77.9%
associate-*r*77.9%
fma-undefine78.0%
cos-diff99.3%
*-commutative99.3%
*-commutative99.3%
cos-diff78.0%
Applied egg-rr78.0%
if -2.6999999999999999e-5 < phi1 < 4e-31Initial program 63.4%
Simplified63.4%
cos-diff88.7%
+-commutative88.7%
Applied egg-rr88.7%
Taylor expanded in phi1 around 0 88.3%
if 4e-31 < phi1 Initial program 79.3%
Simplified79.4%
Final simplification82.8%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(*
R_s
(if (<= phi1 -3.1e-14)
(* R_m (log (exp (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))
(if (<= phi1 4e-31)
(*
R_m
(acos
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda2) (sin lambda1))))))
(* R_m (acos (fma (* (cos phi1) (cos phi2)) t_0 t_1))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -3.1e-14) {
tmp = R_m * log(exp(acos(fma(cos(phi1), (cos(phi2) * t_0), t_1))));
} else if (phi1 <= 4e-31) {
tmp = R_m * acos((cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
} else {
tmp = R_m * acos(fma((cos(phi1) * cos(phi2)), t_0, t_1));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -3.1e-14) tmp = Float64(R_m * log(exp(acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))))); elseif (phi1 <= 4e-31) tmp = Float64(R_m * acos(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))); else tmp = Float64(R_m * acos(fma(Float64(cos(phi1) * cos(phi2)), t_0, t_1))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi1, -3.1e-14], N[(R$95$m * N[Log[N[Exp[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4e-31], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-14}:\\
\;\;\;\;R\_m \cdot \log \left(e^{\cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)}\right)\\
\mathbf{elif}\;\phi_1 \leq 4 \cdot 10^{-31}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
\end{array}
if phi1 < -3.10000000000000004e-14Initial program 76.2%
Simplified76.2%
add-log-exp76.2%
cos-diff98.1%
*-commutative98.1%
*-commutative98.1%
cos-diff76.2%
fma-define76.2%
associate-*r*76.2%
fma-undefine76.3%
cos-diff98.1%
*-commutative98.1%
*-commutative98.1%
cos-diff76.3%
Applied egg-rr76.3%
if -3.10000000000000004e-14 < phi1 < 4e-31Initial program 64.0%
Simplified64.0%
cos-diff89.1%
+-commutative89.1%
Applied egg-rr89.1%
expm1-log1p-u89.1%
expm1-undefine89.1%
Applied egg-rr89.1%
Taylor expanded in phi1 around 0 89.1%
if 4e-31 < phi1 Initial program 79.3%
Simplified79.4%
Final simplification82.4%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))) (t_1 (* (sin phi1) (sin phi2))))
(*
R_s
(if (<= phi1 -2.8e-19)
(* R_m (exp (log (acos (fma (cos phi1) (* (cos phi2) t_0) t_1)))))
(if (<= phi1 4e-31)
(*
R_m
(acos
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda2) (sin lambda1))))))
(* R_m (acos (fma (* (cos phi1) (cos phi2)) t_0 t_1))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double t_1 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -2.8e-19) {
tmp = R_m * exp(log(acos(fma(cos(phi1), (cos(phi2) * t_0), t_1))));
} else if (phi1 <= 4e-31) {
tmp = R_m * acos((cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
} else {
tmp = R_m * acos(fma((cos(phi1) * cos(phi2)), t_0, t_1));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) t_1 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -2.8e-19) tmp = Float64(R_m * exp(log(acos(fma(cos(phi1), Float64(cos(phi2) * t_0), t_1))))); elseif (phi1 <= 4e-31) tmp = Float64(R_m * acos(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))); else tmp = Float64(R_m * acos(fma(Float64(cos(phi1) * cos(phi2)), t_0, t_1))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi1, -2.8e-19], N[(R$95$m * N[Exp[N[Log[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision] + t$95$1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4e-31], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * t$95$0 + t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
t_1 := \sin \phi_1 \cdot \sin \phi_2\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_1 \leq -2.8 \cdot 10^{-19}:\\
\;\;\;\;R\_m \cdot e^{\log \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot t\_0, t\_1\right)\right)}\\
\mathbf{elif}\;\phi_1 \leq 4 \cdot 10^{-31}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, t\_0, t\_1\right)\right)\\
\end{array}
\end{array}
\end{array}
if phi1 < -2.80000000000000003e-19Initial program 76.2%
Simplified76.2%
add-exp-log76.2%
cos-diff98.1%
*-commutative98.1%
*-commutative98.1%
cos-diff76.2%
fma-define76.2%
associate-*r*76.2%
fma-undefine76.3%
cos-diff98.1%
*-commutative98.1%
*-commutative98.1%
cos-diff76.3%
Applied egg-rr76.3%
if -2.80000000000000003e-19 < phi1 < 4e-31Initial program 64.0%
Simplified64.0%
cos-diff89.1%
+-commutative89.1%
Applied egg-rr89.1%
expm1-log1p-u89.1%
expm1-undefine89.1%
Applied egg-rr89.1%
Taylor expanded in phi1 around 0 89.1%
if 4e-31 < phi1 Initial program 79.3%
Simplified79.4%
Final simplification82.4%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (or (<= phi1 -3.1e-14) (not (<= phi1 4e-31)))
(*
R_m
(acos
(fma
(* (cos phi1) (cos phi2))
(cos (- lambda2 lambda1))
(* (sin phi1) (sin phi2)))))
(*
R_m
(acos
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda2) (sin lambda1)))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3.1e-14) || !(phi1 <= 4e-31)) {
tmp = R_m * acos(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), (sin(phi1) * sin(phi2))));
} else {
tmp = R_m * acos((cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -3.1e-14) || !(phi1 <= 4e-31)) tmp = Float64(R_m * acos(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), Float64(sin(phi1) * sin(phi2))))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[Or[LessEqual[phi1, -3.1e-14], N[Not[LessEqual[phi1, 4e-31]], $MachinePrecision]], N[(R$95$m * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-14} \lor \neg \left(\phi_1 \leq 4 \cdot 10^{-31}\right):\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -3.10000000000000004e-14 or 4e-31 < phi1 Initial program 77.6%
Simplified77.7%
if -3.10000000000000004e-14 < phi1 < 4e-31Initial program 64.0%
Simplified64.0%
cos-diff89.1%
+-commutative89.1%
Applied egg-rr89.1%
expm1-log1p-u89.1%
expm1-undefine89.1%
Applied egg-rr89.1%
Taylor expanded in phi1 around 0 89.1%
Final simplification82.4%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2))))
(*
R_s
(if (<= phi1 -3.1e-14)
(*
R_m
(acos (fma (cos phi1) (* (cos phi2) (cos (- lambda1 lambda2))) t_0)))
(if (<= phi1 4e-31)
(*
R_m
(acos
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda2) (sin lambda1))))))
(*
R_m
(acos
(fma (* (cos phi1) (cos phi2)) (cos (- lambda2 lambda1)) t_0))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double tmp;
if (phi1 <= -3.1e-14) {
tmp = R_m * acos(fma(cos(phi1), (cos(phi2) * cos((lambda1 - lambda2))), t_0));
} else if (phi1 <= 4e-31) {
tmp = R_m * acos((cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
} else {
tmp = R_m * acos(fma((cos(phi1) * cos(phi2)), cos((lambda2 - lambda1)), t_0));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) tmp = 0.0 if (phi1 <= -3.1e-14) tmp = Float64(R_m * acos(fma(cos(phi1), Float64(cos(phi2) * cos(Float64(lambda1 - lambda2))), t_0))); elseif (phi1 <= 4e-31) tmp = Float64(R_m * acos(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))); else tmp = Float64(R_m * acos(fma(Float64(cos(phi1) * cos(phi2)), cos(Float64(lambda2 - lambda1)), t_0))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi1, -3.1e-14], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi1, 4e-31], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-14}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1, \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right), t\_0\right)\right)\\
\mathbf{elif}\;\phi_1 \leq 4 \cdot 10^{-31}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_1 \cdot \cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), t\_0\right)\right)\\
\end{array}
\end{array}
\end{array}
if phi1 < -3.10000000000000004e-14Initial program 76.2%
Simplified76.3%
if -3.10000000000000004e-14 < phi1 < 4e-31Initial program 64.0%
Simplified64.0%
cos-diff89.1%
+-commutative89.1%
Applied egg-rr89.1%
expm1-log1p-u89.1%
expm1-undefine89.1%
Applied egg-rr89.1%
Taylor expanded in phi1 around 0 89.1%
if 4e-31 < phi1 Initial program 79.3%
Simplified79.4%
Final simplification82.4%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1)))))
(*
R_s
(if (<= lambda2 -3.6e-13)
(* R_m (acos (* (cos phi2) t_1)))
(if (<= lambda2 0.044)
(* R_m (acos (+ t_0 (* (* (cos phi1) (cos phi2)) (cos lambda1)))))
(if (<= lambda2 4.8e+201)
(* R_m (acos (+ t_0 (* (cos phi2) (* (cos phi1) (cos lambda2))))))
(* R_m (acos (* (cos phi1) t_1)))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
double tmp;
if (lambda2 <= -3.6e-13) {
tmp = R_m * acos((cos(phi2) * t_1));
} else if (lambda2 <= 0.044) {
tmp = R_m * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
} else if (lambda2 <= 4.8e+201) {
tmp = R_m * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))));
} else {
tmp = R_m * acos((cos(phi1) * t_1));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
t_1 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))
if (lambda2 <= (-3.6d-13)) then
tmp = r_m * acos((cos(phi2) * t_1))
else if (lambda2 <= 0.044d0) then
tmp = r_m * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))))
else if (lambda2 <= 4.8d+201) then
tmp = r_m * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))))
else
tmp = r_m * acos((cos(phi1) * t_1))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = (Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1));
double tmp;
if (lambda2 <= -3.6e-13) {
tmp = R_m * Math.acos((Math.cos(phi2) * t_1));
} else if (lambda2 <= 0.044) {
tmp = R_m * Math.acos((t_0 + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda1))));
} else if (lambda2 <= 4.8e+201) {
tmp = R_m * Math.acos((t_0 + (Math.cos(phi2) * (Math.cos(phi1) * Math.cos(lambda2)))));
} else {
tmp = R_m * Math.acos((Math.cos(phi1) * t_1));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = (math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1)) tmp = 0 if lambda2 <= -3.6e-13: tmp = R_m * math.acos((math.cos(phi2) * t_1)) elif lambda2 <= 0.044: tmp = R_m * math.acos((t_0 + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda1)))) elif lambda2 <= 4.8e+201: tmp = R_m * math.acos((t_0 + (math.cos(phi2) * (math.cos(phi1) * math.cos(lambda2))))) else: tmp = R_m * math.acos((math.cos(phi1) * t_1)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1))) tmp = 0.0 if (lambda2 <= -3.6e-13) tmp = Float64(R_m * acos(Float64(cos(phi2) * t_1))); elseif (lambda2 <= 0.044) tmp = Float64(R_m * acos(Float64(t_0 + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda1))))); elseif (lambda2 <= 4.8e+201) tmp = Float64(R_m * acos(Float64(t_0 + Float64(cos(phi2) * Float64(cos(phi1) * cos(lambda2)))))); else tmp = Float64(R_m * acos(Float64(cos(phi1) * t_1))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = sin(phi1) * sin(phi2);
t_1 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
tmp = 0.0;
if (lambda2 <= -3.6e-13)
tmp = R_m * acos((cos(phi2) * t_1));
elseif (lambda2 <= 0.044)
tmp = R_m * acos((t_0 + ((cos(phi1) * cos(phi2)) * cos(lambda1))));
elseif (lambda2 <= 4.8e+201)
tmp = R_m * acos((t_0 + (cos(phi2) * (cos(phi1) * cos(lambda2)))));
else
tmp = R_m * acos((cos(phi1) * t_1));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[lambda2, -3.6e-13], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 0.044], N[(R$95$m * N[ArcCos[N[(t$95$0 + N[(N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 4.8e+201], N[(R$95$m * N[ArcCos[N[(t$95$0 + N[(N[Cos[phi2], $MachinePrecision] * N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -3.6 \cdot 10^{-13}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_1\right)\\
\mathbf{elif}\;\lambda_2 \leq 0.044:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(t\_0 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\lambda_2 \leq 4.8 \cdot 10^{+201}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(t\_0 + \cos \phi_2 \cdot \left(\cos \phi_1 \cdot \cos \lambda_2\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_1\right)\\
\end{array}
\end{array}
\end{array}
if lambda2 < -3.5999999999999998e-13Initial program 61.3%
Simplified61.3%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
expm1-log1p-u99.1%
expm1-undefine99.0%
Applied egg-rr99.0%
Taylor expanded in phi1 around 0 56.2%
if -3.5999999999999998e-13 < lambda2 < 0.043999999999999997Initial program 88.5%
Taylor expanded in lambda2 around 0 88.5%
if 0.043999999999999997 < lambda2 < 4.79999999999999985e201Initial program 57.9%
add-cube-cbrt57.9%
pow357.9%
Applied egg-rr57.9%
Taylor expanded in lambda1 around 0 57.7%
cos-neg57.7%
associate-*r*57.7%
*-commutative57.7%
associate-*r*57.7%
*-commutative57.7%
Simplified57.7%
if 4.79999999999999985e201 < lambda2 Initial program 50.8%
Simplified50.9%
Taylor expanded in phi2 around 0 40.8%
cos-diff98.6%
+-commutative98.6%
Applied egg-rr70.7%
Final simplification71.7%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (* (sin phi1) (sin phi2)))
(t_1
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1))))
(t_2 (* (cos phi1) (cos phi2))))
(*
R_s
(if (<= lambda2 -3.6e-13)
(* R_m (acos (* (cos phi2) t_1)))
(if (<= lambda2 0.044)
(* R_m (acos (+ t_0 (* t_2 (cos lambda1)))))
(if (<= lambda2 7e+198)
(* R_m (acos (+ t_0 (* t_2 (cos lambda2)))))
(* R_m (acos (* (cos phi1) t_1)))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = sin(phi1) * sin(phi2);
double t_1 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
double t_2 = cos(phi1) * cos(phi2);
double tmp;
if (lambda2 <= -3.6e-13) {
tmp = R_m * acos((cos(phi2) * t_1));
} else if (lambda2 <= 0.044) {
tmp = R_m * acos((t_0 + (t_2 * cos(lambda1))));
} else if (lambda2 <= 7e+198) {
tmp = R_m * acos((t_0 + (t_2 * cos(lambda2))));
} else {
tmp = R_m * acos((cos(phi1) * t_1));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: t_0
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_0 = sin(phi1) * sin(phi2)
t_1 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))
t_2 = cos(phi1) * cos(phi2)
if (lambda2 <= (-3.6d-13)) then
tmp = r_m * acos((cos(phi2) * t_1))
else if (lambda2 <= 0.044d0) then
tmp = r_m * acos((t_0 + (t_2 * cos(lambda1))))
else if (lambda2 <= 7d+198) then
tmp = r_m * acos((t_0 + (t_2 * cos(lambda2))))
else
tmp = r_m * acos((cos(phi1) * t_1))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.sin(phi1) * Math.sin(phi2);
double t_1 = (Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1));
double t_2 = Math.cos(phi1) * Math.cos(phi2);
double tmp;
if (lambda2 <= -3.6e-13) {
tmp = R_m * Math.acos((Math.cos(phi2) * t_1));
} else if (lambda2 <= 0.044) {
tmp = R_m * Math.acos((t_0 + (t_2 * Math.cos(lambda1))));
} else if (lambda2 <= 7e+198) {
tmp = R_m * Math.acos((t_0 + (t_2 * Math.cos(lambda2))));
} else {
tmp = R_m * Math.acos((Math.cos(phi1) * t_1));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = math.sin(phi1) * math.sin(phi2) t_1 = (math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1)) t_2 = math.cos(phi1) * math.cos(phi2) tmp = 0 if lambda2 <= -3.6e-13: tmp = R_m * math.acos((math.cos(phi2) * t_1)) elif lambda2 <= 0.044: tmp = R_m * math.acos((t_0 + (t_2 * math.cos(lambda1)))) elif lambda2 <= 7e+198: tmp = R_m * math.acos((t_0 + (t_2 * math.cos(lambda2)))) else: tmp = R_m * math.acos((math.cos(phi1) * t_1)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = Float64(sin(phi1) * sin(phi2)) t_1 = Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1))) t_2 = Float64(cos(phi1) * cos(phi2)) tmp = 0.0 if (lambda2 <= -3.6e-13) tmp = Float64(R_m * acos(Float64(cos(phi2) * t_1))); elseif (lambda2 <= 0.044) tmp = Float64(R_m * acos(Float64(t_0 + Float64(t_2 * cos(lambda1))))); elseif (lambda2 <= 7e+198) tmp = Float64(R_m * acos(Float64(t_0 + Float64(t_2 * cos(lambda2))))); else tmp = Float64(R_m * acos(Float64(cos(phi1) * t_1))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = sin(phi1) * sin(phi2);
t_1 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
t_2 = cos(phi1) * cos(phi2);
tmp = 0.0;
if (lambda2 <= -3.6e-13)
tmp = R_m * acos((cos(phi2) * t_1));
elseif (lambda2 <= 0.044)
tmp = R_m * acos((t_0 + (t_2 * cos(lambda1))));
elseif (lambda2 <= 7e+198)
tmp = R_m * acos((t_0 + (t_2 * cos(lambda2))));
else
tmp = R_m * acos((cos(phi1) * t_1));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[Cos[phi1], $MachinePrecision] * N[Cos[phi2], $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[lambda2, -3.6e-13], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 0.044], N[(R$95$m * N[ArcCos[N[(t$95$0 + N[(t$95$2 * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[lambda2, 7e+198], N[(R$95$m * N[ArcCos[N[(t$95$0 + N[(t$95$2 * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \sin \phi_1 \cdot \sin \phi_2\\
t_1 := \cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\\
t_2 := \cos \phi_1 \cdot \cos \phi_2\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\lambda_2 \leq -3.6 \cdot 10^{-13}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_1\right)\\
\mathbf{elif}\;\lambda_2 \leq 0.044:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(t\_0 + t\_2 \cdot \cos \lambda_1\right)\\
\mathbf{elif}\;\lambda_2 \leq 7 \cdot 10^{+198}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(t\_0 + t\_2 \cdot \cos \lambda_2\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_1\right)\\
\end{array}
\end{array}
\end{array}
if lambda2 < -3.5999999999999998e-13Initial program 61.3%
Simplified61.3%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
expm1-log1p-u99.1%
expm1-undefine99.0%
Applied egg-rr99.0%
Taylor expanded in phi1 around 0 56.2%
if -3.5999999999999998e-13 < lambda2 < 0.043999999999999997Initial program 88.5%
Taylor expanded in lambda2 around 0 88.5%
if 0.043999999999999997 < lambda2 < 7.00000000000000026e198Initial program 57.9%
Simplified57.9%
Taylor expanded in lambda1 around 0 57.7%
if 7.00000000000000026e198 < lambda2 Initial program 50.8%
Simplified50.9%
Taylor expanded in phi2 around 0 40.8%
cos-diff98.6%
+-commutative98.6%
Applied egg-rr70.7%
Final simplification71.7%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (or (<= phi1 -3.1e-14) (not (<= phi1 4e-31)))
(*
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos (- lambda1 lambda2)))))
R_m)
(*
R_m
(acos
(*
(cos phi2)
(+
(* (cos lambda2) (cos lambda1))
(* (sin lambda2) (sin lambda1)))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3.1e-14) || !(phi1 <= 4e-31)) {
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R_m;
} else {
tmp = R_m * acos((cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if ((phi1 <= (-3.1d-14)) .or. (.not. (phi1 <= 4d-31))) then
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * r_m
else
tmp = r_m * acos((cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if ((phi1 <= -3.1e-14) || !(phi1 <= 4e-31)) {
tmp = Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos((lambda1 - lambda2))))) * R_m;
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * ((Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1)))));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): tmp = 0 if (phi1 <= -3.1e-14) or not (phi1 <= 4e-31): tmp = math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos((lambda1 - lambda2))))) * R_m else: tmp = R_m * math.acos((math.cos(phi2) * ((math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1))))) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if ((phi1 <= -3.1e-14) || !(phi1 <= 4e-31)) tmp = Float64(acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(Float64(lambda1 - lambda2))))) * R_m); else tmp = Float64(R_m * acos(Float64(cos(phi2) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if ((phi1 <= -3.1e-14) || ~((phi1 <= 4e-31)))
tmp = acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos((lambda1 - lambda2))))) * R_m;
else
tmp = R_m * acos((cos(phi2) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[Or[LessEqual[phi1, -3.1e-14], N[Not[LessEqual[phi1, 4e-31]], $MachinePrecision]], 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$95$m), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_1 \leq -3.1 \cdot 10^{-14} \lor \neg \left(\phi_1 \leq 4 \cdot 10^{-31}\right):\\
\;\;\;\;\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\_m\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\end{array}
\end{array}
if phi1 < -3.10000000000000004e-14 or 4e-31 < phi1 Initial program 77.6%
if -3.10000000000000004e-14 < phi1 < 4e-31Initial program 64.0%
Simplified64.0%
cos-diff89.1%
+-commutative89.1%
Applied egg-rr89.1%
expm1-log1p-u89.1%
expm1-undefine89.1%
Applied egg-rr89.1%
Taylor expanded in phi1 around 0 89.1%
Final simplification82.4%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1)))))
(*
R_s
(if (<= phi2 -0.0142)
(*
R_m
(acos
(+
(* (sin phi1) (sin phi2))
(* (* (cos phi1) (cos phi2)) (cos lambda2)))))
(if (<= phi2 6.5e-5)
(* R_m (acos (* (cos phi1) t_0)))
(* R_m (acos (* (cos phi2) t_0))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
double tmp;
if (phi2 <= -0.0142) {
tmp = R_m * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda2))));
} else if (phi2 <= 6.5e-5) {
tmp = R_m * acos((cos(phi1) * t_0));
} else {
tmp = R_m * acos((cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))
if (phi2 <= (-0.0142d0)) then
tmp = r_m * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda2))))
else if (phi2 <= 6.5d-5) then
tmp = r_m * acos((cos(phi1) * t_0))
else
tmp = r_m * acos((cos(phi2) * t_0))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1));
double tmp;
if (phi2 <= -0.0142) {
tmp = R_m * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + ((Math.cos(phi1) * Math.cos(phi2)) * Math.cos(lambda2))));
} else if (phi2 <= 6.5e-5) {
tmp = R_m * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1)) tmp = 0 if phi2 <= -0.0142: tmp = R_m * math.acos(((math.sin(phi1) * math.sin(phi2)) + ((math.cos(phi1) * math.cos(phi2)) * math.cos(lambda2)))) elif phi2 <= 6.5e-5: tmp = R_m * math.acos((math.cos(phi1) * t_0)) else: tmp = R_m * math.acos((math.cos(phi2) * t_0)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1))) tmp = 0.0 if (phi2 <= -0.0142) tmp = Float64(R_m * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(Float64(cos(phi1) * cos(phi2)) * cos(lambda2))))); elseif (phi2 <= 6.5e-5) tmp = Float64(R_m * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * t_0))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
tmp = 0.0;
if (phi2 <= -0.0142)
tmp = R_m * acos(((sin(phi1) * sin(phi2)) + ((cos(phi1) * cos(phi2)) * cos(lambda2))));
elseif (phi2 <= 6.5e-5)
tmp = R_m * acos((cos(phi1) * t_0));
else
tmp = R_m * acos((cos(phi2) * t_0));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi2, -0.0142], N[(R$95$m * 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[lambda2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], If[LessEqual[phi2, 6.5e-5], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq -0.0142:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \left(\cos \phi_1 \cdot \cos \phi_2\right) \cdot \cos \lambda_2\right)\\
\mathbf{elif}\;\phi_2 \leq 6.5 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
\end{array}
if phi2 < -0.014200000000000001Initial program 79.0%
Simplified79.0%
Taylor expanded in lambda1 around 0 62.0%
if -0.014200000000000001 < phi2 < 6.49999999999999943e-5Initial program 68.4%
Simplified68.4%
Taylor expanded in phi2 around 0 67.5%
cos-diff90.4%
+-commutative90.4%
Applied egg-rr89.4%
if 6.49999999999999943e-5 < phi2 Initial program 71.9%
Simplified72.0%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
expm1-log1p-u99.1%
expm1-undefine99.1%
Applied egg-rr99.1%
Taylor expanded in phi1 around 0 59.6%
Final simplification75.3%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1)))))
(*
R_s
(if (<= phi2 2.1e-5)
(* R_m (acos (* (cos phi1) t_0)))
(* R_m (acos (* (cos phi2) t_0)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
double tmp;
if (phi2 <= 2.1e-5) {
tmp = R_m * acos((cos(phi1) * t_0));
} else {
tmp = R_m * acos((cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1))
if (phi2 <= 2.1d-5) then
tmp = r_m * acos((cos(phi1) * t_0))
else
tmp = r_m * acos((cos(phi2) * t_0))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = (Math.cos(lambda2) * Math.cos(lambda1)) + (Math.sin(lambda2) * Math.sin(lambda1));
double tmp;
if (phi2 <= 2.1e-5) {
tmp = R_m * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = (math.cos(lambda2) * math.cos(lambda1)) + (math.sin(lambda2) * math.sin(lambda1)) tmp = 0 if phi2 <= 2.1e-5: tmp = R_m * math.acos((math.cos(phi1) * t_0)) else: tmp = R_m * math.acos((math.cos(phi2) * t_0)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1))) tmp = 0.0 if (phi2 <= 2.1e-5) tmp = Float64(R_m * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * t_0))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = (cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1));
tmp = 0.0;
if (phi2 <= 2.1e-5)
tmp = R_m * acos((cos(phi1) * t_0));
else
tmp = R_m * acos((cos(phi2) * t_0));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi2, 2.1e-5], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.1 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
\end{array}
if phi2 < 2.09999999999999988e-5Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
cos-diff93.4%
+-commutative93.4%
Applied egg-rr65.3%
if 2.09999999999999988e-5 < phi2 Initial program 71.9%
Simplified72.0%
cos-diff99.1%
+-commutative99.1%
Applied egg-rr99.1%
expm1-log1p-u99.1%
expm1-undefine99.1%
Applied egg-rr99.1%
Taylor expanded in phi1 around 0 59.6%
Final simplification64.0%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (<= phi2 0.00032)
(*
R_m
(acos
(*
(cos phi1)
(+ (* (cos lambda2) (cos lambda1)) (* (sin lambda2) (sin lambda1))))))
(*
R_m
(acos
(fma (cos phi2) (cos (- lambda2 lambda1)) (* (sin phi1) (sin phi2))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.00032) {
tmp = R_m * acos((cos(phi1) * ((cos(lambda2) * cos(lambda1)) + (sin(lambda2) * sin(lambda1)))));
} else {
tmp = R_m * acos(fma(cos(phi2), cos((lambda2 - lambda1)), (sin(phi1) * sin(phi2))));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.00032) tmp = Float64(R_m * acos(Float64(cos(phi1) * Float64(Float64(cos(lambda2) * cos(lambda1)) + Float64(sin(lambda2) * sin(lambda1)))))); else tmp = Float64(R_m * acos(fma(cos(phi2), cos(Float64(lambda2 - lambda1)), Float64(sin(phi1) * sin(phi2))))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[LessEqual[phi2, 0.00032], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[(N[(N[Cos[lambda2], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision] + N[(N[Sin[lambda2], $MachinePrecision] * N[Sin[lambda1], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision] + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.00032:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot \left(\cos \lambda_2 \cdot \cos \lambda_1 + \sin \lambda_2 \cdot \sin \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2, \cos \left(\lambda_2 - \lambda_1\right), \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\end{array}
\end{array}
if phi2 < 3.20000000000000026e-4Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
cos-diff93.4%
+-commutative93.4%
Applied egg-rr65.3%
if 3.20000000000000026e-4 < phi2 Initial program 71.9%
Simplified72.0%
Taylor expanded in phi1 around 0 42.0%
Final simplification59.9%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(*
R_s
(if (<= phi2 4.2e-5)
(* R_m (log (exp (acos (* (cos phi1) t_0)))))
(* R_m (acos (fma (cos phi2) t_0 (* (sin phi1) (sin phi2)))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 4.2e-5) {
tmp = R_m * log(exp(acos((cos(phi1) * t_0))));
} else {
tmp = R_m * acos(fma(cos(phi2), t_0, (sin(phi1) * sin(phi2))));
}
return R_s * tmp;
}
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 4.2e-5) tmp = Float64(R_m * log(exp(acos(Float64(cos(phi1) * t_0))))); else tmp = Float64(R_m * acos(fma(cos(phi2), t_0, Float64(sin(phi1) * sin(phi2))))); end return Float64(R_s * tmp) end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi2, 4.2e-5], N[(R$95$m * N[Log[N[Exp[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0 + N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 4.2 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot \log \left(e^{\cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\mathsf{fma}\left(\cos \phi_2, t\_0, \sin \phi_1 \cdot \sin \phi_2\right)\right)\\
\end{array}
\end{array}
\end{array}
if phi2 < 4.19999999999999977e-5Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
add-log-exp51.0%
Applied egg-rr51.0%
if 4.19999999999999977e-5 < phi2 Initial program 71.9%
Simplified72.0%
Taylor expanded in phi1 around 0 42.0%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (<= phi2 1.3e-5)
(* R_m (log (exp (acos (* (cos phi1) (cos (- lambda2 lambda1)))))))
(*
R_m
(acos
(+
(* (sin phi1) (sin phi2))
(* (cos phi2) (cos (- lambda1 lambda2)))))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.3e-5) {
tmp = R_m * log(exp(acos((cos(phi1) * cos((lambda2 - lambda1))))));
} else {
tmp = R_m * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 1.3d-5) then
tmp = r_m * log(exp(acos((cos(phi1) * cos((lambda2 - lambda1))))))
else
tmp = r_m * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 1.3e-5) {
tmp = R_m * Math.log(Math.exp(Math.acos((Math.cos(phi1) * Math.cos((lambda2 - lambda1))))));
} else {
tmp = R_m * Math.acos(((Math.sin(phi1) * Math.sin(phi2)) + (Math.cos(phi2) * Math.cos((lambda1 - lambda2)))));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 1.3e-5: tmp = R_m * math.log(math.exp(math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1)))))) else: tmp = R_m * math.acos(((math.sin(phi1) * math.sin(phi2)) + (math.cos(phi2) * math.cos((lambda1 - lambda2))))) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 1.3e-5) tmp = Float64(R_m * log(exp(acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))))); else tmp = Float64(R_m * acos(Float64(Float64(sin(phi1) * sin(phi2)) + Float64(cos(phi2) * cos(Float64(lambda1 - lambda2)))))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (phi2 <= 1.3e-5)
tmp = R_m * log(exp(acos((cos(phi1) * cos((lambda2 - lambda1))))));
else
tmp = R_m * acos(((sin(phi1) * sin(phi2)) + (cos(phi2) * cos((lambda1 - lambda2)))));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[LessEqual[phi2, 1.3e-5], N[(R$95$m * N[Log[N[Exp[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[(N[Sin[phi1], $MachinePrecision] * N[Sin[phi2], $MachinePrecision]), $MachinePrecision] + N[(N[Cos[phi2], $MachinePrecision] * N[Cos[N[(lambda1 - lambda2), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.3 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot \log \left(e^{\cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\sin \phi_1 \cdot \sin \phi_2 + \cos \phi_2 \cdot \cos \left(\lambda_1 - \lambda_2\right)\right)\\
\end{array}
\end{array}
if phi2 < 1.29999999999999992e-5Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
add-log-exp51.0%
Applied egg-rr51.0%
if 1.29999999999999992e-5 < phi2 Initial program 71.9%
Taylor expanded in phi1 around 0 42.0%
Final simplification48.9%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(*
R_s
(if (<= phi2 2.5e-5)
(* R_m (log (exp (acos (* (cos phi1) t_0)))))
(* R_m (acos (* (cos phi2) t_0)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 2.5e-5) {
tmp = R_m * log(exp(acos((cos(phi1) * t_0))));
} else {
tmp = R_m * acos((cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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((lambda2 - lambda1))
if (phi2 <= 2.5d-5) then
tmp = r_m * log(exp(acos((cos(phi1) * t_0))))
else
tmp = r_m * acos((cos(phi2) * t_0))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 2.5e-5) {
tmp = R_m * Math.log(Math.exp(Math.acos((Math.cos(phi1) * t_0))));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= 2.5e-5: tmp = R_m * math.log(math.exp(math.acos((math.cos(phi1) * t_0)))) else: tmp = R_m * math.acos((math.cos(phi2) * t_0)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 2.5e-5) tmp = Float64(R_m * log(exp(acos(Float64(cos(phi1) * t_0))))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * t_0))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = cos((lambda2 - lambda1));
tmp = 0.0;
if (phi2 <= 2.5e-5)
tmp = R_m * log(exp(acos((cos(phi1) * t_0))));
else
tmp = R_m * acos((cos(phi2) * t_0));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi2, 2.5e-5], N[(R$95$m * N[Log[N[Exp[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 2.5 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot \log \left(e^{\cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)}\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
\end{array}
if phi2 < 2.50000000000000012e-5Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
add-log-exp51.0%
Applied egg-rr51.0%
if 2.50000000000000012e-5 < phi2 Initial program 71.9%
Simplified72.0%
Taylor expanded in phi1 around 0 41.0%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(*
R_s
(if (<= phi2 1.85e-5)
(* R_m (exp (log (acos (* (cos phi1) t_0)))))
(* R_m (acos (* (cos phi2) t_0)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 1.85e-5) {
tmp = R_m * exp(log(acos((cos(phi1) * t_0))));
} else {
tmp = R_m * acos((cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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((lambda2 - lambda1))
if (phi2 <= 1.85d-5) then
tmp = r_m * exp(log(acos((cos(phi1) * t_0))))
else
tmp = r_m * acos((cos(phi2) * t_0))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 1.85e-5) {
tmp = R_m * Math.exp(Math.log(Math.acos((Math.cos(phi1) * t_0))));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= 1.85e-5: tmp = R_m * math.exp(math.log(math.acos((math.cos(phi1) * t_0)))) else: tmp = R_m * math.acos((math.cos(phi2) * t_0)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 1.85e-5) tmp = Float64(R_m * exp(log(acos(Float64(cos(phi1) * t_0))))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * t_0))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = cos((lambda2 - lambda1));
tmp = 0.0;
if (phi2 <= 1.85e-5)
tmp = R_m * exp(log(acos((cos(phi1) * t_0))));
else
tmp = R_m * acos((cos(phi2) * t_0));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi2, 1.85e-5], N[(R$95$m * N[Exp[N[Log[N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 1.85 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot e^{\log \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)}\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
\end{array}
if phi2 < 1.84999999999999991e-5Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
add-exp-log51.0%
Applied egg-rr51.0%
if 1.84999999999999991e-5 < phi2 Initial program 71.9%
Simplified72.0%
Taylor expanded in phi1 around 0 41.0%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(let* ((t_0 (cos (- lambda2 lambda1))))
(*
R_s
(if (<= phi2 5.4e-5)
(* R_m (acos (* (cos phi1) t_0)))
(* R_m (acos (* (cos phi2) t_0)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 5.4e-5) {
tmp = R_m * acos((cos(phi1) * t_0));
} else {
tmp = R_m * acos((cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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((lambda2 - lambda1))
if (phi2 <= 5.4d-5) then
tmp = r_m * acos((cos(phi1) * t_0))
else
tmp = r_m * acos((cos(phi2) * t_0))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double t_0 = Math.cos((lambda2 - lambda1));
double tmp;
if (phi2 <= 5.4e-5) {
tmp = R_m * Math.acos((Math.cos(phi1) * t_0));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * t_0));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): t_0 = math.cos((lambda2 - lambda1)) tmp = 0 if phi2 <= 5.4e-5: tmp = R_m * math.acos((math.cos(phi1) * t_0)) else: tmp = R_m * math.acos((math.cos(phi2) * t_0)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) t_0 = cos(Float64(lambda2 - lambda1)) tmp = 0.0 if (phi2 <= 5.4e-5) tmp = Float64(R_m * acos(Float64(cos(phi1) * t_0))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * t_0))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
t_0 = cos((lambda2 - lambda1));
tmp = 0.0;
if (phi2 <= 5.4e-5)
tmp = R_m * acos((cos(phi1) * t_0));
else
tmp = R_m * acos((cos(phi2) * t_0));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := Block[{t$95$0 = N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]}, N[(R$95$s * If[LessEqual[phi2, 5.4e-5], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
\begin{array}{l}
t_0 := \cos \left(\lambda_2 - \lambda_1\right)\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 5.4 \cdot 10^{-5}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot t\_0\right)\\
\end{array}
\end{array}
\end{array}
if phi2 < 5.3999999999999998e-5Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
if 5.3999999999999998e-5 < phi2 Initial program 71.9%
Simplified72.0%
Taylor expanded in phi1 around 0 41.0%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (<= phi2 0.012)
(* R_m (acos (* (cos phi1) (cos (- lambda2 lambda1)))))
(* R_m (acos (* (cos phi2) (cos lambda2)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.012) {
tmp = R_m * acos((cos(phi1) * cos((lambda2 - lambda1))));
} else {
tmp = R_m * acos((cos(phi2) * cos(lambda2)));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 0.012d0) then
tmp = r_m * acos((cos(phi1) * cos((lambda2 - lambda1))))
else
tmp = r_m * acos((cos(phi2) * cos(lambda2)))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.012) {
tmp = R_m * Math.acos((Math.cos(phi1) * Math.cos((lambda2 - lambda1))));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.012: tmp = R_m * math.acos((math.cos(phi1) * math.cos((lambda2 - lambda1)))) else: tmp = R_m * math.acos((math.cos(phi2) * math.cos(lambda2))) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.012) tmp = Float64(R_m * acos(Float64(cos(phi1) * cos(Float64(lambda2 - lambda1))))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * cos(lambda2)))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (phi2 <= 0.012)
tmp = R_m * acos((cos(phi1) * cos((lambda2 - lambda1))));
else
tmp = R_m * acos((cos(phi2) * cos(lambda2)));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[LessEqual[phi2, 0.012], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.012:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \left(\lambda_2 - \lambda_1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < 0.012Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
if 0.012 < phi2 Initial program 71.9%
Simplified72.0%
Taylor expanded in lambda1 around 0 55.9%
*-commutative55.9%
associate-*r*55.9%
cos-neg55.9%
fma-define56.0%
cos-neg56.0%
Simplified56.0%
Taylor expanded in phi1 around 0 35.6%
Final simplification47.4%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (<= phi2 0.000105)
(* R_m (acos (* (cos phi1) (cos lambda1))))
(* R_m (acos (* (cos phi2) (cos lambda2)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.000105) {
tmp = R_m * acos((cos(phi1) * cos(lambda1)));
} else {
tmp = R_m * acos((cos(phi2) * cos(lambda2)));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
real(8) :: tmp
if (phi2 <= 0.000105d0) then
tmp = r_m * acos((cos(phi1) * cos(lambda1)))
else
tmp = r_m * acos((cos(phi2) * cos(lambda2)))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (phi2 <= 0.000105) {
tmp = R_m * Math.acos((Math.cos(phi1) * Math.cos(lambda1)));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): tmp = 0 if phi2 <= 0.000105: tmp = R_m * math.acos((math.cos(phi1) * math.cos(lambda1))) else: tmp = R_m * math.acos((math.cos(phi2) * math.cos(lambda2))) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (phi2 <= 0.000105) tmp = Float64(R_m * acos(Float64(cos(phi1) * cos(lambda1)))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * cos(lambda2)))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (phi2 <= 0.000105)
tmp = R_m * acos((cos(phi1) * cos(lambda1)));
else
tmp = R_m * acos((cos(phi2) * cos(lambda2)));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[LessEqual[phi2, 0.000105], N[(R$95$m * N[ArcCos[N[(N[Cos[phi1], $MachinePrecision] * N[Cos[lambda1], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\phi_2 \leq 0.000105:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_1 \cdot \cos \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if phi2 < 1.05e-4Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 51.0%
Taylor expanded in lambda2 around 0 36.5%
cos-neg36.5%
Simplified36.5%
if 1.05e-4 < phi2 Initial program 71.9%
Simplified72.0%
Taylor expanded in lambda1 around 0 55.9%
*-commutative55.9%
associate-*r*55.9%
cos-neg55.9%
fma-define56.0%
cos-neg56.0%
Simplified56.0%
Taylor expanded in phi1 around 0 35.6%
Final simplification36.3%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (<= lambda1 -3.1e-6)
(* R_m (acos (cos (- lambda2 lambda1))))
(* R_m (acos (* (cos phi2) (cos lambda2)))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -3.1e-6) {
tmp = R_m * acos(cos((lambda2 - lambda1)));
} else {
tmp = R_m * acos((cos(phi2) * cos(lambda2)));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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 <= (-3.1d-6)) then
tmp = r_m * acos(cos((lambda2 - lambda1)))
else
tmp = r_m * acos((cos(phi2) * cos(lambda2)))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -3.1e-6) {
tmp = R_m * Math.acos(Math.cos((lambda2 - lambda1)));
} else {
tmp = R_m * Math.acos((Math.cos(phi2) * Math.cos(lambda2)));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -3.1e-6: tmp = R_m * math.acos(math.cos((lambda2 - lambda1))) else: tmp = R_m * math.acos((math.cos(phi2) * math.cos(lambda2))) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -3.1e-6) tmp = Float64(R_m * acos(cos(Float64(lambda2 - lambda1)))); else tmp = Float64(R_m * acos(Float64(cos(phi2) * cos(lambda2)))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (lambda1 <= -3.1e-6)
tmp = R_m * acos(cos((lambda2 - lambda1)));
else
tmp = R_m * acos((cos(phi2) * cos(lambda2)));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[LessEqual[lambda1, -3.1e-6], N[(R$95$m * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[(N[Cos[phi2], $MachinePrecision] * N[Cos[lambda2], $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -3.1 \cdot 10^{-6}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \left(\cos \phi_2 \cdot \cos \lambda_2\right)\\
\end{array}
\end{array}
if lambda1 < -3.1e-6Initial program 59.7%
Simplified59.7%
Taylor expanded in phi2 around 0 38.2%
Taylor expanded in phi1 around 0 27.4%
if -3.1e-6 < lambda1 Initial program 76.9%
Simplified76.9%
Taylor expanded in lambda1 around 0 65.9%
*-commutative65.9%
associate-*r*65.9%
cos-neg65.9%
fma-define66.0%
cos-neg66.0%
Simplified66.0%
Taylor expanded in phi1 around 0 33.7%
Final simplification31.9%
R\_m = (fabs.f64 R)
R\_s = (copysign.f64 #s(literal 1 binary64) R)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
(FPCore (R_s R_m lambda1 lambda2 phi1 phi2)
:precision binary64
(*
R_s
(if (<= lambda1 -5e-8)
(* R_m (acos (cos lambda1)))
(* R_m (acos (cos lambda2))))))R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -5e-8) {
tmp = R_m * acos(cos(lambda1));
} else {
tmp = R_m * acos(cos(lambda2));
}
return R_s * tmp;
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
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 <= (-5d-8)) then
tmp = r_m * acos(cos(lambda1))
else
tmp = r_m * acos(cos(lambda2))
end if
code = r_s * tmp
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
double tmp;
if (lambda1 <= -5e-8) {
tmp = R_m * Math.acos(Math.cos(lambda1));
} else {
tmp = R_m * Math.acos(Math.cos(lambda2));
}
return R_s * tmp;
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): tmp = 0 if lambda1 <= -5e-8: tmp = R_m * math.acos(math.cos(lambda1)) else: tmp = R_m * math.acos(math.cos(lambda2)) return R_s * tmp
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) tmp = 0.0 if (lambda1 <= -5e-8) tmp = Float64(R_m * acos(cos(lambda1))); else tmp = Float64(R_m * acos(cos(lambda2))); end return Float64(R_s * tmp) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp_2 = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = 0.0;
if (lambda1 <= -5e-8)
tmp = R_m * acos(cos(lambda1));
else
tmp = R_m * acos(cos(lambda2));
end
tmp_2 = R_s * tmp;
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * If[LessEqual[lambda1, -5e-8], N[(R$95$m * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(R$95$m * N[ArcCos[N[Cos[lambda2], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \begin{array}{l}
\mathbf{if}\;\lambda_1 \leq -5 \cdot 10^{-8}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \cos \lambda_1\\
\mathbf{else}:\\
\;\;\;\;R\_m \cdot \cos^{-1} \cos \lambda_2\\
\end{array}
\end{array}
if lambda1 < -4.9999999999999998e-8Initial program 60.3%
Simplified60.3%
Taylor expanded in phi2 around 0 37.9%
Taylor expanded in phi1 around 0 27.2%
Taylor expanded in lambda2 around 0 26.7%
cos-neg26.7%
Simplified26.7%
if -4.9999999999999998e-8 < lambda1 Initial program 76.7%
Simplified76.8%
Taylor expanded in phi2 around 0 45.5%
Taylor expanded in phi1 around 0 26.2%
Taylor expanded in lambda1 around 0 20.3%
R\_m = (fabs.f64 R) R\_s = (copysign.f64 #s(literal 1 binary64) R) NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function. (FPCore (R_s R_m lambda1 lambda2 phi1 phi2) :precision binary64 (* R_s (* R_m (acos (cos (- lambda2 lambda1))))))
R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (R_m * acos(cos((lambda2 - lambda1))));
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r_s * (r_m * acos(cos((lambda2 - lambda1))))
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (R_m * Math.acos(Math.cos((lambda2 - lambda1))));
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): return R_s * (R_m * math.acos(math.cos((lambda2 - lambda1))))
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) return Float64(R_s * Float64(R_m * acos(cos(Float64(lambda2 - lambda1))))) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = R_s * (R_m * acos(cos((lambda2 - lambda1))));
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * N[(R$95$m * N[ArcCos[N[Cos[N[(lambda2 - lambda1), $MachinePrecision]], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \left(R\_m \cdot \cos^{-1} \cos \left(\lambda_2 - \lambda_1\right)\right)
\end{array}
Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 26.5%
R\_m = (fabs.f64 R) R\_s = (copysign.f64 #s(literal 1 binary64) R) NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function. (FPCore (R_s R_m lambda1 lambda2 phi1 phi2) :precision binary64 (* R_s (* R_m (acos (cos lambda1)))))
R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (R_m * acos(cos(lambda1)));
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r_s * (r_m * acos(cos(lambda1)))
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (R_m * Math.acos(Math.cos(lambda1)));
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): return R_s * (R_m * math.acos(math.cos(lambda1)))
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) return Float64(R_s * Float64(R_m * acos(cos(lambda1)))) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = R_s * (R_m * acos(cos(lambda1)));
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * N[(R$95$m * N[ArcCos[N[Cos[lambda1], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \left(R\_m \cdot \cos^{-1} \cos \lambda_1\right)
\end{array}
Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 26.5%
Taylor expanded in lambda2 around 0 17.5%
cos-neg17.5%
Simplified17.5%
R\_m = (fabs.f64 R) R\_s = (copysign.f64 #s(literal 1 binary64) R) NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function. (FPCore (R_s R_m lambda1 lambda2 phi1 phi2) :precision binary64 (* R_s (* R_m (- lambda2 lambda1))))
R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (R_m * (lambda2 - lambda1));
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r_s * (r_m * (lambda2 - lambda1))
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (R_m * (lambda2 - lambda1));
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): return R_s * (R_m * (lambda2 - lambda1))
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) return Float64(R_s * Float64(R_m * Float64(lambda2 - lambda1))) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = R_s * (R_m * (lambda2 - lambda1));
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * N[(R$95$m * N[(lambda2 - lambda1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \left(R\_m \cdot \left(\lambda_2 - \lambda_1\right)\right)
\end{array}
Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 26.5%
Taylor expanded in R around 0 5.0%
R\_m = (fabs.f64 R) R\_s = (copysign.f64 #s(literal 1 binary64) R) NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function. (FPCore (R_s R_m lambda1 lambda2 phi1 phi2) :precision binary64 (* R_s (* lambda1 (- R_m))))
R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (lambda1 * -R_m);
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r_s * (lambda1 * -r_m)
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (lambda1 * -R_m);
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): return R_s * (lambda1 * -R_m)
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) return Float64(R_s * Float64(lambda1 * Float64(-R_m))) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = R_s * (lambda1 * -R_m);
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * N[(lambda1 * (-R$95$m)), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \left(\lambda_1 \cdot \left(-R\_m\right)\right)
\end{array}
Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 26.5%
Taylor expanded in lambda2 around 0 5.2%
associate-*r*5.2%
mul-1-neg5.2%
Simplified5.2%
Final simplification5.2%
R\_m = (fabs.f64 R) R\_s = (copysign.f64 #s(literal 1 binary64) R) NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function. (FPCore (R_s R_m lambda1 lambda2 phi1 phi2) :precision binary64 (* R_s (* lambda2 R_m)))
R\_m = fabs(R);
R\_s = copysign(1.0, R);
assert(R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2);
double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (lambda2 * R_m);
}
R\_m = abs(r)
R\_s = copysign(1.0d0, r)
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
real(8) function code(r_s, r_m, lambda1, lambda2, phi1, phi2)
real(8), intent (in) :: r_s
real(8), intent (in) :: r_m
real(8), intent (in) :: lambda1
real(8), intent (in) :: lambda2
real(8), intent (in) :: phi1
real(8), intent (in) :: phi2
code = r_s * (lambda2 * r_m)
end function
R\_m = Math.abs(R);
R\_s = Math.copySign(1.0, R);
assert R_m < lambda1 && lambda1 < lambda2 && lambda2 < phi1 && phi1 < phi2;
public static double code(double R_s, double R_m, double lambda1, double lambda2, double phi1, double phi2) {
return R_s * (lambda2 * R_m);
}
R\_m = math.fabs(R) R\_s = math.copysign(1.0, R) [R_m, lambda1, lambda2, phi1, phi2] = sort([R_m, lambda1, lambda2, phi1, phi2]) def code(R_s, R_m, lambda1, lambda2, phi1, phi2): return R_s * (lambda2 * R_m)
R\_m = abs(R) R\_s = copysign(1.0, R) R_m, lambda1, lambda2, phi1, phi2 = sort([R_m, lambda1, lambda2, phi1, phi2]) function code(R_s, R_m, lambda1, lambda2, phi1, phi2) return Float64(R_s * Float64(lambda2 * R_m)) end
R\_m = abs(R);
R\_s = sign(R) * abs(1.0);
R_m, lambda1, lambda2, phi1, phi2 = num2cell(sort([R_m, lambda1, lambda2, phi1, phi2])){:}
function tmp = code(R_s, R_m, lambda1, lambda2, phi1, phi2)
tmp = R_s * (lambda2 * R_m);
end
R\_m = N[Abs[R], $MachinePrecision]
R\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[R]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
NOTE: R_m, lambda1, lambda2, phi1, and phi2 should be sorted in increasing order before calling this function.
code[R$95$s_, R$95$m_, lambda1_, lambda2_, phi1_, phi2_] := N[(R$95$s * N[(lambda2 * R$95$m), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
R\_m = \left|R\right|
\\
R\_s = \mathsf{copysign}\left(1, R\right)
\\
[R_m, lambda1, lambda2, phi1, phi2] = \mathsf{sort}([R_m, lambda1, lambda2, phi1, phi2])\\
\\
R\_s \cdot \left(\lambda_2 \cdot R\_m\right)
\end{array}
Initial program 72.0%
Simplified72.0%
Taylor expanded in phi2 around 0 43.3%
Taylor expanded in phi1 around 0 26.5%
Taylor expanded in lambda2 around inf 4.7%
*-commutative4.7%
Simplified4.7%
herbie shell --seed 2024182
(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))