
(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 (hypot k (sqrt (fma k 10.0 1.0)))))
(if (<= m -8e-25)
(/ (/ a (fma k (+ k 10.0) 1.0)) (pow (/ 1.0 k) m))
(if (<= m 0.00052) (/ (/ a t_0) t_0) (* a (pow k m))))))
double code(double a, double k, double m) {
double t_0 = hypot(k, sqrt(fma(k, 10.0, 1.0)));
double tmp;
if (m <= -8e-25) {
tmp = (a / fma(k, (k + 10.0), 1.0)) / pow((1.0 / k), m);
} else if (m <= 0.00052) {
tmp = (a / t_0) / t_0;
} else {
tmp = a * pow(k, m);
}
return tmp;
}
function code(a, k, m) t_0 = hypot(k, sqrt(fma(k, 10.0, 1.0))) tmp = 0.0 if (m <= -8e-25) tmp = Float64(Float64(a / fma(k, Float64(k + 10.0), 1.0)) / (Float64(1.0 / k) ^ m)); elseif (m <= 0.00052) tmp = Float64(Float64(a / t_0) / t_0); else tmp = Float64(a * (k ^ m)); end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[Sqrt[k ^ 2 + N[Sqrt[N[(k * 10.0 + 1.0), $MachinePrecision]], $MachinePrecision] ^ 2], $MachinePrecision]}, If[LessEqual[m, -8e-25], N[(N[(a / N[(k * N[(k + 10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Power[N[(1.0 / k), $MachinePrecision], m], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.00052], N[(N[(a / t$95$0), $MachinePrecision] / t$95$0), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{hypot}\left(k, \sqrt{\mathsf{fma}\left(k, 10, 1\right)}\right)\\
\mathbf{if}\;m \leq -8 \cdot 10^{-25}:\\
\;\;\;\;\frac{\frac{a}{\mathsf{fma}\left(k, k + 10, 1\right)}}{{\left(\frac{1}{k}\right)}^{m}}\\
\mathbf{elif}\;m \leq 0.00052:\\
\;\;\;\;\frac{\frac{a}{t_0}}{t_0}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < -8.00000000000000031e-25Initial program 100.0%
sqr-neg100.0%
associate-+l+100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
Simplified100.0%
Taylor expanded in k around inf 57.3%
expm1-log1p-u42.5%
expm1-udef40.2%
Applied egg-rr75.6%
expm1-def77.9%
expm1-log1p100.0%
associate-/r*100.0%
Simplified100.0%
if -8.00000000000000031e-25 < m < 5.19999999999999954e-4Initial program 93.0%
sqr-neg93.0%
associate-+l+93.0%
sqr-neg93.0%
distribute-rgt-out93.0%
Simplified93.0%
Taylor expanded in m around 0 93.0%
*-un-lft-identity93.0%
add-sqr-sqrt92.9%
times-frac92.9%
+-commutative92.9%
+-commutative92.9%
fma-udef92.9%
+-commutative92.9%
+-commutative92.9%
fma-udef92.9%
Applied egg-rr92.9%
associate-*l/92.9%
*-lft-identity92.9%
fma-def92.9%
+-commutative92.9%
distribute-rgt-in92.9%
unpow292.9%
+-commutative92.9%
associate-+r+92.9%
+-commutative92.9%
*-commutative92.9%
fma-udef92.9%
+-commutative92.9%
unpow292.9%
rem-square-sqrt92.9%
hypot-def92.9%
fma-def92.9%
+-commutative92.9%
distribute-rgt-in92.9%
unpow292.9%
+-commutative92.9%
Simplified99.8%
if 5.19999999999999954e-4 < m Initial program 82.6%
sqr-neg82.6%
associate-+l+82.6%
sqr-neg82.6%
distribute-rgt-out82.6%
Simplified82.6%
Taylor expanded in k around 0 100.0%
Final simplification99.9%
(FPCore (a k m) :precision binary64 (if (<= m 3.7) (/ (/ a (fma k (+ k 10.0) 1.0)) (pow (/ 1.0 k) m)) (* a (pow k m))))
double code(double a, double k, double m) {
double tmp;
if (m <= 3.7) {
tmp = (a / fma(k, (k + 10.0), 1.0)) / pow((1.0 / k), m);
} else {
tmp = a * pow(k, m);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 3.7) tmp = Float64(Float64(a / fma(k, Float64(k + 10.0), 1.0)) / (Float64(1.0 / k) ^ m)); else tmp = Float64(a * (k ^ m)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 3.7], N[(N[(a / N[(k * N[(k + 10.0), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] / N[Power[N[(1.0 / k), $MachinePrecision], m], $MachinePrecision]), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 3.7:\\
\;\;\;\;\frac{\frac{a}{\mathsf{fma}\left(k, k + 10, 1\right)}}{{\left(\frac{1}{k}\right)}^{m}}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < 3.7000000000000002Initial program 96.5%
sqr-neg96.5%
associate-+l+96.5%
sqr-neg96.5%
distribute-rgt-out96.5%
Simplified96.5%
Taylor expanded in k around inf 75.1%
expm1-log1p-u61.0%
expm1-udef42.2%
Applied egg-rr59.9%
expm1-def78.6%
expm1-log1p96.5%
associate-/r*96.5%
Simplified96.5%
if 3.7000000000000002 < m Initial program 82.6%
sqr-neg82.6%
associate-+l+82.6%
sqr-neg82.6%
distribute-rgt-out82.6%
Simplified82.6%
Taylor expanded in k around 0 100.0%
Final simplification97.7%
(FPCore (a k m) :precision binary64 (if (<= m 4.5) (* a (/ (- (pow k m)) (- -1.0 (* k (+ k 10.0))))) (* a (pow k m))))
double code(double a, double k, double m) {
double tmp;
if (m <= 4.5) {
tmp = a * (-pow(k, m) / (-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 <= 4.5d0) then
tmp = a * (-(k ** m) / ((-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 <= 4.5) {
tmp = a * (-Math.pow(k, m) / (-1.0 - (k * (k + 10.0))));
} else {
tmp = a * Math.pow(k, m);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 4.5: tmp = a * (-math.pow(k, m) / (-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 <= 4.5) tmp = Float64(a * Float64(Float64(-(k ^ m)) / Float64(-1.0 - Float64(k * Float64(k + 10.0))))); else tmp = Float64(a * (k ^ m)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 4.5) tmp = a * (-(k ^ m) / (-1.0 - (k * (k + 10.0)))); else tmp = a * (k ^ m); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 4.5], N[(a * N[((-N[Power[k, m], $MachinePrecision]) / N[(-1.0 - N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 4.5:\\
\;\;\;\;a \cdot \frac{-{k}^{m}}{-1 - k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < 4.5Initial program 96.5%
sqr-neg96.5%
associate-+l+96.5%
sqr-neg96.5%
distribute-rgt-out96.5%
Simplified96.5%
frac-2neg96.5%
div-inv96.5%
distribute-rgt-neg-in96.5%
+-commutative96.5%
fma-def96.5%
+-commutative96.5%
Applied egg-rr96.5%
associate-*l*96.5%
associate-*r/96.5%
*-rgt-identity96.5%
fma-udef96.5%
+-commutative96.5%
distribute-neg-in96.5%
metadata-eval96.5%
sub-neg96.5%
Simplified96.5%
if 4.5 < m Initial program 82.6%
sqr-neg82.6%
associate-+l+82.6%
sqr-neg82.6%
distribute-rgt-out82.6%
Simplified82.6%
Taylor expanded in k around 0 100.0%
Final simplification97.7%
(FPCore (a k m) :precision binary64 (let* ((t_0 (* a (pow k m)))) (if (<= m 3.6) (/ t_0 (+ 1.0 (* k (+ k 10.0)))) t_0)))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (m <= 3.6) {
tmp = t_0 / (1.0 + (k * (k + 10.0)));
} else {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = a * (k ** m)
if (m <= 3.6d0) then
tmp = t_0 / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a * Math.pow(k, m);
double tmp;
if (m <= 3.6) {
tmp = t_0 / (1.0 + (k * (k + 10.0)));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a * math.pow(k, m) tmp = 0 if m <= 3.6: tmp = t_0 / (1.0 + (k * (k + 10.0))) else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (m <= 3.6) tmp = Float64(t_0 / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a * (k ^ m); tmp = 0.0; if (m <= 3.6) tmp = t_0 / (1.0 + (k * (k + 10.0))); else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, 3.6], N[(t$95$0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;m \leq 3.6:\\
\;\;\;\;\frac{t_0}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if m < 3.60000000000000009Initial program 96.5%
sqr-neg96.5%
associate-+l+96.5%
sqr-neg96.5%
distribute-rgt-out96.5%
Simplified96.5%
if 3.60000000000000009 < m Initial program 82.6%
sqr-neg82.6%
associate-+l+82.6%
sqr-neg82.6%
distribute-rgt-out82.6%
Simplified82.6%
Taylor expanded in k around 0 100.0%
Final simplification97.7%
(FPCore (a k m) :precision binary64 (if (or (<= m -6e-12) (not (<= m 1.05e-10))) (* a (pow k m)) (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0)))))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -6e-12) || !(m <= 1.05e-10)) {
tmp = a * pow(k, m);
} 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 <= (-6d-12)) .or. (.not. (m <= 1.05d-10))) then
tmp = a * (k ** m)
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 <= -6e-12) || !(m <= 1.05e-10)) {
tmp = a * Math.pow(k, m);
} else {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
}
return tmp;
}
def code(a, k, m): tmp = 0 if (m <= -6e-12) or not (m <= 1.05e-10): tmp = a * math.pow(k, m) else: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) return tmp
function code(a, k, m) tmp = 0.0 if ((m <= -6e-12) || !(m <= 1.05e-10)) tmp = Float64(a * (k ^ m)); 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 <= -6e-12) || ~((m <= 1.05e-10))) tmp = a * (k ^ m); else tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); end tmp_2 = tmp; end
code[a_, k_, m_] := If[Or[LessEqual[m, -6e-12], N[Not[LessEqual[m, 1.05e-10]], $MachinePrecision]], N[(a * N[Power[k, m], $MachinePrecision]), $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 -6 \cdot 10^{-12} \lor \neg \left(m \leq 1.05 \cdot 10^{-10}\right):\\
\;\;\;\;a \cdot {k}^{m}\\
\mathbf{else}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\end{array}
\end{array}
if m < -6.0000000000000003e-12 or 1.05e-10 < m Initial program 90.7%
sqr-neg90.7%
associate-+l+90.7%
sqr-neg90.7%
distribute-rgt-out90.7%
Simplified90.7%
Taylor expanded in k around 0 100.0%
if -6.0000000000000003e-12 < m < 1.05e-10Initial program 93.0%
sqr-neg93.0%
associate-+l+93.0%
sqr-neg93.0%
distribute-rgt-out93.0%
Simplified93.0%
frac-2neg93.0%
div-inv93.1%
distribute-rgt-neg-in93.1%
+-commutative93.1%
fma-def93.1%
+-commutative93.1%
Applied egg-rr93.1%
associate-*l*93.1%
associate-*r/93.1%
*-rgt-identity93.1%
fma-udef93.1%
+-commutative93.1%
distribute-neg-in93.1%
metadata-eval93.1%
sub-neg93.1%
Simplified93.1%
Taylor expanded in m around 0 93.0%
Final simplification97.7%
(FPCore (a k m) :precision binary64 (if (<= m -5.4e-12) (/ a (pow (/ 1.0 k) m)) (if (<= m 1.05e-8) (* 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 <= -5.4e-12) {
tmp = a / pow((1.0 / k), m);
} else if (m <= 1.05e-8) {
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 <= (-5.4d-12)) then
tmp = a / ((1.0d0 / k) ** m)
else if (m <= 1.05d-8) 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 <= -5.4e-12) {
tmp = a / Math.pow((1.0 / k), m);
} else if (m <= 1.05e-8) {
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 <= -5.4e-12: tmp = a / math.pow((1.0 / k), m) elif m <= 1.05e-8: 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 <= -5.4e-12) tmp = Float64(a / (Float64(1.0 / k) ^ m)); elseif (m <= 1.05e-8) tmp = Float64(a * Float64(1.0 / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64(a * (k ^ m)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -5.4e-12) tmp = a / ((1.0 / k) ^ m); elseif (m <= 1.05e-8) 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, -5.4e-12], N[(a / N[Power[N[(1.0 / k), $MachinePrecision], m], $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.05e-8], 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 -5.4 \cdot 10^{-12}:\\
\;\;\;\;\frac{a}{{\left(\frac{1}{k}\right)}^{m}}\\
\mathbf{elif}\;m \leq 1.05 \cdot 10^{-8}:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;a \cdot {k}^{m}\\
\end{array}
\end{array}
if m < -5.39999999999999961e-12Initial program 100.0%
sqr-neg100.0%
associate-+l+100.0%
sqr-neg100.0%
distribute-rgt-out100.0%
Simplified100.0%
Taylor expanded in k around inf 56.8%
expm1-log1p-u41.9%
expm1-udef40.7%
Applied egg-rr76.5%
expm1-def77.7%
expm1-log1p100.0%
associate-/r*100.0%
Simplified100.0%
Taylor expanded in k around 0 100.0%
if -5.39999999999999961e-12 < m < 1.04999999999999997e-8Initial program 93.0%
sqr-neg93.0%
associate-+l+93.0%
sqr-neg93.0%
distribute-rgt-out93.0%
Simplified93.0%
frac-2neg93.0%
div-inv93.1%
distribute-rgt-neg-in93.1%
+-commutative93.1%
fma-def93.1%
+-commutative93.1%
Applied egg-rr93.1%
associate-*l*93.1%
associate-*r/93.1%
*-rgt-identity93.1%
fma-udef93.1%
+-commutative93.1%
distribute-neg-in93.1%
metadata-eval93.1%
sub-neg93.1%
Simplified93.1%
Taylor expanded in m around 0 93.0%
if 1.04999999999999997e-8 < m Initial program 82.6%
sqr-neg82.6%
associate-+l+82.6%
sqr-neg82.6%
distribute-rgt-out82.6%
Simplified82.6%
Taylor expanded in k around 0 100.0%
Final simplification97.7%
(FPCore (a k m) :precision binary64 (if (<= m 31000000000.0) (* a (/ 1.0 (+ 1.0 (* k (+ k 10.0))))) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 31000000000.0) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = -10.0 * (a * k);
}
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 <= 31000000000.0d0) then
tmp = a * (1.0d0 / (1.0d0 + (k * (k + 10.0d0))))
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 31000000000.0) {
tmp = a * (1.0 / (1.0 + (k * (k + 10.0))));
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 31000000000.0: tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))) else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 31000000000.0) tmp = Float64(a * Float64(1.0 / Float64(1.0 + Float64(k * Float64(k + 10.0))))); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 31000000000.0) tmp = a * (1.0 / (1.0 + (k * (k + 10.0)))); else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 31000000000.0], N[(a * N[(1.0 / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 31000000000:\\
\;\;\;\;a \cdot \frac{1}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 3.1e10Initial program 96.5%
sqr-neg96.5%
associate-+l+96.5%
sqr-neg96.5%
distribute-rgt-out96.5%
Simplified96.5%
frac-2neg96.5%
div-inv96.5%
distribute-rgt-neg-in96.5%
+-commutative96.5%
fma-def96.5%
+-commutative96.5%
Applied egg-rr96.5%
associate-*l*96.5%
associate-*r/96.5%
*-rgt-identity96.5%
fma-udef96.5%
+-commutative96.5%
distribute-neg-in96.5%
metadata-eval96.5%
sub-neg96.5%
Simplified96.5%
Taylor expanded in m around 0 65.0%
if 3.1e10 < m Initial program 82.4%
sqr-neg82.4%
associate-+l+82.4%
sqr-neg82.4%
distribute-rgt-out82.4%
Simplified82.4%
Taylor expanded in m around 0 2.9%
Taylor expanded in k around 0 5.3%
Taylor expanded in k around inf 17.2%
Final simplification48.0%
(FPCore (a k m) :precision binary64 (if (<= m 600000000.0) (/ a (+ 1.0 (* k (+ k 10.0)))) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 600000000.0) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = -10.0 * (a * k);
}
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 <= 600000000.0d0) then
tmp = a / (1.0d0 + (k * (k + 10.0d0)))
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 600000000.0) {
tmp = a / (1.0 + (k * (k + 10.0)));
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 600000000.0: tmp = a / (1.0 + (k * (k + 10.0))) else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 600000000.0) tmp = Float64(a / Float64(1.0 + Float64(k * Float64(k + 10.0)))); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 600000000.0) tmp = a / (1.0 + (k * (k + 10.0))); else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 600000000.0], N[(a / N[(1.0 + N[(k * N[(k + 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 600000000:\\
\;\;\;\;\frac{a}{1 + k \cdot \left(k + 10\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 6e8Initial program 96.5%
sqr-neg96.5%
associate-+l+96.5%
sqr-neg96.5%
distribute-rgt-out96.5%
Simplified96.5%
Taylor expanded in m around 0 65.0%
if 6e8 < m Initial program 82.4%
sqr-neg82.4%
associate-+l+82.4%
sqr-neg82.4%
distribute-rgt-out82.4%
Simplified82.4%
Taylor expanded in m around 0 2.9%
Taylor expanded in k around 0 5.3%
Taylor expanded in k around inf 17.2%
Final simplification48.0%
(FPCore (a k m) :precision binary64 (if (<= m 680000000.0) (/ a (+ 1.0 (* k 10.0))) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 680000000.0) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = -10.0 * (a * k);
}
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 <= 680000000.0d0) then
tmp = a / (1.0d0 + (k * 10.0d0))
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 680000000.0) {
tmp = a / (1.0 + (k * 10.0));
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 680000000.0: tmp = a / (1.0 + (k * 10.0)) else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 680000000.0) tmp = Float64(a / Float64(1.0 + Float64(k * 10.0))); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 680000000.0) tmp = a / (1.0 + (k * 10.0)); else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 680000000.0], N[(a / N[(1.0 + N[(k * 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 680000000:\\
\;\;\;\;\frac{a}{1 + k \cdot 10}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 6.8e8Initial program 96.5%
sqr-neg96.5%
associate-+l+96.5%
sqr-neg96.5%
distribute-rgt-out96.5%
Simplified96.5%
Taylor expanded in m around 0 65.0%
Taylor expanded in k around 0 41.7%
*-commutative41.7%
Simplified41.7%
if 6.8e8 < m Initial program 82.4%
sqr-neg82.4%
associate-+l+82.4%
sqr-neg82.4%
distribute-rgt-out82.4%
Simplified82.4%
Taylor expanded in m around 0 2.9%
Taylor expanded in k around 0 5.3%
Taylor expanded in k around inf 17.2%
Final simplification33.0%
(FPCore (a k m) :precision binary64 (if (<= m 1250000000.0) a (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 1250000000.0) {
tmp = a;
} else {
tmp = -10.0 * (a * k);
}
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 <= 1250000000.0d0) then
tmp = a
else
tmp = (-10.0d0) * (a * k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1250000000.0) {
tmp = a;
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1250000000.0: tmp = a else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1250000000.0) tmp = a; else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1250000000.0) tmp = a; else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1250000000.0], a, N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1250000000:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 1.25e9Initial program 96.5%
sqr-neg96.5%
associate-+l+96.5%
sqr-neg96.5%
distribute-rgt-out96.5%
Simplified96.5%
Taylor expanded in m around 0 65.0%
Taylor expanded in k around 0 26.6%
if 1.25e9 < m Initial program 82.4%
sqr-neg82.4%
associate-+l+82.4%
sqr-neg82.4%
distribute-rgt-out82.4%
Simplified82.4%
Taylor expanded in m around 0 2.9%
Taylor expanded in k around 0 5.3%
Taylor expanded in k around inf 17.2%
Final simplification23.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 91.5%
sqr-neg91.5%
associate-+l+91.5%
sqr-neg91.5%
distribute-rgt-out91.5%
Simplified91.5%
Taylor expanded in m around 0 42.9%
Taylor expanded in k around 0 18.3%
Final simplification18.3%
herbie shell --seed 2023333
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))