
(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
(let* ((t_0 (* a (pow k m))) (t_1 (/ 1.0 t_0)))
(if (<= k 1e-10)
(* a (* (pow k m) (fma k -10.0 1.0)))
(/ 1.0 (+ t_1 (* k (+ (* 10.0 t_1) (/ k t_0))))))))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double t_1 = 1.0 / t_0;
double tmp;
if (k <= 1e-10) {
tmp = a * (pow(k, m) * fma(k, -10.0, 1.0));
} else {
tmp = 1.0 / (t_1 + (k * ((10.0 * t_1) + (k / t_0))));
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a * (k ^ m)) t_1 = Float64(1.0 / t_0) tmp = 0.0 if (k <= 1e-10) tmp = Float64(a * Float64((k ^ m) * fma(k, -10.0, 1.0))); else tmp = Float64(1.0 / Float64(t_1 + Float64(k * Float64(Float64(10.0 * t_1) + Float64(k / t_0))))); end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 / t$95$0), $MachinePrecision]}, If[LessEqual[k, 1e-10], N[(a * N[(N[Power[k, m], $MachinePrecision] * N[(k * -10.0 + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 / N[(t$95$1 + N[(k * N[(N[(10.0 * t$95$1), $MachinePrecision] + N[(k / t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
t_1 := \frac{1}{t\_0}\\
\mathbf{if}\;k \leq 10^{-10}:\\
\;\;\;\;a \cdot \left({k}^{m} \cdot \mathsf{fma}\left(k, -10, 1\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{t\_1 + k \cdot \left(10 \cdot t\_1 + \frac{k}{t\_0}\right)}\\
\end{array}
\end{array}
if k < 1.00000000000000004e-10Initial program 94.6%
associate-/l*94.6%
remove-double-neg94.6%
distribute-frac-neg294.6%
distribute-neg-frac294.6%
remove-double-neg94.6%
sqr-neg94.6%
associate-+l+94.6%
sqr-neg94.6%
distribute-rgt-out94.6%
Simplified94.6%
Taylor expanded in k around 0 88.7%
associate-*r*88.7%
*-lft-identity88.7%
distribute-rgt-out100.0%
*-commutative100.0%
fma-define100.0%
Simplified100.0%
if 1.00000000000000004e-10 < k Initial program 80.1%
associate-/l*80.1%
remove-double-neg80.1%
distribute-frac-neg280.1%
distribute-neg-frac280.1%
remove-double-neg80.1%
sqr-neg80.1%
associate-+l+80.1%
sqr-neg80.1%
distribute-rgt-out80.1%
Simplified80.1%
distribute-lft-in80.1%
associate-+l+80.1%
associate-*r/80.1%
clear-num80.1%
associate-+l+80.1%
distribute-lft-in80.1%
+-commutative80.1%
+-commutative80.1%
fma-undefine80.1%
*-commutative80.1%
Applied egg-rr80.1%
Taylor expanded in k around 0 99.0%
Final simplification99.7%
(FPCore (a k m) :precision binary64 (if (or (<= m -1.78e-9) (not (<= m 0.0029))) (* a (pow k m)) (/ 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 <= -1.78e-9) || !(m <= 0.0029)) {
tmp = a * pow(k, m);
} 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 <= (-1.78d-9)) .or. (.not. (m <= 0.0029d0))) then
tmp = a * (k ** m)
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 <= -1.78e-9) || !(m <= 0.0029)) {
tmp = a * Math.pow(k, m);
} 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 <= -1.78e-9) or not (m <= 0.0029): tmp = a * math.pow(k, m) 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 <= -1.78e-9) || !(m <= 0.0029)) tmp = Float64(a * (k ^ m)); 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 <= -1.78e-9) || ~((m <= 0.0029))) tmp = a * (k ^ m); 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, -1.78e-9], N[Not[LessEqual[m, 0.0029]], $MachinePrecision]], N[(a * N[Power[k, m], $MachinePrecision]), $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 -1.78 \cdot 10^{-9} \lor \neg \left(m \leq 0.0029\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\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 < -1.78e-9 or 0.0029 < m Initial program 89.1%
associate-/l*89.1%
remove-double-neg89.1%
distribute-frac-neg289.1%
distribute-neg-frac289.1%
remove-double-neg89.1%
sqr-neg89.1%
associate-+l+89.1%
sqr-neg89.1%
distribute-rgt-out89.1%
Simplified89.1%
Taylor expanded in k around 0 100.0%
if -1.78e-9 < m < 0.0029Initial program 90.7%
associate-/l*90.7%
remove-double-neg90.7%
distribute-frac-neg290.7%
distribute-neg-frac290.7%
remove-double-neg90.7%
sqr-neg90.7%
associate-+l+90.7%
sqr-neg90.7%
distribute-rgt-out90.7%
Simplified90.7%
distribute-lft-in90.7%
associate-+l+90.7%
associate-*r/90.7%
clear-num90.6%
associate-+l+90.6%
distribute-lft-in90.6%
+-commutative90.6%
+-commutative90.6%
fma-undefine90.6%
*-commutative90.6%
Applied egg-rr90.6%
Taylor expanded in k around 0 99.0%
Taylor expanded in m around 0 98.5%
Final simplification99.5%
(FPCore (a k m)
:precision binary64
(if (<= m -2e+49)
(/ 1.0 (/ (+ 1.0 (* k (+ k 10.0))) a))
(if (<= m 1.9)
(/ 1.0 (+ (/ 1.0 a) (* k (+ (* 10.0 (/ 1.0 a)) (/ k a)))))
(+ a (* a (* k (- (* k 99.0) 10.0)))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2e+49) {
tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a);
} else if (m <= 1.9) {
tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a))));
} 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 <= (-2d+49)) then
tmp = 1.0d0 / ((1.0d0 + (k * (k + 10.0d0))) / a)
else if (m <= 1.9d0) then
tmp = 1.0d0 / ((1.0d0 / a) + (k * ((10.0d0 * (1.0d0 / a)) + (k / a))))
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 <= -2e+49) {
tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a);
} else if (m <= 1.9) {
tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a))));
} else {
tmp = a + (a * (k * ((k * 99.0) - 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -2e+49: tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a) elif m <= 1.9: tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a)))) else: tmp = a + (a * (k * ((k * 99.0) - 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -2e+49) tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(k * Float64(k + 10.0))) / a)); elseif (m <= 1.9) tmp = Float64(1.0 / Float64(Float64(1.0 / a) + Float64(k * Float64(Float64(10.0 * Float64(1.0 / a)) + Float64(k / a))))); 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 <= -2e+49) tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a); elseif (m <= 1.9) tmp = 1.0 / ((1.0 / a) + (k * ((10.0 * (1.0 / a)) + (k / a)))); else tmp = a + (a * (k * ((k * 99.0) - 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -2e+49], N[(1.0 / N[(N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.9], 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], 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 -2 \cdot 10^{+49}:\\
\;\;\;\;\frac{1}{\frac{1 + k \cdot \left(k + 10\right)}{a}}\\
\mathbf{elif}\;m \leq 1.9:\\
\;\;\;\;\frac{1}{\frac{1}{a} + k \cdot \left(10 \cdot \frac{1}{a} + \frac{k}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99 - 10\right)\right)\\
\end{array}
\end{array}
if m < -1.99999999999999989e49Initial program 100.0%
associate-/l*100.0%
remove-double-neg100.0%
distribute-frac-neg2100.0%
distribute-neg-frac2100.0%
remove-double-neg100.0%
sqr-neg100.0%
associate-+l+100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
Simplified100.0%
distribute-lft-in100.0%
associate-+l+100.0%
associate-*r/100.0%
clear-num100.0%
associate-+l+100.0%
distribute-lft-in100.0%
+-commutative100.0%
+-commutative100.0%
fma-undefine100.0%
*-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in m around 0 35.3%
if -1.99999999999999989e49 < m < 1.8999999999999999Initial program 91.7%
associate-/l*91.7%
remove-double-neg91.7%
distribute-frac-neg291.7%
distribute-neg-frac291.7%
remove-double-neg91.7%
sqr-neg91.7%
associate-+l+91.7%
sqr-neg91.7%
distribute-rgt-out91.7%
Simplified91.7%
distribute-lft-in91.7%
associate-+l+91.7%
associate-*r/91.7%
clear-num91.6%
associate-+l+91.6%
distribute-lft-in91.6%
+-commutative91.6%
+-commutative91.6%
fma-undefine91.6%
*-commutative91.6%
Applied egg-rr91.6%
Taylor expanded in k around 0 96.1%
Taylor expanded in m around 0 92.3%
if 1.8999999999999999 < m Initial program 81.8%
associate-/l*81.8%
remove-double-neg81.8%
distribute-frac-neg281.8%
distribute-neg-frac281.8%
remove-double-neg81.8%
sqr-neg81.8%
associate-+l+81.8%
sqr-neg81.8%
distribute-rgt-out81.8%
Simplified81.8%
Taylor expanded in m around 0 3.1%
Taylor expanded in k around 0 19.9%
cancel-sign-sub-inv19.9%
metadata-eval19.9%
mul-1-neg19.9%
distribute-rgt1-in19.9%
metadata-eval19.9%
*-commutative19.9%
Simplified19.9%
Taylor expanded in k around 0 19.9%
+-commutative19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
*-commutative19.9%
associate-*r*19.9%
fma-define19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
distribute-rgt-neg-in19.9%
fmm-def19.9%
associate-*l*19.9%
distribute-rgt-neg-out19.9%
distribute-lft-neg-out19.9%
distribute-rgt-out--19.9%
distribute-rgt-neg-in19.9%
metadata-eval19.9%
Simplified19.9%
Taylor expanded in a around 0 27.5%
Final simplification54.8%
(FPCore (a k m) :precision binary64 (if (<= m 1.9) (/ 1.0 (/ (+ 1.0 (* k (+ k 10.0))) a)) (+ a (* a (* k (- (* k 99.0) 10.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.9) {
tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a);
} 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 <= 1.9d0) then
tmp = 1.0d0 / ((1.0d0 + (k * (k + 10.0d0))) / a)
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 <= 1.9) {
tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a);
} else {
tmp = a + (a * (k * ((k * 99.0) - 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.9: tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a) else: tmp = a + (a * (k * ((k * 99.0) - 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.9) tmp = Float64(1.0 / Float64(Float64(1.0 + Float64(k * Float64(k + 10.0))) / a)); 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 <= 1.9) tmp = 1.0 / ((1.0 + (k * (k + 10.0))) / a); else tmp = a + (a * (k * ((k * 99.0) - 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.9], N[(1.0 / N[(N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $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 1.9:\\
\;\;\;\;\frac{1}{\frac{1 + k \cdot \left(k + 10\right)}{a}}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99 - 10\right)\right)\\
\end{array}
\end{array}
if m < 1.8999999999999999Initial program 94.7%
associate-/l*94.7%
remove-double-neg94.7%
distribute-frac-neg294.7%
distribute-neg-frac294.7%
remove-double-neg94.7%
sqr-neg94.7%
associate-+l+94.7%
sqr-neg94.7%
distribute-rgt-out94.7%
Simplified94.7%
distribute-lft-in94.7%
associate-+l+94.7%
associate-*r/94.7%
clear-num94.6%
associate-+l+94.6%
distribute-lft-in94.6%
+-commutative94.6%
+-commutative94.6%
fma-undefine94.6%
*-commutative94.6%
Applied egg-rr94.6%
Taylor expanded in m around 0 67.2%
if 1.8999999999999999 < m Initial program 81.8%
associate-/l*81.8%
remove-double-neg81.8%
distribute-frac-neg281.8%
distribute-neg-frac281.8%
remove-double-neg81.8%
sqr-neg81.8%
associate-+l+81.8%
sqr-neg81.8%
distribute-rgt-out81.8%
Simplified81.8%
Taylor expanded in m around 0 3.1%
Taylor expanded in k around 0 19.9%
cancel-sign-sub-inv19.9%
metadata-eval19.9%
mul-1-neg19.9%
distribute-rgt1-in19.9%
metadata-eval19.9%
*-commutative19.9%
Simplified19.9%
Taylor expanded in k around 0 19.9%
+-commutative19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
*-commutative19.9%
associate-*r*19.9%
fma-define19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
distribute-rgt-neg-in19.9%
fmm-def19.9%
associate-*l*19.9%
distribute-rgt-neg-out19.9%
distribute-lft-neg-out19.9%
distribute-rgt-out--19.9%
distribute-rgt-neg-in19.9%
metadata-eval19.9%
Simplified19.9%
Taylor expanded in a around 0 27.5%
Final simplification51.9%
(FPCore (a k m) :precision binary64 (if (<= m 1.98) (/ a (+ 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 <= 1.98) {
tmp = a / (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 <= 1.98d0) then
tmp = a / (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 <= 1.98) {
tmp = a / (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 <= 1.98: tmp = a / (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 <= 1.98) tmp = Float64(a / 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 <= 1.98) tmp = a / (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, 1.98], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $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 1.98:\\
\;\;\;\;\frac{a}{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 < 1.98Initial program 94.7%
associate-/l*94.7%
remove-double-neg94.7%
distribute-frac-neg294.7%
distribute-neg-frac294.7%
remove-double-neg94.7%
sqr-neg94.7%
associate-+l+94.7%
sqr-neg94.7%
distribute-rgt-out94.7%
Simplified94.7%
Taylor expanded in m around 0 66.4%
if 1.98 < m Initial program 81.8%
associate-/l*81.8%
remove-double-neg81.8%
distribute-frac-neg281.8%
distribute-neg-frac281.8%
remove-double-neg81.8%
sqr-neg81.8%
associate-+l+81.8%
sqr-neg81.8%
distribute-rgt-out81.8%
Simplified81.8%
Taylor expanded in m around 0 3.1%
Taylor expanded in k around 0 19.9%
cancel-sign-sub-inv19.9%
metadata-eval19.9%
mul-1-neg19.9%
distribute-rgt1-in19.9%
metadata-eval19.9%
*-commutative19.9%
Simplified19.9%
Taylor expanded in k around 0 19.9%
+-commutative19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
*-commutative19.9%
associate-*r*19.9%
fma-define19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
distribute-rgt-neg-in19.9%
fmm-def19.9%
associate-*l*19.9%
distribute-rgt-neg-out19.9%
distribute-lft-neg-out19.9%
distribute-rgt-out--19.9%
distribute-rgt-neg-in19.9%
metadata-eval19.9%
Simplified19.9%
Taylor expanded in a around 0 27.5%
Final simplification51.3%
(FPCore (a k m) :precision binary64 (if (<= m 2.15) (/ a (+ 1.0 (* k (+ k 10.0)))) (+ a (* k (* 99.0 (* k a))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.15) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (k * (99.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 <= 2.15d0) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a + (k * (99.0d0 * (k * a)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 2.15) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (k * (99.0 * (k * a)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 2.15: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a + (k * (99.0 * (k * a))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 2.15) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a + Float64(k * Float64(99.0 * Float64(k * a)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 2.15) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a + (k * (99.0 * (k * a))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 2.15], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(99.0 * N[(k * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.15:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(99 \cdot \left(k \cdot a\right)\right)\\
\end{array}
\end{array}
if m < 2.14999999999999991Initial program 94.7%
associate-/l*94.7%
remove-double-neg94.7%
distribute-frac-neg294.7%
distribute-neg-frac294.7%
remove-double-neg94.7%
sqr-neg94.7%
associate-+l+94.7%
sqr-neg94.7%
distribute-rgt-out94.7%
Simplified94.7%
Taylor expanded in m around 0 66.4%
if 2.14999999999999991 < m Initial program 81.8%
associate-/l*81.8%
remove-double-neg81.8%
distribute-frac-neg281.8%
distribute-neg-frac281.8%
remove-double-neg81.8%
sqr-neg81.8%
associate-+l+81.8%
sqr-neg81.8%
distribute-rgt-out81.8%
Simplified81.8%
Taylor expanded in m around 0 3.1%
Taylor expanded in k around 0 19.9%
cancel-sign-sub-inv19.9%
metadata-eval19.9%
mul-1-neg19.9%
distribute-rgt1-in19.9%
metadata-eval19.9%
*-commutative19.9%
Simplified19.9%
Taylor expanded in k around 0 19.9%
+-commutative19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
*-commutative19.9%
associate-*r*19.9%
fma-define19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
distribute-rgt-neg-in19.9%
fmm-def19.9%
associate-*l*19.9%
distribute-rgt-neg-out19.9%
distribute-lft-neg-out19.9%
distribute-rgt-out--19.9%
distribute-rgt-neg-in19.9%
metadata-eval19.9%
Simplified19.9%
Taylor expanded in k around inf 19.9%
Final simplification48.4%
(FPCore (a k m) :precision binary64 (if (<= m 1.98) (/ a (+ 1.0 (* k k))) (+ a (* k (* 99.0 (* k a))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.98) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (k * (99.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.98d0) then
tmp = a / (1.0d0 + (k * k))
else
tmp = a + (k * (99.0d0 * (k * a)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.98) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (k * (99.0 * (k * a)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.98: tmp = a / (1.0 + (k * k)) else: tmp = a + (k * (99.0 * (k * a))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.98) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(a + Float64(k * Float64(99.0 * Float64(k * a)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.98) tmp = a / (1.0 + (k * k)); else tmp = a + (k * (99.0 * (k * a))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.98], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(99.0 * N[(k * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.98:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(99 \cdot \left(k \cdot a\right)\right)\\
\end{array}
\end{array}
if m < 1.98Initial program 94.7%
associate-/l*94.7%
remove-double-neg94.7%
distribute-frac-neg294.7%
distribute-neg-frac294.7%
remove-double-neg94.7%
sqr-neg94.7%
associate-+l+94.7%
sqr-neg94.7%
distribute-rgt-out94.7%
Simplified94.7%
Taylor expanded in m around 0 66.4%
Taylor expanded in k around inf 63.0%
if 1.98 < m Initial program 81.8%
associate-/l*81.8%
remove-double-neg81.8%
distribute-frac-neg281.8%
distribute-neg-frac281.8%
remove-double-neg81.8%
sqr-neg81.8%
associate-+l+81.8%
sqr-neg81.8%
distribute-rgt-out81.8%
Simplified81.8%
Taylor expanded in m around 0 3.1%
Taylor expanded in k around 0 19.9%
cancel-sign-sub-inv19.9%
metadata-eval19.9%
mul-1-neg19.9%
distribute-rgt1-in19.9%
metadata-eval19.9%
*-commutative19.9%
Simplified19.9%
Taylor expanded in k around 0 19.9%
+-commutative19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
*-commutative19.9%
associate-*r*19.9%
fma-define19.9%
*-commutative19.9%
metadata-eval19.9%
distribute-lft-neg-in19.9%
distribute-rgt-neg-in19.9%
fmm-def19.9%
associate-*l*19.9%
distribute-rgt-neg-out19.9%
distribute-lft-neg-out19.9%
distribute-rgt-out--19.9%
distribute-rgt-neg-in19.9%
metadata-eval19.9%
Simplified19.9%
Taylor expanded in k around inf 19.9%
Final simplification46.4%
(FPCore (a k m) :precision binary64 (/ a (+ 1.0 (* k k))))
double code(double a, double k, double m) {
return a / (1.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 / (1.0d0 + (k * k))
end function
public static double code(double a, double k, double m) {
return a / (1.0 + (k * k));
}
def code(a, k, m): return a / (1.0 + (k * k))
function code(a, k, m) return Float64(a / Float64(1.0 + Float64(k * k))) end
function tmp = code(a, k, m) tmp = a / (1.0 + (k * k)); end
code[a_, k_, m_] := N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{1 + k \cdot k}
\end{array}
Initial program 89.7%
associate-/l*89.7%
remove-double-neg89.7%
distribute-frac-neg289.7%
distribute-neg-frac289.7%
remove-double-neg89.7%
sqr-neg89.7%
associate-+l+89.7%
sqr-neg89.7%
distribute-rgt-out89.7%
Simplified89.7%
Taylor expanded in m around 0 41.9%
Taylor expanded in k around inf 39.9%
(FPCore (a k m) :precision binary64 (/ a (+ 1.0 (* k 10.0))))
double code(double a, double k, double m) {
return a / (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 / (1.0d0 + (k * 10.0d0))
end function
public static double code(double a, double k, double m) {
return a / (1.0 + (k * 10.0));
}
def code(a, k, m): return a / (1.0 + (k * 10.0))
function code(a, k, m) return Float64(a / Float64(1.0 + Float64(k * 10.0))) end
function tmp = code(a, k, m) tmp = a / (1.0 + (k * 10.0)); end
code[a_, k_, m_] := N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{1 + k \cdot 10}
\end{array}
Initial program 89.7%
associate-/l*89.7%
remove-double-neg89.7%
distribute-frac-neg289.7%
distribute-neg-frac289.7%
remove-double-neg89.7%
sqr-neg89.7%
associate-+l+89.7%
sqr-neg89.7%
distribute-rgt-out89.7%
Simplified89.7%
Taylor expanded in m around 0 41.9%
Taylor expanded in k around 0 27.9%
*-commutative27.9%
Simplified27.9%
(FPCore (a k m) :precision binary64 (+ a (* k (* a -10.0))))
double code(double a, double k, double m) {
return a + (k * (a * -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 * (a * (-10.0d0)))
end function
public static double code(double a, double k, double m) {
return a + (k * (a * -10.0));
}
def code(a, k, m): return a + (k * (a * -10.0))
function code(a, k, m) return Float64(a + Float64(k * Float64(a * -10.0))) end
function tmp = code(a, k, m) tmp = a + (k * (a * -10.0)); end
code[a_, k_, m_] := N[(a + N[(k * N[(a * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a + k \cdot \left(a \cdot -10\right)
\end{array}
Initial program 89.7%
associate-/l*89.7%
remove-double-neg89.7%
distribute-frac-neg289.7%
distribute-neg-frac289.7%
remove-double-neg89.7%
sqr-neg89.7%
associate-+l+89.7%
sqr-neg89.7%
distribute-rgt-out89.7%
Simplified89.7%
Taylor expanded in m around 0 41.9%
Taylor expanded in k around 0 24.9%
cancel-sign-sub-inv24.9%
metadata-eval24.9%
mul-1-neg24.9%
distribute-rgt1-in24.9%
metadata-eval24.9%
*-commutative24.9%
Simplified24.9%
Taylor expanded in k around 0 18.6%
*-commutative18.6%
*-commutative18.6%
associate-*r*18.9%
Simplified18.9%
(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 89.7%
associate-/l*89.7%
remove-double-neg89.7%
distribute-frac-neg289.7%
distribute-neg-frac289.7%
remove-double-neg89.7%
sqr-neg89.7%
associate-+l+89.7%
sqr-neg89.7%
distribute-rgt-out89.7%
Simplified89.7%
Taylor expanded in m around 0 41.9%
Taylor expanded in k around 0 18.7%
herbie shell --seed 2024157
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))