
(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 9 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 -185000000.0)
(/ (* a (pow k m)) (fma k 10.0 1.0))
(if (<= m 5.6e-9)
(/ (fma (* m a) (log k) a) (fma (- k -10.0) k 1.0))
(* (pow k m) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -185000000.0) {
tmp = (a * pow(k, m)) / fma(k, 10.0, 1.0);
} else if (m <= 5.6e-9) {
tmp = fma((m * a), log(k), a) / fma((k - -10.0), k, 1.0);
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -185000000.0) tmp = Float64(Float64(a * (k ^ m)) / fma(k, 10.0, 1.0)); elseif (m <= 5.6e-9) tmp = Float64(fma(Float64(m * a), log(k), a) / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -185000000.0], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(k * 10.0 + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 5.6e-9], N[(N[(N[(m * a), $MachinePrecision] * N[Log[k], $MachinePrecision] + a), $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -185000000:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{\mathsf{fma}\left(k, 10, 1\right)}\\
\mathbf{elif}\;m \leq 5.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{fma}\left(m \cdot a, \log k, a\right)}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < -1.85e8Initial program 91.1%
Taylor expanded in k around 0
Applied rewrites80.4%
Applied rewrites80.4%
if -1.85e8 < m < 5.59999999999999969e-9Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites42.0%
Applied rewrites41.9%
if 5.59999999999999969e-9 < m Initial program 91.1%
Applied rewrites91.1%
Taylor expanded in k around 0
Applied rewrites82.6%
(FPCore (a k m) :precision binary64 (if (<= m 5.6e-9) (* (/ (pow k m) (fma (- k -10.0) k 1.0)) a) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 5.6e-9) {
tmp = (pow(k, m) / fma((k - -10.0), k, 1.0)) * a;
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 5.6e-9) tmp = Float64(Float64((k ^ m) / fma(Float64(k - -10.0), k, 1.0)) * a); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 5.6e-9], N[(N[(N[Power[k, m], $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 5.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < 5.59999999999999969e-9Initial program 91.1%
Applied rewrites91.1%
if 5.59999999999999969e-9 < m Initial program 91.1%
Applied rewrites91.1%
Taylor expanded in k around 0
Applied rewrites82.6%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -185000000.0)
t_0
(if (<= m 5.6e-9)
(/ (fma (* m a) (log k) a) (fma (- k -10.0) k 1.0))
t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -185000000.0) {
tmp = t_0;
} else if (m <= 5.6e-9) {
tmp = fma((m * a), log(k), a) / fma((k - -10.0), k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -185000000.0) tmp = t_0; elseif (m <= 5.6e-9) tmp = Float64(fma(Float64(m * a), log(k), a) / fma(Float64(k - -10.0), k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -185000000.0], t$95$0, If[LessEqual[m, 5.6e-9], N[(N[(N[(m * a), $MachinePrecision] * N[Log[k], $MachinePrecision] + a), $MachinePrecision] / N[(N[(k - -10.0), $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 -185000000:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 5.6 \cdot 10^{-9}:\\
\;\;\;\;\frac{\mathsf{fma}\left(m \cdot a, \log k, a\right)}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -1.85e8 or 5.59999999999999969e-9 < m Initial program 91.1%
Applied rewrites91.1%
Taylor expanded in k around 0
Applied rewrites82.6%
if -1.85e8 < m < 5.59999999999999969e-9Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites42.0%
Applied rewrites41.9%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -3.2e-16)
t_0
(if (<= m 1.85e-9) (/ a (fma (- k -10.0) k 1.0)) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -3.2e-16) {
tmp = t_0;
} else if (m <= 1.85e-9) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -3.2e-16) tmp = t_0; elseif (m <= 1.85e-9) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = t_0; end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[m, -3.2e-16], t$95$0, If[LessEqual[m, 1.85e-9], N[(a / N[(N[(k - -10.0), $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.2 \cdot 10^{-16}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 1.85 \cdot 10^{-9}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -3.20000000000000023e-16 or 1.85e-9 < m Initial program 91.1%
Applied rewrites91.1%
Taylor expanded in k around 0
Applied rewrites82.6%
if -3.20000000000000023e-16 < m < 1.85e-9Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Applied rewrites45.6%
(FPCore (a k m) :precision binary64 (if (<= m 1.75) (/ a (fma (- k -10.0) k 1.0)) (* (fma (fma k 99.0 -10.0) k 1.0) a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 1.75) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = fma(fma(k, 99.0, -10.0), k, 1.0) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 1.75) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(fma(fma(k, 99.0, -10.0), k, 1.0) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 1.75], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(k * 99.0 + -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 1.75:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(k, 99, -10\right), k, 1\right) \cdot a\\
\end{array}
\end{array}
if m < 1.75Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Applied rewrites45.6%
if 1.75 < m Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Applied rewrites45.5%
Taylor expanded in k around 0
Applied rewrites28.8%
Applied rewrites28.8%
(FPCore (a k m) :precision binary64 (if (<= m 7.2e+19) (/ a (fma (- k -10.0) k 1.0)) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 7.2e+19) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 7.2e+19) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 7.2e+19], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 7.2 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 7.2e19Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Applied rewrites45.6%
if 7.2e19 < m Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites21.5%
Taylor expanded in k around inf
Applied rewrites20.6%
Taylor expanded in k around inf
Applied rewrites8.2%
(FPCore (a k m) :precision binary64 (if (<= m 7.2e+19) (/ a (fma 10.0 k 1.0)) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 7.2e+19) {
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 <= 7.2e+19) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 7.2e+19], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 7.2 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 7.2e19Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites29.1%
if 7.2e19 < m Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites21.5%
Taylor expanded in k around inf
Applied rewrites20.6%
Taylor expanded in k around inf
Applied rewrites8.2%
(FPCore (a k m) :precision binary64 (if (<= m 7.2e+19) (/ a 1.0) (* -10.0 (* a k))))
double code(double a, double k, double m) {
double tmp;
if (m <= 7.2e+19) {
tmp = a / 1.0;
} 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 <= 7.2d+19) then
tmp = a / 1.0d0
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 <= 7.2e+19) {
tmp = a / 1.0;
} else {
tmp = -10.0 * (a * k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 7.2e+19: tmp = a / 1.0 else: tmp = -10.0 * (a * k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 7.2e+19) tmp = Float64(a / 1.0); else tmp = Float64(-10.0 * Float64(a * k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 7.2e+19) tmp = a / 1.0; else tmp = -10.0 * (a * k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 7.2e+19], N[(a / 1.0), $MachinePrecision], N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 7.2 \cdot 10^{+19}:\\
\;\;\;\;\frac{a}{1}\\
\mathbf{else}:\\
\;\;\;\;-10 \cdot \left(a \cdot k\right)\\
\end{array}
\end{array}
if m < 7.2e19Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites20.6%
if 7.2e19 < m Initial program 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites21.5%
Taylor expanded in k around inf
Applied rewrites20.6%
Taylor expanded in k around inf
Applied rewrites8.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 91.1%
Taylor expanded in m around 0
Applied rewrites45.6%
Applied rewrites45.6%
Taylor expanded in k around 0
Applied rewrites20.6%
herbie shell --seed 2025161
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))