
(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.8) (/ (* (pow k m) a) (fma (+ 10.0 k) k 1.0)) (/ (* a (pow k m)) 1.0)))
double code(double a, double k, double m) {
double tmp;
if (m <= 2.8) {
tmp = (pow(k, m) * a) / fma((10.0 + k), k, 1.0);
} else {
tmp = (a * pow(k, m)) / 1.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 2.8) tmp = Float64(Float64((k ^ m) * a) / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(a * (k ^ m)) / 1.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 2.8], N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 2.8:\\
\;\;\;\;\frac{{k}^{m} \cdot a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{1}\\
\end{array}
\end{array}
if m < 2.7999999999999998Initial program 90.5%
lift-*.f64N/A
lift-pow.f64N/A
*-commutativeN/A
lower-*.f64N/A
lift-pow.f6490.5
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.5
Applied rewrites90.5%
if 2.7999999999999998 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))))
(if (<= m -4.2e-11)
(/ t_0 (fma 10.0 k 1.0))
(if (<= m 5e-6)
(/ (fma (* (log k) m) a a) (fma (+ 10.0 k) k 1.0))
(/ t_0 1.0)))))
double code(double a, double k, double m) {
double t_0 = a * pow(k, m);
double tmp;
if (m <= -4.2e-11) {
tmp = t_0 / fma(10.0, k, 1.0);
} else if (m <= 5e-6) {
tmp = fma((log(k) * m), a, a) / fma((10.0 + k), k, 1.0);
} else {
tmp = t_0 / 1.0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(a * (k ^ m)) tmp = 0.0 if (m <= -4.2e-11) tmp = Float64(t_0 / fma(10.0, k, 1.0)); elseif (m <= 5e-6) tmp = Float64(fma(Float64(log(k) * m), a, a) / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(t_0 / 1.0); end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[m, -4.2e-11], N[(t$95$0 / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5e-6], N[(N[(N[(N[Log[k], $MachinePrecision] * m), $MachinePrecision] * a + a), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 1.0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;m \leq -4.2 \cdot 10^{-11}:\\
\;\;\;\;\frac{t\_0}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k \cdot m, a, a\right)}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{1}\\
\end{array}
\end{array}
if m < -4.1999999999999997e-11Initial program 90.5%
Taylor expanded in k around 0
+-commutativeN/A
lower-fma.f6479.3
Applied rewrites79.3%
if -4.1999999999999997e-11 < m < 5.00000000000000041e-6Initial program 90.5%
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-+.f6441.5
Applied rewrites41.5%
if 5.00000000000000041e-6 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.0%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) 1.0)))
(if (<= m -2.25e-8)
t_0
(if (<= m 5e-6) (/ (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 = (a * pow(k, m)) / 1.0;
double tmp;
if (m <= -2.25e-8) {
tmp = t_0;
} else if (m <= 5e-6) {
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(Float64(a * (k ^ m)) / 1.0) tmp = 0.0 if (m <= -2.25e-8) tmp = t_0; elseif (m <= 5e-6) 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[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]}, If[LessEqual[m, -2.25e-8], t$95$0, If[LessEqual[m, 5e-6], 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 := \frac{a \cdot {k}^{m}}{1}\\
\mathbf{if}\;m \leq -2.25 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\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 < -2.24999999999999996e-8 or 5.00000000000000041e-6 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.0%
if -2.24999999999999996e-8 < m < 5.00000000000000041e-6Initial program 90.5%
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-+.f6441.5
Applied rewrites41.5%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) 1.0)))
(if (<= m -2.25e-8)
t_0
(if (<= m 5e-6)
(* (/ (fma (log k) m 1.0) (fma (+ 10.0 k) k 1.0)) a)
t_0))))
double code(double a, double k, double m) {
double t_0 = (a * pow(k, m)) / 1.0;
double tmp;
if (m <= -2.25e-8) {
tmp = t_0;
} else if (m <= 5e-6) {
tmp = (fma(log(k), m, 1.0) / fma((10.0 + k), k, 1.0)) * a;
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(Float64(a * (k ^ m)) / 1.0) tmp = 0.0 if (m <= -2.25e-8) tmp = t_0; elseif (m <= 5e-6) tmp = Float64(Float64(fma(log(k), m, 1.0) / fma(Float64(10.0 + k), k, 1.0)) * a); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]}, If[LessEqual[m, -2.25e-8], t$95$0, If[LessEqual[m, 5e-6], N[(N[(N[(N[Log[k], $MachinePrecision] * m + 1.0), $MachinePrecision] / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{1}\\
\mathbf{if}\;m \leq -2.25 \cdot 10^{-8}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\log k, m, 1\right)}{\mathsf{fma}\left(10 + k, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -2.24999999999999996e-8 or 5.00000000000000041e-6 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.0%
if -2.24999999999999996e-8 < m < 5.00000000000000041e-6Initial program 90.5%
Taylor expanded in m around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-log.f6441.5
Applied rewrites41.5%
lift-/.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
lift-+.f64N/A
lift-*.f64N/A
associate-/l*N/A
lower-*.f64N/A
pow2N/A
associate-+l+N/A
lower-/.f64N/A
+-commutativeN/A
pow2N/A
distribute-rgt-inN/A
*-commutativeN/A
lower-fma.f64N/A
lower-+.f6442.1
Applied rewrites42.1%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6442.1
pow-to-exp42.1
*-commutative42.1
pow-exp42.1
Applied rewrites42.1%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ (* a (pow k m)) 1.0))) (if (<= m -6.4e-10) t_0 (if (<= m 5e-6) (/ a (fma (+ 10.0 k) k 1.0)) t_0))))
double code(double a, double k, double m) {
double t_0 = (a * pow(k, m)) / 1.0;
double tmp;
if (m <= -6.4e-10) {
tmp = t_0;
} else if (m <= 5e-6) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64(Float64(a * (k ^ m)) / 1.0) tmp = 0.0 if (m <= -6.4e-10) tmp = t_0; elseif (m <= 5e-6) 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[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]}, If[LessEqual[m, -6.4e-10], t$95$0, If[LessEqual[m, 5e-6], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{1}\\
\mathbf{if}\;m \leq -6.4 \cdot 10^{-10}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -6.39999999999999961e-10 or 5.00000000000000041e-6 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.0%
if -6.39999999999999961e-10 < m < 5.00000000000000041e-6Initial program 90.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-+.f6446.1
Applied rewrites46.1%
(FPCore (a k m)
:precision binary64
(if (<= m -0.04)
(/ a (* k k))
(if (<= m 2.15e+16)
(/ a (fma (+ 10.0 k) k 1.0))
(fma (- (- (* (* -99.0 a) k)) (* 10.0 a)) k a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.04) {
tmp = a / (k * k);
} else if (m <= 2.15e+16) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = fma((-((-99.0 * a) * k) - (10.0 * a)), k, a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.04) tmp = Float64(a / Float64(k * k)); elseif (m <= 2.15e+16) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = fma(Float64(Float64(-Float64(Float64(-99.0 * a) * k)) - Float64(10.0 * a)), k, a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.04], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.15e+16], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[((-N[(N[(-99.0 * a), $MachinePrecision] * k), $MachinePrecision]) - N[(10.0 * a), $MachinePrecision]), $MachinePrecision] * k + a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.04:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 2.15 \cdot 10^{+16}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\left(-\left(-99 \cdot a\right) \cdot k\right) - 10 \cdot a, k, a\right)\\
\end{array}
\end{array}
if m < -0.0400000000000000008Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
if -0.0400000000000000008 < m < 2.15e16Initial program 90.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-+.f6446.1
Applied rewrites46.1%
if 2.15e16 < m Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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.3
Applied rewrites27.3%
(FPCore (a k m) :precision binary64 (if (<= m -0.04) (/ a (* k k)) (if (<= m 2.6e+55) (/ a (fma (+ 10.0 k) k 1.0)) (* (* a m) (log k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.04) {
tmp = a / (k * k);
} else if (m <= 2.6e+55) {
tmp = a / fma((10.0 + k), k, 1.0);
} else {
tmp = (a * m) * log(k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.04) tmp = Float64(a / Float64(k * k)); elseif (m <= 2.6e+55) tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); else tmp = Float64(Float64(a * m) * log(k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.04], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 2.6e+55], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * m), $MachinePrecision] * N[Log[k], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.04:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{elif}\;m \leq 2.6 \cdot 10^{+55}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(a \cdot m\right) \cdot \log k\\
\end{array}
\end{array}
if m < -0.0400000000000000008Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
if -0.0400000000000000008 < m < 2.6e55Initial program 90.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-+.f6446.1
Applied rewrites46.1%
if 2.6e55 < m Initial program 90.5%
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-+.f6441.5
Applied rewrites41.5%
Taylor expanded in k around 0
*-commutativeN/A
*-commutativeN/A
+-commutativeN/A
distribute-lft1-inN/A
*-commutativeN/A
+-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-log.f6423.4
Applied rewrites23.4%
Taylor expanded in m around inf
*-commutativeN/A
lower-*.f64N/A
*-commutativeN/A
lift-log.f64N/A
lift-*.f6410.6
Applied rewrites10.6%
lift-*.f64N/A
lift-*.f64N/A
lift-log.f64N/A
*-commutativeN/A
*-commutativeN/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-log.f6410.6
Applied rewrites10.6%
(FPCore (a k m) :precision binary64 (if (<= m -0.04) (/ a (* k k)) (/ a (fma (+ 10.0 k) k 1.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -0.04) {
tmp = a / (k * k);
} else {
tmp = a / fma((10.0 + k), k, 1.0);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -0.04) tmp = Float64(a / Float64(k * k)); else tmp = Float64(a / fma(Float64(10.0 + k), k, 1.0)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -0.04], N[(a / N[(k * k), $MachinePrecision]), $MachinePrecision], N[(a / N[(N[(10.0 + k), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -0.04:\\
\;\;\;\;\frac{a}{k \cdot k}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10 + k, k, 1\right)}\\
\end{array}
\end{array}
if m < -0.0400000000000000008Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
if -0.0400000000000000008 < m Initial program 90.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-+.f6446.1
Applied rewrites46.1%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k 4.2e-307) t_0 (if (<= k 195000.0) (/ a (fma 10.0 k 1.0)) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= 4.2e-307) {
tmp = t_0;
} else if (k <= 195000.0) {
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)) tmp = 0.0 if (k <= 4.2e-307) tmp = t_0; elseif (k <= 195000.0) 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]}, If[LessEqual[k, 4.2e-307], t$95$0, If[LessEqual[k, 195000.0], 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}\\
\mathbf{if}\;k \leq 4.2 \cdot 10^{-307}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 195000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < 4.2000000000000002e-307 or 195000 < k Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
if 4.2000000000000002e-307 < k < 195000Initial program 90.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-+.f6446.1
Applied rewrites46.1%
Taylor expanded in k around 0
Applied rewrites29.0%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k 4.2e-307) t_0 (if (<= k 0.052) (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 <= 4.2e-307) {
tmp = t_0;
} else if (k <= 0.052) {
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 <= 4.2e-307) tmp = t_0; elseif (k <= 0.052) 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, 4.2e-307], t$95$0, If[LessEqual[k, 0.052], 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 4.2 \cdot 10^{-307}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 0.052:\\
\;\;\;\;\mathsf{fma}\left(a \cdot k, -10, a\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < 4.2000000000000002e-307 or 0.0519999999999999976 < k Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
if 4.2000000000000002e-307 < k < 0.0519999999999999976Initial program 90.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-+.f6446.1
Applied rewrites46.1%
Taylor expanded in k around 0
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6421.2
Applied rewrites21.2%
(FPCore (a k m) :precision binary64 (let* ((t_0 (/ a (* k k)))) (if (<= k 4.2e-307) t_0 (if (<= k 0.052) (/ a 1.0) t_0))))
double code(double a, double k, double m) {
double t_0 = a / (k * k);
double tmp;
if (k <= 4.2e-307) {
tmp = t_0;
} else if (k <= 0.052) {
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) :: tmp
t_0 = a / (k * k)
if (k <= 4.2d-307) then
tmp = t_0
else if (k <= 0.052d0) 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 tmp;
if (k <= 4.2e-307) {
tmp = t_0;
} else if (k <= 0.052) {
tmp = a / 1.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(a, k, m): t_0 = a / (k * k) tmp = 0 if k <= 4.2e-307: tmp = t_0 elif k <= 0.052: tmp = a / 1.0 else: tmp = t_0 return tmp
function code(a, k, m) t_0 = Float64(a / Float64(k * k)) tmp = 0.0 if (k <= 4.2e-307) tmp = t_0; elseif (k <= 0.052) 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); tmp = 0.0; if (k <= 4.2e-307) tmp = t_0; elseif (k <= 0.052) 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]}, If[LessEqual[k, 4.2e-307], t$95$0, If[LessEqual[k, 0.052], N[(a / 1.0), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{a}{k \cdot k}\\
\mathbf{if}\;k \leq 4.2 \cdot 10^{-307}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;k \leq 0.052:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if k < 4.2000000000000002e-307 or 0.0519999999999999976 < k Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
if 4.2000000000000002e-307 < k < 0.0519999999999999976Initial program 90.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
Taylor expanded in k around 0
Applied rewrites20.2%
(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.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-+.f6446.1
Applied rewrites46.1%
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-*.f6436.4
Applied rewrites36.4%
Taylor expanded in k around 0
Applied rewrites20.2%
herbie shell --seed 2025135
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))