
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= m -1.92e-62)
(* a_m (/ (pow k m) (fma k (+ k 10.0) 1.0)))
(if (<= m 0.00065)
(pow
(/ (sqrt (fma a_m (* m (log k)) a_m)) (hypot k (sqrt (fma k 10.0 1.0))))
2.0)
(* a_m (pow k m))))))a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= -1.92e-62) {
tmp = a_m * (pow(k, m) / fma(k, (k + 10.0), 1.0));
} else if (m <= 0.00065) {
tmp = pow((sqrt(fma(a_m, (m * log(k)), a_m)) / hypot(k, sqrt(fma(k, 10.0, 1.0)))), 2.0);
} else {
tmp = a_m * pow(k, m);
}
return a_s * tmp;
}
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= -1.92e-62) tmp = Float64(a_m * Float64((k ^ m) / fma(k, Float64(k + 10.0), 1.0))); elseif (m <= 0.00065) tmp = Float64(sqrt(fma(a_m, Float64(m * log(k)), a_m)) / hypot(k, sqrt(fma(k, 10.0, 1.0)))) ^ 2.0; else tmp = Float64(a_m * (k ^ m)); end return Float64(a_s * tmp) end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -1.92e-62], N[(a$95$m * N[(N[Power[k, m], $MachinePrecision] / N[(k * N[(k + 10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.00065], N[Power[N[(N[Sqrt[N[(a$95$m * N[(m * N[Log[k], $MachinePrecision]), $MachinePrecision] + a$95$m), $MachinePrecision]], $MachinePrecision] / N[Sqrt[k ^ 2 + N[Sqrt[N[(k * 10.0 + 1.0), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision], N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -1.92 \cdot 10^{-62}:\\
\;\;\;\;a\_m \cdot \frac{{k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)}\\
\mathbf{elif}\;m \leq 0.00065:\\
\;\;\;\;{\left(\frac{\sqrt{\mathsf{fma}\left(a\_m, m \cdot \log k, a\_m\right)}}{\mathsf{hypot}\left(k, \sqrt{\mathsf{fma}\left(k, 10, 1\right)}\right)}\right)}^{2}\\
\mathbf{else}:\\
\;\;\;\;a\_m \cdot {k}^{m}\\
\end{array}
\end{array}
if m < -1.92e-62Initial program 100.0%
associate-*l/100.0%
sqr-neg100.0%
associate-+l+100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
+-commutative100.0%
distribute-lft-in100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
distribute-lft-in100.0%
fma-undefine100.0%
associate-*r/100.0%
Simplified100.0%
if -1.92e-62 < m < 6.4999999999999997e-4Initial program 89.8%
*-commutative89.8%
Simplified89.8%
Taylor expanded in m around 0 89.8%
add-sqr-sqrt47.4%
sqrt-div38.9%
+-commutative38.9%
fma-define38.9%
+-commutative38.9%
add-sqr-sqrt38.9%
hypot-define38.9%
+-commutative38.9%
fma-define38.9%
sqrt-div38.9%
Applied egg-rr43.3%
unpow243.3%
Simplified43.3%
if 6.4999999999999997e-4 < m Initial program 78.6%
associate-*l/67.9%
sqr-neg67.9%
associate-+l+67.9%
sqr-neg67.9%
distribute-rgt-out67.9%
Simplified67.9%
Taylor expanded in k around 0 100.0%
Final simplification81.2%
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
:precision binary64
(let* ((t_0 (* a_m (pow k m))))
(*
a_s
(if (<= (/ t_0 (+ (+ 1.0 (* k 10.0)) (* k k))) 1e+271)
(* (pow k m) (/ a_m (+ 1.0 (* k (+ k 10.0)))))
t_0))))a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double t_0 = a_m * pow(k, m);
double tmp;
if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 1e+271) {
tmp = pow(k, m) * (a_m / (1.0 + (k * (k + 10.0))));
} else {
tmp = t_0;
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: tmp
t_0 = a_m * (k ** m)
if ((t_0 / ((1.0d0 + (k * 10.0d0)) + (k * k))) <= 1d+271) then
tmp = (k ** m) * (a_m / (1.0d0 + (k * (k + 10.0d0))))
else
tmp = t_0
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double t_0 = a_m * Math.pow(k, m);
double tmp;
if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 1e+271) {
tmp = Math.pow(k, m) * (a_m / (1.0 + (k * (k + 10.0))));
} else {
tmp = t_0;
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): t_0 = a_m * math.pow(k, m) tmp = 0 if (t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 1e+271: tmp = math.pow(k, m) * (a_m / (1.0 + (k * (k + 10.0)))) else: tmp = t_0 return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) t_0 = Float64(a_m * (k ^ m)) tmp = 0.0 if (Float64(t_0 / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) <= 1e+271) tmp = Float64((k ^ m) * Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = t_0; end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) t_0 = a_m * (k ^ m); tmp = 0.0; if ((t_0 / ((1.0 + (k * 10.0)) + (k * k))) <= 1e+271) tmp = (k ^ m) * (a_m / (1.0 + (k * (k + 10.0)))); else tmp = t_0; end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := Block[{t$95$0 = N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, N[(a$95$s * If[LessEqual[N[(t$95$0 / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 1e+271], N[(N[Power[k, m], $MachinePrecision] * N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]), $MachinePrecision]]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
\begin{array}{l}
t_0 := a\_m \cdot {k}^{m}\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;\frac{t\_0}{\left(1 + k \cdot 10\right) + k \cdot k} \leq 10^{+271}:\\
\;\;\;\;{k}^{m} \cdot \frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) < 9.99999999999999953e270Initial program 95.9%
associate-*l/94.9%
sqr-neg94.9%
associate-+l+94.9%
sqr-neg94.9%
distribute-rgt-out94.9%
Simplified94.9%
if 9.99999999999999953e270 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 1 (*.f64 10 k)) (*.f64 k k))) Initial program 60.0%
associate-*l/44.4%
sqr-neg44.4%
associate-+l+44.4%
sqr-neg44.4%
distribute-rgt-out44.4%
Simplified44.4%
Taylor expanded in k around 0 100.0%
Final simplification95.8%
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (<= m -3.8e-14)
(* a_m (/ (pow k m) (+ 1.0 (* k 10.0))))
(if (<= m 1e-6) (/ a_m (+ 1.0 (* k (+ k 10.0)))) (* a_m (pow k m))))))a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= -3.8e-14) {
tmp = a_m * (pow(k, m) / (1.0 + (k * 10.0)));
} else if (m <= 1e-6) {
tmp = a_m / (1.0 + (k * (k + 10.0)));
} else {
tmp = a_m * pow(k, m);
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= (-3.8d-14)) then
tmp = a_m * ((k ** m) / (1.0d0 + (k * 10.0d0)))
else if (m <= 1d-6) then
tmp = a_m / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a_m * (k ** m)
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= -3.8e-14) {
tmp = a_m * (Math.pow(k, m) / (1.0 + (k * 10.0)));
} else if (m <= 1e-6) {
tmp = a_m / (1.0 + (k * (k + 10.0)));
} else {
tmp = a_m * Math.pow(k, m);
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if m <= -3.8e-14: tmp = a_m * (math.pow(k, m) / (1.0 + (k * 10.0))) elif m <= 1e-6: tmp = a_m / (1.0 + (k * (k + 10.0))) else: tmp = a_m * math.pow(k, m) return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= -3.8e-14) tmp = Float64(a_m * Float64((k ^ m) / Float64(1.0 + Float64(k * 10.0)))); elseif (m <= 1e-6) tmp = Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a_m * (k ^ m)); end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if (m <= -3.8e-14) tmp = a_m * ((k ^ m) / (1.0 + (k * 10.0))); elseif (m <= 1e-6) tmp = a_m / (1.0 + (k * (k + 10.0))); else tmp = a_m * (k ^ m); end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, -3.8e-14], N[(a$95$m * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1e-6], N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -3.8 \cdot 10^{-14}:\\
\;\;\;\;a\_m \cdot \frac{{k}^{m}}{1 + k \cdot 10}\\
\mathbf{elif}\;m \leq 10^{-6}:\\
\;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a\_m \cdot {k}^{m}\\
\end{array}
\end{array}
if m < -3.8000000000000002e-14Initial program 100.0%
associate-*l/100.0%
sqr-neg100.0%
associate-+l+100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
Simplified100.0%
Taylor expanded in a around 0 100.0%
+-commutative100.0%
distribute-lft-in100.0%
unpow2100.0%
+-commutative100.0%
unpow2100.0%
distribute-lft-in100.0%
fma-undefine100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in k around 0 98.8%
if -3.8000000000000002e-14 < m < 9.99999999999999955e-7Initial program 90.6%
associate-*l/90.7%
sqr-neg90.7%
associate-+l+90.7%
sqr-neg90.7%
distribute-rgt-out90.7%
Simplified90.7%
Taylor expanded in m around 0 90.0%
if 9.99999999999999955e-7 < m Initial program 78.6%
associate-*l/67.9%
sqr-neg67.9%
associate-+l+67.9%
sqr-neg67.9%
distribute-rgt-out67.9%
Simplified67.9%
Taylor expanded in k around 0 100.0%
Final simplification96.0%
a_m = (fabs.f64 a)
a_s = (copysign.f64 1 a)
(FPCore (a_s a_m k m)
:precision binary64
(*
a_s
(if (or (<= m -4.6e-14) (not (<= m 7e-5)))
(* a_m (pow k m))
(/ a_m (+ 1.0 (* k (+ k 10.0)))))))a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if ((m <= -4.6e-14) || !(m <= 7e-5)) {
tmp = a_m * pow(k, m);
} else {
tmp = a_m / (1.0 + (k * (k + 10.0)));
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if ((m <= (-4.6d-14)) .or. (.not. (m <= 7d-5))) then
tmp = a_m * (k ** m)
else
tmp = a_m / (1.0d0 + (k * (k + 10.0d0)))
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if ((m <= -4.6e-14) || !(m <= 7e-5)) {
tmp = a_m * Math.pow(k, m);
} else {
tmp = a_m / (1.0 + (k * (k + 10.0)));
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if (m <= -4.6e-14) or not (m <= 7e-5): tmp = a_m * math.pow(k, m) else: tmp = a_m / (1.0 + (k * (k + 10.0))) return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if ((m <= -4.6e-14) || !(m <= 7e-5)) tmp = Float64(a_m * (k ^ m)); else tmp = Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0)))); end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if ((m <= -4.6e-14) || ~((m <= 7e-5))) tmp = a_m * (k ^ m); else tmp = a_m / (1.0 + (k * (k + 10.0))); end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[Or[LessEqual[m, -4.6e-14], N[Not[LessEqual[m, 7e-5]], $MachinePrecision]], N[(a$95$m * N[Power[k, m], $MachinePrecision]), $MachinePrecision], N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq -4.6 \cdot 10^{-14} \lor \neg \left(m \leq 7 \cdot 10^{-5}\right):\\
\;\;\;\;a\_m \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -4.59999999999999996e-14 or 6.9999999999999994e-5 < m Initial program 88.9%
associate-*l/83.4%
sqr-neg83.4%
associate-+l+83.4%
sqr-neg83.4%
distribute-rgt-out83.4%
Simplified83.4%
Taylor expanded in k around 0 99.4%
if -4.59999999999999996e-14 < m < 6.9999999999999994e-5Initial program 90.6%
associate-*l/90.7%
sqr-neg90.7%
associate-+l+90.7%
sqr-neg90.7%
distribute-rgt-out90.7%
Simplified90.7%
Taylor expanded in m around 0 90.0%
Final simplification96.0%
a_m = (fabs.f64 a) a_s = (copysign.f64 1 a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (if (<= m 260000.0) (* a_m (/ 1.0 (+ 1.0 (* k 10.0)))) (* a_m (* k -10.0)))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 260000.0) {
tmp = a_m * (1.0 / (1.0 + (k * 10.0)));
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 260000.0d0) then
tmp = a_m * (1.0d0 / (1.0d0 + (k * 10.0d0)))
else
tmp = a_m * (k * (-10.0d0))
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 260000.0) {
tmp = a_m * (1.0 / (1.0 + (k * 10.0)));
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if m <= 260000.0: tmp = a_m * (1.0 / (1.0 + (k * 10.0))) else: tmp = a_m * (k * -10.0) return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= 260000.0) tmp = Float64(a_m * Float64(1.0 / Float64(1.0 + Float64(k * 10.0)))); else tmp = Float64(a_m * Float64(k * -10.0)); end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if (m <= 260000.0) tmp = a_m * (1.0 / (1.0 + (k * 10.0))); else tmp = a_m * (k * -10.0); end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, 260000.0], N[(a$95$m * N[(1.0 / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m * N[(k * -10.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq 260000:\\
\;\;\;\;a\_m \cdot \frac{1}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;a\_m \cdot \left(k \cdot -10\right)\\
\end{array}
\end{array}
if m < 2.6e5Initial program 95.0%
associate-*l/94.4%
sqr-neg94.4%
associate-+l+94.4%
sqr-neg94.4%
distribute-rgt-out94.4%
Simplified94.4%
Taylor expanded in a around 0 95.0%
+-commutative95.0%
distribute-lft-in95.0%
unpow295.0%
+-commutative95.0%
unpow295.0%
distribute-lft-in95.0%
fma-undefine95.0%
associate-*r/95.0%
Simplified95.0%
Taylor expanded in m around 0 65.6%
Taylor expanded in k around 0 39.2%
*-commutative39.2%
Simplified39.2%
if 2.6e5 < m Initial program 78.0%
associate-*l/68.3%
sqr-neg68.3%
associate-+l+68.3%
sqr-neg68.3%
distribute-rgt-out68.3%
Simplified68.3%
Taylor expanded in a around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
unpow278.0%
+-commutative78.0%
unpow278.0%
distribute-lft-in78.0%
fma-undefine78.0%
associate-*r/78.0%
Simplified78.0%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in k around inf 21.0%
*-commutative21.0%
associate-*r*22.1%
Simplified22.1%
Final simplification33.8%
a_m = (fabs.f64 a) a_s = (copysign.f64 1 a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (if (<= m 1950000.0) (/ a_m (+ 1.0 (* k (+ k 10.0)))) (* a_m (* k -10.0)))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 1950000.0) {
tmp = a_m / (1.0 + (k * (k + 10.0)));
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 1950000.0d0) then
tmp = a_m / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a_m * (k * (-10.0d0))
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 1950000.0) {
tmp = a_m / (1.0 + (k * (k + 10.0)));
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if m <= 1950000.0: tmp = a_m / (1.0 + (k * (k + 10.0))) else: tmp = a_m * (k * -10.0) return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= 1950000.0) tmp = Float64(a_m / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a_m * Float64(k * -10.0)); end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if (m <= 1950000.0) tmp = a_m / (1.0 + (k * (k + 10.0))); else tmp = a_m * (k * -10.0); end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, 1950000.0], N[(a$95$m / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m * N[(k * -10.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq 1950000:\\
\;\;\;\;\frac{a\_m}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a\_m \cdot \left(k \cdot -10\right)\\
\end{array}
\end{array}
if m < 1.95e6Initial program 95.0%
associate-*l/94.4%
sqr-neg94.4%
associate-+l+94.4%
sqr-neg94.4%
distribute-rgt-out94.4%
Simplified94.4%
Taylor expanded in m around 0 65.6%
if 1.95e6 < m Initial program 78.0%
associate-*l/68.3%
sqr-neg68.3%
associate-+l+68.3%
sqr-neg68.3%
distribute-rgt-out68.3%
Simplified68.3%
Taylor expanded in a around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
unpow278.0%
+-commutative78.0%
unpow278.0%
distribute-lft-in78.0%
fma-undefine78.0%
associate-*r/78.0%
Simplified78.0%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in k around inf 21.0%
*-commutative21.0%
associate-*r*22.1%
Simplified22.1%
Final simplification51.7%
a_m = (fabs.f64 a) a_s = (copysign.f64 1 a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (if (<= m 6800000.0) (/ a_m (+ 1.0 (* k 10.0))) (* a_m (* k -10.0)))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 6800000.0) {
tmp = a_m / (1.0 + (k * 10.0));
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 6800000.0d0) then
tmp = a_m / (1.0d0 + (k * 10.0d0))
else
tmp = a_m * (k * (-10.0d0))
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 6800000.0) {
tmp = a_m / (1.0 + (k * 10.0));
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if m <= 6800000.0: tmp = a_m / (1.0 + (k * 10.0)) else: tmp = a_m * (k * -10.0) return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= 6800000.0) tmp = Float64(a_m / Float64(1.0 + Float64(k * 10.0))); else tmp = Float64(a_m * Float64(k * -10.0)); end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if (m <= 6800000.0) tmp = a_m / (1.0 + (k * 10.0)); else tmp = a_m * (k * -10.0); end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, 6800000.0], N[(a$95$m / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a$95$m * N[(k * -10.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq 6800000:\\
\;\;\;\;\frac{a\_m}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;a\_m \cdot \left(k \cdot -10\right)\\
\end{array}
\end{array}
if m < 6.8e6Initial program 95.0%
associate-*l/94.4%
sqr-neg94.4%
associate-+l+94.4%
sqr-neg94.4%
distribute-rgt-out94.4%
Simplified94.4%
Taylor expanded in m around 0 65.6%
Taylor expanded in k around 0 39.2%
*-commutative39.2%
Simplified39.2%
if 6.8e6 < m Initial program 78.0%
associate-*l/68.3%
sqr-neg68.3%
associate-+l+68.3%
sqr-neg68.3%
distribute-rgt-out68.3%
Simplified68.3%
Taylor expanded in a around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
unpow278.0%
+-commutative78.0%
unpow278.0%
distribute-lft-in78.0%
fma-undefine78.0%
associate-*r/78.0%
Simplified78.0%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in k around inf 21.0%
*-commutative21.0%
associate-*r*22.1%
Simplified22.1%
Final simplification33.8%
a_m = (fabs.f64 a) a_s = (copysign.f64 1 a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (if (<= m 2900000000000.0) a_m (* -10.0 (* a_m k)))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 2900000000000.0) {
tmp = a_m;
} else {
tmp = -10.0 * (a_m * k);
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 2900000000000.0d0) then
tmp = a_m
else
tmp = (-10.0d0) * (a_m * k)
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 2900000000000.0) {
tmp = a_m;
} else {
tmp = -10.0 * (a_m * k);
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if m <= 2900000000000.0: tmp = a_m else: tmp = -10.0 * (a_m * k) return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= 2900000000000.0) tmp = a_m; else tmp = Float64(-10.0 * Float64(a_m * k)); end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if (m <= 2900000000000.0) tmp = a_m; else tmp = -10.0 * (a_m * k); end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, 2900000000000.0], a$95$m, N[(-10.0 * N[(a$95$m * k), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq 2900000000000:\\
\;\;\;\;a\_m\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a\_m \cdot k\right)\\
\end{array}
\end{array}
if m < 2.9e12Initial program 95.0%
associate-*l/94.4%
sqr-neg94.4%
associate-+l+94.4%
sqr-neg94.4%
distribute-rgt-out94.4%
Simplified94.4%
Taylor expanded in m around 0 65.6%
Taylor expanded in k around 0 28.7%
if 2.9e12 < m Initial program 78.0%
associate-*l/68.3%
sqr-neg68.3%
associate-+l+68.3%
sqr-neg68.3%
distribute-rgt-out68.3%
Simplified68.3%
Taylor expanded in a around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
unpow278.0%
+-commutative78.0%
unpow278.0%
distribute-lft-in78.0%
fma-undefine78.0%
associate-*r/78.0%
Simplified78.0%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in k around inf 21.0%
Final simplification26.2%
a_m = (fabs.f64 a) a_s = (copysign.f64 1 a) (FPCore (a_s a_m k m) :precision binary64 (* a_s (if (<= m 250000.0) a_m (* a_m (* k -10.0)))))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 250000.0) {
tmp = a_m;
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 250000.0d0) then
tmp = a_m
else
tmp = a_m * (k * (-10.0d0))
end if
code = a_s * tmp
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
double tmp;
if (m <= 250000.0) {
tmp = a_m;
} else {
tmp = a_m * (k * -10.0);
}
return a_s * tmp;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): tmp = 0 if m <= 250000.0: tmp = a_m else: tmp = a_m * (k * -10.0) return a_s * tmp
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) tmp = 0.0 if (m <= 250000.0) tmp = a_m; else tmp = Float64(a_m * Float64(k * -10.0)); end return Float64(a_s * tmp) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp_2 = code(a_s, a_m, k, m) tmp = 0.0; if (m <= 250000.0) tmp = a_m; else tmp = a_m * (k * -10.0); end tmp_2 = a_s * tmp; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * If[LessEqual[m, 250000.0], a$95$m, N[(a$95$m * N[(k * -10.0), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot \begin{array}{l}
\mathbf{if}\;m \leq 250000:\\
\;\;\;\;a\_m\\
\mathbf{else}:\\
\;\;\;\;a\_m \cdot \left(k \cdot -10\right)\\
\end{array}
\end{array}
if m < 2.5e5Initial program 95.0%
associate-*l/94.4%
sqr-neg94.4%
associate-+l+94.4%
sqr-neg94.4%
distribute-rgt-out94.4%
Simplified94.4%
Taylor expanded in m around 0 65.6%
Taylor expanded in k around 0 28.7%
if 2.5e5 < m Initial program 78.0%
associate-*l/68.3%
sqr-neg68.3%
associate-+l+68.3%
sqr-neg68.3%
distribute-rgt-out68.3%
Simplified68.3%
Taylor expanded in a around 0 78.0%
+-commutative78.0%
distribute-lft-in78.0%
unpow278.0%
+-commutative78.0%
unpow278.0%
distribute-lft-in78.0%
fma-undefine78.0%
associate-*r/78.0%
Simplified78.0%
Taylor expanded in m around 0 3.0%
Taylor expanded in k around 0 8.8%
*-commutative8.8%
Simplified8.8%
Taylor expanded in k around inf 21.0%
*-commutative21.0%
associate-*r*22.1%
Simplified22.1%
Final simplification26.6%
a_m = (fabs.f64 a) a_s = (copysign.f64 1 a) (FPCore (a_s a_m k m) :precision binary64 (* a_s a_m))
a_m = fabs(a);
a_s = copysign(1.0, a);
double code(double a_s, double a_m, double k, double m) {
return a_s * a_m;
}
a_m = abs(a)
a_s = copysign(1.0d0, a)
real(8) function code(a_s, a_m, k, m)
real(8), intent (in) :: a_s
real(8), intent (in) :: a_m
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a_s * a_m
end function
a_m = Math.abs(a);
a_s = Math.copySign(1.0, a);
public static double code(double a_s, double a_m, double k, double m) {
return a_s * a_m;
}
a_m = math.fabs(a) a_s = math.copysign(1.0, a) def code(a_s, a_m, k, m): return a_s * a_m
a_m = abs(a) a_s = copysign(1.0, a) function code(a_s, a_m, k, m) return Float64(a_s * a_m) end
a_m = abs(a); a_s = sign(a) * abs(1.0); function tmp = code(a_s, a_m, k, m) tmp = a_s * a_m; end
a_m = N[Abs[a], $MachinePrecision]
a_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[a$95$s_, a$95$m_, k_, m_] := N[(a$95$s * a$95$m), $MachinePrecision]
\begin{array}{l}
a_m = \left|a\right|
\\
a_s = \mathsf{copysign}\left(1, a\right)
\\
a\_s \cdot a\_m
\end{array}
Initial program 89.6%
associate-*l/86.1%
sqr-neg86.1%
associate-+l+86.1%
sqr-neg86.1%
distribute-rgt-out86.1%
Simplified86.1%
Taylor expanded in m around 0 45.5%
Taylor expanded in k around 0 20.8%
Final simplification20.8%
herbie shell --seed 2024036
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))