
(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 13 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}
(FPCore (a k m) :precision binary64 (if (<= (/ (* (pow k m) a) (+ (+ 1.0 (* k 10.0)) (* k k))) INFINITY) (* a (/ (pow k m) (+ 1.0 (* k (+ k 10.0))))) (+ a (* a (* k (- (* k 99.0) 10.0))))))
double code(double a, double k, double m) {
double tmp;
if (((pow(k, m) * a) / ((1.0 + (k * 10.0)) + (k * k))) <= ((double) INFINITY)) {
tmp = a * (pow(k, m) / (1.0 + (k * (k + 10.0))));
} else {
tmp = a + (a * (k * ((k * 99.0) - 10.0)));
}
return tmp;
}
public static double code(double a, double k, double m) {
double tmp;
if (((Math.pow(k, m) * a) / ((1.0 + (k * 10.0)) + (k * k))) <= Double.POSITIVE_INFINITY) {
tmp = a * (Math.pow(k, m) / (1.0 + (k * (k + 10.0))));
} else {
tmp = a + (a * (k * ((k * 99.0) - 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if ((math.pow(k, m) * a) / ((1.0 + (k * 10.0)) + (k * k))) <= math.inf: tmp = a * (math.pow(k, m) / (1.0 + (k * (k + 10.0)))) else: tmp = a + (a * (k * ((k * 99.0) - 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (Float64(Float64((k ^ m) * a) / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) <= Inf) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64(a + Float64(a * Float64(k * Float64(Float64(k * 99.0) - 10.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((((k ^ m) * a) / ((1.0 + (k * 10.0)) + (k * k))) <= Inf) tmp = a * ((k ^ m) / (1.0 + (k * (k + 10.0)))); else tmp = a + (a * (k * ((k * 99.0) - 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], Infinity], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(N[(k * 99.0), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{{k}^{m} \cdot a}{\left(1 + k \cdot 10\right) + k \cdot k} \leq \infty:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99 - 10\right)\right)\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < +inf.0Initial program 99.1%
associate-/l*99.1%
remove-double-neg99.1%
distribute-frac-neg299.1%
distribute-neg-frac299.1%
remove-double-neg99.1%
sqr-neg99.1%
associate-+l+99.1%
sqr-neg99.1%
distribute-rgt-out99.1%
Simplified99.1%
if +inf.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 0.0%
associate-/l*0.0%
remove-double-neg0.0%
distribute-frac-neg20.0%
distribute-neg-frac20.0%
remove-double-neg0.0%
sqr-neg0.0%
associate-+l+0.0%
sqr-neg0.0%
distribute-rgt-out0.0%
Simplified0.0%
Taylor expanded in m around 0 1.6%
Taylor expanded in k around 0 87.5%
cancel-sign-sub-inv87.5%
metadata-eval87.5%
associate-*r*87.5%
neg-mul-187.5%
distribute-rgt1-in87.5%
metadata-eval87.5%
*-commutative87.5%
Simplified87.5%
Taylor expanded in a around 0 100.0%
Final simplification99.2%
(FPCore (a k m) :precision binary64 (pow (/ (sqrt (* (pow k m) a)) (hypot 1.0 k)) 2.0))
double code(double a, double k, double m) {
return pow((sqrt((pow(k, m) * a)) / hypot(1.0, k)), 2.0);
}
public static double code(double a, double k, double m) {
return Math.pow((Math.sqrt((Math.pow(k, m) * a)) / Math.hypot(1.0, k)), 2.0);
}
def code(a, k, m): return math.pow((math.sqrt((math.pow(k, m) * a)) / math.hypot(1.0, k)), 2.0)
function code(a, k, m) return Float64(sqrt(Float64((k ^ m) * a)) / hypot(1.0, k)) ^ 2.0 end
function tmp = code(a, k, m) tmp = (sqrt(((k ^ m) * a)) / hypot(1.0, k)) ^ 2.0; end
code[a_, k_, m_] := N[Power[N[(N[Sqrt[N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]
\begin{array}{l}
\\
{\left(\frac{\sqrt{{k}^{m} \cdot a}}{\mathsf{hypot}\left(1, k\right)}\right)}^{2}
\end{array}
Initial program 90.6%
associate-/l*90.6%
remove-double-neg90.6%
distribute-frac-neg290.6%
distribute-neg-frac290.6%
remove-double-neg90.6%
sqr-neg90.6%
associate-+l+90.6%
sqr-neg90.6%
distribute-rgt-out90.6%
Simplified90.6%
Taylor expanded in k around inf 89.9%
add-sqr-sqrt65.5%
pow265.5%
associate-*r/65.5%
*-commutative65.5%
add-sqr-sqrt60.4%
unpow260.4%
sqrt-div60.4%
unpow260.4%
add-sqr-sqrt60.4%
hypot-1-def65.4%
Applied egg-rr65.4%
(FPCore (a k m) :precision binary64 (* a (/ (/ (pow k m) (hypot 1.0 k)) (hypot 1.0 k))))
double code(double a, double k, double m) {
return a * ((pow(k, m) / hypot(1.0, k)) / hypot(1.0, k));
}
public static double code(double a, double k, double m) {
return a * ((Math.pow(k, m) / Math.hypot(1.0, k)) / Math.hypot(1.0, k));
}
def code(a, k, m): return a * ((math.pow(k, m) / math.hypot(1.0, k)) / math.hypot(1.0, k))
function code(a, k, m) return Float64(a * Float64(Float64((k ^ m) / hypot(1.0, k)) / hypot(1.0, k))) end
function tmp = code(a, k, m) tmp = a * (((k ^ m) / hypot(1.0, k)) / hypot(1.0, k)); end
code[a_, k_, m_] := N[(a * N[(N[(N[Power[k, m], $MachinePrecision] / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \frac{\frac{{k}^{m}}{\mathsf{hypot}\left(1, k\right)}}{\mathsf{hypot}\left(1, k\right)}
\end{array}
Initial program 90.6%
associate-/l*90.6%
remove-double-neg90.6%
distribute-frac-neg290.6%
distribute-neg-frac290.6%
remove-double-neg90.6%
sqr-neg90.6%
associate-+l+90.6%
sqr-neg90.6%
distribute-rgt-out90.6%
Simplified90.6%
Taylor expanded in k around inf 89.9%
*-un-lft-identity89.9%
add-sqr-sqrt89.9%
times-frac89.9%
hypot-1-def89.9%
hypot-1-def98.8%
Applied egg-rr98.8%
associate-*l/98.8%
*-lft-identity98.8%
Simplified98.8%
(FPCore (a k m) :precision binary64 (if (<= m 3.95) (* a (/ (pow k m) (+ 1.0 (* k k)))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.95) {
tmp = a * (pow(k, m) / (1.0 + (k * k)));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 3.95d0) then
tmp = a * ((k ** m) / (1.0d0 + (k * k)))
else
tmp = (k ** m) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 3.95) {
tmp = a * (Math.pow(k, m) / (1.0 + (k * k)));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 3.95: tmp = a * (math.pow(k, m) / (1.0 + (k * k))) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 3.95) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * k)))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 3.95) tmp = a * ((k ^ m) / (1.0 + (k * k))); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 3.95], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.95:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 3.9500000000000002Initial program 98.9%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
distribute-neg-frac298.9%
remove-double-neg98.9%
sqr-neg98.9%
associate-+l+98.9%
sqr-neg98.9%
distribute-rgt-out98.9%
Simplified98.9%
Taylor expanded in k around inf 97.9%
if 3.9500000000000002 < m Initial program 69.9%
associate-/l*69.9%
remove-double-neg69.9%
distribute-frac-neg269.9%
distribute-neg-frac269.9%
remove-double-neg69.9%
sqr-neg69.9%
associate-+l+69.9%
sqr-neg69.9%
distribute-rgt-out69.9%
Simplified69.9%
Taylor expanded in k around 0 100.0%
Final simplification98.5%
(FPCore (a k m) :precision binary64 (if (or (<= m -9.5e-7) (not (<= m 0.0004))) (* (pow k m) a) (/ 1.0 (+ (/ 1.0 a) (* k (+ (* 10.0 (/ 1.0 a)) (/ k a)))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -9.5e-7) || !(m <= 0.0004)) {
tmp = pow(k, m) * a;
} else {
tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a))));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if ((m <= (-9.5d-7)) .or. (.not. (m <= 0.0004d0))) then
tmp = (k ** m) * a
else
tmp = 1.0d0 / ((1.0d0 / a) + (k * ((10.0d0 * (1.0d0 / a)) + (k / a))))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((m <= -9.5e-7) || !(m <= 0.0004)) {
tmp = Math.pow(k, m) * a;
} else {
tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a))));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -9.5e-7) or not (m <= 0.0004): tmp = math.pow(k, m) * a else: tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a)))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -9.5e-7) || !(m <= 0.0004)) tmp = Float64((k ^ m) * a); else tmp = Float64(1.0 / Float64(Float64(1.0 / a) + Float64(k * Float64(Float64(10.0 * Float64(1.0 / a)) + Float64(k / a))))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((m <= -9.5e-7) || ~((m <= 0.0004))) tmp = (k ^ m) * a; else tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a)))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -9.5e-7], N[Not[LessEqual[m, 0.0004]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(1.0 / N[(N[(1.0 / a), $MachinePrecision] + N[(k * N[(N[(10.0 * N[(1.0 / a), $MachinePrecision]), $MachinePrecision] + N[(k / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -9.5 \cdot 10^{-7} \lor \neg \left(m \leq 0.0004\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\frac{1}{a} + k \cdot \left(10 \cdot \frac{1}{a} + \frac{k}{a}\right)}\\
\end{array}
\end{array}
if m < -9.5000000000000001e-7 or 4.00000000000000019e-4 < m Initial program 87.0%
associate-/l*87.0%
remove-double-neg87.0%
distribute-frac-neg287.0%
distribute-neg-frac287.0%
remove-double-neg87.0%
sqr-neg87.0%
associate-+l+87.0%
sqr-neg87.0%
distribute-rgt-out87.0%
Simplified87.0%
Taylor expanded in k around 0 99.4%
if -9.5000000000000001e-7 < m < 4.00000000000000019e-4Initial program 97.6%
associate-/l*97.7%
remove-double-neg97.7%
distribute-frac-neg297.7%
distribute-neg-frac297.7%
remove-double-neg97.7%
sqr-neg97.7%
associate-+l+97.7%
sqr-neg97.7%
distribute-rgt-out97.7%
Simplified97.7%
Taylor expanded in m around 0 97.2%
clear-num96.2%
inv-pow96.2%
+-commutative96.2%
fma-define96.2%
+-commutative96.2%
Applied egg-rr96.2%
unpow-196.2%
Simplified96.2%
Taylor expanded in k around 0 98.4%
Final simplification99.1%
(FPCore (a k m) :precision binary64 (if (<= m 1650.0) (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0))))) (+ a (* a (* k (- (* k 99.0) 10.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1650.0) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = a + (a * (k * ((k * 99.0) - 10.0)));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 1650.0d0) then
tmp = a * (1.0d0 / (1.0d0 + (k * (k + 10.0d0))))
else
tmp = a + (a * (k * ((k * 99.0d0) - 10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1650.0) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = a + (a * (k * ((k * 99.0) - 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1650.0: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) else: tmp = a + (a * (k * ((k * 99.0) - 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1650.0) tmp = Float64(a * Float64(1.0 / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64(a + Float64(a * Float64(k * Float64(Float64(k * 99.0) - 10.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1650.0) tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); else tmp = a + (a * (k * ((k * 99.0) - 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1650.0], N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(N[(k * 99.0), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1650:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99 - 10\right)\right)\\
\end{array}
\end{array}
if m < 1650Initial program 98.9%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
distribute-neg-frac298.9%
remove-double-neg98.9%
sqr-neg98.9%
associate-+l+98.9%
sqr-neg98.9%
distribute-rgt-out98.9%
Simplified98.9%
Taylor expanded in m around 0 66.1%
if 1650 < m Initial program 69.4%
associate-/l*69.4%
remove-double-neg69.4%
distribute-frac-neg269.4%
distribute-neg-frac269.4%
remove-double-neg69.4%
sqr-neg69.4%
associate-+l+69.4%
sqr-neg69.4%
distribute-rgt-out69.4%
Simplified69.4%
Taylor expanded in m around 0 2.7%
Taylor expanded in k around 0 37.3%
cancel-sign-sub-inv37.3%
metadata-eval37.3%
associate-*r*37.3%
neg-mul-137.3%
distribute-rgt1-in37.3%
metadata-eval37.3%
*-commutative37.3%
Simplified37.3%
Taylor expanded in a around 0 41.1%
Final simplification59.0%
(FPCore (a k m) :precision binary64 (if (<= m 1e+16) (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0))))) (+ a (* k (* a -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1e+16) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 1d+16) then
tmp = a * (1.0d0 / (1.0d0 + (k * (k + 10.0d0))))
else
tmp = a + (k * (a * (-10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1e+16) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1e+16: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) else: tmp = a + (k * (a * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1e+16) tmp = Float64(a * Float64(1.0 / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64(a + Float64(k * Float64(a * -10.0))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1e+16) tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); else tmp = a + (k * (a * -10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1e+16], N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(a * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 10^{+16}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(a \cdot -10\right)\\
\end{array}
\end{array}
if m < 1e16Initial program 98.9%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
distribute-neg-frac298.9%
remove-double-neg98.9%
sqr-neg98.9%
associate-+l+98.9%
sqr-neg98.9%
distribute-rgt-out98.9%
Simplified98.9%
Taylor expanded in m around 0 65.4%
if 1e16 < m Initial program 68.6%
associate-/l*68.6%
remove-double-neg68.6%
distribute-frac-neg268.6%
distribute-neg-frac268.6%
remove-double-neg68.6%
sqr-neg68.6%
associate-+l+68.6%
sqr-neg68.6%
distribute-rgt-out68.6%
Simplified68.6%
Taylor expanded in m around 0 2.7%
clear-num2.7%
inv-pow2.7%
+-commutative2.7%
fma-define2.7%
+-commutative2.7%
Applied egg-rr2.7%
unpow-12.7%
Simplified2.7%
Taylor expanded in k around 0 15.5%
*-commutative15.5%
*-commutative15.5%
associate-*r*15.5%
Simplified15.5%
Final simplification51.8%
(FPCore (a k m) :precision binary64 (if (<= m 4.5e+15) (/ a (+ 1.0 (* k (+ k 10.0)))) (+ a (* k (* a -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 4.5e+15) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 4.5d+15) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a + (k * (a * (-10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 4.5e+15) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 4.5e+15: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a + (k * (a * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 4.5e+15) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a + Float64(k * Float64(a * -10.0))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 4.5e+15) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a + (k * (a * -10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 4.5e+15], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(a * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 4.5 \cdot 10^{+15}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(a \cdot -10\right)\\
\end{array}
\end{array}
if m < 4.5e15Initial program 98.9%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
distribute-neg-frac298.9%
remove-double-neg98.9%
sqr-neg98.9%
associate-+l+98.9%
sqr-neg98.9%
distribute-rgt-out98.9%
Simplified98.9%
Taylor expanded in m around 0 65.4%
if 4.5e15 < m Initial program 68.6%
associate-/l*68.6%
remove-double-neg68.6%
distribute-frac-neg268.6%
distribute-neg-frac268.6%
remove-double-neg68.6%
sqr-neg68.6%
associate-+l+68.6%
sqr-neg68.6%
distribute-rgt-out68.6%
Simplified68.6%
Taylor expanded in m around 0 2.7%
clear-num2.7%
inv-pow2.7%
+-commutative2.7%
fma-define2.7%
+-commutative2.7%
Applied egg-rr2.7%
unpow-12.7%
Simplified2.7%
Taylor expanded in k around 0 15.5%
*-commutative15.5%
*-commutative15.5%
associate-*r*15.5%
Simplified15.5%
Final simplification51.7%
(FPCore (a k m) :precision binary64 (if (<= m 5.5e+15) (* a (/ 1.0 (+ 1.0 (* k k)))) (+ a (* k (* a -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 5.5e+15) {
tmp = a * (1.0 / (1.0 + (k * k)));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 5.5d+15) then
tmp = a * (1.0d0 / (1.0d0 + (k * k)))
else
tmp = a + (k * (a * (-10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 5.5e+15) {
tmp = a * (1.0 / (1.0 + (k * k)));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 5.5e+15: tmp = a * (1.0 / (1.0 + (k * k))) else: tmp = a + (k * (a * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 5.5e+15) tmp = Float64(a * Float64(1.0 / Float64(1.0 + Float64(k * k)))); else tmp = Float64(a + Float64(k * Float64(a * -10.0))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 5.5e+15) tmp = a * (1.0 / (1.0 + (k * k))); else tmp = a + (k * (a * -10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 5.5e+15], N[(a * N[(1.0 / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(a * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 5.5 \cdot 10^{+15}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(a \cdot -10\right)\\
\end{array}
\end{array}
if m < 5.5e15Initial program 98.9%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
distribute-neg-frac298.9%
remove-double-neg98.9%
sqr-neg98.9%
associate-+l+98.9%
sqr-neg98.9%
distribute-rgt-out98.9%
Simplified98.9%
Taylor expanded in k around inf 98.0%
Taylor expanded in m around 0 64.5%
if 5.5e15 < m Initial program 68.6%
associate-/l*68.6%
remove-double-neg68.6%
distribute-frac-neg268.6%
distribute-neg-frac268.6%
remove-double-neg68.6%
sqr-neg68.6%
associate-+l+68.6%
sqr-neg68.6%
distribute-rgt-out68.6%
Simplified68.6%
Taylor expanded in m around 0 2.7%
clear-num2.7%
inv-pow2.7%
+-commutative2.7%
fma-define2.7%
+-commutative2.7%
Applied egg-rr2.7%
unpow-12.7%
Simplified2.7%
Taylor expanded in k around 0 15.5%
*-commutative15.5%
*-commutative15.5%
associate-*r*15.5%
Simplified15.5%
(FPCore (a k m) :precision binary64 (if (<= m 1.38e+19) (/ a (+ 1.0 (* k k))) (+ a (* -10.0 (* k a)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.38e+19) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (-10.0 * (k * a));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 1.38d+19) then
tmp = a / (1.0d0 + (k * k))
else
tmp = a + ((-10.0d0) * (k * a))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.38e+19) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (-10.0 * (k * a));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.38e+19: tmp = a / (1.0 + (k * k)) else: tmp = a + (-10.0 * (k * a)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.38e+19) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(a + Float64(-10.0 * Float64(k * a))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.38e+19) tmp = a / (1.0 + (k * k)); else tmp = a + (-10.0 * (k * a)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.38e+19], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(-10.0 * N[(k * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.38 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + -10 \cdot \left(k \cdot a\right)\\
\end{array}
\end{array}
if m < 1.38e19Initial program 98.9%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
distribute-neg-frac298.9%
remove-double-neg98.9%
sqr-neg98.9%
associate-+l+98.9%
sqr-neg98.9%
distribute-rgt-out98.9%
Simplified98.9%
Taylor expanded in m around 0 65.1%
Taylor expanded in k around inf 64.1%
if 1.38e19 < m Initial program 68.1%
associate-/l*68.1%
remove-double-neg68.1%
distribute-frac-neg268.1%
distribute-neg-frac268.1%
remove-double-neg68.1%
sqr-neg68.1%
associate-+l+68.1%
sqr-neg68.1%
distribute-rgt-out68.1%
Simplified68.1%
Taylor expanded in m around 0 2.6%
Taylor expanded in k around 0 15.7%
Final simplification51.1%
(FPCore (a k m) :precision binary64 (if (<= m 2.5e+17) (/ a (+ 1.0 (* k 10.0))) (+ a (* k (* a -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.5e+17) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 2.5d+17) then
tmp = a / (1.0d0 + (k * 10.0d0))
else
tmp = a + (k * (a * (-10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 2.5e+17) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 2.5e+17: tmp = a / (1.0 + (k * 10.0)) else: tmp = a + (k * (a * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 2.5e+17) tmp = Float64(a / Float64(1.0 + Float64(k * 10.0))); else tmp = Float64(a + Float64(k * Float64(a * -10.0))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 2.5e+17) tmp = a / (1.0 + (k * 10.0)); else tmp = a + (k * (a * -10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 2.5e+17], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(a * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.5 \cdot 10^{+17}:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(a \cdot -10\right)\\
\end{array}
\end{array}
if m < 2.5e17Initial program 98.9%
associate-/l*98.9%
remove-double-neg98.9%
distribute-frac-neg298.9%
distribute-neg-frac298.9%
remove-double-neg98.9%
sqr-neg98.9%
associate-+l+98.9%
sqr-neg98.9%
distribute-rgt-out98.9%
Simplified98.9%
Taylor expanded in m around 0 65.4%
Taylor expanded in k around 0 39.8%
*-commutative39.8%
Simplified39.8%
if 2.5e17 < m Initial program 68.6%
associate-/l*68.6%
remove-double-neg68.6%
distribute-frac-neg268.6%
distribute-neg-frac268.6%
remove-double-neg68.6%
sqr-neg68.6%
associate-+l+68.6%
sqr-neg68.6%
distribute-rgt-out68.6%
Simplified68.6%
Taylor expanded in m around 0 2.7%
clear-num2.7%
inv-pow2.7%
+-commutative2.7%
fma-define2.7%
+-commutative2.7%
Applied egg-rr2.7%
unpow-12.7%
Simplified2.7%
Taylor expanded in k around 0 15.5%
*-commutative15.5%
*-commutative15.5%
associate-*r*15.5%
Simplified15.5%
(FPCore (a k m) :precision binary64 (+ a (* -10.0 (* k a))))
double code(double a, double k, double m) {
return a + (-10.0 * (k * a));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a + ((-10.0d0) * (k * a))
end function
public static double code(double a, double k, double m) {
return a + (-10.0 * (k * a));
}
def code(a, k, m): return a + (-10.0 * (k * a))
function code(a, k, m) return Float64(a + Float64(-10.0 * Float64(k * a))) end
function tmp = code(a, k, m) tmp = a + (-10.0 * (k * a)); end
code[a_, k_, m_] := N[(a + N[(-10.0 * N[(k * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + -10 \cdot \left(k \cdot a\right)
\end{array}
Initial program 90.6%
associate-/l*90.6%
remove-double-neg90.6%
distribute-frac-neg290.6%
distribute-neg-frac290.6%
remove-double-neg90.6%
sqr-neg90.6%
associate-+l+90.6%
sqr-neg90.6%
distribute-rgt-out90.6%
Simplified90.6%
Taylor expanded in m around 0 48.2%
Taylor expanded in k around 0 23.3%
Final simplification23.3%
(FPCore (a k m) :precision binary64 a)
double code(double a, double k, double m) {
return a;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a
end function
public static double code(double a, double k, double m) {
return a;
}
def code(a, k, m): return a
function code(a, k, m) return a end
function tmp = code(a, k, m) tmp = a; end
code[a_, k_, m_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 90.6%
associate-/l*90.6%
remove-double-neg90.6%
distribute-frac-neg290.6%
distribute-neg-frac290.6%
remove-double-neg90.6%
sqr-neg90.6%
associate-+l+90.6%
sqr-neg90.6%
distribute-rgt-out90.6%
Simplified90.6%
Taylor expanded in k around 0 83.4%
Taylor expanded in m around 0 20.2%
herbie shell --seed 2024167
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))