
(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 -2.75e-8)
(/ (* a (pow k m)) (* k k))
(if (<= m 4.6e-26)
(/ (fma (* (log k) m) a a) (fma (+ 10.0 k) k 1.0))
(* (pow k m) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -2.75e-8) {
tmp = (a * pow(k, m)) / (k * k);
} else if (m <= 4.6e-26) {
tmp = fma((log(k) * m), a, a) / 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 <= -2.75e-8) tmp = Float64(Float64(a * (k ^ m)) / Float64(k * k)); elseif (m <= 4.6e-26) tmp = Float64(fma(Float64(log(k) * m), a, a) / 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, -2.75e-8], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.6e-26], N[(N[(N[(N[Log[k], $MachinePrecision] * m), $MachinePrecision] * a + a), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.75 \cdot 10^{-8}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{k \cdot k}\\
\mathbf{elif}\;m \leq 4.6 \cdot 10^{-26}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k \cdot m, a, a\right)}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < -2.7500000000000001e-8Initial program 99.8%
Taylor expanded in k around inf
pow2N/A
lift-*.f6499.3
Applied rewrites99.3%
if -2.7500000000000001e-8 < m < 4.60000000000000018e-26Initial program 93.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.2
Applied rewrites93.2%
if 4.60000000000000018e-26 < m Initial program 78.7%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6497.7
Applied rewrites97.7%
(FPCore (a k m) :precision binary64 (if (<= m 4.6e-26) (/ (* 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 <= 4.6e-26) {
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 <= 4.6d-26) 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 <= 4.6e-26) {
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 <= 4.6e-26: 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 <= 4.6e-26) 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 <= 4.6e-26) 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, 4.6e-26], 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 4.6 \cdot 10^{-26}:\\
\;\;\;\;\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 < 4.60000000000000018e-26Initial program 96.5%
if 4.60000000000000018e-26 < m Initial program 78.7%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6497.7
Applied rewrites97.7%
(FPCore (a k m) :precision binary64 (if (<= m 4.6e-26) (* 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 <= 4.6e-26) {
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 <= 4.6e-26) 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, 4.6e-26], 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 4.6 \cdot 10^{-26}:\\
\;\;\;\;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 < 4.60000000000000018e-26Initial program 96.5%
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-+.f6496.5
Applied rewrites96.5%
if 4.60000000000000018e-26 < m Initial program 78.7%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6497.7
Applied rewrites97.7%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -3.8e-6)
t_0
(if (<= m 4.6e-26)
(/ (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 <= -3.8e-6) {
tmp = t_0;
} else if (m <= 4.6e-26) {
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 <= -3.8e-6) tmp = t_0; elseif (m <= 4.6e-26) 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, -3.8e-6], t$95$0, If[LessEqual[m, 4.6e-26], 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 -3.8 \cdot 10^{-6}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 4.6 \cdot 10^{-26}:\\
\;\;\;\;\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 < -3.8e-6 or 4.60000000000000018e-26 < m Initial program 88.9%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6498.6
Applied rewrites98.6%
if -3.8e-6 < m < 4.60000000000000018e-26Initial program 93.2%
Taylor expanded in m around 0
div-add-revN/A
lower-/.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-log.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.2
Applied rewrites93.2%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -2.2e-13)
t_0
(if (<= m 4.6e-26) (/ 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 <= -2.2e-13) {
tmp = t_0;
} else if (m <= 4.6e-26) {
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 <= -2.2e-13) tmp = t_0; elseif (m <= 4.6e-26) 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, -2.2e-13], t$95$0, If[LessEqual[m, 4.6e-26], 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 -2.2 \cdot 10^{-13}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 4.6 \cdot 10^{-26}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -2.19999999999999997e-13 or 4.60000000000000018e-26 < m Initial program 88.9%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6498.4
Applied rewrites98.4%
if -2.19999999999999997e-13 < m < 4.60000000000000018e-26Initial program 93.2%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.1
Applied rewrites93.1%
(FPCore (a k m) :precision binary64 (if (<= m -0.4) (/ a (* k k)) (if (<= m 0.75) (/ a (fma (+ 10.0 k) k 1.0)) (* (* 99.0 a) (* k k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.4) {
tmp = a / (k * k);
} else if (m <= 0.75) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (99.0 * a) * (k * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.4) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.75) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(99.0 * a) * Float64(k * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.4], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.75], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * a), $MachinePrecision] * N[(k * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.4:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.75:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot a\right) \cdot \left(k \cdot k\right)\\
\end{array}
\end{array}
if m < -0.40000000000000002Initial 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-+.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6462.5
Applied rewrites62.5%
if -0.40000000000000002 < m < 0.75Initial program 93.2%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.7
Applied rewrites91.7%
if 0.75 < m Initial program 78.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-+.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.4
Applied rewrites25.4%
Taylor expanded in k around inf
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6447.5
Applied rewrites47.5%
Taylor expanded in k around inf
lift-*.f6460.9
Applied rewrites60.9%
(FPCore (a k m) :precision binary64 (if (<= m -0.4) (/ a (* k k)) (if (<= m 0.75) (/ a (fma k k 1.0)) (* (* 99.0 a) (* k k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.4) {
tmp = a / (k * k);
} else if (m <= 0.75) {
tmp = a / fma(k, k, 1.0);
} else {
tmp = (99.0 * a) * (k * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.4) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.75) tmp = Float64(a / fma(k, k, 1.0)); else tmp = Float64(Float64(99.0 * a) * Float64(k * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.4], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.75], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(99.0 * a), $MachinePrecision] * N[(k * k), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.4:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.75:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(99 \cdot a\right) \cdot \left(k \cdot k\right)\\
\end{array}
\end{array}
if m < -0.40000000000000002Initial 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-+.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6462.5
Applied rewrites62.5%
if -0.40000000000000002 < m < 0.75Initial program 93.2%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6491.7
Applied rewrites91.7%
Taylor expanded in k around inf
Applied rewrites89.3%
if 0.75 < m Initial program 78.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-+.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.4
Applied rewrites25.4%
Taylor expanded in k around inf
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6447.5
Applied rewrites47.5%
Taylor expanded in k around inf
lift-*.f6460.9
Applied rewrites60.9%
(FPCore (a k m) :precision binary64 (if (<= m -0.4) (/ a (* k k)) (if (<= m 400.0) (/ a (fma k k 1.0)) (* (* k a) -10.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.4) {
tmp = a / (k * k);
} else if (m <= 400.0) {
tmp = a / fma(k, k, 1.0);
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.4) tmp = Float64(a / Float64(k * k)); elseif (m <= 400.0) tmp = Float64(a / fma(k, k, 1.0)); else tmp = Float64(Float64(k * a) * -10.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.4], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 400.0], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.4:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 400:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < -0.40000000000000002Initial 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-+.f6437.9
Applied rewrites37.9%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6462.5
Applied rewrites62.5%
if -0.40000000000000002 < m < 400Initial program 93.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-+.f6491.4
Applied rewrites91.4%
Taylor expanded in k around inf
Applied rewrites89.1%
if 400 < m Initial program 78.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-+.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.5
Applied rewrites25.5%
Taylor expanded in k around inf
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6447.6
Applied rewrites47.6%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6419.9
Applied rewrites19.9%
(FPCore (a k m) :precision binary64 (if (<= k 2.7e-304) (/ a (* k k)) (if (<= k 90000000.0) (/ a (fma 10.0 k 1.0)) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 2.7e-304) {
tmp = a / (k * k);
} else if (k <= 90000000.0) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = (a / k) / k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 2.7e-304) tmp = Float64(a / Float64(k * k)); elseif (k <= 90000000.0) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(a / k) / k); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 2.7e-304], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 90000000.0], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.7 \cdot 10^{-304}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 90000000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < 2.7000000000000001e-304Initial program 89.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-+.f6421.5
Applied rewrites21.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6429.7
Applied rewrites29.7%
if 2.7000000000000001e-304 < k < 9e7Initial 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-+.f6451.8
Applied rewrites51.8%
Taylor expanded in k around 0
Applied rewrites50.3%
if 9e7 < k Initial program 81.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-+.f6459.7
Applied rewrites59.7%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6459.4
Applied rewrites59.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6463.0
Applied rewrites63.0%
(FPCore (a k m) :precision binary64 (if (<= k 2.7e-304) (/ a (* k k)) (if (<= k 0.1) (fma (* -10.0 a) k a) (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 2.7e-304) {
tmp = a / (k * k);
} else if (k <= 0.1) {
tmp = fma((-10.0 * a), k, a);
} else {
tmp = (a / k) / k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (k <= 2.7e-304) tmp = Float64(a / Float64(k * k)); elseif (k <= 0.1) tmp = fma(Float64(-10.0 * a), k, a); else tmp = Float64(Float64(a / k) / k); end return tmp end
code[a_, k_, m_] := If[LessEqual[k, 2.7e-304], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 0.1], N[(N[(-10.0 * a), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.7 \cdot 10^{-304}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 0.1:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot a, k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < 2.7000000000000001e-304Initial program 89.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-+.f6421.5
Applied rewrites21.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6429.7
Applied rewrites29.7%
if 2.7000000000000001e-304 < k < 0.10000000000000001Initial 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-+.f6451.8
Applied rewrites51.8%
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-*.f6451.5
Applied rewrites51.5%
Taylor expanded in k around 0
lower-*.f6451.2
Applied rewrites51.2%
if 0.10000000000000001 < k Initial program 81.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-+.f6459.5
Applied rewrites59.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6458.3
Applied rewrites58.3%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6461.8
Applied rewrites61.8%
(FPCore (a k m) :precision binary64 (if (<= k 2.7e-304) (/ a (* k k)) (if (<= k 90000000.0) a (/ (/ a k) k))))
double code(double a, double k, double m) {
double tmp;
if (k <= 2.7e-304) {
tmp = a / (k * k);
} else if (k <= 90000000.0) {
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) :: tmp
if (k <= 2.7d-304) then
tmp = a / (k * k)
else if (k <= 90000000.0d0) 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 tmp;
if (k <= 2.7e-304) {
tmp = a / (k * k);
} else if (k <= 90000000.0) {
tmp = a;
} else {
tmp = (a / k) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 2.7e-304: tmp = a / (k * k) elif k <= 90000000.0: tmp = a else: tmp = (a / k) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 2.7e-304) tmp = Float64(a / Float64(k * k)); elseif (k <= 90000000.0) tmp = a; else tmp = Float64(Float64(a / k) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 2.7e-304) tmp = a / (k * k); elseif (k <= 90000000.0) tmp = a; else tmp = (a / k) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 2.7e-304], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[k, 90000000.0], a, N[(N[(a / k), $MachinePrecision] / k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;k \leq 2.7 \cdot 10^{-304}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;k \leq 90000000:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{k}}{k}\\
\end{array}
\end{array}
if k < 2.7000000000000001e-304Initial program 89.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-+.f6421.5
Applied rewrites21.5%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6429.7
Applied rewrites29.7%
if 2.7000000000000001e-304 < k < 9e7Initial 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-+.f6451.8
Applied rewrites51.8%
Taylor expanded in k around 0
Applied rewrites49.4%
if 9e7 < k Initial program 81.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-+.f6459.7
Applied rewrites59.7%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6459.4
Applied rewrites59.4%
lift-*.f64N/A
lift-/.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-/.f6463.0
Applied rewrites63.0%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k 2.7e-304) t_0 (if (<= k 90000000.0) a t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= 2.7e-304) {
tmp = t_0;
} else if (k <= 90000000.0) {
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) :: tmp
t_0 = a / (k * k)
if (k <= 2.7d-304) then
tmp = t_0
else if (k <= 90000000.0d0) 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 tmp;
if (k <= 2.7e-304) {
tmp = t_0;
} else if (k <= 90000000.0) {
tmp = a;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) tmp = 0 if k <= 2.7e-304: tmp = t_0 elif k <= 90000000.0: tmp = a else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (k <= 2.7e-304) tmp = t_0; elseif (k <= 90000000.0) tmp = a; else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); tmp = 0.0; if (k <= 2.7e-304) tmp = t_0; elseif (k <= 90000000.0) 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]}, If[LessEqual[k, 2.7e-304], t$95$0, If[LessEqual[k, 90000000.0], a, t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;k \leq 2.7 \cdot 10^{-304}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 90000000:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < 2.7000000000000001e-304 or 9e7 < k Initial program 85.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-+.f6442.0
Applied rewrites42.0%
Taylor expanded in k around inf
lower-/.f64N/A
pow2N/A
lift-*.f6445.6
Applied rewrites45.6%
if 2.7000000000000001e-304 < k < 9e7Initial 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-+.f6451.8
Applied rewrites51.8%
Taylor expanded in k around 0
Applied rewrites49.4%
(FPCore (a k m) :precision binary64 (if (<= m 400.0) a (* (* k a) -10.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 400.0) {
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 <= 400.0d0) 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 <= 400.0) {
tmp = a;
} else {
tmp = (k * a) * -10.0;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 400.0: tmp = a else: tmp = (k * a) * -10.0 return tmp
function code(a, k, m) tmp = 0.0 if (m <= 400.0) 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 <= 400.0) tmp = a; else tmp = (k * a) * -10.0; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 400.0], a, N[(N[(k * a), $MachinePrecision] * -10.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 400:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot a\right) \cdot -10\\
\end{array}
\end{array}
if m < 400Initial program 96.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-+.f6466.2
Applied rewrites66.2%
Taylor expanded in k around 0
Applied rewrites28.4%
if 400 < m Initial program 78.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-+.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.5
Applied rewrites25.5%
Taylor expanded in k around inf
metadata-evalN/A
fp-cancel-sub-sign-invN/A
*-commutativeN/A
lower-*.f64N/A
fp-cancel-sub-sign-invN/A
metadata-evalN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-*.f64N/A
pow2N/A
lift-*.f6447.6
Applied rewrites47.6%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-*.f6419.9
Applied rewrites19.9%
(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.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-+.f6445.4
Applied rewrites45.4%
Taylor expanded in k around 0
Applied rewrites20.3%
herbie shell --seed 2025122
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))