
(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]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
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]
\frac{a \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}
(FPCore (a k m) :precision binary64 (if (<= k 1.5e-38) (/ (* a (pow k m)) 1.0) (/ (/ (* (pow k m) a) (- (- k -10.0) (/ -1.0 k))) k)))
double code(double a, double k, double m) {
double tmp;
if (k <= 1.5e-38) {
tmp = (a * pow(k, m)) / 1.0;
} else {
tmp = ((pow(k, m) * a) / ((k - -10.0) - (-1.0 / k))) / 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 (k <= 1.5d-38) then
tmp = (a * (k ** m)) / 1.0d0
else
tmp = (((k ** m) * a) / ((k - (-10.0d0)) - ((-1.0d0) / k))) / k
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (k <= 1.5e-38) {
tmp = (a * Math.pow(k, m)) / 1.0;
} else {
tmp = ((Math.pow(k, m) * a) / ((k - -10.0) - (-1.0 / k))) / k;
}
return tmp;
}
def code(a, k, m): tmp = 0 if k <= 1.5e-38: tmp = (a * math.pow(k, m)) / 1.0 else: tmp = ((math.pow(k, m) * a) / ((k - -10.0) - (-1.0 / k))) / k return tmp
function code(a, k, m) tmp = 0.0 if (k <= 1.5e-38) tmp = Float64(Float64(a * (k ^ m)) / 1.0); else tmp = Float64(Float64(Float64((k ^ m) * a) / Float64(Float64(k - -10.0) - Float64(-1.0 / k))) / k); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (k <= 1.5e-38) tmp = (a * (k ^ m)) / 1.0; else tmp = (((k ^ m) * a) / ((k - -10.0) - (-1.0 / k))) / k; end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[k, 1.5e-38], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision], N[(N[(N[(N[Power[k, m], $MachinePrecision] * a), $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] - N[(-1.0 / k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;k \leq 1.5 \cdot 10^{-38}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{1}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{{k}^{m} \cdot a}{\left(k - -10\right) - \frac{-1}{k}}}{k}\\
\end{array}
if k < 1.49999999999999994e-38Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.2%
if 1.49999999999999994e-38 < k Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (* a (pow k m))))
(if (<= (/ t_0 (+ (+ 1.0 (* 10.0 k)) (* k k))) 5e+236)
(* (pow k m) (/ a (fma (- k -10.0) 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 ((t_0 / ((1.0 + (10.0 * k)) + (k * k))) <= 5e+236) {
tmp = pow(k, m) * (a / fma((k - -10.0), 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 (Float64(t_0 / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) <= 5e+236) tmp = Float64((k ^ m) * Float64(a / fma(Float64(k - -10.0), 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[N[(t$95$0 / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 5e+236], N[(N[Power[k, m], $MachinePrecision] * N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$0 / 1.0), $MachinePrecision]]]
\begin{array}{l}
t_0 := a \cdot {k}^{m}\\
\mathbf{if}\;\frac{t\_0}{\left(1 + 10 \cdot k\right) + k \cdot k} \leq 5 \cdot 10^{+236}:\\
\;\;\;\;{k}^{m} \cdot \frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_0}{1}\\
\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.9999999999999997e236Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6488.6
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
Applied rewrites88.6%
if 4.9999999999999997e236 < (/.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.5%
Taylor expanded in k around 0
Applied rewrites82.2%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) 1.0)))
(if (<= m -1.65)
t_0
(if (<= m 62000.0)
(* (/ a (fma (- k -10.0) k 1.0)) (fma (log k) m 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 <= -1.65) {
tmp = t_0;
} else if (m <= 62000.0) {
tmp = (a / fma((k - -10.0), k, 1.0)) * fma(log(k), m, 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 <= -1.65) tmp = t_0; elseif (m <= 62000.0) tmp = Float64(Float64(a / fma(Float64(k - -10.0), k, 1.0)) * fma(log(k), m, 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, -1.65], t$95$0, If[LessEqual[m, 62000.0], N[(N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[Log[k], $MachinePrecision] * m + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{1}\\
\mathbf{if}\;m \leq -1.65:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 62000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)} \cdot \mathsf{fma}\left(\log k, m, 1\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if m < -1.6499999999999999 or 62000 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.2%
if -1.6499999999999999 < m < 62000Initial program 90.5%
lift-/.f64N/A
mult-flipN/A
lift-*.f64N/A
*-commutativeN/A
associate-*l*N/A
lower-*.f64N/A
mult-flip-revN/A
lower-/.f6488.6
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
Applied rewrites88.6%
Taylor expanded in m around 0
lower-+.f64N/A
lower-*.f64N/A
lower-log.f6440.9
Applied rewrites40.9%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6440.9
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f32N/A
lower-unsound-log.f64N/A
lower-unsound-*.f32N/A
lower-unsound-*.f64N/A
lower-*.f64N/A
lower-fma.f64N/A
lower-unsound-log.f6440.9
Applied rewrites40.9%
(FPCore (a k m) :precision binary64 (if (<= m -3.1e-9) (/ (pow k m) (/ 1.0 a)) (if (<= m 65000.0) (/ a (fma (- k -10.0) k 1.0)) (/ (* a (pow k m)) 1.0))))
double code(double a, double k, double m) {
double tmp;
if (m <= -3.1e-9) {
tmp = pow(k, m) / (1.0 / a);
} else if (m <= 65000.0) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = (a * pow(k, m)) / 1.0;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= -3.1e-9) tmp = Float64((k ^ m) / Float64(1.0 / a)); elseif (m <= 65000.0) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(Float64(a * (k ^ m)) / 1.0); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, -3.1e-9], N[(N[Power[k, m], $MachinePrecision] / N[(1.0 / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[m, 65000.0], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]]]
\begin{array}{l}
\mathbf{if}\;m \leq -3.1 \cdot 10^{-9}:\\
\;\;\;\;\frac{{k}^{m}}{\frac{1}{a}}\\
\mathbf{elif}\;m \leq 65000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\frac{a \cdot {k}^{m}}{1}\\
\end{array}
if m < -3.10000000000000005e-9Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.2%
lift-/.f64N/A
div-flipN/A
lower-unsound-/.f64N/A
lower-unsound-/.f6482.2
lift-*.f64N/A
*-commutativeN/A
lift-*.f6482.2
Applied rewrites82.2%
lift-/.f64N/A
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
div-flip-revN/A
lower-/.f64N/A
lower-/.f6482.2
Applied rewrites82.2%
if -3.10000000000000005e-9 < m < 65000Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
distribute-rgt-inN/A
lift-/.f64N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lower-fma.f64N/A
lower--.f6444.5
Applied rewrites44.5%
if 65000 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.2%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* a (pow k m)) 1.0)))
(if (<= m -3.1e-9)
t_0
(if (<= m 65000.0) (/ a (fma (- k -10.0) 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 <= -3.1e-9) {
tmp = t_0;
} else if (m <= 65000.0) {
tmp = a / fma((k - -10.0), 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 <= -3.1e-9) tmp = t_0; elseif (m <= 65000.0) 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[(a * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / 1.0), $MachinePrecision]}, If[LessEqual[m, -3.1e-9], t$95$0, If[LessEqual[m, 65000.0], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
t_0 := \frac{a \cdot {k}^{m}}{1}\\
\mathbf{if}\;m \leq -3.1 \cdot 10^{-9}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;m \leq 65000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
if m < -3.10000000000000005e-9 or 65000 < m Initial program 90.5%
Taylor expanded in k around 0
Applied rewrites82.2%
if -3.10000000000000005e-9 < m < 65000Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
distribute-rgt-inN/A
lift-/.f64N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lower-fma.f64N/A
lower--.f6444.5
Applied rewrites44.5%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* (fabs a) (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(*
(copysign 1.0 a)
(if (<= t_0 0.0)
(/ (fabs a) (* k (* (- 1.0 (/ (- (/ -1.0 k) 10.0) k)) k)))
(if (<= t_0 1e+285)
(/ (fabs a) (fma (- k -10.0) k 1.0))
(if (<= t_0 INFINITY)
(/ (fabs a) (pow k 2.0))
(+ (fabs a) (* -10.0 (* (fabs a) k)))))))))double code(double a, double k, double m) {
double t_0 = (fabs(a) * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_0 <= 0.0) {
tmp = fabs(a) / (k * ((1.0 - (((-1.0 / k) - 10.0) / k)) * k));
} else if (t_0 <= 1e+285) {
tmp = fabs(a) / fma((k - -10.0), k, 1.0);
} else if (t_0 <= ((double) INFINITY)) {
tmp = fabs(a) / pow(k, 2.0);
} else {
tmp = fabs(a) + (-10.0 * (fabs(a) * k));
}
return copysign(1.0, a) * tmp;
}
function code(a, k, m) t_0 = Float64(Float64(abs(a) * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(abs(a) / Float64(k * Float64(Float64(1.0 - Float64(Float64(Float64(-1.0 / k) - 10.0) / k)) * k))); elseif (t_0 <= 1e+285) tmp = Float64(abs(a) / fma(Float64(k - -10.0), k, 1.0)); elseif (t_0 <= Inf) tmp = Float64(abs(a) / (k ^ 2.0)); else tmp = Float64(abs(a) + Float64(-10.0 * Float64(abs(a) * k))); end return Float64(copysign(1.0, a) * tmp) end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[(N[Abs[a], $MachinePrecision] * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$0, 0.0], N[(N[Abs[a], $MachinePrecision] / N[(k * N[(N[(1.0 - N[(N[(N[(-1.0 / k), $MachinePrecision] - 10.0), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 1e+285], N[(N[Abs[a], $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, Infinity], N[(N[Abs[a], $MachinePrecision] / N[Power[k, 2.0], $MachinePrecision]), $MachinePrecision], N[(N[Abs[a], $MachinePrecision] + N[(-10.0 * N[(N[Abs[a], $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{\left|a\right| \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\left|a\right|}{k \cdot \left(\left(1 - \frac{\frac{-1}{k} - 10}{k}\right) \cdot k\right)}\\
\mathbf{elif}\;t\_0 \leq 10^{+285}:\\
\;\;\;\;\frac{\left|a\right|}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{elif}\;t\_0 \leq \infty:\\
\;\;\;\;\frac{\left|a\right|}{{k}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\left|a\right| + -10 \cdot \left(\left|a\right| \cdot 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))) < 0.0Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
add-flipN/A
mul-1-negN/A
lift-/.f64N/A
mult-flipN/A
lift-/.f64N/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
associate--l-N/A
+-commutativeN/A
sub-to-multN/A
lower-unsound-*.f64N/A
lower-unsound--.f64N/A
lower-unsound-/.f64N/A
add-flipN/A
metadata-evalN/A
lower--.f6445.2
Applied rewrites45.2%
if 0.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 9.9999999999999998e284Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
distribute-rgt-inN/A
lift-/.f64N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lower-fma.f64N/A
lower--.f6444.5
Applied rewrites44.5%
if 9.9999999999999998e284 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < +inf.0Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around inf
lower-pow.f6436.7
Applied rewrites36.7%
if +inf.0 < (/.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.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.1
Applied rewrites20.1%
(FPCore (a k m) :precision binary64 (if (<= m -3.2e-9) (/ a (pow k 2.0)) (* (/ a (- (- k (/ -1.0 k)) -10.0)) (/ 1.0 k))))
double code(double a, double k, double m) {
double tmp;
if (m <= -3.2e-9) {
tmp = a / pow(k, 2.0);
} else {
tmp = (a / ((k - (-1.0 / k)) - -10.0)) * (1.0 / 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 <= (-3.2d-9)) then
tmp = a / (k ** 2.0d0)
else
tmp = (a / ((k - ((-1.0d0) / k)) - (-10.0d0))) * (1.0d0 / k)
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= -3.2e-9) {
tmp = a / Math.pow(k, 2.0);
} else {
tmp = (a / ((k - (-1.0 / k)) - -10.0)) * (1.0 / k);
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= -3.2e-9: tmp = a / math.pow(k, 2.0) else: tmp = (a / ((k - (-1.0 / k)) - -10.0)) * (1.0 / k) return tmp
function code(a, k, m) tmp = 0.0 if (m <= -3.2e-9) tmp = Float64(a / (k ^ 2.0)); else tmp = Float64(Float64(a / Float64(Float64(k - Float64(-1.0 / k)) - -10.0)) * Float64(1.0 / k)); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= -3.2e-9) tmp = a / (k ^ 2.0); else tmp = (a / ((k - (-1.0 / k)) - -10.0)) * (1.0 / k); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, -3.2e-9], N[(a / N[Power[k, 2.0], $MachinePrecision]), $MachinePrecision], N[(N[(a / N[(N[(k - N[(-1.0 / k), $MachinePrecision]), $MachinePrecision] - -10.0), $MachinePrecision]), $MachinePrecision] * N[(1.0 / k), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;m \leq -3.2 \cdot 10^{-9}:\\
\;\;\;\;\frac{a}{{k}^{2}}\\
\mathbf{else}:\\
\;\;\;\;\frac{a}{\left(k - \frac{-1}{k}\right) - -10} \cdot \frac{1}{k}\\
\end{array}
if m < -3.20000000000000012e-9Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around inf
lower-pow.f6436.7
Applied rewrites36.7%
if -3.20000000000000012e-9 < m Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Applied rewrites44.5%
(FPCore (a k m)
:precision binary64
(let* ((t_0 (/ (* (fabs a) (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k)))))
(*
(copysign 1.0 a)
(if (<= t_0 0.0)
(/ (/ (fabs a) (- (- k (/ -1.0 k)) -10.0)) k)
(if (<= t_0 5e+236)
(/ (fabs a) (fma (- k -10.0) k 1.0))
(+ (fabs a) (* -10.0 (* (fabs a) k))))))))double code(double a, double k, double m) {
double t_0 = (fabs(a) * pow(k, m)) / ((1.0 + (10.0 * k)) + (k * k));
double tmp;
if (t_0 <= 0.0) {
tmp = (fabs(a) / ((k - (-1.0 / k)) - -10.0)) / k;
} else if (t_0 <= 5e+236) {
tmp = fabs(a) / fma((k - -10.0), k, 1.0);
} else {
tmp = fabs(a) + (-10.0 * (fabs(a) * k));
}
return copysign(1.0, a) * tmp;
}
function code(a, k, m) t_0 = Float64(Float64(abs(a) * (k ^ m)) / Float64(Float64(1.0 + Float64(10.0 * k)) + Float64(k * k))) tmp = 0.0 if (t_0 <= 0.0) tmp = Float64(Float64(abs(a) / Float64(Float64(k - Float64(-1.0 / k)) - -10.0)) / k); elseif (t_0 <= 5e+236) tmp = Float64(abs(a) / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(abs(a) + Float64(-10.0 * Float64(abs(a) * k))); end return Float64(copysign(1.0, a) * tmp) end
code[a_, k_, m_] := Block[{t$95$0 = N[(N[(N[Abs[a], $MachinePrecision] * N[Power[k, m], $MachinePrecision]), $MachinePrecision] / N[(N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision] + N[(k * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, N[(N[With[{TMP1 = Abs[1.0], TMP2 = Sign[a]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision] * If[LessEqual[t$95$0, 0.0], N[(N[(N[Abs[a], $MachinePrecision] / N[(N[(k - N[(-1.0 / k), $MachinePrecision]), $MachinePrecision] - -10.0), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision], If[LessEqual[t$95$0, 5e+236], N[(N[Abs[a], $MachinePrecision] / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(N[Abs[a], $MachinePrecision] + N[(-10.0 * N[(N[Abs[a], $MachinePrecision] * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]), $MachinePrecision]]
\begin{array}{l}
t_0 := \frac{\left|a\right| \cdot {k}^{m}}{\left(1 + 10 \cdot k\right) + k \cdot k}\\
\mathsf{copysign}\left(1, a\right) \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{\frac{\left|a\right|}{\left(k - \frac{-1}{k}\right) - -10}}{k}\\
\mathbf{elif}\;t\_0 \leq 5 \cdot 10^{+236}:\\
\;\;\;\;\frac{\left|a\right|}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;\left|a\right| + -10 \cdot \left(\left|a\right| \cdot 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))) < 0.0Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
add-flipN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-/.f64N/A
distribute-neg-frac2N/A
metadata-evalN/A
frac-2negN/A
lower-/.f64N/A
Applied rewrites44.5%
if 0.0 < (/.f64 (*.f64 a (pow.f64 k m)) (+.f64 (+.f64 #s(literal 1 binary64) (*.f64 #s(literal 10 binary64) k)) (*.f64 k k))) < 4.9999999999999997e236Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
distribute-rgt-inN/A
lift-/.f64N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lower-fma.f64N/A
lower--.f6444.5
Applied rewrites44.5%
if 4.9999999999999997e236 < (/.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.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.1
Applied rewrites20.1%
(FPCore (a k m) :precision binary64 (if (<= m 6.2e-186) (/ a (/ (* (fma (- k -10.0) k 1.0) k) k)) (/ (/ a (- (- k (/ -1.0 k)) -10.0)) k)))
double code(double a, double k, double m) {
double tmp;
if (m <= 6.2e-186) {
tmp = a / ((fma((k - -10.0), k, 1.0) * k) / k);
} else {
tmp = (a / ((k - (-1.0 / k)) - -10.0)) / k;
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 6.2e-186) tmp = Float64(a / Float64(Float64(fma(Float64(k - -10.0), k, 1.0) * k) / k)); else tmp = Float64(Float64(a / Float64(Float64(k - Float64(-1.0 / k)) - -10.0)) / k); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 6.2e-186], N[(a / N[(N[(N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision] * k), $MachinePrecision] / k), $MachinePrecision]), $MachinePrecision], N[(N[(a / N[(N[(k - N[(-1.0 / k), $MachinePrecision]), $MachinePrecision] - -10.0), $MachinePrecision]), $MachinePrecision] / k), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;m \leq 6.2 \cdot 10^{-186}:\\
\;\;\;\;\frac{a}{\frac{\mathsf{fma}\left(k - -10, k, 1\right) \cdot k}{k}}\\
\mathbf{else}:\\
\;\;\;\;\frac{\frac{a}{\left(k - \frac{-1}{k}\right) - -10}}{k}\\
\end{array}
if m < 6.20000000000000018e-186Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-*.f64N/A
*-commutativeN/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
add-flipN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-/.f64N/A
distribute-neg-frac2N/A
metadata-evalN/A
frac-2negN/A
sub-to-fractionN/A
associate-*l/N/A
lower-/.f64N/A
Applied rewrites44.7%
if 6.20000000000000018e-186 < m Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-/.f64N/A
lift-*.f64N/A
*-commutativeN/A
associate-/r*N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
add-flipN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lift-/.f64N/A
distribute-neg-frac2N/A
metadata-evalN/A
frac-2negN/A
lower-/.f64N/A
Applied rewrites44.5%
(FPCore (a k m) :precision binary64 (if (<= m 65000.0) (/ a (fma (- k -10.0) k 1.0)) (+ a (* -10.0 (* a k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 65000.0) {
tmp = a / fma((k - -10.0), k, 1.0);
} else {
tmp = a + (-10.0 * (a * k));
}
return tmp;
}
function code(a, k, m) tmp = 0.0 if (m <= 65000.0) tmp = Float64(a / fma(Float64(k - -10.0), k, 1.0)); else tmp = Float64(a + Float64(-10.0 * Float64(a * k))); end return tmp end
code[a_, k_, m_] := If[LessEqual[m, 65000.0], N[(a / N[(N[(k - -10.0), $MachinePrecision] * k + 1.0), $MachinePrecision]), $MachinePrecision], N[(a + N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;m \leq 65000:\\
\;\;\;\;\frac{a}{\mathsf{fma}\left(k - -10, k, 1\right)}\\
\mathbf{else}:\\
\;\;\;\;a + -10 \cdot \left(a \cdot k\right)\\
\end{array}
if m < 65000Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
lift-*.f64N/A
lift-+.f64N/A
lift-+.f64N/A
associate-+r+N/A
distribute-rgt-inN/A
lift-/.f64N/A
inv-powN/A
pow-plusN/A
metadata-evalN/A
metadata-evalN/A
+-commutativeN/A
metadata-evalN/A
sub-flipN/A
lower-fma.f64N/A
lower--.f6444.5
Applied rewrites44.5%
if 65000 < m Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.1
Applied rewrites20.1%
(FPCore (a k m) :precision binary64 (if (<= m 5e+15) (/ a (+ 1.0 (* 10.0 k))) (+ a (* -10.0 (* a k)))))
double code(double a, double k, double m) {
double tmp;
if (m <= 5e+15) {
tmp = a / (1.0 + (10.0 * k));
} else {
tmp = a + (-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 <= 5d+15) then
tmp = a / (1.0d0 + (10.0d0 * k))
else
tmp = a + ((-10.0d0) * (a * k))
end if
code = tmp
end function
public static double code(double a, double k, double m) {
double tmp;
if (m <= 5e+15) {
tmp = a / (1.0 + (10.0 * k));
} else {
tmp = a + (-10.0 * (a * k));
}
return tmp;
}
def code(a, k, m): tmp = 0 if m <= 5e+15: tmp = a / (1.0 + (10.0 * k)) else: tmp = a + (-10.0 * (a * k)) return tmp
function code(a, k, m) tmp = 0.0 if (m <= 5e+15) tmp = Float64(a / Float64(1.0 + Float64(10.0 * k))); else tmp = Float64(a + Float64(-10.0 * Float64(a * k))); end return tmp end
function tmp_2 = code(a, k, m) tmp = 0.0; if (m <= 5e+15) tmp = a / (1.0 + (10.0 * k)); else tmp = a + (-10.0 * (a * k)); end tmp_2 = tmp; end
code[a_, k_, m_] := If[LessEqual[m, 5e+15], N[(a / N[(1.0 + N[(10.0 * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(a + N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;m \leq 5 \cdot 10^{+15}:\\
\;\;\;\;\frac{a}{1 + 10 \cdot k}\\
\mathbf{else}:\\
\;\;\;\;a + -10 \cdot \left(a \cdot k\right)\\
\end{array}
if m < 5e15Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f6427.7
Applied rewrites27.7%
if 5e15 < m Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.1
Applied rewrites20.1%
(FPCore (a k m) :precision binary64 (+ a (* -10.0 (* a k))))
double code(double a, double k, double m) {
return a + (-10.0 * (a * 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 + ((-10.0d0) * (a * k))
end function
public static double code(double a, double k, double m) {
return a + (-10.0 * (a * k));
}
def code(a, k, m): return a + (-10.0 * (a * k))
function code(a, k, m) return Float64(a + Float64(-10.0 * Float64(a * k))) end
function tmp = code(a, k, m) tmp = a + (-10.0 * (a * k)); end
code[a_, k_, m_] := N[(a + N[(-10.0 * N[(a * k), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
a + -10 \cdot \left(a \cdot k\right)
Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
lower-+.f64N/A
lower-*.f64N/A
lower-*.f6420.1
Applied rewrites20.1%
(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]
\frac{a}{1}
Initial program 90.5%
lift-*.f64N/A
*-commutativeN/A
lower-*.f6490.5
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
Applied rewrites90.5%
Applied rewrites96.7%
Taylor expanded in m around 0
lower-/.f64N/A
lower-*.f64N/A
lower-+.f64N/A
lower-+.f64N/A
lower-/.f6444.5
Applied rewrites44.5%
Taylor expanded in k around 0
Applied rewrites19.1%
herbie shell --seed 2025173
(FPCore (a k m)
:name "Falkner and Boettcher, Appendix A"
:precision binary64
(/ (* a (pow k m)) (+ (+ 1.0 (* 10.0 k)) (* k k))))