
(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 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (a k m) :precision binary64 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))
double code(double a, double k, double m) {
return (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
}
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 3.65) (/ (* 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 <= 3.65) {
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 <= 3.65d0) 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 <= 3.65) {
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 <= 3.65: 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 <= 3.65) 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 <= 3.65) 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, 3.65], 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 3.65:\\
\;\;\;\;\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 < 3.64999999999999991Initial program 96.7%
if 3.64999999999999991 < m Initial program 77.3%
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 3.65) (* 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 <= 3.65) {
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 <= 3.65) 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, 3.65], 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 3.65:\\
\;\;\;\;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 < 3.64999999999999991Initial program 96.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-+.f6496.7
Applied rewrites96.7%
if 3.64999999999999991 < m Initial program 77.3%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -4.9e-15)
t_0
(if (<= m 2.85e-7) (/ a (fma k k (fma 10.0 k 1.0))) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -4.9e-15) {
tmp = t_0;
} else if (m <= 2.85e-7) {
tmp = a / fma(k, k, fma(10.0, k, 1.0));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -4.9e-15) tmp = t_0; elseif (m <= 2.85e-7) tmp = Float64(a / fma(k, k, fma(10.0, 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, -4.9e-15], t$95$0, If[LessEqual[m, 2.85e-7], N[(a / N[(k * k + N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -4.9 \cdot 10^{-15}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 2.85 \cdot 10^{-7}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, \mathsf{fma}\left(10, k, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -4.8999999999999999e-15 or 2.8500000000000002e-7 < m Initial program 88.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6499.2
Applied rewrites99.2%
if -4.8999999999999999e-15 < m < 2.8500000000000002e-7Initial program 93.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-+.f6493.6
Applied rewrites93.6%
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6493.6
Applied rewrites93.6%
(FPCore (a k m) :precision binary64 (if (<= m -0.33) (/ (* (/ a (* k k)) 99.0) (* k k)) (if (<= m 0.8) (/ a (fma k k (fma 10.0 k 1.0))) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.33) {
tmp = ((a / (k * k)) * 99.0) / (k * k);
} else if (m <= 0.8) {
tmp = a / fma(k, k, 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 <= -0.33) tmp = Float64(Float64(Float64(a / Float64(k * k)) * 99.0) / Float64(k * k)); elseif (m <= 0.8) tmp = Float64(a / fma(k, k, 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, -0.33], N[(N[(N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision] * 99.0), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.8], N[(a / N[(k * k + N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.33:\\
\;\;\;\;\frac{\frac{a}{k \cdot k} \cdot 99}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.8:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, \mathsf{fma}\left(10, k, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.330000000000000016Initial program 99.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-+.f6438.9
Applied rewrites38.9%
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 rewrites67.9%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6474.8
Applied rewrites74.8%
if -0.330000000000000016 < m < 0.80000000000000004Initial program 93.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-+.f6492.3
Applied rewrites92.3%
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6492.3
Applied rewrites92.3%
if 0.80000000000000004 < m Initial program 77.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-+.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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
(FPCore (a k m) :precision binary64 (if (<= m -1.65e+23) (* a (/ 1.0 (* k k))) (if (<= m 0.8) (/ a (fma k k (fma 10.0 k 1.0))) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1.65e+23) {
tmp = a * (1.0 / (k * k));
} else if (m <= 0.8) {
tmp = a / fma(k, k, 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 <= -1.65e+23) tmp = Float64(a * Float64(1.0 / Float64(k * k))); elseif (m <= 0.8) tmp = Float64(a / fma(k, k, 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, -1.65e+23], N[(a * N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.8], N[(a / N[(k * k + N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.65 \cdot 10^{+23}:\\
\;\;\;\;a \cdot \frac{1}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.8:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, \mathsf{fma}\left(10, k, 1\right)\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -1.65000000000000015e23Initial program 99.9%
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-+.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites38.9%
Taylor expanded in k around inf
pow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if -1.65000000000000015e23 < m < 0.80000000000000004Initial program 94.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-+.f6489.5
Applied rewrites89.5%
lift-+.f64N/A
lift-fma.f64N/A
+-commutativeN/A
*-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+r+N/A
+-commutativeN/A
pow2N/A
lower-fma.f64N/A
+-commutativeN/A
lower-fma.f6489.5
Applied rewrites89.5%
if 0.80000000000000004 < m Initial program 77.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-+.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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
(FPCore (a k m) :precision binary64 (if (<= m -1.65e+23) (* a (/ 1.0 (* k k))) (if (<= m 0.8) (/ 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 <= -1.65e+23) {
tmp = a * (1.0 / (k * k));
} else if (m <= 0.8) {
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 <= -1.65e+23) tmp = Float64(a * Float64(1.0 / Float64(k * k))); elseif (m <= 0.8) 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, -1.65e+23], N[(a * N[(1.0 / N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.8], 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 -1.65 \cdot 10^{+23}:\\
\;\;\;\;a \cdot \frac{1}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.8:\\
\;\;\;\;\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 < -1.65000000000000015e23Initial program 99.9%
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-+.f64100.0
Applied rewrites100.0%
lift-pow.f64N/A
sqr-powN/A
pow2N/A
lower-pow.f64N/A
lower-pow.f64N/A
lower-/.f64100.0
Applied rewrites100.0%
Taylor expanded in m around 0
Applied rewrites38.9%
Taylor expanded in k around inf
pow2N/A
lower-*.f6462.6
Applied rewrites62.6%
if -1.65000000000000015e23 < m < 0.80000000000000004Initial program 94.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-+.f6489.5
Applied rewrites89.5%
if 0.80000000000000004 < m Initial program 77.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-+.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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
(FPCore (a k m) :precision binary64 (if (<= m -1.65e+23) (/ a (* k k)) (if (<= m 0.8) (/ 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 <= -1.65e+23) {
tmp = a / (k * k);
} else if (m <= 0.8) {
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 <= -1.65e+23) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.8) 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, -1.65e+23], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.8], 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 -1.65 \cdot 10^{+23}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.8:\\
\;\;\;\;\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 < -1.65000000000000015e23Initial program 99.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-+.f6438.9
Applied rewrites38.9%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6461.9
Applied rewrites61.9%
if -1.65000000000000015e23 < m < 0.80000000000000004Initial program 94.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-+.f6489.5
Applied rewrites89.5%
if 0.80000000000000004 < m Initial program 77.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-+.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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
(FPCore (a k m) :precision binary64 (if (<= m -2.22e+21) (/ a (* k k)) (if (<= m 0.8) (/ a (fma k k 1.0)) (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.22e+21) {
tmp = a / (k * k);
} else if (m <= 0.8) {
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 <= -2.22e+21) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.8) 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, -2.22e+21], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.8], 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 -2.22 \cdot 10^{+21}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.8:\\
\;\;\;\;\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 < -2.22e21Initial program 99.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-+.f6438.9
Applied rewrites38.9%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6461.9
Applied rewrites61.9%
if -2.22e21 < m < 0.80000000000000004Initial program 94.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-+.f6489.9
Applied rewrites89.9%
Taylor expanded in k around inf
Applied rewrites87.9%
if 0.80000000000000004 < m Initial program 77.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-+.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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
(FPCore (a k m) :precision binary64 (if (<= m -0.0021) (/ a (* k k)) (if (<= m 0.33) a (* (* (* k k) a) 99.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.0021) {
tmp = a / (k * k);
} else if (m <= 0.33) {
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.0021d0)) then
tmp = a / (k * k)
else if (m <= 0.33d0) 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.0021) {
tmp = a / (k * k);
} else if (m <= 0.33) {
tmp = a;
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -0.0021: tmp = a / (k * k) elif m <= 0.33: tmp = a else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= -0.0021) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.33) 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.0021) tmp = a / (k * k); elseif (m <= 0.33) tmp = a; else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -0.0021], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.33], a, N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.0021:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.33:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < -0.00209999999999999987Initial program 99.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-+.f6439.0
Applied rewrites39.0%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6461.9
Applied rewrites61.9%
if -0.00209999999999999987 < m < 0.330000000000000016Initial program 93.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-+.f6492.5
Applied rewrites92.5%
Taylor expanded in k around 0
Applied rewrites49.3%
if 0.330000000000000016 < m Initial program 77.4%
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
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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
(FPCore (a k m) :precision binary64 (if (<= m 0.33) a (* (* (* k k) a) 99.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.33) {
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.33d0) 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.33) {
tmp = a;
} else {
tmp = ((k * k) * a) * 99.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.33: tmp = a else: tmp = ((k * k) * a) * 99.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.33) 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.33) tmp = a; else tmp = ((k * k) * a) * 99.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.33], a, N[(N[(N[(k * k), $MachinePrecision] * a), $MachinePrecision] * 99.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.33:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot a\right) \cdot 99\\
\end{array}
\end{array}
if m < 0.330000000000000016Initial program 96.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-+.f6467.7
Applied rewrites67.7%
Taylor expanded in k around 0
Applied rewrites28.2%
if 0.330000000000000016 < m Initial program 77.4%
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
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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6462.4
Applied rewrites62.4%
(FPCore (a k m) :precision binary64 (if (<= m 0.33) a (* (* (* k k) 99.0) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 0.33) {
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.33d0) 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.33) {
tmp = a;
} else {
tmp = ((k * k) * 99.0) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 0.33: tmp = a else: tmp = ((k * k) * 99.0) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 0.33) 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.33) tmp = a; else tmp = ((k * k) * 99.0) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 0.33], a, N[(N[(N[(k * k), $MachinePrecision] * 99.0), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 0.33:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(\left(k \cdot k\right) \cdot 99\right) \cdot a\\
\end{array}
\end{array}
if m < 0.330000000000000016Initial program 96.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-+.f6467.7
Applied rewrites67.7%
Taylor expanded in k around 0
Applied rewrites28.2%
if 0.330000000000000016 < m Initial program 77.4%
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
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-*.f6427.6
Applied rewrites27.6%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6432.5
Applied rewrites32.5%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lower-*.f6462.5
Applied rewrites62.5%
(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.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-+.f6446.5
Applied rewrites46.5%
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-*.f6427.5
Applied rewrites27.5%
Taylor expanded in k around 0
lift-*.f6421.0
Applied rewrites21.0%
(FPCore (a k m) :precision binary64 (* (fma -10.0 k 1.0) a))
double code(double a, double k, double m) {
return fma(-10.0, k, 1.0) * a;
}
function code(a, k, m) return Float64(fma(-10.0, k, 1.0) * a) end
code[a_, k_, m_] := N[(N[(-10.0 * k + 1.0), $MachinePrecision] * a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-10, k, 1\right) \cdot a
\end{array}
Initial program 90.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-+.f6446.5
Applied rewrites46.5%
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-*.f6427.5
Applied rewrites27.5%
Taylor expanded in a around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64N/A
lower-*.f6429.1
Applied rewrites29.1%
Taylor expanded in k around 0
Applied rewrites21.0%
(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.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-+.f6446.5
Applied rewrites46.5%
Taylor expanded in k around 0
Applied rewrites20.2%
herbie shell --seed 2025093
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))