
(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 10 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 (let* ((t_0 (* (pow k m) a))) (if (<= m 3.0) (/ t_0 (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.0) {
tmp = t_0 / 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.0) tmp = Float64(t_0 / 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.0], N[(t$95$0 / 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:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < 3Initial program 90.0%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6490.0
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-+l+N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.0
Applied rewrites90.0%
if 3 < m Initial program 90.0%
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-+.f6440.3
Applied rewrites40.3%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites36.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6483.0
Applied rewrites83.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -8.5e-9)
(/ t_0 (* k k))
(if (<= m 7.8e-5)
(/ (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 <= -8.5e-9) {
tmp = t_0 / (k * k);
} else if (m <= 7.8e-5) {
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 <= -8.5e-9) tmp = Float64(t_0 / Float64(k * k)); elseif (m <= 7.8e-5) 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, -8.5e-9], N[(t$95$0 / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 7.8e-5], 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 -8.5 \cdot 10^{-9}:\\
\;\;\;\;\frac{t\_0}{k \cdot k}\\
\mathbf{elif}\;m \leq 7.8 \cdot 10^{-5}:\\
\;\;\;\;\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 < -8.5e-9Initial program 90.0%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6490.0
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
pow2N/A
associate-+l+N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6490.0
Applied rewrites90.0%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6464.6
Applied rewrites64.6%
if -8.5e-9 < m < 7.7999999999999999e-5Initial program 90.0%
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-+.f6440.3
Applied rewrites40.3%
if 7.7999999999999999e-5 < m Initial program 90.0%
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-+.f6440.3
Applied rewrites40.3%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites36.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6483.0
Applied rewrites83.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -0.13)
t_0
(if (<= m 7.8e-5)
(/ (fma (* (log k) m) a a) (fma (+ 10.0 k) k 1.0))
t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -0.13) {
tmp = t_0;
} else if (m <= 7.8e-5) {
tmp = fma((log(k) * m), a, a) / fma((10.0 + k), k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -0.13) tmp = t_0; elseif (m <= 7.8e-5) tmp = Float64(fma(Float64(log(k) * m), a, a) / fma(Float64(10.0 + k), k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -0.13], t$95$0, If[LessEqual[m, 7.8e-5], N[(N[(N[(N[Log[k], $MachinePrecision] * m), $MachinePrecision] * a + a), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -0.13:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 7.8 \cdot 10^{-5}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k \cdot m, a, a\right)}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -0.13 or 7.7999999999999999e-5 < m Initial program 90.0%
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-+.f6440.3
Applied rewrites40.3%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites36.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6483.0
Applied rewrites83.0%
if -0.13 < m < 7.7999999999999999e-5Initial program 90.0%
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-+.f6440.3
Applied rewrites40.3%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -0.13)
t_0
(if (<= m 1.55e-23) (/ a (fma (+ 10.0 k) k 1.0)) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -0.13) {
tmp = t_0;
} else if (m <= 1.55e-23) {
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 <= -0.13) tmp = t_0; elseif (m <= 1.55e-23) 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, -0.13], t$95$0, If[LessEqual[m, 1.55e-23], 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 -0.13:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 1.55 \cdot 10^{-23}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -0.13 or 1.5499999999999999e-23 < m Initial program 90.0%
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-+.f6440.3
Applied rewrites40.3%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites36.4%
Taylor expanded in k around 0
*-commutativeN/A
lower-*.f64N/A
lower-pow.f6483.0
Applied rewrites83.0%
if -0.13 < m < 1.5499999999999999e-23Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
(FPCore (a k m) :precision binary64 (if (<= m -0.35) (/ a (* k k)) (if (<= m 0.64) (/ a (fma (+ 10.0 k) k 1.0)) (* (* k k) (* 99.0 a)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.35) {
tmp = a / (k * k);
} else if (m <= 0.64) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (k * k) * (99.0 * a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.35) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.64) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(k * k) * Float64(99.0 * a)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.35], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.64], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(k * k), $MachinePrecision] * N[(99.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.35:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.64:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot k\right) \cdot \left(99 \cdot a\right)\\
\end{array}
\end{array}
if m < -0.34999999999999998Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6435.6
Applied rewrites35.6%
if -0.34999999999999998 < m < 0.640000000000000013Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
if 0.640000000000000013 < m Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
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-*.f6427.8
Applied rewrites27.8%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6423.4
Applied rewrites23.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f6423.4
Applied rewrites23.4%
(FPCore (a k m) :precision binary64 (if (<= m -3.7e-13) (/ a (* k k)) (if (<= m 0.19) (/ a (fma 10.0 k 1.0)) (* (* k k) (* 99.0 a)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -3.7e-13) {
tmp = a / (k * k);
} else if (m <= 0.19) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = (k * k) * (99.0 * a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -3.7e-13) tmp = Float64(a / Float64(k * k)); elseif (m <= 0.19) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(Float64(k * k) * Float64(99.0 * a)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -3.7e-13], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 0.19], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(k * k), $MachinePrecision] * N[(99.0 * a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -3.7 \cdot 10^{-13}:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 0.19:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(k \cdot k\right) \cdot \left(99 \cdot a\right)\\
\end{array}
\end{array}
if m < -3.69999999999999989e-13Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6435.6
Applied rewrites35.6%
if -3.69999999999999989e-13 < m < 0.19Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around 0
Applied rewrites28.3%
if 0.19 < m Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
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-*.f6427.8
Applied rewrites27.8%
Taylor expanded in k around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6423.4
Applied rewrites23.4%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
associate-*l*N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f6423.4
Applied rewrites23.4%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k)))
(t_1 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (<= t_1 5e-202) t_0 (if (<= t_1 1e+271) (/ a (fma 10.0 k 1.0)) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 5e-202) {
tmp = t_0;
} else if (t_1 <= 1e+271) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) t_1 = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 5e-202) tmp = t_0; elseif (t_1 <= 1e+271) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-202], t$95$0, If[LessEqual[t$95$1, 1e+271], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
t_1 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-202}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{+271}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.99999999999999973e-202 or 9.99999999999999953e270 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6435.6
Applied rewrites35.6%
if 4.99999999999999973e-202 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 9.99999999999999953e270Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around 0
Applied rewrites28.3%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k 6.2e-305) t_0 (if (<= k 0.1) (fma (* a k) -10.0 a) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= 6.2e-305) {
tmp = t_0;
} else if (k <= 0.1) {
tmp = fma((a * k), -10.0, a);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (k <= 6.2e-305) tmp = t_0; elseif (k <= 0.1) tmp = fma(Float64(a * k), -10.0, 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, 6.2e-305], t$95$0, If[LessEqual[k, 0.1], N[(N[(a * k), $MachinePrecision] * -10.0 + a), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;k \leq 6.2 \cdot 10^{-305}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 0.1:\\
\;\;\;\;\mathsf{fma}\left(a \cdot k, -10, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < 6.1999999999999997e-305 or 0.10000000000000001 < k Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6435.6
Applied rewrites35.6%
if 6.1999999999999997e-305 < k < 0.10000000000000001Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6421.1
Applied rewrites21.1%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ a (* k k)))
(t_1 (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(if (<= t_1 5e-202) t_0 (if (<= t_1 1e+271) (/ a 1.0) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = (a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 5e-202) {
tmp = t_0;
} else if (t_1 <= 1e+271) {
tmp = a / 1.0;
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(a, k, m)
use fmin_fmax_functions
real(8), intent (in) :: a
real(8), intent (in) :: k
real(8), intent (in) :: m
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = a / (k * k)
t_1 = (a * (k ** m)) / ((1.0d0 + (10.0d0 * k)) + (k * k))
if (t_1 <= 5d-202) then
tmp = t_0
else if (t_1 <= 1d+271) then
tmp = a / 1.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double t_0 = a / (k * k);
double t_1 = (a * Math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_1 <= 5e-202) {
tmp = t_0;
} else if (t_1 <= 1e+271) {
tmp = a / 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) t_1 = (a * math.pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k)) tmp = 0 if t_1 <= 5e-202: tmp = t_0 elif t_1 <= 1e+271: tmp = a / 1.0 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) t_1 = Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_1 <= 5e-202) tmp = t_0; elseif (t_1 <= 1e+271) tmp = Float64(a / 1.0); else tmp = t_0; end return tmp end
function tmp_2 = code(a, k, m) t_0 = a / (k * k); t_1 = (a * (k ^ m)) / ((1.0 + (10.0 * k)) + (k * k)); tmp = 0.0; if (t_1 <= 5e-202) tmp = t_0; elseif (t_1 <= 1e+271) tmp = a / 1.0; else tmp = t_0; end tmp_2 = tmp; end
code[a_, k_, m_] := Block[{t$95$0 = N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, 5e-202], t$95$0, If[LessEqual[t$95$1, 1e+271], N[(a / 1.0), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
t_1 := \frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathbf{if}\;t\_1 \leq 5 \cdot 10^{-202}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_1 \leq 10^{+271}:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.99999999999999973e-202 or 9.99999999999999953e270 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6435.6
Applied rewrites35.6%
if 4.99999999999999973e-202 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 9.99999999999999953e270Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6435.6
Applied rewrites35.6%
Taylor expanded in k around 0
Applied rewrites19.9%
(FPCore (a k m) :precision binary64 (/ a 1.0))
double code(double a, double k, double m) {
return a / 1.0;
}
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 / 1.0d0
end function
public static double code(double a, double k, double m) {
return a / 1.0;
}
def code(a, k, m): return a / 1.0
function code(a, k, m) return Float64(a / 1.0) end
function tmp = code(a, k, m) tmp = a / 1.0; end
code[a_, k_, m_] := N[(a / 1.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{a}{1}
\end{array}
Initial program 90.0%
Taylor expanded in m around 0
lower-/.f64N/A
pow2N/A
distribute-rgt-inN/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6444.4
Applied rewrites44.4%
Taylor expanded in k around inf
*-commutativeN/A
+-commutativeN/A
distribute-rgt-inN/A
pow2N/A
associate-+l+N/A
pow2N/A
pow2N/A
lower-*.f6435.6
Applied rewrites35.6%
Taylor expanded in k around 0
Applied rewrites19.9%
herbie shell --seed 2025130
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))