
(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 14 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 (pow k (* 0.5 m))) (t_1 (* (pow k m) a)))
(if (<= (/ t_1 (+ (* k k) (+ (* 10.0 k) 1.0))) 2e+18)
(* (/ (* t_0 a) (fma (+ 10.0 k) k 1.0)) t_0)
t_1)))
double code(double a, double k, double m) {
double t_0 = pow(k, (0.5 * m));
double t_1 = pow(k, m) * a;
double tmp;
if ((t_1 / ((k * k) + ((10.0 * k) + 1.0))) <= 2e+18) {
tmp = ((t_0 * a) / fma((10.0 + k), k, 1.0)) * t_0;
} else {
tmp = t_1;
}
return tmp;
}
function code(a, k, m) t_0 = k ^ Float64(0.5 * m) t_1 = Float64((k ^ m) * a) tmp = 0.0 if (Float64(t_1 / Float64(Float64(k * k) + Float64(Float64(10.0 * k) + 1.0))) <= 2e+18) tmp = Float64(Float64(Float64(t_0 * a) / fma(Float64(10.0 + k), k, 1.0)) * t_0); else tmp = t_1; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[Power[k, N[(0.5 * m), $MachinePrecision]], $MachinePrecision]}, Block[{t$95$1 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[N[(t$95$1 / N[(N[(k * k), $MachinePrecision] + N[(N[(10.0 * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+18], N[(N[(N[(t$95$0 * a), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{\left(0.5 \cdot m\right)}\\
t_1 := {k}^{m} \cdot a\\
\mathbf{if}\;\frac{t\_1}{k \cdot k + \left(10 \cdot k + 1\right)} \leq 2 \cdot 10^{+18}:\\
\;\;\;\;\frac{t\_0 \cdot a}{\mathsf{fma}\left(10 + k, k, 1\right)} \cdot t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 2e18Initial program 95.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
lower-pow.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites96.4%
if 2e18 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 66.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Final simplification97.4%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= (/ t_0 (+ (* k k) (+ (* 10.0 k) 1.0))) 2e+18)
(/ (pow k m) (/ (fma (+ 10.0 k) k 1.0) a))
t_0)))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if ((t_0 / ((k * k) + ((10.0 * k) + 1.0))) <= 2e+18) {
tmp = pow(k, m) / (fma((10.0 + k), k, 1.0) / a);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (Float64(t_0 / Float64(Float64(k * k) + Float64(Float64(10.0 * k) + 1.0))) <= 2e+18) tmp = Float64((k ^ m) / Float64(fma(Float64(10.0 + k), k, 1.0) / a)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(k * k), $MachinePrecision] + N[(N[(10.0 * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2e+18], N[(N[Power[k, m], $MachinePrecision] / N[(N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;\frac{t\_0}{k \cdot k + \left(10 \cdot k + 1\right)} \leq 2 \cdot 10^{+18}:\\
\;\;\;\;\frac{{k}^{m}}{\frac{\mathsf{fma}\left(10 + k, k, 1\right)}{a}}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 2e18Initial program 95.9%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
lower-pow.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites96.4%
lift-*.f64N/A
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
associate-*r*N/A
lift-pow.f64N/A
lift-pow.f64N/A
unpow-prod-downN/A
lift-*.f64N/A
*-commutativeN/A
metadata-evalN/A
div-invN/A
pow-prod-downN/A
sqr-powN/A
lift-pow.f64N/A
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
clear-numN/A
un-div-invN/A
Applied rewrites94.8%
if 2e18 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 66.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f64100.0
Applied rewrites100.0%
Final simplification96.2%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (pow k (* 0.5 m))))
(if (<= m 2.4)
(/ (* (pow k m) a) (+ (* k k) (+ (* 10.0 k) 1.0)))
(* (* t_0 a) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, (0.5 * m));
double tmp;
if (m <= 2.4) {
tmp = (pow(k, m) * a) / ((k * k) + ((10.0 * k) + 1.0));
} else {
tmp = (t_0 * a) * 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 = k ** (0.5d0 * m)
if (m <= 2.4d0) then
tmp = ((k ** m) * a) / ((k * k) + ((10.0d0 * k) + 1.0d0))
else
tmp = (t_0 * a) * t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = Math.pow(k, (0.5 * m));
double tmp;
if (m <= 2.4) {
tmp = (Math.pow(k, m) * a) / ((k * k) + ((10.0 * k) + 1.0));
} else {
tmp = (t_0 * a) * t_0;
}
return tmp;
}
def code(a, k, m): t_0 = math.pow(k, (0.5 * m)) tmp = 0 if m <= 2.4: tmp = (math.pow(k, m) * a) / ((k * k) + ((10.0 * k) + 1.0)) else: tmp = (t_0 * a) * t_0 return tmp
function code(a, k, m) t_0 = k ^ Float64(0.5 * m) tmp = 0.0 if (m <= 2.4) tmp = Float64(Float64((k ^ m) * a) / Float64(Float64(k * k) + Float64(Float64(10.0 * k) + 1.0))); else tmp = Float64(Float64(t_0 * a) * t_0); end return tmp end
function tmp_2 = code(a, k, m) t_0 = k ^ (0.5 * m); tmp = 0.0; if (m <= 2.4) tmp = ((k ^ m) * a) / ((k * k) + ((10.0 * k) + 1.0)); else tmp = (t_0 * a) * t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[Power[k, N[(0.5 * m), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[m, 2.4], N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[(N[(k * k), $MachinePrecision] + N[(N[(10.0 * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(t$95$0 * a), $MachinePrecision] * t$95$0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{\left(0.5 \cdot m\right)}\\
\mathbf{if}\;m \leq 2.4:\\
\;\;\;\;\frac{{k}^{m} \cdot a}{k \cdot k + \left(10 \cdot k + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(t\_0 \cdot a\right) \cdot t\_0\\
\end{array}
\end{array}
if m < 2.39999999999999991Initial program 95.8%
if 2.39999999999999991 < m Initial program 75.3%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-pow.f64N/A
sqr-powN/A
associate-*l*N/A
associate-/l*N/A
lower-*.f64N/A
lower-pow.f64N/A
clear-numN/A
associate-/r/N/A
lower-*.f64N/A
metadata-evalN/A
*-commutativeN/A
lower-/.f64N/A
Applied rewrites76.3%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
associate-*r*N/A
*-commutativeN/A
exp-to-powN/A
lower-pow.f64N/A
*-commutativeN/A
lower-*.f64100.0
Applied rewrites100.0%
Final simplification97.4%
(FPCore (a k m) :precision binary64 (let* ((t_0 (* (pow k m) a))) (if (<= m 0.00062) (/ t_0 (+ (* k k) (+ (* 10.0 k) 1.0))) t_0)))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= 0.00062) {
tmp = t_0 / ((k * k) + ((10.0 * k) + 1.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 = (k ** m) * a
if (m <= 0.00062d0) then
tmp = t_0 / ((k * k) + ((10.0d0 * k) + 1.0d0))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = Math.pow(k, m) * a;
double tmp;
if (m <= 0.00062) {
tmp = t_0 / ((k * k) + ((10.0 * k) + 1.0));
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = math.pow(k, m) * a tmp = 0 if m <= 0.00062: tmp = t_0 / ((k * k) + ((10.0 * k) + 1.0)) else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= 0.00062) tmp = Float64(t_0 / Float64(Float64(k * k) + Float64(Float64(10.0 * k) + 1.0))); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = (k ^ m) * a; tmp = 0.0; if (m <= 0.00062) tmp = t_0 / ((k * k) + ((10.0 * k) + 1.0)); else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, 0.00062], N[(t$95$0 / N[(N[(k * k), $MachinePrecision] + N[(N[(10.0 * k), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq 0.00062:\\
\;\;\;\;\frac{t\_0}{k \cdot k + \left(10 \cdot k + 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < 6.2e-4Initial program 95.7%
if 6.2e-4 < m Initial program 75.6%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6499.1
Applied rewrites99.1%
Final simplification97.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -7.5e-15)
(/ t_0 (fma 10.0 k 1.0))
(if (<= m 7.8e-7) (/ a (fma (+ 10.0 k) k 1.0)) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -7.5e-15) {
tmp = t_0 / fma(10.0, k, 1.0);
} else if (m <= 7.8e-7) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -7.5e-15) tmp = Float64(t_0 / fma(10.0, k, 1.0)); elseif (m <= 7.8e-7) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -7.5e-15], N[(t$95$0 / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 7.8e-7], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -7.5 \cdot 10^{-15}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{elif}\;m \leq 7.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -7.4999999999999996e-15Initial program 100.0%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f64100.0
Applied rewrites100.0%
if -7.4999999999999996e-15 < m < 7.80000000000000049e-7Initial program 91.4%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites91.4%
if 7.80000000000000049e-7 < m Initial program 75.6%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6499.1
Applied rewrites99.1%
Final simplification97.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -7.5e-15)
t_0
(if (<= m 7.8e-7) (/ a (fma (+ 10.0 k) k 1.0)) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -7.5e-15) {
tmp = t_0;
} else if (m <= 7.8e-7) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -7.5e-15) tmp = t_0; elseif (m <= 7.8e-7) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -7.5e-15], t$95$0, If[LessEqual[m, 7.8e-7], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -7.5 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 7.8 \cdot 10^{-7}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -7.4999999999999996e-15 or 7.80000000000000049e-7 < m Initial program 86.5%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6498.9
Applied rewrites98.9%
if -7.4999999999999996e-15 < m < 7.80000000000000049e-7Initial program 91.4%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites91.4%
(FPCore (a k m) :precision binary64 (if (<= m -0.62) (/ (* 99.0 (/ a (* k k))) (* k k)) (if (<= m 0.95) (/ a (fma (+ 10.0 k) k 1.0)) (* (* (* k a) k) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.62) {
tmp = (99.0 * (a / (k * k))) / (k * k);
} else if (m <= 0.95) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = ((k * a) * k) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.62) tmp = Float64(Float64(99.0 * Float64(a / Float64(k * k))) / Float64(k * k)); elseif (m <= 0.95) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(k * a) * k) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.62], N[(N[(99.0 * N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.95], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * a), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.62:\\
\;\;\;\;\frac{99 \cdot \frac{a}{k \cdot k}}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.95:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot a\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.619999999999999996Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites36.1%
Taylor expanded in k around inf
Applied rewrites64.7%
Taylor expanded in k around 0
Applied rewrites71.7%
if -0.619999999999999996 < m < 0.94999999999999996Initial program 91.7%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites90.2%
if 0.94999999999999996 < m Initial program 75.3%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites31.7%
Taylor expanded in k around inf
Applied rewrites52.6%
Final simplification70.3%
(FPCore (a k m) :precision binary64 (if (<= m -0.65) (/ a (* k k)) (if (<= m 0.95) (/ a (fma (+ 10.0 k) k 1.0)) (* (* (* k a) k) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.65) {
tmp = a / (k * k);
} else if (m <= 0.95) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = ((k * a) * k) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.65) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.95) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(k * a) * k) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.65], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.95], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * a), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.65:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.95:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot a\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.650000000000000022Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites36.1%
Taylor expanded in k around inf
Applied rewrites57.2%
if -0.650000000000000022 < m < 0.94999999999999996Initial program 91.7%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites90.2%
if 0.94999999999999996 < m Initial program 75.3%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites31.7%
Taylor expanded in k around inf
Applied rewrites52.6%
(FPCore (a k m) :precision binary64 (if (<= m -0.65) (/ a (* k k)) (if (<= m 0.95) (/ a (fma k k 1.0)) (* (* (* k a) k) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.65) {
tmp = a / (k * k);
} else if (m <= 0.95) {
tmp = a / fma(k, k, 1.0);
} else {
tmp = ((k * a) * k) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.65) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.95) tmp = Float64(a / fma(k, k, 1.0)); else tmp = Float64(Float64(Float64(k * a) * k) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.65], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.95], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * a), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.65:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.95:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot a\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.650000000000000022Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites36.1%
Taylor expanded in k around inf
Applied rewrites57.2%
if -0.650000000000000022 < m < 0.94999999999999996Initial program 91.7%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites90.2%
Applied rewrites89.3%
Taylor expanded in k around 0
Applied rewrites89.3%
if 0.94999999999999996 < m Initial program 75.3%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites31.7%
Taylor expanded in k around inf
Applied rewrites52.6%
(FPCore (a k m) :precision binary64 (if (<= m -7.5e-226) (/ a (* k k)) (if (<= m 0.5) (* 1.0 a) (* (* (* k a) k) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -7.5e-226) {
tmp = a / (k * k);
} else if (m <= 0.5) {
tmp = 1.0 * a;
} else {
tmp = ((k * a) * 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 <= (-7.5d-226)) then
tmp = a / (k * k)
else if (m <= 0.5d0) then
tmp = 1.0d0 * a
else
tmp = ((k * a) * k) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -7.5e-226) {
tmp = a / (k * k);
} else if (m <= 0.5) {
tmp = 1.0 * a;
} else {
tmp = ((k * a) * k) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -7.5e-226: tmp = a / (k * k) elif m <= 0.5: tmp = 1.0 * a else: tmp = ((k * a) * k) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -7.5e-226) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.5) tmp = Float64(1.0 * a); else tmp = Float64(Float64(Float64(k * a) * k) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -7.5e-226) tmp = a / (k * k); elseif (m <= 0.5) tmp = 1.0 * a; else tmp = ((k * a) * k) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -7.5e-226], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.5], N[(1.0 * a), $MachinePrecision], N[(N[(N[(k * a), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -7.5 \cdot 10^{-226}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.5:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot a\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < -7.50000000000000044e-226Initial program 96.5%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites50.0%
Taylor expanded in k around inf
Applied rewrites53.7%
if -7.50000000000000044e-226 < m < 0.5Initial program 94.1%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6454.5
Applied rewrites54.5%
Taylor expanded in m around 0
Applied rewrites52.9%
if 0.5 < m Initial program 75.3%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites31.7%
Taylor expanded in k around inf
Applied rewrites52.6%
(FPCore (a k m) :precision binary64 (if (<= m 0.5) (* 1.0 a) (* (* (* k a) k) 99.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.5) {
tmp = 1.0 * a;
} else {
tmp = ((k * a) * 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 <= 0.5d0) then
tmp = 1.0d0 * a
else
tmp = ((k * a) * k) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.5) {
tmp = 1.0 * a;
} else {
tmp = ((k * a) * k) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.5: tmp = 1.0 * a else: tmp = ((k * a) * k) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.5) tmp = Float64(1.0 * a); else tmp = Float64(Float64(Float64(k * a) * k) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.5) tmp = 1.0 * a; else tmp = ((k * a) * k) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.5], N[(1.0 * a), $MachinePrecision], N[(N[(N[(k * a), $MachinePrecision] * k), $MachinePrecision] * 99.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.5:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot a\right) \cdot k\right) \cdot 99\\
\end{array}
\end{array}
if m < 0.5Initial program 95.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6474.6
Applied rewrites74.6%
Taylor expanded in m around 0
Applied rewrites27.3%
if 0.5 < m Initial program 75.3%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites31.7%
Taylor expanded in k around inf
Applied rewrites52.6%
(FPCore (a k m) :precision binary64 (if (<= k 1e-297) (* (* k a) -10.0) (fma (* 10.0 a) k a)))
double code(double a, double k, double m) {
double tmp;
if (k <= 1e-297) {
tmp = (k * a) * -10.0;
} else {
tmp = fma((10.0 * a), k, a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 1e-297) tmp = Float64(Float64(k * a) * -10.0); else tmp = fma(Float64(10.0 * a), k, a); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 1e-297], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision], N[(N[(10.0 * a), $MachinePrecision] * k + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 10^{-297}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(10 \cdot a, k, a\right)\\
\end{array}
\end{array}
if k < 1.00000000000000004e-297Initial program 90.2%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites18.3%
Taylor expanded in k around 0
Applied rewrites8.9%
Taylor expanded in k around inf
Applied rewrites16.5%
if 1.00000000000000004e-297 < k Initial program 86.8%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites53.1%
Applied rewrites52.7%
Taylor expanded in k around 0
Applied rewrites32.0%
(FPCore (a k m) :precision binary64 (if (<= m 1550.0) (* 1.0 a) (* (* k a) -10.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 1550.0) {
tmp = 1.0 * a;
} else {
tmp = (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 <= 1550.0d0) then
tmp = 1.0d0 * a
else
tmp = (k * a) * (-10.0d0)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 1550.0) {
tmp = 1.0 * a;
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 1550.0: tmp = 1.0 * a else: tmp = (k * a) * -10.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 1550.0) tmp = Float64(1.0 * a); else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 1550.0) tmp = 1.0 * a; else tmp = (k * a) * -10.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 1550.0], N[(1.0 * a), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1550:\\
\;\;\;\;1 \cdot a\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < 1550Initial program 95.2%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6474.2
Applied rewrites74.2%
Taylor expanded in m around 0
Applied rewrites27.1%
if 1550 < m Initial program 76.0%
Taylor expanded in m around 0
lower-/.f64N/A
unpow2N/A
distribute-rgt-inN/A
+-commutativeN/A
metadata-evalN/A
lft-mult-inverseN/A
associate-*l*N/A
*-lft-identityN/A
distribute-rgt-inN/A
+-commutativeN/A
associate-*l*N/A
unpow2N/A
*-commutativeN/A
unpow2N/A
associate-*r*N/A
lower-fma.f64N/A
Applied rewrites2.9%
Taylor expanded in k around 0
Applied rewrites7.9%
Taylor expanded in k around inf
Applied rewrites19.0%
(FPCore (a k m) :precision binary64 (* 1.0 a))
double code(double a, double k, double m) {
return 1.0 * a;
}
real(8) function code(a, k, m)
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = 1.0d0 * a
end function
public static double code(double a, double k, double m) {
return 1.0 * a;
}
def code(a, k, m): return 1.0 * a
function code(a, k, m) return Float64(1.0 * a) end
function tmp = code(a, k, m) tmp = 1.0 * a; end
code[a_, k_, m_] := N[(1.0 * a), $MachinePrecision]
\begin{array}{l}
\\
1 \cdot a
\end{array}
Initial program 88.0%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6483.9
Applied rewrites83.9%
Taylor expanded in m around 0
Applied rewrites18.4%
herbie shell --seed 2024236
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))