
(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}
Herbie found 13 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.0055) (* 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.0055) {
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.0055) 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.0055], 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.0055:\\
\;\;\;\;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.0054999999999999997Initial program 97.0%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-+l+N/A
associate-/l*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-+.f6497.0
Applied rewrites97.0%
if 0.0054999999999999997 < m Initial program 78.7%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6499.6
Applied rewrites99.6%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -0.075)
t_0
(if (<= m 0.00205)
(/ (fma (* (log k) m) a 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 <= -0.075) {
tmp = t_0;
} else if (m <= 0.00205) {
tmp = fma((log(k) * m), a, 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 <= -0.075) tmp = t_0; elseif (m <= 0.00205) tmp = Float64(fma(Float64(log(k) * m), a, 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, -0.075], t$95$0, If[LessEqual[m, 0.00205], N[(N[(N[(N[Log[k], $MachinePrecision] * m), $MachinePrecision] * a + a), $MachinePrecision] / 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 -0.075:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 0.00205:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k \cdot m, a, a\right)}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -0.0749999999999999972 or 0.00205000000000000017 < m Initial program 89.1%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6499.7
Applied rewrites99.7%
if -0.0749999999999999972 < m < 0.00205000000000000017Initial program 94.3%
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.5
Applied rewrites93.5%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -5.5e-5)
t_0
(if (<= m 1.4e-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 <= -5.5e-5) {
tmp = t_0;
} else if (m <= 1.4e-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 <= -5.5e-5) tmp = t_0; elseif (m <= 1.4e-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, -5.5e-5], t$95$0, If[LessEqual[m, 1.4e-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 -5.5 \cdot 10^{-5}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 1.4 \cdot 10^{-7}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -5.5000000000000002e-5 or 1.4000000000000001e-7 < m Initial program 89.1%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6499.4
Applied rewrites99.4%
if -5.5000000000000002e-5 < m < 1.4000000000000001e-7Initial program 94.3%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.5
Applied rewrites93.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.053) (* (/ 1.0 (* k k)) a) (if (<= m 0.62) (/ 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.053) {
tmp = (1.0 / (k * k)) * a;
} else if (m <= 0.62) {
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.053) tmp = Float64(Float64(1.0 / Float64(k * k)) * a); elseif (m <= 0.62) 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.053], N[(N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 0.62], 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.053:\\
\;\;\;\;\frac{1}{k \cdot k} \cdot a\\
\mathbf{elif}\;m \leq 0.62:\\
\;\;\;\;\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.0529999999999999985Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6499.9
pow299.9
associate-+l+99.9
pow299.9
distribute-rgt-in99.9
+-commutative99.9
*-commutative99.9
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in m around 0
Applied rewrites63.9%
if -0.0529999999999999985 < m < 0.619999999999999996Initial program 94.3%
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.6
Applied rewrites92.6%
if 0.619999999999999996 < 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-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6425.9
Applied rewrites25.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.5
Applied rewrites59.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.053) (* (/ 1.0 (* k k)) a) (if (<= m 0.62) (/ a (fma k k 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.053) {
tmp = (1.0 / (k * k)) * a;
} else if (m <= 0.62) {
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 <= -0.053) tmp = Float64(Float64(1.0 / Float64(k * k)) * a); elseif (m <= 0.62) 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, -0.053], N[(N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 0.62], 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 -0.053:\\
\;\;\;\;\frac{1}{k \cdot k} \cdot a\\
\mathbf{elif}\;m \leq 0.62:\\
\;\;\;\;\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 < -0.0529999999999999985Initial program 100.0%
Taylor expanded in k around inf
pow2N/A
lift-*.f6499.9
Applied rewrites99.9%
lift-/.f64N/A
lift-*.f64N/A
lift-pow.f64N/A
associate-/l*N/A
lower-*.f64N/A
lower-/.f64N/A
lift-pow.f6499.9
pow299.9
associate-+l+99.9
pow299.9
distribute-rgt-in99.9
+-commutative99.9
*-commutative99.9
Applied rewrites99.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6499.9
Applied rewrites99.9%
Taylor expanded in m around 0
Applied rewrites63.9%
if -0.0529999999999999985 < m < 0.619999999999999996Initial program 94.3%
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.6
Applied rewrites92.6%
Taylor expanded in k around inf
Applied rewrites90.4%
if 0.619999999999999996 < 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-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6425.9
Applied rewrites25.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.5
Applied rewrites59.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.053) (/ a (* k k)) (if (<= m 0.62) (/ a (fma k k 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.053) {
tmp = a / (k * k);
} else if (m <= 0.62) {
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 <= -0.053) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.62) 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, -0.053], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.62], 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 -0.053:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.62:\\
\;\;\;\;\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 < -0.0529999999999999985Initial 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-+.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6463.5
Applied rewrites63.5%
if -0.0529999999999999985 < m < 0.619999999999999996Initial program 94.3%
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.6
Applied rewrites92.6%
Taylor expanded in k around inf
Applied rewrites90.4%
if 0.619999999999999996 < 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-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6425.9
Applied rewrites25.9%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6459.5
Applied rewrites59.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.053) (/ a (* k k)) (if (<= m 1.65e+38) (/ a (fma k k 1.0)) (fma (* k a) -10.0 a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.053) {
tmp = a / (k * k);
} else if (m <= 1.65e+38) {
tmp = a / fma(k, k, 1.0);
} else {
tmp = fma((k * a), -10.0, a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.053) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.65e+38) tmp = Float64(a / fma(k, k, 1.0)); else tmp = fma(Float64(k * a), -10.0, a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.053], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.65e+38], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0 + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.053:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.65 \cdot 10^{+38}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(k \cdot a, -10, a\right)\\
\end{array}
\end{array}
if m < -0.0529999999999999985Initial 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-+.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6463.5
Applied rewrites63.5%
if -0.0529999999999999985 < m < 1.65e38Initial program 92.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-+.f6484.7
Applied rewrites84.7%
Taylor expanded in k around inf
Applied rewrites82.7%
if 1.65e38 < m Initial program 78.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-+.f643.0
Applied rewrites3.0%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f648.1
Applied rewrites8.1%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (<= t_0 2e-303)
(/ (/ a k) k)
(if (<= t_0 5e+295)
(/ a (fma 10.0 k 1.0))
(if (<= t_0 INFINITY) (/ a (* k k)) (fma (* k a) -10.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 <= 2e-303) {
tmp = (a / k) / k;
} else if (t_0 <= 5e+295) {
tmp = a / fma(10.0, k, 1.0);
} else if (t_0 <= ((double) INFINITY)) {
tmp = a / (k * k);
} else {
tmp = fma((k * a), -10.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 <= 2e-303) tmp = Float64(Float64(a / k) / k); elseif (t_0 <= 5e+295) tmp = Float64(a / fma(10.0, k, 1.0)); elseif (t_0 <= Inf) tmp = Float64(a / Float64(k * k)); else tmp = fma(Float64(k * a), -10.0, a); end return 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, 2e-303], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision], If[LessEqual[t$95$0, 5e+295], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0 + 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 2 \cdot 10^{-303}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(k \cdot a, -10, a\right)\\
\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))) < 1.99999999999999986e-303Initial program 97.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-+.f6448.8
Applied rewrites48.8%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6440.5
Applied rewrites40.5%
if 1.99999999999999986e-303 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.99999999999999991e295Initial program 99.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-+.f6497.2
Applied rewrites97.2%
Taylor expanded in k around 0
Applied rewrites71.6%
if 4.99999999999999991e295 < (/.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 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-+.f644.5
Applied rewrites4.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6438.5
Applied rewrites38.5%
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.7
Applied rewrites1.7%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6417.1
Applied rewrites17.1%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (<= t_0 2e-303)
(/ (/ a k) k)
(if (<= t_0 5e+295)
(fma (* -10.0 a) k a)
(if (<= t_0 INFINITY) (/ a (* k k)) (fma (* k a) -10.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 <= 2e-303) {
tmp = (a / k) / k;
} else if (t_0 <= 5e+295) {
tmp = fma((-10.0 * a), k, a);
} else if (t_0 <= ((double) INFINITY)) {
tmp = a / (k * k);
} else {
tmp = fma((k * a), -10.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 <= 2e-303) tmp = Float64(Float64(a / k) / k); elseif (t_0 <= 5e+295) tmp = fma(Float64(-10.0 * a), k, a); elseif (t_0 <= Inf) tmp = Float64(a / Float64(k * k)); else tmp = fma(Float64(k * a), -10.0, a); end return 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, 2e-303], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision], If[LessEqual[t$95$0, 5e+295], N[(N[(-10.0 * a), $MachinePrecision] * k + a), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0 + 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 2 \cdot 10^{-303}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot a, k, a\right)\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(k \cdot a, -10, a\right)\\
\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))) < 1.99999999999999986e-303Initial program 97.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-+.f6448.8
Applied rewrites48.8%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6440.5
Applied rewrites40.5%
if 1.99999999999999986e-303 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.99999999999999991e295Initial program 99.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-+.f6497.2
Applied rewrites97.2%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6470.8
Applied rewrites70.8%
Taylor expanded in k around 0
lower-*.f6469.9
Applied rewrites69.9%
if 4.99999999999999991e295 < (/.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 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-+.f644.5
Applied rewrites4.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6438.5
Applied rewrites38.5%
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.7
Applied rewrites1.7%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6417.1
Applied rewrites17.1%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
(t_1 (fma (* -10.0 a) k a)))
(if (<= t_0 2e-303)
(/ (/ a k) k)
(if (<= t_0 5e+295) t_1 (if (<= t_0 INFINITY) (/ a (* k k)) t_1)))))
double code(double a, double k, double m) {
double t_0 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double t_1 = fma((-10.0 * a), k, a);
double tmp;
if (t_0 <= 2e-303) {
tmp = (a / k) / k;
} else if (t_0 <= 5e+295) {
tmp = t_1;
} else if (t_0 <= ((double) INFINITY)) {
tmp = a / (k * k);
} else {
tmp = t_1;
}
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))) t_1 = fma(Float64(-10.0 * a), k, a) tmp = 0.0 if (t_0 <= 2e-303) tmp = Float64(Float64(a / k) / k); elseif (t_0 <= 5e+295) tmp = t_1; elseif (t_0 <= Inf) tmp = Float64(a / Float64(k * k)); else tmp = t_1; end return 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]}, Block[{t$95$1 = N[(N[(-10.0 * a), $MachinePrecision] * k + a), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-303], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision], If[LessEqual[t$95$0, 5e+295], t$95$1, If[LessEqual[t$95$0, Infinity], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
t_1 := \mathsf{fma}\left(-10 \cdot a, k, a\right)\\
\mathbf{if}\;t\_0 \leq 2 \cdot 10^{-303}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\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))) < 1.99999999999999986e-303Initial program 97.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-+.f6448.8
Applied rewrites48.8%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6440.5
Applied rewrites40.5%
if 1.99999999999999986e-303 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.99999999999999991e295 or +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 62.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-+.f6461.2
Applied rewrites61.2%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
lower-*.f6473.1
Applied rewrites73.1%
Taylor expanded in k around 0
lower-*.f6449.9
Applied rewrites49.9%
if 4.99999999999999991e295 < (/.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 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-+.f644.5
Applied rewrites4.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6438.5
Applied rewrites38.5%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))) (if (<= t_0 2e-303) (/ (/ a k) k) (if (<= t_0 5e+295) a (/ a (* k k))))))
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 <= 2e-303) {
tmp = (a / k) / k;
} else if (t_0 <= 5e+295) {
tmp = a;
} else {
tmp = a / (k * k);
}
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) :: t_0
real(8) :: tmp
t_0 = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
if (t_0 <= 2d-303) then
tmp = (a / k) / k
else if (t_0 <= 5d+295) then
tmp = a
else
tmp = a / (k * k)
end if
code = tmp
end function
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 <= 2e-303) {
tmp = (a / k) / k;
} else if (t_0 <= 5e+295) {
tmp = a;
} else {
tmp = a / (k * k);
}
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 <= 2e-303: tmp = (a / k) / k elif t_0 <= 5e+295: tmp = a else: tmp = a / (k * k) 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 <= 2e-303) tmp = Float64(Float64(a / k) / k); elseif (t_0 <= 5e+295) tmp = a; else tmp = Float64(a / Float64(k * k)); 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 <= 2e-303) tmp = (a / k) / k; elseif (t_0 <= 5e+295) tmp = a; else tmp = a / (k * k); 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, 2e-303], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision], If[LessEqual[t$95$0, 5e+295], a, N[(a / N[(k * k), $MachinePrecision]), $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 2 \cdot 10^{-303}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\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))) < 1.99999999999999986e-303Initial program 97.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-+.f6448.8
Applied rewrites48.8%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6441.7
Applied rewrites41.7%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lower-/.f6440.5
Applied rewrites40.5%
if 1.99999999999999986e-303 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.99999999999999991e295Initial program 99.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-+.f6497.2
Applied rewrites97.2%
Taylor expanded in k around 0
Applied rewrites70.2%
if 4.99999999999999991e295 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 63.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-+.f643.5
Applied rewrites3.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6425.2
Applied rewrites25.2%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k)))
(t_1 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (<= t_1 2e-303) t_0 (if (<= t_1 5e+295) a t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 2e-303) {
tmp = t_0;
} else if (t_1 <= 5e+295) {
tmp = a;
} else {
tmp = t_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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a / (k * k)
t_1 = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
if (t_1 <= 2d-303) then
tmp = t_0
else if (t_1 <= 5d+295) then
tmp = a
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 2e-303) {
tmp = t_0;
} else if (t_1 <= 5e+295) {
tmp = a;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) t_1 = (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k)) tmp = 0 if t_1 <= 2e-303: tmp = t_0 elif t_1 <= 5e+295: tmp = a else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) t_1 = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 2e-303) tmp = t_0; elseif (t_1 <= 5e+295) tmp = a; else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); t_1 = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); tmp = 0.0; if (t_1 <= 2e-303) tmp = t_0; elseif (t_1 <= 5e+295) tmp = a; else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = 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$1, 2e-303], t$95$0, If[LessEqual[t$95$1, 5e+295], a, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
t_1 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 2 \cdot 10^{-303}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+295}:\\
\;\;\;\;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))) < 1.99999999999999986e-303 or 4.99999999999999991e295 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 89.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-+.f6438.8
Applied rewrites38.8%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6438.1
Applied rewrites38.1%
if 1.99999999999999986e-303 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.99999999999999991e295Initial program 99.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-+.f6497.2
Applied rewrites97.2%
Taylor expanded in k around 0
Applied rewrites70.2%
(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-+.f6445.6
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites19.9%
herbie shell --seed 2025133
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))