
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.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(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.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(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
(FPCore (x eps)
:precision binary64
(if (<= x -5.2e-57)
(*
(*
(fma
(fma (fma 10.0 eps (* 5.0 x)) x (* (* eps eps) 10.0))
x
(* (pow eps 3.0) 5.0))
x)
eps)
(if (<= x 1.22e-59)
(pow eps 5.0)
(* (* (fma (/ eps x) 10.0 5.0) eps) (pow x 4.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -5.2e-57) {
tmp = (fma(fma(fma(10.0, eps, (5.0 * x)), x, ((eps * eps) * 10.0)), x, (pow(eps, 3.0) * 5.0)) * x) * eps;
} else if (x <= 1.22e-59) {
tmp = pow(eps, 5.0);
} else {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * pow(x, 4.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5.2e-57) tmp = Float64(Float64(fma(fma(fma(10.0, eps, Float64(5.0 * x)), x, Float64(Float64(eps * eps) * 10.0)), x, Float64((eps ^ 3.0) * 5.0)) * x) * eps); elseif (x <= 1.22e-59) tmp = eps ^ 5.0; else tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * (x ^ 4.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5.2e-57], N[(N[(N[(N[(N[(10.0 * eps + N[(5.0 * x), $MachinePrecision]), $MachinePrecision] * x + N[(N[(eps * eps), $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision] * x + N[(N[Power[eps, 3.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 1.22e-59], N[Power[eps, 5.0], $MachinePrecision], N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{-57}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(10, \varepsilon, 5 \cdot x\right), x, \left(\varepsilon \cdot \varepsilon\right) \cdot 10\right), x, {\varepsilon}^{3} \cdot 5\right) \cdot x\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-59}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot {x}^{4}\\
\end{array}
\end{array}
if x < -5.19999999999999971e-57Initial program 46.8%
Taylor expanded in eps around 0
Applied rewrites90.3%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.2%
if -5.19999999999999971e-57 < x < 1.22e-59Initial program 99.9%
Taylor expanded in x around 0
lower-pow.f6499.8
Applied rewrites99.8%
if 1.22e-59 < x Initial program 47.0%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.3
Applied rewrites90.3%
(FPCore (x eps)
:precision binary64
(if (<= x -5.2e-57)
(*
(/ (- (fma (* 5.0 x) eps (* (* eps eps) 6.0)) (* (* eps eps) -4.0)) x)
(* (* x x) (* x x)))
(if (<= x 1.22e-59)
(pow eps 5.0)
(* (* (fma (/ eps x) 10.0 5.0) eps) (pow x 4.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -5.2e-57) {
tmp = ((fma((5.0 * x), eps, ((eps * eps) * 6.0)) - ((eps * eps) * -4.0)) / x) * ((x * x) * (x * x));
} else if (x <= 1.22e-59) {
tmp = pow(eps, 5.0);
} else {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * pow(x, 4.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -5.2e-57) tmp = Float64(Float64(Float64(fma(Float64(5.0 * x), eps, Float64(Float64(eps * eps) * 6.0)) - Float64(Float64(eps * eps) * -4.0)) / x) * Float64(Float64(x * x) * Float64(x * x))); elseif (x <= 1.22e-59) tmp = eps ^ 5.0; else tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * (x ^ 4.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -5.2e-57], N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * eps + N[(N[(eps * eps), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision] - N[(N[(eps * eps), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.22e-59], N[Power[eps, 5.0], $MachinePrecision], N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5.2 \cdot 10^{-57}:\\
\;\;\;\;\frac{\mathsf{fma}\left(5 \cdot x, \varepsilon, \left(\varepsilon \cdot \varepsilon\right) \cdot 6\right) - \left(\varepsilon \cdot \varepsilon\right) \cdot -4}{x} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-59}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot {x}^{4}\\
\end{array}
\end{array}
if x < -5.19999999999999971e-57Initial program 46.8%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.4%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.2
Applied rewrites89.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6489.2
Applied rewrites89.2%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites89.1%
if -5.19999999999999971e-57 < x < 1.22e-59Initial program 99.9%
Taylor expanded in x around 0
lower-pow.f6499.8
Applied rewrites99.8%
if 1.22e-59 < x Initial program 47.0%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.3%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6490.3
Applied rewrites90.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(*
(/
(- (fma (* 5.0 x) eps (* (* eps eps) 6.0)) (* (* eps eps) -4.0))
x)
(* (* x x) (* x x)))))
(if (<= x -5.2e-57) t_0 (if (<= x 1.22e-59) (pow eps 5.0) t_0))))
double code(double x, double eps) {
double t_0 = ((fma((5.0 * x), eps, ((eps * eps) * 6.0)) - ((eps * eps) * -4.0)) / x) * ((x * x) * (x * x));
double tmp;
if (x <= -5.2e-57) {
tmp = t_0;
} else if (x <= 1.22e-59) {
tmp = pow(eps, 5.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(Float64(fma(Float64(5.0 * x), eps, Float64(Float64(eps * eps) * 6.0)) - Float64(Float64(eps * eps) * -4.0)) / x) * Float64(Float64(x * x) * Float64(x * x))) tmp = 0.0 if (x <= -5.2e-57) tmp = t_0; elseif (x <= 1.22e-59) tmp = eps ^ 5.0; else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * eps + N[(N[(eps * eps), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision] - N[(N[(eps * eps), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.2e-57], t$95$0, If[LessEqual[x, 1.22e-59], N[Power[eps, 5.0], $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(5 \cdot x, \varepsilon, \left(\varepsilon \cdot \varepsilon\right) \cdot 6\right) - \left(\varepsilon \cdot \varepsilon\right) \cdot -4}{x} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-59}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.19999999999999971e-57 or 1.22e-59 < x Initial program 46.9%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.7
Applied rewrites89.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6489.7
Applied rewrites89.7%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites89.6%
if -5.19999999999999971e-57 < x < 1.22e-59Initial program 99.9%
Taylor expanded in x around 0
lower-pow.f6499.8
Applied rewrites99.8%
(FPCore (x eps)
:precision binary64
(let* ((t_0
(*
(/
(- (fma (* 5.0 x) eps (* (* eps eps) 6.0)) (* (* eps eps) -4.0))
x)
(* (* x x) (* x x)))))
(if (<= x -8.5e-57)
t_0
(if (<= x 1.22e-59)
(* (* (fma 5.0 x eps) (* eps eps)) (* eps eps))
t_0))))
double code(double x, double eps) {
double t_0 = ((fma((5.0 * x), eps, ((eps * eps) * 6.0)) - ((eps * eps) * -4.0)) / x) * ((x * x) * (x * x));
double tmp;
if (x <= -8.5e-57) {
tmp = t_0;
} else if (x <= 1.22e-59) {
tmp = (fma(5.0, x, eps) * (eps * eps)) * (eps * eps);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(Float64(fma(Float64(5.0 * x), eps, Float64(Float64(eps * eps) * 6.0)) - Float64(Float64(eps * eps) * -4.0)) / x) * Float64(Float64(x * x) * Float64(x * x))) tmp = 0.0 if (x <= -8.5e-57) tmp = t_0; elseif (x <= 1.22e-59) tmp = Float64(Float64(fma(5.0, x, eps) * Float64(eps * eps)) * Float64(eps * eps)); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * eps + N[(N[(eps * eps), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision] - N[(N[(eps * eps), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.5e-57], t$95$0, If[LessEqual[x, 1.22e-59], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{\mathsf{fma}\left(5 \cdot x, \varepsilon, \left(\varepsilon \cdot \varepsilon\right) \cdot 6\right) - \left(\varepsilon \cdot \varepsilon\right) \cdot -4}{x} \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-59}:\\
\;\;\;\;\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.49999999999999955e-57 or 1.22e-59 < x Initial program 46.9%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.7
Applied rewrites89.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6489.7
Applied rewrites89.7%
Taylor expanded in x around 0
lower-/.f64N/A
Applied rewrites89.6%
if -8.49999999999999955e-57 < x < 1.22e-59Initial program 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* x x) (* x x))))
(if (<= x -8.5e-57)
(* (/ (fma (* eps x) 5.0 (* (* eps eps) 10.0)) x) t_0)
(if (<= x 1.22e-59)
(* (* (fma 5.0 x eps) (* eps eps)) (* eps eps))
(* (* (fma (/ eps x) 10.0 5.0) eps) t_0)))))
double code(double x, double eps) {
double t_0 = (x * x) * (x * x);
double tmp;
if (x <= -8.5e-57) {
tmp = (fma((eps * x), 5.0, ((eps * eps) * 10.0)) / x) * t_0;
} else if (x <= 1.22e-59) {
tmp = (fma(5.0, x, eps) * (eps * eps)) * (eps * eps);
} else {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(x * x) * Float64(x * x)) tmp = 0.0 if (x <= -8.5e-57) tmp = Float64(Float64(fma(Float64(eps * x), 5.0, Float64(Float64(eps * eps) * 10.0)) / x) * t_0); elseif (x <= 1.22e-59) tmp = Float64(Float64(fma(5.0, x, eps) * Float64(eps * eps)) * Float64(eps * eps)); else tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.5e-57], N[(N[(N[(N[(eps * x), $MachinePrecision] * 5.0 + N[(N[(eps * eps), $MachinePrecision] * 10.0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, 1.22e-59], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{-57}:\\
\;\;\;\;\frac{\mathsf{fma}\left(\varepsilon \cdot x, 5, \left(\varepsilon \cdot \varepsilon\right) \cdot 10\right)}{x} \cdot t\_0\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-59}:\\
\;\;\;\;\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot t\_0\\
\end{array}
\end{array}
if x < -8.49999999999999955e-57Initial program 46.7%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.4%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.2
Applied rewrites89.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
lift-*.f6470.7
Applied rewrites70.7%
Taylor expanded in x around 0
lower-/.f64N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
pow2N/A
lift-*.f6489.1
Applied rewrites89.1%
if -8.49999999999999955e-57 < x < 1.22e-59Initial program 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
if 1.22e-59 < x Initial program 47.0%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.3%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.1
Applied rewrites90.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* x x) (* x x))))
(if (<= x -8.5e-57)
(* (fma (/ (* eps eps) x) 10.0 (* 5.0 eps)) t_0)
(if (<= x 1.22e-59)
(* (* (fma 5.0 x eps) (* eps eps)) (* eps eps))
(* (* (fma (/ eps x) 10.0 5.0) eps) t_0)))))
double code(double x, double eps) {
double t_0 = (x * x) * (x * x);
double tmp;
if (x <= -8.5e-57) {
tmp = fma(((eps * eps) / x), 10.0, (5.0 * eps)) * t_0;
} else if (x <= 1.22e-59) {
tmp = (fma(5.0, x, eps) * (eps * eps)) * (eps * eps);
} else {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(x * x) * Float64(x * x)) tmp = 0.0 if (x <= -8.5e-57) tmp = Float64(fma(Float64(Float64(eps * eps) / x), 10.0, Float64(5.0 * eps)) * t_0); elseif (x <= 1.22e-59) tmp = Float64(Float64(fma(5.0, x, eps) * Float64(eps * eps)) * Float64(eps * eps)); else tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * t_0); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.5e-57], N[(N[(N[(N[(eps * eps), $MachinePrecision] / x), $MachinePrecision] * 10.0 + N[(5.0 * eps), $MachinePrecision]), $MachinePrecision] * t$95$0), $MachinePrecision], If[LessEqual[x, 1.22e-59], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * t$95$0), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{-57}:\\
\;\;\;\;\mathsf{fma}\left(\frac{\varepsilon \cdot \varepsilon}{x}, 10, 5 \cdot \varepsilon\right) \cdot t\_0\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-59}:\\
\;\;\;\;\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot t\_0\\
\end{array}
\end{array}
if x < -8.49999999999999955e-57Initial program 46.7%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.4%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.2
Applied rewrites89.2%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-+.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
associate-*r/N/A
metadata-evalN/A
lower-/.f64N/A
pow2N/A
lift-*.f6470.7
Applied rewrites70.7%
Taylor expanded in x around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f64N/A
pow2N/A
lift-*.f64N/A
lower-*.f6489.2
Applied rewrites89.2%
if -8.49999999999999955e-57 < x < 1.22e-59Initial program 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
if 1.22e-59 < x Initial program 47.0%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.3%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6490.1
Applied rewrites90.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6490.1
Applied rewrites90.1%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* (fma (/ eps x) 10.0 5.0) eps) (* (* x x) (* x x)))))
(if (<= x -8.5e-57)
t_0
(if (<= x 1.22e-59)
(* (* (fma 5.0 x eps) (* eps eps)) (* eps eps))
t_0))))
double code(double x, double eps) {
double t_0 = (fma((eps / x), 10.0, 5.0) * eps) * ((x * x) * (x * x));
double tmp;
if (x <= -8.5e-57) {
tmp = t_0;
} else if (x <= 1.22e-59) {
tmp = (fma(5.0, x, eps) * (eps * eps)) * (eps * eps);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(Float64(x * x) * Float64(x * x))) tmp = 0.0 if (x <= -8.5e-57) tmp = t_0; elseif (x <= 1.22e-59) tmp = Float64(Float64(fma(5.0, x, eps) * Float64(eps * eps)) * Float64(eps * eps)); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.5e-57], t$95$0, If[LessEqual[x, 1.22e-59], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.22 \cdot 10^{-59}:\\
\;\;\;\;\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.49999999999999955e-57 or 1.22e-59 < x Initial program 46.9%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6489.7
Applied rewrites89.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6489.7
Applied rewrites89.7%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lift-/.f6489.7
Applied rewrites89.7%
if -8.49999999999999955e-57 < x < 1.22e-59Initial program 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* 5.0 (* (* x x) (* x x))) eps)))
(if (<= x -8.5e-57)
t_0
(if (<= x 1.35e-59)
(* (* (fma 5.0 x eps) (* eps eps)) (* eps eps))
t_0))))
double code(double x, double eps) {
double t_0 = (5.0 * ((x * x) * (x * x))) * eps;
double tmp;
if (x <= -8.5e-57) {
tmp = t_0;
} else if (x <= 1.35e-59) {
tmp = (fma(5.0, x, eps) * (eps * eps)) * (eps * eps);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(5.0 * Float64(Float64(x * x) * Float64(x * x))) * eps) tmp = 0.0 if (x <= -8.5e-57) tmp = t_0; elseif (x <= 1.35e-59) tmp = Float64(Float64(fma(5.0, x, eps) * Float64(eps * eps)) * Float64(eps * eps)); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(5.0 * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -8.5e-57], t$95$0, If[LessEqual[x, 1.35e-59], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(5 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-59}:\\
\;\;\;\;\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.49999999999999955e-57 or 1.3499999999999999e-59 < x Initial program 46.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6488.8
Applied rewrites88.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.7
Applied rewrites88.7%
if -8.49999999999999955e-57 < x < 1.3499999999999999e-59Initial program 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
lift-*.f64N/A
lift-fma.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-fma.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* 5.0 (* (* x x) (* x x))) eps)))
(if (<= x -5.2e-57)
t_0
(if (<= x 1.35e-59) (* eps (* (* eps eps) (* eps eps))) t_0))))
double code(double x, double eps) {
double t_0 = (5.0 * ((x * x) * (x * x))) * eps;
double tmp;
if (x <= -5.2e-57) {
tmp = t_0;
} else if (x <= 1.35e-59) {
tmp = eps * ((eps * eps) * (eps * eps));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = (5.0d0 * ((x * x) * (x * x))) * eps
if (x <= (-5.2d-57)) then
tmp = t_0
else if (x <= 1.35d-59) then
tmp = eps * ((eps * eps) * (eps * eps))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (5.0 * ((x * x) * (x * x))) * eps;
double tmp;
if (x <= -5.2e-57) {
tmp = t_0;
} else if (x <= 1.35e-59) {
tmp = eps * ((eps * eps) * (eps * eps));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = (5.0 * ((x * x) * (x * x))) * eps tmp = 0 if x <= -5.2e-57: tmp = t_0 elif x <= 1.35e-59: tmp = eps * ((eps * eps) * (eps * eps)) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(Float64(5.0 * Float64(Float64(x * x) * Float64(x * x))) * eps) tmp = 0.0 if (x <= -5.2e-57) tmp = t_0; elseif (x <= 1.35e-59) tmp = Float64(eps * Float64(Float64(eps * eps) * Float64(eps * eps))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = (5.0 * ((x * x) * (x * x))) * eps; tmp = 0.0; if (x <= -5.2e-57) tmp = t_0; elseif (x <= 1.35e-59) tmp = eps * ((eps * eps) * (eps * eps)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(5.0 * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -5.2e-57], t$95$0, If[LessEqual[x, 1.35e-59], N[(eps * N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(5 \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-59}:\\
\;\;\;\;\varepsilon \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.19999999999999971e-57 or 1.3499999999999999e-59 < x Initial program 46.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6488.8
Applied rewrites88.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.7
Applied rewrites88.7%
if -5.19999999999999971e-57 < x < 1.3499999999999999e-59Initial program 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* 5.0 eps) (* (* x x) (* x x)))))
(if (<= x -5.2e-57)
t_0
(if (<= x 1.35e-59) (* eps (* (* eps eps) (* eps eps))) t_0))))
double code(double x, double eps) {
double t_0 = (5.0 * eps) * ((x * x) * (x * x));
double tmp;
if (x <= -5.2e-57) {
tmp = t_0;
} else if (x <= 1.35e-59) {
tmp = eps * ((eps * eps) * (eps * eps));
} else {
tmp = t_0;
}
return tmp;
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
real(8) :: t_0
real(8) :: tmp
t_0 = (5.0d0 * eps) * ((x * x) * (x * x))
if (x <= (-5.2d-57)) then
tmp = t_0
else if (x <= 1.35d-59) then
tmp = eps * ((eps * eps) * (eps * eps))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (5.0 * eps) * ((x * x) * (x * x));
double tmp;
if (x <= -5.2e-57) {
tmp = t_0;
} else if (x <= 1.35e-59) {
tmp = eps * ((eps * eps) * (eps * eps));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, eps): t_0 = (5.0 * eps) * ((x * x) * (x * x)) tmp = 0 if x <= -5.2e-57: tmp = t_0 elif x <= 1.35e-59: tmp = eps * ((eps * eps) * (eps * eps)) else: tmp = t_0 return tmp
function code(x, eps) t_0 = Float64(Float64(5.0 * eps) * Float64(Float64(x * x) * Float64(x * x))) tmp = 0.0 if (x <= -5.2e-57) tmp = t_0; elseif (x <= 1.35e-59) tmp = Float64(eps * Float64(Float64(eps * eps) * Float64(eps * eps))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, eps) t_0 = (5.0 * eps) * ((x * x) * (x * x)); tmp = 0.0; if (x <= -5.2e-57) tmp = t_0; elseif (x <= 1.35e-59) tmp = eps * ((eps * eps) * (eps * eps)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(5.0 * eps), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.2e-57], t$95$0, If[LessEqual[x, 1.35e-59], N[(eps * N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(5 \cdot \varepsilon\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{if}\;x \leq -5.2 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.35 \cdot 10^{-59}:\\
\;\;\;\;\varepsilon \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.19999999999999971e-57 or 1.3499999999999999e-59 < x Initial program 46.9%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6488.9
Applied rewrites88.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6488.7
Applied rewrites88.7%
if -5.19999999999999971e-57 < x < 1.3499999999999999e-59Initial program 99.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.7
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.6%
(FPCore (x eps) :precision binary64 (* eps (* (* eps eps) (* eps eps))))
double code(double x, double eps) {
return eps * ((eps * eps) * (eps * eps));
}
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(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = eps * ((eps * eps) * (eps * eps))
end function
public static double code(double x, double eps) {
return eps * ((eps * eps) * (eps * eps));
}
def code(x, eps): return eps * ((eps * eps) * (eps * eps))
function code(x, eps) return Float64(eps * Float64(Float64(eps * eps) * Float64(eps * eps))) end
function tmp = code(x, eps) tmp = eps * ((eps * eps) * (eps * eps)); end
code[x_, eps_] := N[(eps * N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\varepsilon \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)
\end{array}
Initial program 88.6%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6487.6
Applied rewrites87.6%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
lower-fma.f64N/A
lower-pow.f6487.5
Applied rewrites87.5%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6487.4
Applied rewrites87.4%
Taylor expanded in x around 0
Applied rewrites87.2%
herbie shell --seed 2025088
(FPCore (x eps)
:name "ENA, Section 1.4, Exercise 4b, n=5"
:precision binary64
:pre (and (and (<= -1000000000.0 x) (<= x 1000000000.0)) (and (<= -1.0 eps) (<= eps 1.0)))
(- (pow (+ x eps) 5.0) (pow x 5.0)))