
(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 13 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 (<= k 1e-61)
t_0
(/ 1.0 (fma (/ (- k -10.0) t_0) k (/ (pow k (- m)) a))))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (k <= 1e-61) {
tmp = t_0;
} else {
tmp = 1.0 / fma(((k - -10.0) / t_0), k, (pow(k, -m) / a));
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (k <= 1e-61) tmp = t_0; else tmp = Float64(1.0 / fma(Float64(Float64(k - -10.0) / t_0), k, Float64((k ^ Float64(-m)) / a))); end return tmp end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]}, If[LessEqual[k, 1e-61], t$95$0, N[(1.0 / N[(N[(N[(k - -10.0), $MachinePrecision] / t$95$0), $MachinePrecision] * k + N[(N[Power[k, (-m)], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;k \leq 10^{-61}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{k - -10}{t\_0}, k, \frac{{k}^{\left(-m\right)}}{a}\right)}\\
\end{array}
\end{array}
if k < 1e-61Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.6%
Taylor expanded in k around 0
lower-pow.f6483.6
Applied rewrites83.6%
if 1e-61 < k Initial program 90.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6490.4
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
+-lft-identityN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-eval90.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
Applied rewrites90.5%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-pow.f64N/A
pow-flipN/A
lower-pow.f64N/A
lower-neg.f6488.3
Applied rewrites88.3%
(FPCore (a k m)
:precision binary64
(if (<= m -6e-110)
(* (/ (pow k m) (fma (- k -10.0) k 1.0)) a)
(if (<= m 6.3e-25)
(/ 1.0 (fma (- k -10.0) (/ k a) (/ 1.0 a)))
(* (pow k m) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -6e-110) {
tmp = (pow(k, m) / fma((k - -10.0), k, 1.0)) * a;
} else if (m <= 6.3e-25) {
tmp = 1.0 / fma((k - -10.0), (k / a), (1.0 / a));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -6e-110) tmp = Float64(Float64((k ^ m) / fma(Float64(k - -10.0), k, 1.0)) * a); elseif (m <= 6.3e-25) tmp = Float64(1.0 / fma(Float64(k - -10.0), Float64(k / a), Float64(1.0 / a))); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -6e-110], N[(N[(N[Power[k, m], $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision], If[LessEqual[m, 6.3e-25], N[(1.0 / N[(N[(k - -10.0), $MachinePrecision] * N[(k / a), $MachinePrecision] + N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -6 \cdot 10^{-110}:\\
\;\;\;\;\frac{{k}^{m}}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot a\\
\mathbf{elif}\;m \leq 6.3 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k - -10, \frac{k}{a}, \frac{1}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\end{array}
\end{array}
if m < -5.99999999999999972e-110Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.6%
if -5.99999999999999972e-110 < m < 6.29999999999999961e-25Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
div-flipN/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lower-unsound-/.f32N/A
lower-/.f32N/A
lower-unsound-/.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6444.4
Applied rewrites44.4%
if 6.29999999999999961e-25 < m Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.6%
Taylor expanded in k around 0
lower-pow.f6483.6
Applied rewrites83.6%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* (pow k m) a)))
(if (<= m -0.0017)
t_0
(if (<= m 6.3e-25) (/ 1.0 (fma (- k -10.0) (/ k a) (/ 1.0 a))) t_0))))
double code(double a, double k, double m) {
double t_0 = pow(k, m) * a;
double tmp;
if (m <= -0.0017) {
tmp = t_0;
} else if (m <= 6.3e-25) {
tmp = 1.0 / fma((k - -10.0), (k / a), (1.0 / a));
} else {
tmp = t_0;
}
return tmp;
}
function code(a, k, m) t_0 = Float64((k ^ m) * a) tmp = 0.0 if (m <= -0.0017) tmp = t_0; elseif (m <= 6.3e-25) tmp = Float64(1.0 / fma(Float64(k - -10.0), Float64(k / a), Float64(1.0 / a))); 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.0017], t$95$0, If[LessEqual[m, 6.3e-25], N[(1.0 / N[(N[(k - -10.0), $MachinePrecision] * N[(k / a), $MachinePrecision] + N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {k}^{m} \cdot a\\
\mathbf{if}\;m \leq -0.0017:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 6.3 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k - -10, \frac{k}{a}, \frac{1}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if m < -0.00169999999999999991 or 6.29999999999999961e-25 < m Initial program 90.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.6%
Taylor expanded in k around 0
lower-pow.f6483.6
Applied rewrites83.6%
if -0.00169999999999999991 < m < 6.29999999999999961e-25Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
div-flipN/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lower-unsound-/.f32N/A
lower-/.f32N/A
lower-unsound-/.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6444.4
Applied rewrites44.4%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 1e+223) (/ 1.0 (fma (/ 1.0 (/ a (+ 10.0 k))) k (/ (pow k (- m)) a))) (* (pow k m) a)))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 1e+223) {
tmp = 1.0 / fma((1.0 / (a / (10.0 + k))), k, (pow(k, -m) / a));
} else {
tmp = pow(k, m) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 1e+223) tmp = Float64(1.0 / fma(Float64(1.0 / Float64(a / Float64(10.0 + k))), k, Float64((k ^ Float64(-m)) / a))); else tmp = Float64((k ^ m) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 1e+223], N[(1.0 / N[(N[(1.0 / N[(a / N[(10.0 + k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * k + N[(N[Power[k, (-m)], $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 10^{+223}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(\frac{1}{\frac{a}{10 + k}}, k, \frac{{k}^{\left(-m\right)}}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;{k}^{m} \cdot a\\
\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))) < 1.00000000000000005e223Initial program 90.6%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6490.4
lift-+.f64N/A
+-commutativeN/A
lift-+.f64N/A
+-commutativeN/A
associate-+r+N/A
+-commutativeN/A
metadata-evalN/A
associate-+r+N/A
+-commutativeN/A
+-lft-identityN/A
lift-*.f64N/A
lift-*.f64N/A
distribute-rgt-outN/A
*-commutativeN/A
lower-fma.f64N/A
+-commutativeN/A
add-flipN/A
lower--.f64N/A
metadata-eval90.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
Applied rewrites90.5%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
*-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-/r*N/A
lower-/.f64N/A
lift-pow.f64N/A
pow-flipN/A
lower-pow.f64N/A
lower-neg.f6488.3
Applied rewrites88.3%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6488.3
Applied rewrites88.3%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f6471.9
Applied rewrites71.9%
if 1.00000000000000005e223 < (/.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.6%
lift-/.f64N/A
lift-*.f64N/A
associate-/l*N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.6%
Taylor expanded in k around 0
lower-pow.f6483.6
Applied rewrites83.6%
(FPCore (a k m)
:precision binary64
(if (<= m -5e+45)
(/ 1.0 (/ (fma (- k -10.0) k 1.0) a))
(if (<= m 6.3e-25)
(/ 1.0 (fma (- k -10.0) (/ k a) (/ 1.0 a)))
(* (+ 1.0 (* k (- (* 99.0 k) 10.0))) a))))
double code(double a, double k, double m) {
double tmp;
if (m <= -5e+45) {
tmp = 1.0 / (fma((k - -10.0), k, 1.0) / a);
} else if (m <= 6.3e-25) {
tmp = 1.0 / fma((k - -10.0), (k / a), (1.0 / a));
} else {
tmp = (1.0 + (k * ((99.0 * k) - 10.0))) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -5e+45) tmp = Float64(1.0 / Float64(fma(Float64(k - -10.0), k, 1.0) / a)); elseif (m <= 6.3e-25) tmp = Float64(1.0 / fma(Float64(k - -10.0), Float64(k / a), Float64(1.0 / a))); else tmp = Float64(Float64(1.0 + Float64(k * Float64(Float64(99.0 * k) - 10.0))) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -5e+45], N[(1.0 / N[(N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 6.3e-25], N[(1.0 / N[(N[(k - -10.0), $MachinePrecision] * N[(k / a), $MachinePrecision] + N[(1.0 / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(k * N[(N[(99.0 * k), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq -5 \cdot 10^{+45}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(k - -10, k, 1\right)}{a}}\\
\mathbf{elif}\;m \leq 6.3 \cdot 10^{-25}:\\
\;\;\;\;\frac{1}{\mathsf{fma}\left(k - -10, \frac{k}{a}, \frac{1}{a}\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + k \cdot \left(99 \cdot k - 10\right)\right) \cdot a\\
\end{array}
\end{array}
if m < -5e45Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
div-flipN/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lower-unsound-/.f32N/A
lower-/.f32N/A
lower-unsound-/.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
if -5e45 < m < 6.29999999999999961e-25Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
div-flipN/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lower-unsound-/.f32N/A
lower-/.f32N/A
lower-unsound-/.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-fma.f64N/A
div-addN/A
associate-/l*N/A
lower-fma.f64N/A
lower-/.f64N/A
lower-/.f6444.4
Applied rewrites44.4%
if 6.29999999999999961e-25 < m Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 1e+223) (/ 1.0 (/ (fma (- k -10.0) k 1.0) a)) (* (+ 1.0 (* k (- (* 99.0 k) 10.0))) a)))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 1e+223) {
tmp = 1.0 / (fma((k - -10.0), k, 1.0) / a);
} else {
tmp = (1.0 + (k * ((99.0 * k) - 10.0))) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 1e+223) tmp = Float64(1.0 / Float64(fma(Float64(k - -10.0), k, 1.0) / a)); else tmp = Float64(Float64(1.0 + Float64(k * Float64(Float64(99.0 * k) - 10.0))) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 1e+223], N[(1.0 / N[(N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(k * N[(N[(99.0 * k), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 10^{+223}:\\
\;\;\;\;\frac{1}{\frac{\mathsf{fma}\left(k - -10, k, 1\right)}{a}}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + k \cdot \left(99 \cdot k - 10\right)\right) \cdot a\\
\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))) < 1.00000000000000005e223Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
div-flipN/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
lower-unsound-/.f32N/A
lower-/.f32N/A
lower-unsound-/.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
if 1.00000000000000005e223 < (/.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.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 1e+223) (/ a (fma (- k -10.0) k 1.0)) (* (+ 1.0 (* k (- (* 99.0 k) 10.0))) a)))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 1e+223) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = (1.0 + (k * ((99.0 * k) - 10.0))) * a;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 1e+223) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(Float64(1.0 + Float64(k * Float64(Float64(99.0 * k) - 10.0))) * a); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 1e+223], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(1.0 + N[(k * N[(N[(99.0 * k), $MachinePrecision] - 10.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 10^{+223}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left(1 + k \cdot \left(99 \cdot k - 10\right)\right) \cdot a\\
\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))) < 1.00000000000000005e223Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.5
Applied rewrites44.5%
if 1.00000000000000005e223 < (/.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.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
mult-flip-revN/A
*-commutativeN/A
lower-*.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower--.f64N/A
lower-*.f6429.2
Applied rewrites29.2%
(FPCore (a k m) :precision binary64 (if (<= (/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))) 1e+275) (/ a (fma (- k -10.0) k 1.0)) (* k (fma -10.0 a (/ a k)))))
double code(double a, double k, double m) {
double tmp;
if (((a * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k))) <= 1e+275) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = k * fma(-10.0, a, (a / k));
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (Float64(Float64(a * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 1e+275) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(k * fma(-10.0, a, Float64(a / k))); end return tmp end
code[a_, k_, m_] := If[LessEqual[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], 1e+275], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(k * N[(-10.0 * a + N[(a / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 10^{+275}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;k \cdot \mathsf{fma}\left(-10, a, \frac{a}{k}\right)\\
\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))) < 9.9999999999999996e274Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.5
Applied rewrites44.5%
if 9.9999999999999996e274 < (/.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.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.2
Applied rewrites21.2%
Taylor expanded in k around inf
lower-*.f64N/A
lower-fma.f64N/A
lower-/.f6419.9
Applied rewrites19.9%
(FPCore (a k m) :precision binary64 (if (<= m 6.8e+15) (/ a (fma (- k -10.0) k 1.0)) (fma (* a k) -10.0 a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 6.8e+15) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = fma((a * k), -10.0, a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 6.8e+15) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = fma(Float64(a * k), -10.0, a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 6.8e+15], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * k), $MachinePrecision] * -10.0 + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 6.8 \cdot 10^{+15}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot k, -10, a\right)\\
\end{array}
\end{array}
if m < 6.8e15Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.5
Applied rewrites44.5%
if 6.8e15 < m Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.2
Applied rewrites21.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6421.2
Applied rewrites21.2%
(FPCore (a k m) :precision binary64 (if (<= m 6.8e+15) (/ a (fma 10.0 k 1.0)) (fma (* a k) -10.0 a)))
double code(double a, double k, double m) {
double tmp;
if (m <= 6.8e+15) {
tmp = a / fma(10.0, k, 1.0);
} else {
tmp = fma((a * k), -10.0, a);
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 6.8e+15) tmp = Float64(a / fma(10.0, k, 1.0)); else tmp = fma(Float64(a * k), -10.0, a); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 6.8e+15], N[(a / N[(10.0 * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * k), $MachinePrecision] * -10.0 + a), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;m \leq 6.8 \cdot 10^{+15}:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(a \cdot k, -10, a\right)\\
\end{array}
\end{array}
if m < 6.8e15Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
Applied rewrites28.4%
if 6.8e15 < m Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.2
Applied rewrites21.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6421.2
Applied rewrites21.2%
(FPCore (a k m) :precision binary64 (fma (* a k) -10.0 a))
double code(double a, double k, double m) {
return fma((a * k), -10.0, a);
}
function code(a, k, m) return fma(Float64(a * k), -10.0, a) end
code[a_, k_, m_] := N[(N[(a * k), $MachinePrecision] * -10.0 + a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(a \cdot k, -10, a\right)
\end{array}
Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.2
Applied rewrites21.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-fma.f6421.2
Applied rewrites21.2%
(FPCore (a k m) :precision binary64 (fma (* -10.0 k) a a))
double code(double a, double k, double m) {
return fma((-10.0 * k), a, a);
}
function code(a, k, m) return fma(Float64(-10.0 * k), a, a) end
code[a_, k_, m_] := N[(N[(-10.0 * k), $MachinePrecision] * a + a), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(-10 \cdot k, a, a\right)
\end{array}
Initial program 90.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6421.2
Applied rewrites21.2%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-*r*N/A
metadata-evalN/A
distribute-lft-neg-outN/A
lower-fma.f64N/A
distribute-lft-neg-outN/A
metadata-evalN/A
lower-*.f6421.2
Applied rewrites21.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.6%
Taylor expanded in m around 0
lower-/.f64N/A
lower-+.f64N/A
lower-fma.f64N/A
lower-pow.f6444.5
Applied rewrites44.5%
lift-fma.f64N/A
lift-pow.f64N/A
pow2N/A
distribute-rgt-outN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift--.f64N/A
*-commutativeN/A
lower-+.f64N/A
+-commutativeN/A
lift-fma.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
Applied rewrites20.3%
herbie shell --seed 2025162
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))