
(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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
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 10 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));
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
end function
public static double code(double a, double k, double m) {
return (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
def code(a, k, m): return (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))
function code(a, k, m) return Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) end
function tmp = code(a, k, m) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); end
code[a_, k_, m_] := N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
\end{array}
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))) (if (<= t_0 INFINITY) t_0 (* (* (* k k) 99.0) a))))
double code(double a, double k, double m) {
double t_0 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_0 <= ((double) INFINITY)) {
tmp = t_0;
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
public static double code(double a, double k, double m) {
double t_0 = (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_0 <= Double.POSITIVE_INFINITY) {
tmp = t_0;
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
def code(a, k, m): t_0 = (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k)) tmp = 0 if t_0 <= math.inf: tmp = t_0 else: tmp = ((k * k) * 99.0) * a return tmp
function code(a, k, m) t_0 = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_0 <= Inf) tmp = t_0; else tmp = Float64(Float64(Float64(k * k) * 99.0) * a); end return tmp end
function tmp_2 = code(a, k, m) t_0 = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); tmp = 0.0; if (t_0 <= Inf) tmp = t_0; else tmp = ((k * k) * 99.0) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = 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]}, If[LessEqual[t$95$0, Infinity], t$95$0, N[(N[(N[(k * k), $MachinePrecision] * 99.0), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_0 \leq \infty:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot 99\right) \cdot a\\
\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))) < +inf.0Initial program 97.0%
if +inf.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 0.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f641.6
Applied rewrites1.6%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6476.6
Applied rewrites76.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f64100.0
Applied rewrites100.0%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -1.32e-6) (not (<= m 0.0095))) (* (pow k m) a) (/ (fma (* (log k) m) a a) (fma (+ 10.0 k) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -1.32e-6) || !(m <= 0.0095)) {
tmp = pow(k, m) * a;
} else {
tmp = fma((log(k) * m), a, a) / fma((10.0 + k), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if ((m <= -1.32e-6) || !(m <= 0.0095)) tmp = Float64((k ^ m) * a); else tmp = Float64(fma(Float64(log(k) * m), a, a) / fma(Float64(10.0 + k), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[Or[LessEqual[m, -1.32e-6], N[Not[LessEqual[m, 0.0095]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(N[(N[(N[Log[k], $MachinePrecision] * m), $MachinePrecision] * a + a), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.32 \cdot 10^{-6} \lor \neg \left(m \leq 0.0095\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k \cdot m, a, a\right)}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\end{array}
\end{array}
if m < -1.3200000000000001e-6 or 0.00949999999999999976 < m Initial program 89.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -1.3200000000000001e-6 < m < 0.00949999999999999976Initial program 93.2%
Taylor expanded in m around 0
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.0
Applied rewrites93.0%
Final simplification97.1%
(FPCore (a k m) :precision binary64 (if (or (<= m -3.2e-7) (not (<= m 0.0105))) (* (pow k m) a) (/ a (fma (+ 10.0 k) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -3.2e-7) || !(m <= 0.0105)) {
tmp = pow(k, m) * a;
} else {
tmp = a / fma((10.0 + k), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if ((m <= -3.2e-7) || !(m <= 0.0105)) tmp = Float64((k ^ m) * a); else tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[Or[LessEqual[m, -3.2e-7], N[Not[LessEqual[m, 0.0105]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.2 \cdot 10^{-7} \lor \neg \left(m \leq 0.0105\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\end{array}
\end{array}
if m < -3.2000000000000001e-7 or 0.0105000000000000007 < m Initial program 89.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -3.2000000000000001e-7 < m < 0.0105000000000000007Initial program 93.2%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6492.5
Applied rewrites92.5%
Final simplification96.9%
(FPCore (a k m) :precision binary64 (if (<= m -0.205) (/ (* (/ a (* k k)) 99.0) (* k k)) (if (<= m 0.78) (/ a (fma (+ 10.0 k) k 1.0)) (* (* (* k k) 99.0) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.205) {
tmp = ((a / (k * k)) * 99.0) / (k * k);
} else if (m <= 0.78) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.205) tmp = Float64(Float64(Float64(a / Float64(k * k)) * 99.0) / Float64(k * k)); elseif (m <= 0.78) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * 99.0) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.205], N[(N[(N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision] * 99.0), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.78], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * 99.0), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.205:\\
\;\;\;\;\frac{\frac{a}{k \cdot k} \cdot 99}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.78:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot 99\right) \cdot a\\
\end{array}
\end{array}
if m < -0.204999999999999988Initial program 100.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6439.8
Applied rewrites39.8%
Taylor expanded in k around -inf
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
fp-cancel-sub-sign-invN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
metadata-evalN/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
Applied rewrites68.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6481.0
Applied rewrites81.0%
if -0.204999999999999988 < m < 0.78000000000000003Initial program 93.2%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.9
Applied rewrites91.9%
if 0.78000000000000003 < m Initial program 80.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6420.4
Applied rewrites20.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6424.9
Applied rewrites24.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.7
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m -0.205) (/ a (* k k)) (if (<= m 0.78) (/ a (fma (+ 10.0 k) k 1.0)) (* (* (* k k) 99.0) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.205) {
tmp = a / (k * k);
} else if (m <= 0.78) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.205) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.78) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * 99.0) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.205], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.78], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * 99.0), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.205:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.78:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot 99\right) \cdot a\\
\end{array}
\end{array}
if m < -0.204999999999999988Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites61.7%
if -0.204999999999999988 < m < 0.78000000000000003Initial program 93.2%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.9
Applied rewrites91.9%
if 0.78000000000000003 < m Initial program 80.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6420.4
Applied rewrites20.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6424.9
Applied rewrites24.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.7
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m -1.5e-13) (/ a (* k k)) (if (<= m 0.78) (/ a (fma 10.0 k 1.0)) (* (* (* k k) 99.0) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1.5e-13) {
tmp = a / (k * k);
} else if (m <= 0.78) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -1.5e-13) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.78) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * 99.0) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -1.5e-13], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.78], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * 99.0), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.5 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.78:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot 99\right) \cdot a\\
\end{array}
\end{array}
if m < -1.49999999999999992e-13Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f6498.6
Applied rewrites98.6%
Taylor expanded in m around 0
Applied rewrites60.7%
if -1.49999999999999992e-13 < m < 0.78000000000000003Initial program 93.1%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f6462.3
Applied rewrites62.3%
Taylor expanded in m around 0
Applied rewrites62.0%
if 0.78000000000000003 < m Initial program 80.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6420.4
Applied rewrites20.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6424.9
Applied rewrites24.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.7
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m 0.78) (/ a (* k k)) (* (* (* k k) 99.0) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.78) {
tmp = a / (k * k);
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 0.78d0) then
tmp = a / (k * k)
else
tmp = ((k * k) * 99.0d0) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.78) {
tmp = a / (k * k);
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.78: tmp = a / (k * k) else: tmp = ((k * k) * 99.0) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.78) tmp = Float64(a / Float64(k * k)); else tmp = Float64(Float64(Float64(k * k) * 99.0) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.78) tmp = a / (k * k); else tmp = ((k * k) * 99.0) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.78], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * 99.0), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.78:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot 99\right) \cdot a\\
\end{array}
\end{array}
if m < 0.78000000000000003Initial program 95.8%
Taylor expanded in k around inf
pow2N/A
lift-*.f6468.3
Applied rewrites68.3%
Taylor expanded in m around 0
Applied rewrites53.2%
if 0.78000000000000003 < m Initial program 80.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6420.4
Applied rewrites20.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6424.9
Applied rewrites24.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.7
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (if (<= m 0.55) a (* (* (* k k) 99.0) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.55) {
tmp = a;
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: tmp
if (m <= 0.55d0) then
tmp = a
else
tmp = ((k * k) * 99.0d0) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.55) {
tmp = a;
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.55: tmp = a else: tmp = ((k * k) * 99.0) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.55) tmp = a; else tmp = Float64(Float64(Float64(k * k) * 99.0) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.55) tmp = a; else tmp = ((k * k) * 99.0) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.55], a, N[(N[(N[(k * k), $MachinePrecision] * 99.0), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.55:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot 99\right) \cdot a\\
\end{array}
\end{array}
if m < 0.55000000000000004Initial program 95.8%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6471.7
Applied rewrites71.7%
Taylor expanded in k around 0
Applied rewrites30.4%
if 0.55000000000000004 < m Initial program 80.7%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
fp-cancel-sub-sign-invN/A
associate-*r*N/A
metadata-evalN/A
lower-fma.f64N/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6420.4
Applied rewrites20.4%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6424.9
Applied rewrites24.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.7
Applied rewrites59.7%
(FPCore (a k m) :precision binary64 (fma (* -10.0 a) k a))
double code(double a, double k, double m) {
return fma((-10.0 * a), k, a);
}
function code(a, k, m) return fma(Float64(-10.0 * a), k, a) end
code[a_, k_, m_] := N[(N[(-10.0 * a), $MachinePrecision] * k + a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-10 \cdot a, k, a\right)
\end{array}
Initial program 90.9%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites25.3%
Taylor expanded in k around 0
lift-*.f6422.5
Applied rewrites22.5%
(FPCore (a k m) :precision binary64 a)
double code(double a, double k, double m) {
return a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
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.9%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6449.4
Applied rewrites49.4%
Taylor expanded in k around 0
Applied rewrites21.7%
herbie shell --seed 2025037
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))