
(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 12 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.85) (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (/ 1.0 (pow k -2.0)))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.85) {
tmp = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (1.0 / pow(k, -2.0)));
} 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 <= 2.85d0) then
tmp = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (1.0d0 / (k ** (-2.0d0))))
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 <= 2.85) {
tmp = (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (1.0 / Math.pow(k, -2.0)));
} else {
tmp = Math.pow(k, m) * a;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 2.85: tmp = (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (1.0 / math.pow(k, -2.0))) else: tmp = math.pow(k, m) * a return tmp
function code(a, k, m) tmp = 0.0 if (m <= 2.85) tmp = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(1.0 / (k ^ -2.0)))); else tmp = Float64((k ^ m) * a); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 2.85) tmp = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (1.0 / (k ^ -2.0))); else tmp = (k ^ m) * a; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 2.85], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(1.0 / N[Power[k, -2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.85:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + \frac{1}{{k}^{-2}}}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 2.85000000000000009Initial program 98.2%
lift-*.f64N/A
pow2N/A
pow-to-expN/A
lower-exp.f64N/A
lower-*.f64N/A
lower-log.f6482.4
Applied rewrites82.4%
lift-exp.f64N/A
lift-*.f64N/A
lift-log.f64N/A
pow-to-expN/A
metadata-evalN/A
pow-powN/A
inv-powN/A
metadata-evalN/A
pow-negN/A
pow2N/A
inv-powN/A
inv-powN/A
unpow-prod-downN/A
pow2N/A
inv-powN/A
lower-/.f64N/A
pow-flipN/A
metadata-evalN/A
lower-pow.f6498.2
Applied rewrites98.2%
if 2.85000000000000009 < m Initial program 79.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (<= m 2.85) (/ (* 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 <= 2.85) {
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 <= 2.85d0) 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 <= 2.85) {
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 <= 2.85: 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 <= 2.85) 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 <= 2.85) 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, 2.85], 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 2.85:\\
\;\;\;\;\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 < 2.85000000000000009Initial program 98.2%
if 2.85000000000000009 < m Initial program 79.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
(FPCore (a k m) :precision binary64 (if (or (<= m -2.05e-17) (not (<= m 0.0037))) (* (pow k m) a) (/ a (fma (+ 10.0 k) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if ((m <= -2.05e-17) || !(m <= 0.0037)) {
tmp = pow(k, m) * a;
} else {
tmp = a / fma((10.0 + k), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if ((m <= -2.05e-17) || !(m <= 0.0037)) tmp = Float64((k ^ m) * a); else tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[Or[LessEqual[m, -2.05e-17], N[Not[LessEqual[m, 0.0037]], $MachinePrecision]], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -2.05 \cdot 10^{-17} \lor \neg \left(m \leq 0.0037\right):\\
\;\;\;\;{k}^{m} \cdot a\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\end{array}
\end{array}
if m < -2.05e-17 or 0.0037000000000000002 < m Initial program 89.0%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lift-pow.f64100.0
Applied rewrites100.0%
if -2.05e-17 < m < 0.0037000000000000002Initial program 96.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-+.f6496.8
Applied rewrites96.8%
Final simplification98.8%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* k (+ 10.0 k))))
(if (<= m -0.49)
(/ (* (/ a (* k k)) 99.0) (* k k))
(if (<= m 22500000.0)
(/ a (fma (+ 10.0 k) k 1.0))
(/ (* a 1.0) (/ (- 1.0 (* t_0 t_0)) (* (- k) k)))))))
double code(double a, double k, double m) {
double t_0 = k * (10.0 + k);
double tmp;
if (m <= -0.49) {
tmp = ((a / (k * k)) * 99.0) / (k * k);
} else if (m <= 22500000.0) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (a * 1.0) / ((1.0 - (t_0 * t_0)) / (-k * k));
}
return tmp;
}
function code(a, k, m) t_0 = Float64(k * Float64(10.0 + k)) tmp = 0.0 if (m <= -0.49) tmp = Float64(Float64(Float64(a / Float64(k * k)) * 99.0) / Float64(k * k)); elseif (m <= 22500000.0) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(a * 1.0) / Float64(Float64(1.0 - Float64(t_0 * t_0)) / Float64(Float64(-k) * k))); end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(k * N[(10.0 + k), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -0.49], N[(N[(N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision] * 99.0), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 22500000.0], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * 1.0), $MachinePrecision] / N[(N[(1.0 - N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision] / N[((-k) * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := k \cdot \left(10 + k\right)\\
\mathbf{if}\;m \leq -0.49:\\
\;\;\;\;\frac{\frac{a}{k \cdot k} \cdot 99}{k \cdot k}\\
\mathbf{elif}\;m \leq 22500000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot 1}{\frac{1 - t\_0 \cdot t\_0}{\left(-k\right) \cdot k}}\\
\end{array}
\end{array}
if m < -0.48999999999999999Initial 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-+.f6433.1
Applied rewrites33.1%
Taylor expanded in k around inf
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-*.f6460.8
Applied rewrites60.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6476.2
Applied rewrites76.2%
if -0.48999999999999999 < m < 2.25e7Initial 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.2
Applied rewrites93.2%
if 2.25e7 < m Initial program 82.6%
lift-+.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-+r+N/A
pow2N/A
distribute-rgt-inN/A
fp-cancel-sign-sub-invN/A
flip--N/A
lower-/.f64N/A
Applied rewrites73.3%
Taylor expanded in m around 0
Applied rewrites3.1%
Taylor expanded in k around inf
mul-1-negN/A
lower-neg.f64N/A
pow2N/A
lift-*.f6444.2
Applied rewrites44.2%
Final simplification72.0%
(FPCore (a k m)
:precision binary64
(if (<= m -0.49)
(/ (* (/ a (* k k)) 99.0) (* k k))
(if (<= m 1.85)
(/ a (fma (+ 10.0 k) k 1.0))
(if (<= m 4.7e+123)
(fma (fma (* 99.0 a) k (* -10.0 a)) k a)
(* (* -10.0 a) k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.49) {
tmp = ((a / (k * k)) * 99.0) / (k * k);
} else if (m <= 1.85) {
tmp = a / fma((10.0 + k), k, 1.0);
} else if (m <= 4.7e+123) {
tmp = fma(fma((99.0 * a), k, (-10.0 * a)), k, a);
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.49) tmp = Float64(Float64(Float64(a / Float64(k * k)) * 99.0) / Float64(k * k)); elseif (m <= 1.85) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); elseif (m <= 4.7e+123) tmp = fma(fma(Float64(99.0 * a), k, Float64(-10.0 * a)), k, a); else tmp = Float64(Float64(-10.0 * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.49], N[(N[(N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision] * 99.0), $MachinePrecision] / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.85], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.7e+123], N[(N[(N[(99.0 * a), $MachinePrecision] * k + N[(-10.0 * a), $MachinePrecision]), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.49:\\
\;\;\;\;\frac{\frac{a}{k \cdot k} \cdot 99}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.85:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{elif}\;m \leq 4.7 \cdot 10^{+123}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -0.48999999999999999Initial 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-+.f6433.1
Applied rewrites33.1%
Taylor expanded in k around inf
lower-/.f64N/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
distribute-rgt1-inN/A
lower-*.f64N/A
metadata-evalN/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lower-*.f6460.8
Applied rewrites60.8%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f6476.2
Applied rewrites76.2%
if -0.48999999999999999 < m < 1.8500000000000001Initial program 96.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-+.f6496.1
Applied rewrites96.1%
if 1.8500000000000001 < m < 4.69999999999999979e123Initial program 74.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-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites15.0%
Taylor expanded in k around 0
lower-*.f6428.6
Applied rewrites28.6%
if 4.69999999999999979e123 < m Initial program 84.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-+.f643.7
Applied rewrites3.7%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f643.3
Applied rewrites3.3%
Taylor expanded in k around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6428.3
Applied rewrites28.3%
(FPCore (a k m)
:precision binary64
(if (<= m -0.49)
(/ a (* k k))
(if (<= m 1.85)
(/ a (fma (+ 10.0 k) k 1.0))
(if (<= m 4.7e+123)
(fma (fma (* 99.0 a) k (* -10.0 a)) k a)
(* (* -10.0 a) k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.49) {
tmp = a / (k * k);
} else if (m <= 1.85) {
tmp = a / fma((10.0 + k), k, 1.0);
} else if (m <= 4.7e+123) {
tmp = fma(fma((99.0 * a), k, (-10.0 * a)), k, a);
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.49) tmp = Float64(a / Float64(k * k)); elseif (m <= 1.85) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); elseif (m <= 4.7e+123) tmp = fma(fma(Float64(99.0 * a), k, Float64(-10.0 * a)), k, a); else tmp = Float64(Float64(-10.0 * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.49], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 1.85], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 4.7e+123], N[(N[(N[(99.0 * a), $MachinePrecision] * k + N[(-10.0 * a), $MachinePrecision]), $MachinePrecision] * k + a), $MachinePrecision], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.49:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 1.85:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{elif}\;m \leq 4.7 \cdot 10^{+123}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(99 \cdot a, k, -10 \cdot a\right), k, a\right)\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -0.48999999999999999Initial 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-+.f6433.1
Applied rewrites33.1%
Taylor expanded in k around inf
Applied rewrites67.9%
if -0.48999999999999999 < m < 1.8500000000000001Initial program 96.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-+.f6496.1
Applied rewrites96.1%
if 1.8500000000000001 < m < 4.69999999999999979e123Initial program 74.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-+.f642.9
Applied rewrites2.9%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
Applied rewrites15.0%
Taylor expanded in k around 0
lower-*.f6428.6
Applied rewrites28.6%
if 4.69999999999999979e123 < m Initial program 84.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-+.f643.7
Applied rewrites3.7%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f643.3
Applied rewrites3.3%
Taylor expanded in k around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6428.3
Applied rewrites28.3%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k))))
(if (<= k -8.8e-103)
t_0
(if (<= k 2.65e-306)
(* (* -10.0 a) k)
(if (<= k 0.1) (fma (* -10.0 a) k a) t_0)))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= -8.8e-103) {
tmp = t_0;
} else if (k <= 2.65e-306) {
tmp = (-10.0 * a) * k;
} else if (k <= 0.1) {
tmp = fma((-10.0 * a), k, a);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (k <= -8.8e-103) tmp = t_0; elseif (k <= 2.65e-306) tmp = Float64(Float64(-10.0 * a) * k); elseif (k <= 0.1) tmp = fma(Float64(-10.0 * a), k, a); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[k, -8.8e-103], t$95$0, If[LessEqual[k, 2.65e-306], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision], If[LessEqual[k, 0.1], N[(N[(-10.0 * a), $MachinePrecision] * k + a), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;k \leq -8.8 \cdot 10^{-103}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 2.65 \cdot 10^{-306}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\mathbf{elif}\;k \leq 0.1:\\
\;\;\;\;\mathsf{fma}\left(-10 \cdot a, k, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < -8.7999999999999997e-103 or 0.10000000000000001 < k Initial program 83.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-+.f6449.9
Applied rewrites49.9%
Taylor expanded in k around inf
Applied rewrites51.7%
if -8.7999999999999997e-103 < k < 2.6499999999999999e-306Initial 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.4
Applied rewrites4.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f644.4
Applied rewrites4.4%
Taylor expanded in k around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6450.5
Applied rewrites50.5%
if 2.6499999999999999e-306 < k < 0.10000000000000001Initial 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-+.f6452.6
Applied rewrites52.6%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6451.0
Applied rewrites51.0%
lift-*.f64N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
lift-*.f6451.0
Applied rewrites51.0%
(FPCore (a k m) :precision binary64 (if (<= m -0.49) (/ a (* k k)) (if (<= m 22500000.0) (/ a (fma (+ 10.0 k) k 1.0)) (* (* -10.0 a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.49) {
tmp = a / (k * k);
} else if (m <= 22500000.0) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.49) tmp = Float64(a / Float64(k * k)); elseif (m <= 22500000.0) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(-10.0 * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.49], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 22500000.0], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.49:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 22500000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -0.48999999999999999Initial 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-+.f6433.1
Applied rewrites33.1%
Taylor expanded in k around inf
Applied rewrites67.9%
if -0.48999999999999999 < m < 2.25e7Initial 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.2
Applied rewrites93.2%
if 2.25e7 < m Initial program 82.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.4
Applied rewrites3.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f643.3
Applied rewrites3.3%
Taylor expanded in k around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6424.5
Applied rewrites24.5%
(FPCore (a k m) :precision binary64 (if (<= m -0.49) (/ a (* k k)) (if (<= m 22500000.0) (/ a (fma k k 1.0)) (* (* -10.0 a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.49) {
tmp = a / (k * k);
} else if (m <= 22500000.0) {
tmp = a / fma(k, k, 1.0);
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.49) tmp = Float64(a / Float64(k * k)); elseif (m <= 22500000.0) tmp = Float64(a / fma(k, k, 1.0)); else tmp = Float64(Float64(-10.0 * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.49], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 22500000.0], N[(a / N[(k * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.49:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 22500000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -0.48999999999999999Initial 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-+.f6433.1
Applied rewrites33.1%
Taylor expanded in k around inf
Applied rewrites67.9%
if -0.48999999999999999 < m < 2.25e7Initial 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.2
Applied rewrites93.2%
Taylor expanded in k around inf
Applied rewrites89.5%
if 2.25e7 < m Initial program 82.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.4
Applied rewrites3.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f643.3
Applied rewrites3.3%
Taylor expanded in k around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6424.5
Applied rewrites24.5%
(FPCore (a k m) :precision binary64 (if (<= m -1.25e-38) (/ a (* k k)) (if (<= m 22500000.0) (/ a (fma 10.0 k 1.0)) (* (* -10.0 a) k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -1.25e-38) {
tmp = a / (k * k);
} else if (m <= 22500000.0) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -1.25e-38) tmp = Float64(a / Float64(k * k)); elseif (m <= 22500000.0) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(-10.0 * a) * k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -1.25e-38], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 22500000.0], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -1.25 \cdot 10^{-38}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 22500000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < -1.25000000000000008e-38Initial 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-+.f6438.1
Applied rewrites38.1%
Taylor expanded in k around inf
Applied rewrites66.6%
if -1.25000000000000008e-38 < m < 2.25e7Initial program 93.5%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6493.5
Applied rewrites93.5%
Taylor expanded in k around 0
Applied rewrites68.7%
if 2.25e7 < m Initial program 82.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.4
Applied rewrites3.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f643.3
Applied rewrites3.3%
Taylor expanded in k around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6424.5
Applied rewrites24.5%
(FPCore (a k m) :precision binary64 (if (<= m 22500000.0) a (* (* -10.0 a) k)))
double code(double a, double k, double m) {
double tmp;
if (m <= 22500000.0) {
tmp = a;
} else {
tmp = (-10.0 * a) * 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 (m <= 22500000.0d0) then
tmp = a
else
tmp = ((-10.0d0) * a) * k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 22500000.0) {
tmp = a;
} else {
tmp = (-10.0 * a) * k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 22500000.0: tmp = a else: tmp = (-10.0 * a) * k return tmp
function code(a, k, m) tmp = 0.0 if (m <= 22500000.0) tmp = a; else tmp = Float64(Float64(-10.0 * a) * k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 22500000.0) tmp = a; else tmp = (-10.0 * a) * k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 22500000.0], a, N[(N[(-10.0 * a), $MachinePrecision] * k), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 22500000:\\
\;\;\;\;a\\
\mathbf{else}:\\
\;\;\;\;\left(-10 \cdot a\right) \cdot k\\
\end{array}
\end{array}
if m < 2.25e7Initial program 96.5%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6467.8
Applied rewrites67.8%
Taylor expanded in k around 0
Applied rewrites31.7%
if 2.25e7 < m Initial program 82.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.4
Applied rewrites3.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f643.3
Applied rewrites3.3%
Taylor expanded in k around inf
associate-*r*N/A
lower-*.f64N/A
lift-*.f6424.5
Applied rewrites24.5%
(FPCore (a k m) :precision binary64 a)
double code(double a, double k, double m) {
return a;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
code = a
end function
public static double code(double a, double k, double m) {
return a;
}
def code(a, k, m): return a
function code(a, k, m) return a end
function tmp = code(a, k, m) tmp = a; end
code[a_, k_, m_] := a
\begin{array}{l}
\\
a
\end{array}
Initial program 91.8%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6446.1
Applied rewrites46.1%
Taylor expanded in k around 0
Applied rewrites22.4%
herbie shell --seed 2025084
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))