
(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 12 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 5.4e-36) (* (/ (pow k m) (fma k (+ k 10.0) 1.0)) a) (/ a (pow k (- m)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 5.4e-36) {
tmp = (pow(k, m) / fma(k, (k + 10.0), 1.0)) * a;
} else {
tmp = a / pow(k, -m);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 5.4e-36) tmp = Float64(Float64((k ^ m) / fma(k, Float64(k + 10.0), 1.0)) * a); else tmp = Float64(a / (k ^ Float64(-m))); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 5.4e-36], N[(N[(N[Power[k, m], $MachinePrecision] / N[(k * N[(k + 10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(a / N[Power[k, (-m)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 5.4 \cdot 10^{-36}:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k, k + 10, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{{k}^{\left(-m\right)}}\\
\end{array}
\end{array}
if m < 5.40000000000000015e-36Initial program 97.5%
associate-*r/97.5%
*-commutative97.5%
associate-+l+97.5%
+-commutative97.5%
distribute-rgt-out97.5%
fma-def97.5%
+-commutative97.5%
Simplified97.5%
if 5.40000000000000015e-36 < m Initial program 80.6%
associate-/l*80.7%
associate-+l+80.7%
distribute-rgt-out80.7%
Simplified80.7%
Taylor expanded in k around 0 100.0%
pow-neg100.0%
neg-mul-1100.0%
pow-unpow100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
expm1-log1p-u74.9%
expm1-udef72.8%
inv-pow72.8%
metadata-eval72.8%
pow-pow72.8%
metadata-eval72.8%
Applied egg-rr72.8%
expm1-def74.9%
expm1-log1p100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification98.4%
(FPCore (a k m) :precision binary64 (if (<= m 5.4e-36) (/ a (/ (+ 1.0 (* k (+ k 10.0))) (pow k m))) (/ a (pow k (- m)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 5.4e-36) {
tmp = a / ((1.0 + (k * (k + 10.0))) / pow(k, m));
} else {
tmp = a / pow(k, -m);
}
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.4d-36) then
tmp = a / ((1.0d0 + (k * (k + 10.0d0))) / (k ** m))
else
tmp = a / (k ** -m)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 5.4e-36) {
tmp = a / ((1.0 + (k * (k + 10.0))) / Math.pow(k, m));
} else {
tmp = a / Math.pow(k, -m);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 5.4e-36: tmp = a / ((1.0 + (k * (k + 10.0))) / math.pow(k, m)) else: tmp = a / math.pow(k, -m) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 5.4e-36) tmp = Float64(a / Float64(Float64(1.0 + Float64(k * Float64(k + 10.0))) / (k ^ m))); else tmp = Float64(a / (k ^ Float64(-m))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 5.4e-36) tmp = a / ((1.0 + (k * (k + 10.0))) / (k ^ m)); else tmp = a / (k ^ -m); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 5.4e-36], N[(a / N[(N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[k, m], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / N[Power[k, (-m)], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 5.4 \cdot 10^{-36}:\\
\;\;\;\;\frac{a}{\frac{1 + k \cdot \left(k + 10\right)}{{k}^{m}}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{{k}^{\left(-m\right)}}\\
\end{array}
\end{array}
if m < 5.40000000000000015e-36Initial program 97.5%
associate-/l*97.5%
associate-+l+97.5%
distribute-rgt-out97.5%
Simplified97.5%
if 5.40000000000000015e-36 < m Initial program 80.6%
associate-/l*80.7%
associate-+l+80.7%
distribute-rgt-out80.7%
Simplified80.7%
Taylor expanded in k around 0 100.0%
pow-neg100.0%
neg-mul-1100.0%
pow-unpow100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
expm1-log1p-u74.9%
expm1-udef72.8%
inv-pow72.8%
metadata-eval72.8%
pow-pow72.8%
metadata-eval72.8%
Applied egg-rr72.8%
expm1-def74.9%
expm1-log1p100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification98.3%
(FPCore (a k m)
:precision binary64
(if (<= m -1.45e-5)
(* (pow k m) a)
(if (<= m 5.4e-36)
(* a (/ 1.0 (+ 1.0 (* k (+ k 10.0)))))
(/ a (pow k (- m))))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1.45e-5) {
tmp = pow(k, m) * a;
} else if (m <= 5.4e-36) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = a / pow(k, -m);
}
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.45d-5)) then
tmp = (k ** m) * a
else if (m <= 5.4d-36) then
tmp = a * (1.0d0 / (1.0d0 + (k * (k + 10.0d0))))
else
tmp = a / (k ** -m)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -1.45e-5) {
tmp = Math.pow(k, m) * a;
} else if (m <= 5.4e-36) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = a / Math.pow(k, -m);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -1.45e-5: tmp = math.pow(k, m) * a elif m <= 5.4e-36: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) else: tmp = a / math.pow(k, -m) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -1.45e-5) tmp = Float64((k ^ m) * a); elseif (m <= 5.4e-36) tmp = Float64(a * Float64(1.0 / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64(a / (k ^ Float64(-m))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -1.45e-5) tmp = (k ^ m) * a; elseif (m <= 5.4e-36) tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); else tmp = a / (k ^ -m); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -1.45e-5], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 5.4e-36], N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a / N[Power[k, (-m)], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.45 \cdot 10^{-5}:\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{elif}\;m \leq 5.4 \cdot 10^{-36}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{{k}^{\left(-m\right)}}\\
\end{array}
\end{array}
if m < -1.45e-5Initial program 100.0%
associate-*r/100.0%
*-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in k around 0 100.0%
if -1.45e-5 < m < 5.40000000000000015e-36Initial program 94.5%
associate-*r/94.6%
*-commutative94.6%
associate-+l+94.6%
+-commutative94.6%
distribute-rgt-out94.6%
fma-def94.6%
+-commutative94.6%
Simplified94.6%
Taylor expanded in m around 0 94.1%
if 5.40000000000000015e-36 < m Initial program 80.6%
associate-/l*80.7%
associate-+l+80.7%
distribute-rgt-out80.7%
Simplified80.7%
Taylor expanded in k around 0 100.0%
pow-neg100.0%
neg-mul-1100.0%
pow-unpow100.0%
Applied egg-rr100.0%
unpow-1100.0%
Simplified100.0%
expm1-log1p-u74.9%
expm1-udef72.8%
inv-pow72.8%
metadata-eval72.8%
pow-pow72.8%
metadata-eval72.8%
Applied egg-rr72.8%
expm1-def74.9%
expm1-log1p100.0%
mul-1-neg100.0%
Simplified100.0%
Final simplification98.2%
(FPCore (a k m) :precision binary64 (if (or (<= m -4.4e-10) (not (<= m 5.4e-36))) (* (pow k m) a) (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0)))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -4.4e-10) || !(m <= 5.4e-36)) {
tmp = pow(k, m) * a;
} else {
tmp = a * (1.0 / (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 <= (-4.4d-10)) .or. (.not. (m <= 5.4d-36))) then
tmp = (k ** m) * a
else
tmp = a * (1.0d0 / (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 <= -4.4e-10) || !(m <= 5.4e-36)) {
tmp = Math.pow(k, m) * a;
} else {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -4.4e-10) or not (m <= 5.4e-36): tmp = math.pow(k, m) * a else: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -4.4e-10) || !(m <= 5.4e-36)) tmp = Float64((k ^ m) * a); else tmp = Float64(a * Float64(1.0 / 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 <= -4.4e-10) || ~((m <= 5.4e-36))) tmp = (k ^ m) * a; else tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -4.4e-10], N[Not[LessEqual[m, 5.4e-36]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -4.4 \cdot 10^{-10} \lor \neg \left(m \leq 5.4 \cdot 10^{-36}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -4.3999999999999998e-10 or 5.40000000000000015e-36 < m Initial program 90.5%
associate-*r/90.5%
*-commutative90.5%
associate-+l+90.5%
+-commutative90.5%
distribute-rgt-out90.5%
fma-def90.5%
+-commutative90.5%
Simplified90.5%
Taylor expanded in k around 0 100.0%
if -4.3999999999999998e-10 < m < 5.40000000000000015e-36Initial program 94.5%
associate-*r/94.6%
*-commutative94.6%
associate-+l+94.6%
+-commutative94.6%
distribute-rgt-out94.6%
fma-def94.6%
+-commutative94.6%
Simplified94.6%
Taylor expanded in m around 0 94.1%
Final simplification98.2%
(FPCore (a k m) :precision binary64 (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0))))))
double code(double a, double k, double m) {
return a * (1.0 / (1.0 + (k * (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 / (1.0d0 + (k * (k + 10.0d0))))
end function
public static double code(double a, double k, double m) {
return a * (1.0 / (1.0 + (k * (k + 10.0))));
}
def code(a, k, m): return a * (1.0 / (1.0 + (k * (k + 10.0))))
function code(a, k, m) return Float64(a * Float64(1.0 / Float64(1.0 + Float64(k * Float64(k + 10.0))))) end
function tmp = code(a, k, m) tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); end
code[a_, k_, m_] := N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}
\end{array}
Initial program 91.7%
associate-*r/91.7%
*-commutative91.7%
associate-+l+91.7%
+-commutative91.7%
distribute-rgt-out91.7%
fma-def91.7%
+-commutative91.7%
Simplified91.7%
Taylor expanded in m around 0 44.6%
Final simplification44.6%
(FPCore (a k m) :precision binary64 (if (or (<= k -2.3e+159) (not (<= k 0.1))) (/ 0.1 (/ k a)) a))
double code(double a, double k, double m) {
double tmp;
if ((k <= -2.3e+159) || !(k <= 0.1)) {
tmp = 0.1 / (k / a);
} 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 ((k <= (-2.3d+159)) .or. (.not. (k <= 0.1d0))) then
tmp = 0.1d0 / (k / a)
else
tmp = a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if ((k <= -2.3e+159) || !(k <= 0.1)) {
tmp = 0.1 / (k / a);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if (k <= -2.3e+159) or not (k <= 0.1): tmp = 0.1 / (k / a) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if ((k <= -2.3e+159) || !(k <= 0.1)) tmp = Float64(0.1 / Float64(k / a)); else tmp = a; end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if ((k <= -2.3e+159) || ~((k <= 0.1))) tmp = 0.1 / (k / a); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[k, -2.3e+159], N[Not[LessEqual[k, 0.1]], $MachinePrecision]], N[(0.1 / N[(k / a), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq -2.3 \cdot 10^{+159} \lor \neg \left(k \leq 0.1\right):\\
\;\;\;\;\frac{0.1}{\frac{k}{a}}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if k < -2.29999999999999995e159 or 0.10000000000000001 < k Initial program 82.6%
associate-*r/82.6%
*-commutative82.6%
associate-+l+82.6%
+-commutative82.6%
distribute-rgt-out82.6%
fma-def82.6%
+-commutative82.6%
Simplified82.6%
Taylor expanded in m around 0 62.5%
Taylor expanded in k around 0 26.7%
*-commutative26.7%
Simplified26.7%
Taylor expanded in k around inf 26.7%
associate-*r/26.7%
associate-/l*28.6%
Simplified28.6%
if -2.29999999999999995e159 < k < 0.10000000000000001Initial program 98.6%
associate-*r/98.6%
*-commutative98.6%
associate-+l+98.6%
+-commutative98.6%
distribute-rgt-out98.6%
fma-def98.6%
+-commutative98.6%
Simplified98.6%
Taylor expanded in m around 0 31.1%
Taylor expanded in k around 0 30.1%
Final simplification29.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.0026) (/ 0.1 (/ k a)) (+ a (* -10.0 (* k a)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.0026) {
tmp = 0.1 / (k / a);
} 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 <= (-0.0026d0)) then
tmp = 0.1d0 / (k / a)
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 <= -0.0026) {
tmp = 0.1 / (k / a);
} else {
tmp = a + (-10.0 * (k * a));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.0026: tmp = 0.1 / (k / a) else: tmp = a + (-10.0 * (k * a)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.0026) tmp = Float64(0.1 / Float64(k / a)); 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 <= -0.0026) tmp = 0.1 / (k / a); else tmp = a + (-10.0 * (k * a)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.0026], N[(0.1 / N[(k / a), $MachinePrecision]), $MachinePrecision], N[(a + N[(-10.0 * N[(k * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.0026:\\
\;\;\;\;\frac{0.1}{\frac{k}{a}}\\
\mathbf{else}:\\
\;\;\;\;a + -10 \cdot \left(k \cdot a\right)\\
\end{array}
\end{array}
if m < -0.0025999999999999999Initial program 100.0%
associate-*r/100.0%
*-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 39.1%
Taylor expanded in k around 0 22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in k around inf 28.1%
associate-*r/28.1%
associate-/l*29.4%
Simplified29.4%
if -0.0025999999999999999 < m Initial program 87.2%
associate-*r/87.2%
*-commutative87.2%
associate-+l+87.2%
+-commutative87.2%
distribute-rgt-out87.2%
fma-def87.2%
+-commutative87.2%
Simplified87.2%
Taylor expanded in m around 0 47.6%
Taylor expanded in k around 0 28.0%
Final simplification28.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.0026) (/ 0.1 (/ k a)) (+ a (* k (* a -10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.0026) {
tmp = 0.1 / (k / a);
} 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 <= (-0.0026d0)) then
tmp = 0.1d0 / (k / a)
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 <= -0.0026) {
tmp = 0.1 / (k / a);
} else {
tmp = a + (k * (a * -10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.0026: tmp = 0.1 / (k / a) else: tmp = a + (k * (a * -10.0)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.0026) tmp = Float64(0.1 / Float64(k / a)); 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 <= -0.0026) tmp = 0.1 / (k / a); else tmp = a + (k * (a * -10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.0026], N[(0.1 / N[(k / a), $MachinePrecision]), $MachinePrecision], N[(a + N[(k * N[(a * -10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.0026:\\
\;\;\;\;\frac{0.1}{\frac{k}{a}}\\
\mathbf{else}:\\
\;\;\;\;a + k \cdot \left(a \cdot -10\right)\\
\end{array}
\end{array}
if m < -0.0025999999999999999Initial program 100.0%
associate-*r/100.0%
*-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 39.1%
Taylor expanded in k around 0 22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in k around inf 28.1%
associate-*r/28.1%
associate-/l*29.4%
Simplified29.4%
if -0.0025999999999999999 < m Initial program 87.2%
associate-*r/87.2%
*-commutative87.2%
associate-+l+87.2%
+-commutative87.2%
distribute-rgt-out87.2%
fma-def87.2%
+-commutative87.2%
Simplified87.2%
Taylor expanded in m around 0 47.6%
Taylor expanded in k around 0 32.3%
*-commutative32.3%
Simplified32.3%
Taylor expanded in k around 0 28.0%
*-commutative28.0%
*-commutative28.0%
associate-*l*28.0%
Simplified28.0%
Final simplification28.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.25) (/ 0.1 (/ k a)) (/ a (+ 1.0 (* k 10.0)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.25) {
tmp = 0.1 / (k / a);
} 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 <= (-0.25d0)) then
tmp = 0.1d0 / (k / a)
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 <= -0.25) {
tmp = 0.1 / (k / a);
} else {
tmp = a / (1.0 + (k * 10.0));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.25: tmp = 0.1 / (k / a) else: tmp = a / (1.0 + (k * 10.0)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.25) tmp = Float64(0.1 / Float64(k / a)); 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 <= -0.25) tmp = 0.1 / (k / a); else tmp = a / (1.0 + (k * 10.0)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.25], N[(0.1 / N[(k / a), $MachinePrecision]), $MachinePrecision], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.25:\\
\;\;\;\;\frac{0.1}{\frac{k}{a}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\end{array}
\end{array}
if m < -0.25Initial program 100.0%
associate-*r/100.0%
*-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 39.1%
Taylor expanded in k around 0 22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in k around inf 28.1%
associate-*r/28.1%
associate-/l*29.4%
Simplified29.4%
if -0.25 < m Initial program 87.2%
associate-*r/87.2%
*-commutative87.2%
associate-+l+87.2%
+-commutative87.2%
distribute-rgt-out87.2%
fma-def87.2%
+-commutative87.2%
Simplified87.2%
Taylor expanded in m around 0 47.6%
Taylor expanded in k around 0 32.3%
*-commutative32.3%
Simplified32.3%
Final simplification31.3%
(FPCore (a k m) :precision binary64 (/ a (+ 1.0 (* k (+ k 10.0)))))
double code(double a, double k, double m) {
return a / (1.0 + (k * (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 * (k + 10.0d0)))
end function
public static double code(double a, double k, double m) {
return a / (1.0 + (k * (k + 10.0)));
}
def code(a, k, m): return a / (1.0 + (k * (k + 10.0)))
function code(a, k, m) return Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))) end
function tmp = code(a, k, m) tmp = a / (1.0 + (k * (k + 10.0))); end
code[a_, k_, m_] := N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{1 + k \cdot \left(k + 10\right)}
\end{array}
Initial program 91.7%
associate-*r/91.7%
*-commutative91.7%
associate-+l+91.7%
+-commutative91.7%
distribute-rgt-out91.7%
fma-def91.7%
+-commutative91.7%
Simplified91.7%
Taylor expanded in m around 0 44.6%
Final simplification44.6%
(FPCore (a k m) :precision binary64 (if (<= m -0.00052) (* 0.1 (/ a k)) a))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.00052) {
tmp = 0.1 * (a / 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 <= (-0.00052d0)) then
tmp = 0.1d0 * (a / k)
else
tmp = a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -0.00052) {
tmp = 0.1 * (a / k);
} else {
tmp = a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.00052: tmp = 0.1 * (a / k) else: tmp = a return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.00052) tmp = Float64(0.1 * Float64(a / k)); else tmp = a; end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -0.00052) tmp = 0.1 * (a / k); else tmp = a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.00052], N[(0.1 * N[(a / k), $MachinePrecision]), $MachinePrecision], a]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.00052:\\
\;\;\;\;0.1 \cdot \frac{a}{k}\\
\mathbf{else}:\\
\;\;\;\;a\\
\end{array}
\end{array}
if m < -5.19999999999999954e-4Initial program 100.0%
associate-*r/100.0%
*-commutative100.0%
associate-+l+100.0%
+-commutative100.0%
distribute-rgt-out100.0%
fma-def100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in m around 0 39.1%
Taylor expanded in k around 0 22.0%
*-commutative22.0%
Simplified22.0%
Taylor expanded in k around inf 28.1%
if -5.19999999999999954e-4 < m Initial program 87.2%
associate-*r/87.2%
*-commutative87.2%
associate-+l+87.2%
+-commutative87.2%
distribute-rgt-out87.2%
fma-def87.2%
+-commutative87.2%
Simplified87.2%
Taylor expanded in m around 0 47.6%
Taylor expanded in k around 0 27.1%
Final simplification27.4%
(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 91.7%
associate-*r/91.7%
*-commutative91.7%
associate-+l+91.7%
+-commutative91.7%
distribute-rgt-out91.7%
fma-def91.7%
+-commutative91.7%
Simplified91.7%
Taylor expanded in m around 0 44.6%
Taylor expanded in k around 0 19.0%
Final simplification19.0%
herbie shell --seed 2023301
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))