
(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 11 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 (* a (/ (pow k m) (fma k (+ k 10.0) 1.0))))
double code(double a, double k, double m) {
return a * (pow(k, m) / fma(k, (k + 10.0), 1.0));
}
function code(a, k, m) return Float64(a * Float64((k ^ m) / fma(k, Float64(k + 10.0), 1.0))) end
code[a_, k_, m_] := N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(k * N[(k + 10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \frac{{k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)}
\end{array}
Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* k 10.0)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (k * 10.0)) + (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 + (k * 10.0d0)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (k * 10.0)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (k * 10.0)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(k * 10.0)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (k * 10.0)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + k \cdot 10\right) + k \cdot k}
\end{array}
Initial program 100.0%
Final simplification100.0%
(FPCore (a k m) :precision binary64 (/ a (/ (+ 1.0 (* k (+ k 10.0))) (pow k m))))
double code(double a, double k, double m) {
return a / ((1.0 + (k * (k + 10.0))) / pow(k, m));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a / ((1.0d0 + (k * (k + 10.0d0))) / (k ** m))
end function
public static double code(double a, double k, double m) {
return a / ((1.0 + (k * (k + 10.0))) / Math.pow(k, m));
}
def code(a, k, m): return a / ((1.0 + (k * (k + 10.0))) / math.pow(k, m))
function code(a, k, m) return Float64(a / Float64(Float64(1.0 + Float64(k * Float64(k + 10.0))) / (k ^ m))) end
function tmp = code(a, k, m) tmp = a / ((1.0 + (k * (k + 10.0))) / (k ^ m)); end
code[a_, k_, m_] := N[(a / N[(N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[k, m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{\frac{1 + k \cdot \left(k + 10\right)}{{k}^{m}}}
\end{array}
Initial program 100.0%
associate-/l*100.0%
associate-+l+100.0%
*-commutative100.0%
Simplified100.0%
distribute-lft-out100.0%
+-commutative100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (a k m) :precision binary64 (* (* a (pow k m)) (+ 1.0 (* k -10.0))))
double code(double a, double k, double m) {
return (a * pow(k, m)) * (1.0 + (k * -10.0));
}
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 + (k * (-10.0d0)))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) * (1.0 + (k * -10.0));
}
def code(a, k, m): return (a * math.pow(k, m)) * (1.0 + (k * -10.0))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) * Float64(1.0 + Float64(k * -10.0))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) * (1.0 + (k * -10.0)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] * N[(1.0 + N[(k * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(a \cdot {k}^{m}\right) \cdot \left(1 + k \cdot -10\right)
\end{array}
Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 47.4%
exp-to-pow47.4%
exp-to-pow47.4%
exp-to-pow47.5%
exp-to-pow47.4%
associate-*r*47.4%
exp-to-pow47.4%
*-commutative47.4%
exp-to-pow81.1%
*-commutative81.1%
distribute-lft1-in99.0%
*-commutative99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (a k m) :precision binary64 (/ a (/ (+ 1.0 (* k k)) (pow k m))))
double code(double a, double k, double m) {
return a / ((1.0 + (k * k)) / pow(k, m));
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a / ((1.0d0 + (k * k)) / (k ** m))
end function
public static double code(double a, double k, double m) {
return a / ((1.0 + (k * k)) / Math.pow(k, m));
}
def code(a, k, m): return a / ((1.0 + (k * k)) / math.pow(k, m))
function code(a, k, m) return Float64(a / Float64(Float64(1.0 + Float64(k * k)) / (k ^ m))) end
function tmp = code(a, k, m) tmp = a / ((1.0 + (k * k)) / (k ^ m)); end
code[a_, k_, m_] := N[(a / N[(N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision] / N[Power[k, m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{\frac{1 + k \cdot k}{{k}^{m}}}
\end{array}
Initial program 100.0%
associate-/l*100.0%
associate-+l+100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around inf 99.4%
unpow299.4%
Simplified99.4%
Final simplification99.4%
(FPCore (a k m) :precision binary64 (/ a (pow k (- m))))
double code(double a, double k, double m) {
return a / pow(k, -m);
}
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)
end function
public static double code(double a, double k, double m) {
return a / Math.pow(k, -m);
}
def code(a, k, m): return a / math.pow(k, -m)
function code(a, k, m) return Float64(a / (k ^ Float64(-m))) end
function tmp = code(a, k, m) tmp = a / (k ^ -m); end
code[a_, k_, m_] := N[(a / N[Power[k, (-m)], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{{k}^{\left(-m\right)}}
\end{array}
Initial program 100.0%
associate-/l*100.0%
associate-+l+100.0%
*-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 65.2%
exp-to-pow98.8%
Simplified98.8%
Taylor expanded in k around 0 65.2%
rec-exp65.2%
distribute-rgt-neg-out65.2%
exp-to-pow98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (a k m) :precision binary64 (* a (pow k m)))
double code(double a, double k, double m) {
return a * pow(k, m);
}
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)
end function
public static double code(double a, double k, double m) {
return a * Math.pow(k, m);
}
def code(a, k, m): return a * math.pow(k, m)
function code(a, k, m) return Float64(a * (k ^ m)) end
function tmp = code(a, k, m) tmp = a * (k ^ m); end
code[a_, k_, m_] := N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot {k}^{m}
\end{array}
Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 65.2%
exp-to-pow98.8%
*-commutative98.8%
Simplified98.8%
Final simplification98.8%
(FPCore (a k m) :precision binary64 (if (<= m -0.136) (/ a (* k k)) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.136) {
tmp = a / (k * k);
} else {
tmp = a / (1.0 + (k * (k + 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 <= (-0.136d0)) then
tmp = a / (k * k)
else
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.136) {
tmp = a / (k * k);
} else {
tmp = a / (1.0 + (k * (k + 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.136: tmp = a / (k * k) else: tmp = a / (1.0 + (k * (k + 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.136) tmp = Float64(a / Float64(k * k)); else tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.136) tmp = a / (k * k); else tmp = a / (1.0 + (k * (k + 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.136], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.136:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -0.13600000000000001Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 4.0%
Taylor expanded in k around inf 63.6%
unpow263.6%
Simplified63.6%
if -0.13600000000000001 < m Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 50.0%
Final simplification54.9%
(FPCore (a k m) :precision binary64 (if (<= m -4.4e-5) (/ a (* k k)) (* a (+ 1.0 (* k -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -4.4e-5) {
tmp = a / (k * k);
} else {
tmp = a * (1.0 + (k * -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.4d-5)) then
tmp = a / (k * k)
else
tmp = a * (1.0d0 + (k * (-10.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -4.4e-5) {
tmp = a / (k * k);
} else {
tmp = a * (1.0 + (k * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -4.4e-5: tmp = a / (k * k) else: tmp = a * (1.0 + (k * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -4.4e-5) tmp = Float64(a / Float64(k * k)); else tmp = Float64(a * Float64(1.0 + Float64(k * -10.0))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -4.4e-5) tmp = a / (k * k); else tmp = a * (1.0 + (k * -10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -4.4e-5], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(a * N[(1.0 + N[(k * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -4.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \left(1 + k \cdot -10\right)\\
\end{array}
\end{array}
if m < -4.3999999999999999e-5Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 4.3%
Taylor expanded in k around inf 63.3%
unpow263.3%
Simplified63.3%
if -4.3999999999999999e-5 < m Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 72.0%
exp-to-pow72.0%
exp-to-pow72.0%
exp-to-pow72.1%
exp-to-pow72.0%
associate-*r*72.0%
exp-to-pow72.0%
*-commutative72.0%
exp-to-pow99.1%
*-commutative99.1%
distribute-lft1-in99.1%
*-commutative99.1%
Simplified99.1%
Taylor expanded in m around 0 49.2%
Final simplification54.3%
(FPCore (a k m) :precision binary64 (if (<= m -4.4e-5) (/ a (* k k)) a))
double code(double a, double k, double m) {
double tmp;
if (m <= -4.4e-5) {
tmp = a / (k * k);
} else {
tmp = 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 <= (-4.4d-5)) then
tmp = a / (k * k)
else
tmp = a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -4.4e-5) {
tmp = a / (k * k);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -4.4e-5: tmp = a / (k * k) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if (m <= -4.4e-5) tmp = Float64(a / Float64(k * k)); else tmp = a; end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -4.4e-5) tmp = a / (k * k); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -4.4e-5], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -4.4 \cdot 10^{-5}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if m < -4.3999999999999999e-5Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 4.3%
Taylor expanded in k around inf 63.3%
unpow263.3%
Simplified63.3%
if -4.3999999999999999e-5 < m Initial program 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 50.1%
Taylor expanded in k around 0 48.9%
Final simplification54.1%
(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 100.0%
associate-*r/100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 33.4%
Taylor expanded in k around 0 32.6%
Final simplification32.6%
herbie shell --seed 2023278
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))