
(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 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));
}
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 (if (<= m 0.00145) (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.00145) {
tmp = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
} else {
tmp = pow(k, m) * 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.00145d0) then
tmp = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
else
tmp = (k ** m) * a
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.00145) {
tmp = (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.00145: tmp = (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k)) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.00145) tmp = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.00145) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.00145], 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], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.00145:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 0.00145Initial program 95.7%
if 0.00145 < m Initial program 79.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (<= m 0.00145) (* a (/ (pow k m) (fma (+ 10.0 k) k 1.0))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.00145) {
tmp = a * (pow(k, m) / fma((10.0 + k), k, 1.0));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 0.00145) tmp = Float64(a * Float64((k ^ m) / fma(Float64(10.0 + k), k, 1.0))); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 0.00145], N[(a * N[(N[Power[k, m], $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.00145:\\
\;\;\;\;a \cdot \frac{{k}^{m}}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 0.00145Initial program 95.7%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
associate-/l*N/A
pow2N/A
associate-+r+N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6495.7
Applied rewrites95.7%
if 0.00145 < m Initial program 79.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -0.00048) (not (<= m 9e-11))) (* (pow k m) a) (/ a (fma (+ 10.0 k) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -0.00048) || !(m <= 9e-11)) {
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 <= -0.00048) || !(m <= 9e-11)) 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, -0.00048], N[Not[LessEqual[m, 9e-11]], $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 -0.00048 \lor \neg \left(m \leq 9 \cdot 10^{-11}\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\end{array}
\end{array}
if m < -4.80000000000000012e-4 or 8.9999999999999999e-11 < m Initial program 89.3%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -4.80000000000000012e-4 < m < 8.9999999999999999e-11Initial program 91.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-+.f6490.7
Applied rewrites90.7%
Final simplification96.8%
(FPCore (a k m) :precision binary64 (if (<= m -0.26) (/ (* (/ a (* k k)) 99.0) (* k k)) (if (<= m 1.05) (/ a (fma (+ 10.0 k) k 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.26) {
tmp = ((a / (k * k)) * 99.0) / (k * k);
} else if (m <= 1.05) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.26) tmp = Float64(Float64(Float64(a / Float64(k * k)) * 99.0) / Float64(k * k)); elseif (m <= 1.05) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.26], N[(N[(N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision] * 99.0), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.05], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.26:\\
\;\;\;\;\frac{\frac{a}{k \cdot k} \cdot 99}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.05:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.26000000000000001Initial 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-+.f6444.2
Applied rewrites44.2%
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.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6471.3
Applied rewrites71.3%
if -0.26000000000000001 < m < 1.05000000000000004Initial program 91.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-+.f6489.9
Applied rewrites89.9%
if 1.05000000000000004 < m Initial program 79.5%
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.8
Applied rewrites2.8%
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-*.f6422.5
Applied rewrites22.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6451.3
Applied rewrites51.3%
(FPCore (a k m) :precision binary64 (if (<= m -14.2) (/ a (* k k)) (if (<= m 1.05) (/ a (fma (+ 10.0 k) k 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -14.2) {
tmp = a / (k * k);
} else if (m <= 1.05) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -14.2) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.05) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -14.2], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.05], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -14.2:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.05:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -14.199999999999999Initial 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-+.f6444.7
Applied rewrites44.7%
Taylor expanded in k around inf
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
pow2N/A
lift-*.f6464.2
Applied rewrites64.2%
if -14.199999999999999 < m < 1.05000000000000004Initial program 91.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-+.f6488.9
Applied rewrites88.9%
if 1.05000000000000004 < m Initial program 79.5%
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.8
Applied rewrites2.8%
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-*.f6422.5
Applied rewrites22.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6451.3
Applied rewrites51.3%
(FPCore (a k m) :precision binary64 (if (<= m -14.2) (/ a (* k k)) (if (<= m 1.05) (/ a (fma k k 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -14.2) {
tmp = a / (k * k);
} else if (m <= 1.05) {
tmp = a / fma(k, k, 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -14.2) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.05) tmp = Float64(a / fma(k, k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -14.2], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.05], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -14.2:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.05:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -14.199999999999999Initial 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-+.f6444.7
Applied rewrites44.7%
Taylor expanded in k around inf
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
pow2N/A
lift-*.f6464.2
Applied rewrites64.2%
if -14.199999999999999 < m < 1.05000000000000004Initial program 91.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-+.f6488.9
Applied rewrites88.9%
Taylor expanded in k around inf
Applied rewrites86.6%
if 1.05000000000000004 < m Initial program 79.5%
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.8
Applied rewrites2.8%
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-*.f6422.5
Applied rewrites22.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6451.3
Applied rewrites51.3%
(FPCore (a k m) :precision binary64 (if (<= m -6.5e-8) (/ a (* k k)) (if (<= m 1.06) (/ a (fma 10.0 k 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -6.5e-8) {
tmp = a / (k * k);
} else if (m <= 1.06) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -6.5e-8) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.06) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -6.5e-8], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.06], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -6.5 \cdot 10^{-8}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.06:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -6.49999999999999997e-8Initial 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-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around inf
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
pow2N/A
lift-*.f6463.9
Applied rewrites63.9%
if -6.49999999999999997e-8 < m < 1.0600000000000001Initial program 91.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-+.f6489.8
Applied rewrites89.8%
Taylor expanded in k around 0
Applied rewrites60.3%
if 1.0600000000000001 < m Initial program 79.5%
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.8
Applied rewrites2.8%
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-*.f6422.5
Applied rewrites22.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6451.3
Applied rewrites51.3%
(FPCore (a k m) :precision binary64 (if (<= m -9e-10) (/ a (* k k)) (if (<= m 0.42) a (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -9e-10) {
tmp = a / (k * k);
} else if (m <= 0.42) {
tmp = a;
} else {
tmp = ((k * k) * a) * 99.0;
}
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 <= (-9d-10)) then
tmp = a / (k * k)
else if (m <= 0.42d0) then
tmp = a
else
tmp = ((k * k) * a) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -9e-10) {
tmp = a / (k * k);
} else if (m <= 0.42) {
tmp = a;
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -9e-10: tmp = a / (k * k) elif m <= 0.42: tmp = a else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -9e-10) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.42) tmp = a; else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -9e-10) tmp = a / (k * k); elseif (m <= 0.42) tmp = a; else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -9e-10], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.42], a, N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -9 \cdot 10^{-10}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.42:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -8.9999999999999999e-10Initial 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-+.f6444.9
Applied rewrites44.9%
Taylor expanded in k around inf
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
pow2N/A
pow2N/A
lift-*.f6463.9
Applied rewrites63.9%
if -8.9999999999999999e-10 < m < 0.419999999999999984Initial program 91.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-+.f6489.8
Applied rewrites89.8%
Taylor expanded in k around 0
Applied rewrites50.8%
if 0.419999999999999984 < m Initial program 79.5%
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.8
Applied rewrites2.8%
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-*.f6422.5
Applied rewrites22.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6451.3
Applied rewrites51.3%
(FPCore (a k m) :precision binary64 (if (<= m 0.42) a (* (* (* k k) a) 99.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.42) {
tmp = a;
} else {
tmp = ((k * k) * a) * 99.0;
}
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.42d0) then
tmp = a
else
tmp = ((k * k) * a) * 99.0d0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 0.42) {
tmp = a;
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.42: tmp = a else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.42) tmp = a; else tmp = Float64(Float64(Float64(k * k) * a) * 99.0); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 0.42) tmp = a; else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.42], a, N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.42:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < 0.419999999999999984Initial program 95.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-+.f6468.1
Applied rewrites68.1%
Taylor expanded in k around 0
Applied rewrites28.3%
if 0.419999999999999984 < m Initial program 79.5%
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.8
Applied rewrites2.8%
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-*.f6422.5
Applied rewrites22.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6451.3
Applied rewrites51.3%
(FPCore (a k m) :precision binary64 (if (<= m 4e+24) a (* (* k a) -10.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 4e+24) {
tmp = a;
} else {
tmp = (k * a) * -10.0;
}
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 <= 4d+24) then
tmp = 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 <= 4e+24) {
tmp = a;
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 4e+24: tmp = a else: tmp = (k * a) * -10.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 4e+24) tmp = 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 <= 4e+24) tmp = a; else tmp = (k * a) * -10.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 4e+24], a, N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 4 \cdot 10^{+24}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < 3.9999999999999999e24Initial 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-+.f6466.6
Applied rewrites66.6%
Taylor expanded in k around 0
Applied rewrites27.7%
if 3.9999999999999999e24 < m Initial program 78.6%
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.8
Applied rewrites2.8%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f647.5
Applied rewrites7.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6417.1
Applied rewrites17.1%
(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.1%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6445.7
Applied rewrites45.7%
Taylor expanded in k around 0
Applied rewrites19.8%
herbie shell --seed 2025056
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))