
(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 (if (<= m -5e-127) (* a (/ (pow k m) (+ 1.0 (* k (+ k 10.0))))) (if (<= m 1.25e-11) (/ (/ a (hypot 1.0 k)) (hypot 1.0 k)) (* (pow k m) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -5e-127) {
tmp = a * (pow(k, m) / (1.0 + (k * (k + 10.0))));
} else if (m <= 1.25e-11) {
tmp = (a / hypot(1.0, k)) / hypot(1.0, k);
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
public static double code(double a, double k, double m) {
double tmp;
if (m <= -5e-127) {
tmp = a * (Math.pow(k, m) / (1.0 + (k * (k + 10.0))));
} else if (m <= 1.25e-11) {
tmp = (a / Math.hypot(1.0, k)) / Math.hypot(1.0, k);
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -5e-127: tmp = a * (math.pow(k, m) / (1.0 + (k * (k + 10.0)))) elif m <= 1.25e-11: tmp = (a / math.hypot(1.0, k)) / math.hypot(1.0, k) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= -5e-127) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * Float64(k + 10.0))))); elseif (m <= 1.25e-11) tmp = Float64(Float64(a / hypot(1.0, k)) / hypot(1.0, k)); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -5e-127) tmp = a * ((k ^ m) / (1.0 + (k * (k + 10.0)))); elseif (m <= 1.25e-11) tmp = (a / hypot(1.0, k)) / hypot(1.0, k); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -5e-127], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.25e-11], N[(N[(a / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision] / N[Sqrt[1.0 ^ 2 + k ^ 2], $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5 \cdot 10^{-127}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{elif}\;m \leq 1.25 \cdot 10^{-11}:\\
\;\;\;\;\frac{\frac{a}{\mathsf{hypot}\left(1, k\right)}}{\mathsf{hypot}\left(1, k\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < -4.9999999999999997e-127Initial 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%
if -4.9999999999999997e-127 < m < 1.25000000000000005e-11Initial program 90.3%
associate-/l*90.3%
remove-double-neg90.3%
distribute-frac-neg290.3%
distribute-neg-frac290.3%
remove-double-neg90.3%
sqr-neg90.3%
associate-+l+90.3%
sqr-neg90.3%
distribute-rgt-out90.3%
Simplified90.3%
Taylor expanded in m around 0 90.1%
Taylor expanded in k around inf 88.6%
*-un-lft-identity88.6%
add-sqr-sqrt88.6%
hypot-1-def88.6%
hypot-1-def88.6%
times-frac98.0%
Applied egg-rr98.0%
associate-*l/98.1%
*-lft-identity98.1%
Simplified98.1%
if 1.25000000000000005e-11 < m Initial program 79.7%
associate-/l*79.7%
remove-double-neg79.7%
distribute-frac-neg279.7%
distribute-neg-frac279.7%
remove-double-neg79.7%
sqr-neg79.7%
associate-+l+79.7%
sqr-neg79.7%
distribute-rgt-out79.7%
Simplified79.7%
Taylor expanded in k around 0 100.0%
Final simplification99.4%
(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.4%
associate-/l*90.4%
remove-double-neg90.4%
distribute-frac-neg290.4%
distribute-neg-frac290.4%
remove-double-neg90.4%
sqr-neg90.4%
associate-+l+90.4%
sqr-neg90.4%
distribute-rgt-out90.4%
Simplified90.4%
Taylor expanded in k around inf 89.8%
add-sqr-sqrt62.8%
pow262.8%
associate-*r/62.8%
*-commutative62.8%
sqrt-div59.9%
hypot-1-def63.7%
Applied egg-rr63.7%
(FPCore (a k m) :precision binary64 (if (<= m 1.35e-11) (* a (/ (pow k m) (+ 1.0 (* k (+ k 10.0))))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.35e-11) {
tmp = a * (pow(k, m) / (1.0 + (k * (k + 10.0))));
} 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 <= 1.35d-11) then
tmp = a * ((k ** m) / (1.0d0 + (k * (k + 10.0d0))))
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 <= 1.35e-11) {
tmp = a * (Math.pow(k, m) / (1.0 + (k * (k + 10.0))));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.35e-11: tmp = a * (math.pow(k, m) / (1.0 + (k * (k + 10.0)))) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.35e-11) tmp = Float64(a * Float64((k ^ m) / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.35e-11) tmp = a * ((k ^ m) / (1.0 + (k * (k + 10.0)))); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.35e-11], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.35 \cdot 10^{-11}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 1.35000000000000002e-11Initial program 95.6%
associate-/l*95.6%
remove-double-neg95.6%
distribute-frac-neg295.6%
distribute-neg-frac295.6%
remove-double-neg95.6%
sqr-neg95.6%
associate-+l+95.6%
sqr-neg95.6%
distribute-rgt-out95.6%
Simplified95.6%
if 1.35000000000000002e-11 < m Initial program 79.7%
associate-/l*79.7%
remove-double-neg79.7%
distribute-frac-neg279.7%
distribute-neg-frac279.7%
remove-double-neg79.7%
sqr-neg79.7%
associate-+l+79.7%
sqr-neg79.7%
distribute-rgt-out79.7%
Simplified79.7%
Taylor expanded in k around 0 100.0%
Final simplification97.0%
(FPCore (a k m) :precision binary64 (if (<= m 1.35e-11) (* a (/ (pow k m) (+ 1.0 (* k k)))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.35e-11) {
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 <= 1.35d-11) 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 <= 1.35e-11) {
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 <= 1.35e-11: 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 <= 1.35e-11) 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 <= 1.35e-11) 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, 1.35e-11], 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 1.35 \cdot 10^{-11}:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 1.35000000000000002e-11Initial program 95.6%
associate-/l*95.6%
remove-double-neg95.6%
distribute-frac-neg295.6%
distribute-neg-frac295.6%
remove-double-neg95.6%
sqr-neg95.6%
associate-+l+95.6%
sqr-neg95.6%
distribute-rgt-out95.6%
Simplified95.6%
Taylor expanded in k around inf 94.7%
if 1.35000000000000002e-11 < m Initial program 79.7%
associate-/l*79.7%
remove-double-neg79.7%
distribute-frac-neg279.7%
distribute-neg-frac279.7%
remove-double-neg79.7%
sqr-neg79.7%
associate-+l+79.7%
sqr-neg79.7%
distribute-rgt-out79.7%
Simplified79.7%
Taylor expanded in k around 0 100.0%
Final simplification96.5%
(FPCore (a k m) :precision binary64 (if (or (<= m -3.8e-6) (not (<= m 1.35e-11))) (* (pow k m) a) (/ a (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -3.8e-6) || !(m <= 1.35e-11)) {
tmp = pow(k, m) * a;
} 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 <= (-3.8d-6)) .or. (.not. (m <= 1.35d-11))) then
tmp = (k ** m) * a
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 <= -3.8e-6) || !(m <= 1.35e-11)) {
tmp = Math.pow(k, m) * a;
} else {
tmp = a / (1.0 + (k * (k + 10.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -3.8e-6) or not (m <= 1.35e-11): tmp = math.pow(k, m) * a else: tmp = a / (1.0 + (k * (k + 10.0))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -3.8e-6) || !(m <= 1.35e-11)) tmp = Float64((k ^ m) * a); 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 <= -3.8e-6) || ~((m <= 1.35e-11))) tmp = (k ^ m) * a; else tmp = a / (1.0 + (k * (k + 10.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -3.8e-6], N[Not[LessEqual[m, 1.35e-11]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $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 -3.8 \cdot 10^{-6} \lor \neg \left(m \leq 1.35 \cdot 10^{-11}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -3.8e-6 or 1.35000000000000002e-11 < m 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 k around 0 100.0%
if -3.8e-6 < m < 1.35000000000000002e-11Initial program 91.7%
associate-/l*91.6%
remove-double-neg91.6%
distribute-frac-neg291.6%
distribute-neg-frac291.6%
remove-double-neg91.6%
sqr-neg91.6%
associate-+l+91.6%
sqr-neg91.6%
distribute-rgt-out91.7%
Simplified91.7%
Taylor expanded in m around 0 91.0%
Final simplification96.8%
(FPCore (a k m) :precision binary64 (if (<= m 1.35e-11) (/ a (+ 1.0 (* k (+ k 10.0)))) (+ a (* a (* k (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.35e-11) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (k * (k * 99.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.35d-11) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = a + (a * (k * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.35e-11) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = a + (a * (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.35e-11: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = a + (a * (k * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.35e-11) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(a + Float64(a * Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.35e-11) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = a + (a * (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.35e-11], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.35 \cdot 10^{-11}:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 1.35000000000000002e-11Initial program 95.6%
associate-/l*95.6%
remove-double-neg95.6%
distribute-frac-neg295.6%
distribute-neg-frac295.6%
remove-double-neg95.6%
sqr-neg95.6%
associate-+l+95.6%
sqr-neg95.6%
distribute-rgt-out95.6%
Simplified95.6%
Taylor expanded in m around 0 65.3%
if 1.35000000000000002e-11 < m Initial program 79.7%
associate-/l*79.7%
remove-double-neg79.7%
distribute-frac-neg279.7%
distribute-neg-frac279.7%
remove-double-neg79.7%
sqr-neg79.7%
associate-+l+79.7%
sqr-neg79.7%
distribute-rgt-out79.7%
Simplified79.7%
Taylor expanded in m around 0 3.9%
Taylor expanded in k around 0 25.6%
cancel-sign-sub-inv25.6%
metadata-eval25.6%
mul-1-neg25.6%
distribute-rgt-neg-in25.6%
distribute-rgt1-in25.6%
distribute-lft-neg-in25.6%
metadata-eval25.6%
metadata-eval25.6%
*-commutative25.6%
Simplified25.6%
Taylor expanded in a around 0 32.3%
Taylor expanded in k around inf 32.3%
*-commutative32.3%
Simplified32.3%
Final simplification54.5%
(FPCore (a k m) :precision binary64 (if (<= m 1.35e-11) (/ a (+ 1.0 (* k k))) (+ a (* a (* k (* k 99.0))))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.35e-11) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (a * (k * (k * 99.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.35d-11) then
tmp = a / (1.0d0 + (k * k))
else
tmp = a + (a * (k * (k * 99.0d0)))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1.35e-11) {
tmp = a / (1.0 + (k * k));
} else {
tmp = a + (a * (k * (k * 99.0)));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1.35e-11: tmp = a / (1.0 + (k * k)) else: tmp = a + (a * (k * (k * 99.0))) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1.35e-11) tmp = Float64(a / Float64(1.0 + Float64(k * k))); else tmp = Float64(a + Float64(a * Float64(k * Float64(k * 99.0)))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1.35e-11) tmp = a / (1.0 + (k * k)); else tmp = a + (a * (k * (k * 99.0))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1.35e-11], N[(a / N[(1.0 + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(a * N[(k * N[(k * 99.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.35 \cdot 10^{-11}:\\
\;\;\;\;\frac{a}{1 + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + a \cdot \left(k \cdot \left(k \cdot 99\right)\right)\\
\end{array}
\end{array}
if m < 1.35000000000000002e-11Initial program 95.6%
associate-/l*95.6%
remove-double-neg95.6%
distribute-frac-neg295.6%
distribute-neg-frac295.6%
remove-double-neg95.6%
sqr-neg95.6%
associate-+l+95.6%
sqr-neg95.6%
distribute-rgt-out95.6%
Simplified95.6%
Taylor expanded in m around 0 65.3%
Taylor expanded in k around inf 64.5%
if 1.35000000000000002e-11 < m Initial program 79.7%
associate-/l*79.7%
remove-double-neg79.7%
distribute-frac-neg279.7%
distribute-neg-frac279.7%
remove-double-neg79.7%
sqr-neg79.7%
associate-+l+79.7%
sqr-neg79.7%
distribute-rgt-out79.7%
Simplified79.7%
Taylor expanded in m around 0 3.9%
Taylor expanded in k around 0 25.6%
cancel-sign-sub-inv25.6%
metadata-eval25.6%
mul-1-neg25.6%
distribute-rgt-neg-in25.6%
distribute-rgt1-in25.6%
distribute-lft-neg-in25.6%
metadata-eval25.6%
metadata-eval25.6%
*-commutative25.6%
Simplified25.6%
Taylor expanded in a around 0 32.3%
Taylor expanded in k around inf 32.3%
*-commutative32.3%
Simplified32.3%
(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 90.4%
associate-/l*90.4%
remove-double-neg90.4%
distribute-frac-neg290.4%
distribute-neg-frac290.4%
remove-double-neg90.4%
sqr-neg90.4%
associate-+l+90.4%
sqr-neg90.4%
distribute-rgt-out90.4%
Simplified90.4%
Taylor expanded in m around 0 45.2%
Taylor expanded in k around inf 44.6%
(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 90.4%
associate-/l*90.4%
remove-double-neg90.4%
distribute-frac-neg290.4%
distribute-neg-frac290.4%
remove-double-neg90.4%
sqr-neg90.4%
associate-+l+90.4%
sqr-neg90.4%
distribute-rgt-out90.4%
Simplified90.4%
Taylor expanded in m around 0 45.2%
Taylor expanded in k around 0 28.0%
*-commutative28.0%
Simplified28.0%
(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.4%
associate-/l*90.4%
remove-double-neg90.4%
distribute-frac-neg290.4%
distribute-neg-frac290.4%
remove-double-neg90.4%
sqr-neg90.4%
associate-+l+90.4%
sqr-neg90.4%
distribute-rgt-out90.4%
Simplified90.4%
Taylor expanded in m around 0 45.2%
Taylor expanded in k around 0 22.2%
Final simplification22.2%
(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.4%
associate-/l*90.4%
remove-double-neg90.4%
distribute-frac-neg290.4%
distribute-neg-frac290.4%
remove-double-neg90.4%
sqr-neg90.4%
associate-+l+90.4%
sqr-neg90.4%
distribute-rgt-out90.4%
Simplified90.4%
Taylor expanded in k around 0 83.6%
Taylor expanded in m around 0 21.8%
herbie shell --seed 2024158
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))