
(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}
Sampling outcomes in binary64 precision:
Herbie found 13 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 -1.58e-47)
(*
(*
(fma (fma (* 5.0 x) x (* (* 10.0 eps) (+ eps x))) x (* (pow eps 3.0) 5.0))
x)
eps)
(if (<= x 1.06e-40)
(- (pow (+ x eps) 5.0) (pow x 5.0))
(* (+ (fma 4.0 eps (/ (* 10.0 (* eps eps)) x)) eps) (pow x 4.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -1.58e-47) {
tmp = (fma(fma((5.0 * x), x, ((10.0 * eps) * (eps + x))), x, (pow(eps, 3.0) * 5.0)) * x) * eps;
} else if (x <= 1.06e-40) {
tmp = pow((x + eps), 5.0) - pow(x, 5.0);
} else {
tmp = (fma(4.0, eps, ((10.0 * (eps * eps)) / x)) + eps) * pow(x, 4.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -1.58e-47) tmp = Float64(Float64(fma(fma(Float64(5.0 * x), x, Float64(Float64(10.0 * eps) * Float64(eps + x))), x, Float64((eps ^ 3.0) * 5.0)) * x) * eps); elseif (x <= 1.06e-40) tmp = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)); else tmp = Float64(Float64(fma(4.0, eps, Float64(Float64(10.0 * Float64(eps * eps)) / x)) + eps) * (x ^ 4.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -1.58e-47], N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x + N[(N[(10.0 * eps), $MachinePrecision] * N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + N[(N[Power[eps, 3.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 1.06e-40], N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(4.0 * eps + N[(N[(10.0 * N[(eps * eps), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.58 \cdot 10^{-47}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(5 \cdot x, x, \left(10 \cdot \varepsilon\right) \cdot \left(\varepsilon + x\right)\right), x, {\varepsilon}^{3} \cdot 5\right) \cdot x\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-40}:\\
\;\;\;\;{\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(4, \varepsilon, \frac{10 \cdot \left(\varepsilon \cdot \varepsilon\right)}{x}\right) + \varepsilon\right) \cdot {x}^{4}\\
\end{array}
\end{array}
if x < -1.58e-47Initial program 17.1%
Taylor expanded in eps around 0
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites98.7%
if -1.58e-47 < x < 1.06e-40Initial program 99.4%
if 1.06e-40 < x Initial program 25.0%
Taylor expanded in x around inf
Applied rewrites99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -6.4e-48)
(*
(*
(fma (fma (* 5.0 x) x (* (* 10.0 eps) (+ eps x))) x (* (pow eps 3.0) 5.0))
x)
eps)
(if (<= x 1.06e-40)
(* (fma (fma 5.0 x eps) eps (* (* 10.0 x) x)) (pow eps 3.0))
(* (+ (fma 4.0 eps (/ (* 10.0 (* eps eps)) x)) eps) (pow x 4.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -6.4e-48) {
tmp = (fma(fma((5.0 * x), x, ((10.0 * eps) * (eps + x))), x, (pow(eps, 3.0) * 5.0)) * x) * eps;
} else if (x <= 1.06e-40) {
tmp = fma(fma(5.0, x, eps), eps, ((10.0 * x) * x)) * pow(eps, 3.0);
} else {
tmp = (fma(4.0, eps, ((10.0 * (eps * eps)) / x)) + eps) * pow(x, 4.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -6.4e-48) tmp = Float64(Float64(fma(fma(Float64(5.0 * x), x, Float64(Float64(10.0 * eps) * Float64(eps + x))), x, Float64((eps ^ 3.0) * 5.0)) * x) * eps); elseif (x <= 1.06e-40) tmp = Float64(fma(fma(5.0, x, eps), eps, Float64(Float64(10.0 * x) * x)) * (eps ^ 3.0)); else tmp = Float64(Float64(fma(4.0, eps, Float64(Float64(10.0 * Float64(eps * eps)) / x)) + eps) * (x ^ 4.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -6.4e-48], N[(N[(N[(N[(N[(5.0 * x), $MachinePrecision] * x + N[(N[(10.0 * eps), $MachinePrecision] * N[(eps + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + N[(N[Power[eps, 3.0], $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 1.06e-40], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps + N[(N[(10.0 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(4.0 * eps + N[(N[(10.0 * N[(eps * eps), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48}:\\
\;\;\;\;\left(\mathsf{fma}\left(\mathsf{fma}\left(5 \cdot x, x, \left(10 \cdot \varepsilon\right) \cdot \left(\varepsilon + x\right)\right), x, {\varepsilon}^{3} \cdot 5\right) \cdot x\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-40}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(5, x, \varepsilon\right), \varepsilon, \left(10 \cdot x\right) \cdot x\right) \cdot {\varepsilon}^{3}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(4, \varepsilon, \frac{10 \cdot \left(\varepsilon \cdot \varepsilon\right)}{x}\right) + \varepsilon\right) \cdot {x}^{4}\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48Initial program 17.1%
Taylor expanded in eps around 0
Applied rewrites98.7%
Taylor expanded in x around 0
Applied rewrites98.7%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
if 1.06e-40 < x Initial program 25.0%
Taylor expanded in x around inf
Applied rewrites99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -6.4e-48)
(* (* (* (fma (/ eps x) 10.0 5.0) eps) (* x x)) (* x x))
(if (<= x 1.06e-40)
(* (fma (fma 5.0 x eps) eps (* (* 10.0 x) x)) (pow eps 3.0))
(* (+ (fma 4.0 eps (/ (* 10.0 (* eps eps)) x)) eps) (pow x 4.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -6.4e-48) {
tmp = ((fma((eps / x), 10.0, 5.0) * eps) * (x * x)) * (x * x);
} else if (x <= 1.06e-40) {
tmp = fma(fma(5.0, x, eps), eps, ((10.0 * x) * x)) * pow(eps, 3.0);
} else {
tmp = (fma(4.0, eps, ((10.0 * (eps * eps)) / x)) + eps) * pow(x, 4.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -6.4e-48) tmp = Float64(Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(x * x)) * Float64(x * x)); elseif (x <= 1.06e-40) tmp = Float64(fma(fma(5.0, x, eps), eps, Float64(Float64(10.0 * x) * x)) * (eps ^ 3.0)); else tmp = Float64(Float64(fma(4.0, eps, Float64(Float64(10.0 * Float64(eps * eps)) / x)) + eps) * (x ^ 4.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -6.4e-48], N[(N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.06e-40], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps + N[(N[(10.0 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(4.0 * eps + N[(N[(10.0 * N[(eps * eps), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]), $MachinePrecision] + eps), $MachinePrecision] * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-40}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(5, x, \varepsilon\right), \varepsilon, \left(10 \cdot x\right) \cdot x\right) \cdot {\varepsilon}^{3}\\
\mathbf{else}:\\
\;\;\;\;\left(\mathsf{fma}\left(4, \varepsilon, \frac{10 \cdot \left(\varepsilon \cdot \varepsilon\right)}{x}\right) + \varepsilon\right) \cdot {x}^{4}\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48Initial program 17.1%
Taylor expanded in x around inf
Applied rewrites96.4%
Applied rewrites95.9%
Taylor expanded in x around inf
Applied rewrites95.9%
Applied rewrites96.7%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
if 1.06e-40 < x Initial program 25.0%
Taylor expanded in x around inf
Applied rewrites99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (fma (/ eps x) 10.0 5.0) eps)))
(if (<= x -6.4e-48)
(* (* t_0 (* x x)) (* x x))
(if (<= x 1.06e-40)
(* (fma (fma 5.0 x eps) eps (* (* 10.0 x) x)) (pow eps 3.0))
(* t_0 (* (* (* x x) x) (fabs x)))))))
double code(double x, double eps) {
double t_0 = fma((eps / x), 10.0, 5.0) * eps;
double tmp;
if (x <= -6.4e-48) {
tmp = (t_0 * (x * x)) * (x * x);
} else if (x <= 1.06e-40) {
tmp = fma(fma(5.0, x, eps), eps, ((10.0 * x) * x)) * pow(eps, 3.0);
} else {
tmp = t_0 * (((x * x) * x) * fabs(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) tmp = 0.0 if (x <= -6.4e-48) tmp = Float64(Float64(t_0 * Float64(x * x)) * Float64(x * x)); elseif (x <= 1.06e-40) tmp = Float64(fma(fma(5.0, x, eps), eps, Float64(Float64(10.0 * x) * x)) * (eps ^ 3.0)); else tmp = Float64(t_0 * Float64(Float64(Float64(x * x) * x) * abs(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -6.4e-48], N[(N[(t$95$0 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.06e-40], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps + N[(N[(10.0 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[Power[eps, 3.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48}:\\
\;\;\;\;\left(t\_0 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-40}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(5, x, \varepsilon\right), \varepsilon, \left(10 \cdot x\right) \cdot x\right) \cdot {\varepsilon}^{3}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left|x\right|\right)\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48Initial program 17.1%
Taylor expanded in x around inf
Applied rewrites96.4%
Applied rewrites95.9%
Taylor expanded in x around inf
Applied rewrites95.9%
Applied rewrites96.7%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
if 1.06e-40 < x Initial program 25.0%
Taylor expanded in x around inf
Applied rewrites99.6%
Applied rewrites99.6%
Taylor expanded in x around inf
Applied rewrites99.6%
Applied rewrites99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (fma (/ eps x) 10.0 5.0) eps)))
(if (<= x -6.4e-48)
(* (* t_0 (* x x)) (* x x))
(if (<= x 2.6e-46)
(* (fma (/ x eps) 5.0 1.0) (pow eps 5.0))
(* t_0 (* (* (* x x) x) (fabs x)))))))
double code(double x, double eps) {
double t_0 = fma((eps / x), 10.0, 5.0) * eps;
double tmp;
if (x <= -6.4e-48) {
tmp = (t_0 * (x * x)) * (x * x);
} else if (x <= 2.6e-46) {
tmp = fma((x / eps), 5.0, 1.0) * pow(eps, 5.0);
} else {
tmp = t_0 * (((x * x) * x) * fabs(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) tmp = 0.0 if (x <= -6.4e-48) tmp = Float64(Float64(t_0 * Float64(x * x)) * Float64(x * x)); elseif (x <= 2.6e-46) tmp = Float64(fma(Float64(x / eps), 5.0, 1.0) * (eps ^ 5.0)); else tmp = Float64(t_0 * Float64(Float64(Float64(x * x) * x) * abs(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -6.4e-48], N[(N[(t$95$0 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-46], N[(N[(N[(x / eps), $MachinePrecision] * 5.0 + 1.0), $MachinePrecision] * N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], N[(t$95$0 * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48}:\\
\;\;\;\;\left(t\_0 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-46}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{\varepsilon}, 5, 1\right) \cdot {\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left|x\right|\right)\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48Initial program 17.1%
Taylor expanded in x around inf
Applied rewrites96.4%
Applied rewrites95.9%
Taylor expanded in x around inf
Applied rewrites95.9%
Applied rewrites96.7%
if -6.39999999999999959e-48 < x < 2.6000000000000002e-46Initial program 99.7%
Taylor expanded in eps around inf
Applied rewrites99.3%
if 2.6000000000000002e-46 < x Initial program 33.1%
Taylor expanded in x around inf
Applied rewrites96.5%
Applied rewrites96.4%
Taylor expanded in x around inf
Applied rewrites96.4%
Applied rewrites96.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (fma (/ eps x) 10.0 5.0) eps)))
(if (<= x -6.4e-48)
(* (* t_0 (* x x)) (* x x))
(if (<= x 2.6e-46)
(* (* (* (fma (fma 5.0 x eps) eps (* (* 10.0 x) x)) eps) eps) eps)
(* t_0 (* (* (* x x) x) (fabs x)))))))
double code(double x, double eps) {
double t_0 = fma((eps / x), 10.0, 5.0) * eps;
double tmp;
if (x <= -6.4e-48) {
tmp = (t_0 * (x * x)) * (x * x);
} else if (x <= 2.6e-46) {
tmp = ((fma(fma(5.0, x, eps), eps, ((10.0 * x) * x)) * eps) * eps) * eps;
} else {
tmp = t_0 * (((x * x) * x) * fabs(x));
}
return tmp;
}
function code(x, eps) t_0 = Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) tmp = 0.0 if (x <= -6.4e-48) tmp = Float64(Float64(t_0 * Float64(x * x)) * Float64(x * x)); elseif (x <= 2.6e-46) tmp = Float64(Float64(Float64(fma(fma(5.0, x, eps), eps, Float64(Float64(10.0 * x) * x)) * eps) * eps) * eps); else tmp = Float64(t_0 * Float64(Float64(Float64(x * x) * x) * abs(x))); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision]}, If[LessEqual[x, -6.4e-48], N[(N[(t$95$0 * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.6e-46], N[(N[(N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps + N[(N[(10.0 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision], N[(t$95$0 * N[(N[(N[(x * x), $MachinePrecision] * x), $MachinePrecision] * N[Abs[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\\
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48}:\\
\;\;\;\;\left(t\_0 \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{-46}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(5, x, \varepsilon\right), \varepsilon, \left(10 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;t\_0 \cdot \left(\left(\left(x \cdot x\right) \cdot x\right) \cdot \left|x\right|\right)\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48Initial program 17.1%
Taylor expanded in x around inf
Applied rewrites96.4%
Applied rewrites95.9%
Taylor expanded in x around inf
Applied rewrites95.9%
Applied rewrites96.7%
if -6.39999999999999959e-48 < x < 2.6000000000000002e-46Initial program 99.7%
Taylor expanded in eps around inf
Applied rewrites92.3%
Taylor expanded in eps around 0
Applied rewrites99.3%
Applied rewrites99.3%
Applied rewrites99.3%
if 2.6000000000000002e-46 < x Initial program 33.1%
Taylor expanded in x around inf
Applied rewrites96.5%
Applied rewrites96.4%
Taylor expanded in x around inf
Applied rewrites96.4%
Applied rewrites96.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.4e-48) (not (<= x 1.06e-40))) (* (* (* (fma (/ eps x) 10.0 5.0) eps) (* x x)) (* x x)) (* (* (* (fma (fma 5.0 x eps) eps (* (* 10.0 x) x)) eps) eps) eps)))
double code(double x, double eps) {
double tmp;
if ((x <= -6.4e-48) || !(x <= 1.06e-40)) {
tmp = ((fma((eps / x), 10.0, 5.0) * eps) * (x * x)) * (x * x);
} else {
tmp = ((fma(fma(5.0, x, eps), eps, ((10.0 * x) * x)) * eps) * eps) * eps;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((x <= -6.4e-48) || !(x <= 1.06e-40)) tmp = Float64(Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(x * x)) * Float64(x * x)); else tmp = Float64(Float64(Float64(fma(fma(5.0, x, eps), eps, Float64(Float64(10.0 * x) * x)) * eps) * eps) * eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[x, -6.4e-48], N[Not[LessEqual[x, 1.06e-40]], $MachinePrecision]], N[(N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps + N[(N[(10.0 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48} \lor \neg \left(x \leq 1.06 \cdot 10^{-40}\right):\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(5, x, \varepsilon\right), \varepsilon, \left(10 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48 or 1.06e-40 < x Initial program 21.8%
Taylor expanded in x around inf
Applied rewrites98.3%
Applied rewrites98.1%
Taylor expanded in x around inf
Applied rewrites98.1%
Applied rewrites98.3%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
Applied rewrites98.9%
Applied rewrites98.9%
Final simplification98.8%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.4e-48) (not (<= x 1.06e-40))) (* (* x x) (* (* (* eps x) 5.0) x)) (* (* (* (fma (fma 5.0 x eps) eps (* (* 10.0 x) x)) eps) eps) eps)))
double code(double x, double eps) {
double tmp;
if ((x <= -6.4e-48) || !(x <= 1.06e-40)) {
tmp = (x * x) * (((eps * x) * 5.0) * x);
} else {
tmp = ((fma(fma(5.0, x, eps), eps, ((10.0 * x) * x)) * eps) * eps) * eps;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((x <= -6.4e-48) || !(x <= 1.06e-40)) tmp = Float64(Float64(x * x) * Float64(Float64(Float64(eps * x) * 5.0) * x)); else tmp = Float64(Float64(Float64(fma(fma(5.0, x, eps), eps, Float64(Float64(10.0 * x) * x)) * eps) * eps) * eps); end return tmp end
code[x_, eps_] := If[Or[LessEqual[x, -6.4e-48], N[Not[LessEqual[x, 1.06e-40]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(N[(N[(eps * x), $MachinePrecision] * 5.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps + N[(N[(10.0 * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48} \lor \neg \left(x \leq 1.06 \cdot 10^{-40}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\left(\varepsilon \cdot x\right) \cdot 5\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(\mathsf{fma}\left(5, x, \varepsilon\right), \varepsilon, \left(10 \cdot x\right) \cdot x\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48 or 1.06e-40 < x Initial program 21.8%
Taylor expanded in x around inf
Applied rewrites97.3%
Applied rewrites97.3%
Applied rewrites97.3%
Applied rewrites97.5%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
Applied rewrites98.9%
Applied rewrites98.9%
Final simplification98.7%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.4e-48) (not (<= x 1.06e-40))) (* (* x x) (* (* (* eps x) 5.0) x)) (* (* (* (fma 5.0 x eps) eps) eps) (* eps eps))))
double code(double x, double eps) {
double tmp;
if ((x <= -6.4e-48) || !(x <= 1.06e-40)) {
tmp = (x * x) * (((eps * x) * 5.0) * x);
} else {
tmp = ((fma(5.0, x, eps) * eps) * eps) * (eps * eps);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if ((x <= -6.4e-48) || !(x <= 1.06e-40)) tmp = Float64(Float64(x * x) * Float64(Float64(Float64(eps * x) * 5.0) * x)); else tmp = Float64(Float64(Float64(fma(5.0, x, eps) * eps) * eps) * Float64(eps * eps)); end return tmp end
code[x_, eps_] := If[Or[LessEqual[x, -6.4e-48], N[Not[LessEqual[x, 1.06e-40]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(N[(N[(eps * x), $MachinePrecision] * 5.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48} \lor \neg \left(x \leq 1.06 \cdot 10^{-40}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\left(\varepsilon \cdot x\right) \cdot 5\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48 or 1.06e-40 < x Initial program 21.8%
Taylor expanded in x around inf
Applied rewrites97.3%
Applied rewrites97.3%
Applied rewrites97.3%
Applied rewrites97.5%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites98.8%
Applied rewrites98.7%
Final simplification98.5%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.4e-48) (not (<= x 1.06e-40))) (* (* x x) (* (* (* eps x) 5.0) x)) (* (* (* eps eps) (* eps eps)) eps)))
double code(double x, double eps) {
double tmp;
if ((x <= -6.4e-48) || !(x <= 1.06e-40)) {
tmp = (x * x) * (((eps * x) * 5.0) * x);
} else {
tmp = ((eps * eps) * (eps * eps)) * eps;
}
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) :: tmp
if ((x <= (-6.4d-48)) .or. (.not. (x <= 1.06d-40))) then
tmp = (x * x) * (((eps * x) * 5.0d0) * x)
else
tmp = ((eps * eps) * (eps * eps)) * eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6.4e-48) || !(x <= 1.06e-40)) {
tmp = (x * x) * (((eps * x) * 5.0) * x);
} else {
tmp = ((eps * eps) * (eps * eps)) * eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6.4e-48) or not (x <= 1.06e-40): tmp = (x * x) * (((eps * x) * 5.0) * x) else: tmp = ((eps * eps) * (eps * eps)) * eps return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6.4e-48) || !(x <= 1.06e-40)) tmp = Float64(Float64(x * x) * Float64(Float64(Float64(eps * x) * 5.0) * x)); else tmp = Float64(Float64(Float64(eps * eps) * Float64(eps * eps)) * eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6.4e-48) || ~((x <= 1.06e-40))) tmp = (x * x) * (((eps * x) * 5.0) * x); else tmp = ((eps * eps) * (eps * eps)) * eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6.4e-48], N[Not[LessEqual[x, 1.06e-40]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(N[(N[(eps * x), $MachinePrecision] * 5.0), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision], N[(N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48} \lor \neg \left(x \leq 1.06 \cdot 10^{-40}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\left(\varepsilon \cdot x\right) \cdot 5\right) \cdot x\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48 or 1.06e-40 < x Initial program 21.8%
Taylor expanded in x around inf
Applied rewrites97.3%
Applied rewrites97.3%
Applied rewrites97.3%
Applied rewrites97.5%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites98.7%
Final simplification98.5%
(FPCore (x eps) :precision binary64 (if (or (<= x -6.4e-48) (not (<= x 1.06e-40))) (* (* x x) (* (* x x) (* 5.0 eps))) (* (* (* eps eps) (* eps eps)) eps)))
double code(double x, double eps) {
double tmp;
if ((x <= -6.4e-48) || !(x <= 1.06e-40)) {
tmp = (x * x) * ((x * x) * (5.0 * eps));
} else {
tmp = ((eps * eps) * (eps * eps)) * eps;
}
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) :: tmp
if ((x <= (-6.4d-48)) .or. (.not. (x <= 1.06d-40))) then
tmp = (x * x) * ((x * x) * (5.0d0 * eps))
else
tmp = ((eps * eps) * (eps * eps)) * eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x <= -6.4e-48) || !(x <= 1.06e-40)) {
tmp = (x * x) * ((x * x) * (5.0 * eps));
} else {
tmp = ((eps * eps) * (eps * eps)) * eps;
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -6.4e-48) or not (x <= 1.06e-40): tmp = (x * x) * ((x * x) * (5.0 * eps)) else: tmp = ((eps * eps) * (eps * eps)) * eps return tmp
function code(x, eps) tmp = 0.0 if ((x <= -6.4e-48) || !(x <= 1.06e-40)) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) * Float64(5.0 * eps))); else tmp = Float64(Float64(Float64(eps * eps) * Float64(eps * eps)) * eps); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -6.4e-48) || ~((x <= 1.06e-40))) tmp = (x * x) * ((x * x) * (5.0 * eps)); else tmp = ((eps * eps) * (eps * eps)) * eps; end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -6.4e-48], N[Not[LessEqual[x, 1.06e-40]], $MachinePrecision]], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48} \lor \neg \left(x \leq 1.06 \cdot 10^{-40}\right):\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48 or 1.06e-40 < x Initial program 21.8%
Taylor expanded in x around inf
Applied rewrites97.3%
Applied rewrites97.3%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites98.7%
Final simplification98.4%
(FPCore (x eps)
:precision binary64
(if (<= x -6.4e-48)
(* (* x x) (* (* x x) (* 5.0 eps)))
(if (<= x 1.06e-40)
(* (* (* eps eps) (* eps eps)) eps)
(* (* x x) (* (* (* 5.0 eps) x) x)))))
double code(double x, double eps) {
double tmp;
if (x <= -6.4e-48) {
tmp = (x * x) * ((x * x) * (5.0 * eps));
} else if (x <= 1.06e-40) {
tmp = ((eps * eps) * (eps * eps)) * eps;
} else {
tmp = (x * x) * (((5.0 * eps) * x) * x);
}
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) :: tmp
if (x <= (-6.4d-48)) then
tmp = (x * x) * ((x * x) * (5.0d0 * eps))
else if (x <= 1.06d-40) then
tmp = ((eps * eps) * (eps * eps)) * eps
else
tmp = (x * x) * (((5.0d0 * eps) * x) * x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if (x <= -6.4e-48) {
tmp = (x * x) * ((x * x) * (5.0 * eps));
} else if (x <= 1.06e-40) {
tmp = ((eps * eps) * (eps * eps)) * eps;
} else {
tmp = (x * x) * (((5.0 * eps) * x) * x);
}
return tmp;
}
def code(x, eps): tmp = 0 if x <= -6.4e-48: tmp = (x * x) * ((x * x) * (5.0 * eps)) elif x <= 1.06e-40: tmp = ((eps * eps) * (eps * eps)) * eps else: tmp = (x * x) * (((5.0 * eps) * x) * x) return tmp
function code(x, eps) tmp = 0.0 if (x <= -6.4e-48) tmp = Float64(Float64(x * x) * Float64(Float64(x * x) * Float64(5.0 * eps))); elseif (x <= 1.06e-40) tmp = Float64(Float64(Float64(eps * eps) * Float64(eps * eps)) * eps); else tmp = Float64(Float64(x * x) * Float64(Float64(Float64(5.0 * eps) * x) * x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if (x <= -6.4e-48) tmp = (x * x) * ((x * x) * (5.0 * eps)); elseif (x <= 1.06e-40) tmp = ((eps * eps) * (eps * eps)) * eps; else tmp = (x * x) * (((5.0 * eps) * x) * x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[x, -6.4e-48], N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.06e-40], N[(N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(N[(N[(5.0 * eps), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.4 \cdot 10^{-48}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot \left(5 \cdot \varepsilon\right)\right)\\
\mathbf{elif}\;x \leq 1.06 \cdot 10^{-40}:\\
\;\;\;\;\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \left(\left(\left(5 \cdot \varepsilon\right) \cdot x\right) \cdot x\right)\\
\end{array}
\end{array}
if x < -6.39999999999999959e-48Initial program 17.1%
Taylor expanded in x around inf
Applied rewrites95.2%
Applied rewrites95.4%
if -6.39999999999999959e-48 < x < 1.06e-40Initial program 99.4%
Taylor expanded in eps around inf
Applied rewrites91.1%
Taylor expanded in eps around 0
Applied rewrites98.9%
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites98.7%
if 1.06e-40 < x Initial program 25.0%
Taylor expanded in x around inf
Applied rewrites98.7%
Applied rewrites98.5%
Applied rewrites98.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(Float64(Float64(eps * eps) * Float64(eps * eps)) * eps) end
function tmp = code(x, eps) tmp = ((eps * eps) * (eps * eps)) * eps; end
code[x_, eps_] := N[(N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \varepsilon
\end{array}
Initial program 86.7%
Taylor expanded in eps around inf
Applied rewrites76.7%
Taylor expanded in eps around 0
Applied rewrites85.8%
Applied rewrites85.8%
Taylor expanded in x around 0
Applied rewrites85.5%
herbie shell --seed 2025022
(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)))