
(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 16 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 -3.5e-52)
(* (pow x 4.0) (* 5.0 eps))
(if (<= x 9.5e-50)
(- (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 <= -3.5e-52) {
tmp = pow(x, 4.0) * (5.0 * eps);
} else if (x <= 9.5e-50) {
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 <= -3.5e-52) tmp = Float64((x ^ 4.0) * Float64(5.0 * eps)); elseif (x <= 9.5e-50) 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, -3.5e-52], N[(N[Power[x, 4.0], $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e-50], 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 -3.5 \cdot 10^{-52}:\\
\;\;\;\;{x}^{4} \cdot \left(5 \cdot \varepsilon\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;{\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 < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.9%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (pow x 4.0) (* 5.0 eps))
(if (<= x 9.5e-50)
(* (fma (/ x eps) 5.0 1.0) (pow eps 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 <= -3.5e-52) {
tmp = pow(x, 4.0) * (5.0 * eps);
} else if (x <= 9.5e-50) {
tmp = fma((x / eps), 5.0, 1.0) * pow(eps, 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 <= -3.5e-52) tmp = Float64((x ^ 4.0) * Float64(5.0 * eps)); elseif (x <= 9.5e-50) tmp = Float64(fma(Float64(x / eps), 5.0, 1.0) * (eps ^ 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, -3.5e-52], N[(N[Power[x, 4.0], $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(N[(x / eps), $MachinePrecision] * 5.0 + 1.0), $MachinePrecision] * N[Power[eps, 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 -3.5 \cdot 10^{-52}:\\
\;\;\;\;{x}^{4} \cdot \left(5 \cdot \varepsilon\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{\varepsilon}, 5, 1\right) \cdot {\varepsilon}^{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 < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.9%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (pow x 4.0) (* 5.0 eps))
(if (<= x 9.5e-50)
(* (fma (/ x eps) 5.0 1.0) (pow eps 5.0))
(* (fma (* 5.0 eps) x (* 10.0 (* eps eps))) (pow x 3.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-52) {
tmp = pow(x, 4.0) * (5.0 * eps);
} else if (x <= 9.5e-50) {
tmp = fma((x / eps), 5.0, 1.0) * pow(eps, 5.0);
} else {
tmp = fma((5.0 * eps), x, (10.0 * (eps * eps))) * pow(x, 3.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64((x ^ 4.0) * Float64(5.0 * eps)); elseif (x <= 9.5e-50) tmp = Float64(fma(Float64(x / eps), 5.0, 1.0) * (eps ^ 5.0)); else tmp = Float64(fma(Float64(5.0 * eps), x, Float64(10.0 * Float64(eps * eps))) * (x ^ 3.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.5e-52], N[(N[Power[x, 4.0], $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(N[(x / eps), $MachinePrecision] * 5.0 + 1.0), $MachinePrecision] * N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(5.0 * eps), $MachinePrecision] * x + N[(10.0 * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;{x}^{4} \cdot \left(5 \cdot \varepsilon\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{\varepsilon}, 5, 1\right) \cdot {\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(5 \cdot \varepsilon, x, 10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot {x}^{3}\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.9%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in eps around inf
Applied rewrites12.7%
Taylor expanded in eps around 0
Applied rewrites99.5%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (pow x 4.0) (* 5.0 eps))
(if (<= x 9.5e-50)
(* (fma (/ x eps) 5.0 1.0) (pow eps 5.0))
(* (* (* (* (fma (/ eps x) 10.0 5.0) eps) (* x x)) x) x))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-52) {
tmp = pow(x, 4.0) * (5.0 * eps);
} else if (x <= 9.5e-50) {
tmp = fma((x / eps), 5.0, 1.0) * pow(eps, 5.0);
} else {
tmp = (((fma((eps / x), 10.0, 5.0) * eps) * (x * x)) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64((x ^ 4.0) * Float64(5.0 * eps)); elseif (x <= 9.5e-50) tmp = Float64(fma(Float64(x / eps), 5.0, 1.0) * (eps ^ 5.0)); else tmp = Float64(Float64(Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(x * x)) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.5e-52], N[(N[Power[x, 4.0], $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(N[(x / eps), $MachinePrecision] * 5.0 + 1.0), $MachinePrecision] * N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;{x}^{4} \cdot \left(5 \cdot \varepsilon\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(\frac{x}{\varepsilon}, 5, 1\right) \cdot {\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.9%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites99.2%
Applied rewrites99.4%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (pow x 4.0) (* 5.0 eps))
(if (<= x 9.5e-50)
(* (fma 5.0 x eps) (pow eps 4.0))
(* (* (* (* (fma (/ eps x) 10.0 5.0) eps) (* x x)) x) x))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-52) {
tmp = pow(x, 4.0) * (5.0 * eps);
} else if (x <= 9.5e-50) {
tmp = fma(5.0, x, eps) * pow(eps, 4.0);
} else {
tmp = (((fma((eps / x), 10.0, 5.0) * eps) * (x * x)) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64((x ^ 4.0) * Float64(5.0 * eps)); elseif (x <= 9.5e-50) tmp = Float64(fma(5.0, x, eps) * (eps ^ 4.0)); else tmp = Float64(Float64(Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(x * x)) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.5e-52], N[(N[Power[x, 4.0], $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(5.0 * x + eps), $MachinePrecision] * N[Power[eps, 4.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;{x}^{4} \cdot \left(5 \cdot \varepsilon\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(5, x, \varepsilon\right) \cdot {\varepsilon}^{4}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.9%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites99.2%
Applied rewrites99.4%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (pow x 4.0) (* 5.0 eps))
(if (<= x 9.5e-50)
(pow eps 5.0)
(* (* (* (* (fma (/ eps x) 10.0 5.0) eps) (* x x)) x) x))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-52) {
tmp = pow(x, 4.0) * (5.0 * eps);
} else if (x <= 9.5e-50) {
tmp = pow(eps, 5.0);
} else {
tmp = (((fma((eps / x), 10.0, 5.0) * eps) * (x * x)) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64((x ^ 4.0) * Float64(5.0 * eps)); elseif (x <= 9.5e-50) tmp = eps ^ 5.0; else tmp = Float64(Float64(Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(x * x)) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.5e-52], N[(N[Power[x, 4.0], $MachinePrecision] * N[(5.0 * eps), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[Power[eps, 5.0], $MachinePrecision], N[(N[(N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;{x}^{4} \cdot \left(5 \cdot \varepsilon\right)\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.9%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites99.7%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites99.2%
Applied rewrites99.4%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (* (* x x) (* (* x x) 5.0)) eps)
(if (<= x 9.5e-50)
(pow eps 5.0)
(* (* (* (* (fma (/ eps x) 10.0 5.0) eps) (* x x)) x) x))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * ((x * x) * 5.0)) * eps;
} else if (x <= 9.5e-50) {
tmp = pow(eps, 5.0);
} else {
tmp = (((fma((eps / x), 10.0, 5.0) * eps) * (x * x)) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * x) * 5.0)) * eps); elseif (x <= 9.5e-50) tmp = eps ^ 5.0; else tmp = Float64(Float64(Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(x * x)) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.5e-52], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[Power[eps, 5.0], $MachinePrecision], N[(N[(N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 5\right)\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;{\varepsilon}^{5}\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.7%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in x around 0
Applied rewrites99.7%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites99.2%
Applied rewrites99.4%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (* (* x x) (* (* x x) 5.0)) eps)
(if (<= x 9.5e-50)
(* (* (* (* (fma 5.0 x eps) eps) eps) eps) eps)
(* (* (* (* (fma (/ eps x) 10.0 5.0) eps) (* x x)) x) x))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * ((x * x) * 5.0)) * eps;
} else if (x <= 9.5e-50) {
tmp = (((fma(5.0, x, eps) * eps) * eps) * eps) * eps;
} else {
tmp = (((fma((eps / x), 10.0, 5.0) * eps) * (x * x)) * x) * x;
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * x) * 5.0)) * eps); elseif (x <= 9.5e-50) tmp = Float64(Float64(Float64(Float64(fma(5.0, x, eps) * eps) * eps) * eps) * eps); else tmp = Float64(Float64(Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(x * x)) * x) * x); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.5e-52], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision], N[(N[(N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * x), $MachinePrecision] * x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 5\right)\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot x\right) \cdot x\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.7%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.6%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites99.2%
Applied rewrites99.4%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(if (<= x -3.5e-52)
(* (* (* x x) (* (* x x) 5.0)) eps)
(if (<= x 9.5e-50)
(* (* (* (* (fma 5.0 x eps) eps) eps) eps) eps)
(* (* (fma (/ eps x) 10.0 5.0) eps) (* (* x x) (* x x))))))
double code(double x, double eps) {
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * ((x * x) * 5.0)) * eps;
} else if (x <= 9.5e-50) {
tmp = (((fma(5.0, x, eps) * eps) * eps) * eps) * eps;
} else {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * ((x * x) * (x * x));
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64(Float64(Float64(x * x) * Float64(Float64(x * x) * 5.0)) * eps); elseif (x <= 9.5e-50) tmp = Float64(Float64(Float64(Float64(fma(5.0, x, eps) * eps) * eps) * eps) * eps); else tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(Float64(x * x) * Float64(x * x))); end return tmp end
code[x_, eps_] := If[LessEqual[x, -3.5e-52], N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision], 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]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot \left(\left(x \cdot x\right) \cdot 5\right)\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\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)\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.7%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.6%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites99.5%
Applied rewrites99.2%
Taylor expanded in x around inf
Applied rewrites99.2%
Final simplification99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* x x) 5.0)))
(if (<= x -3.5e-52)
(* (* (* x x) t_0) eps)
(if (<= x 9.5e-50)
(* (* (* (* (fma 5.0 x eps) eps) eps) eps) eps)
(* (* x (* x t_0)) eps)))))
double code(double x, double eps) {
double t_0 = (x * x) * 5.0;
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * t_0) * eps;
} else if (x <= 9.5e-50) {
tmp = (((fma(5.0, x, eps) * eps) * eps) * eps) * eps;
} else {
tmp = (x * (x * t_0)) * eps;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(x * x) * 5.0) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64(Float64(Float64(x * x) * t_0) * eps); elseif (x <= 9.5e-50) tmp = Float64(Float64(Float64(Float64(fma(5.0, x, eps) * eps) * eps) * eps) * eps); else tmp = Float64(Float64(x * Float64(x * t_0)) * eps); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]}, If[LessEqual[x, -3.5e-52], N[(N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(N[(N[(N[(5.0 * x + eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision] * eps), $MachinePrecision], N[(N[(x * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot 5\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot t\_0\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\left(\left(\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\right) \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(x \cdot t\_0\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.7%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.5%
Applied rewrites99.6%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites97.6%
Applied rewrites97.3%
Applied rewrites97.4%
Final simplification99.5%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* x x) 5.0)))
(if (<= x -3.5e-52)
(* (* (* x x) t_0) eps)
(if (<= x 9.5e-50)
(* (fma 5.0 x eps) (* (* eps eps) (* eps eps)))
(* (* x (* x t_0)) eps)))))
double code(double x, double eps) {
double t_0 = (x * x) * 5.0;
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * t_0) * eps;
} else if (x <= 9.5e-50) {
tmp = fma(5.0, x, eps) * ((eps * eps) * (eps * eps));
} else {
tmp = (x * (x * t_0)) * eps;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(x * x) * 5.0) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64(Float64(Float64(x * x) * t_0) * eps); elseif (x <= 9.5e-50) tmp = Float64(fma(5.0, x, eps) * Float64(Float64(eps * eps) * Float64(eps * eps))); else tmp = Float64(Float64(x * Float64(x * t_0)) * eps); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]}, If[LessEqual[x, -3.5e-52], N[(N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(5.0 * x + eps), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot 5\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot t\_0\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(x \cdot t\_0\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.7%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.6%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites97.6%
Applied rewrites97.3%
Applied rewrites97.4%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* x x) 5.0)))
(if (<= x -3.5e-52)
(* (* (* x x) t_0) eps)
(if (<= x 9.5e-50)
(* (* (fma 5.0 x eps) (* eps eps)) (* eps eps))
(* (* x (* x t_0)) eps)))))
double code(double x, double eps) {
double t_0 = (x * x) * 5.0;
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * t_0) * eps;
} else if (x <= 9.5e-50) {
tmp = (fma(5.0, x, eps) * (eps * eps)) * (eps * eps);
} else {
tmp = (x * (x * t_0)) * eps;
}
return tmp;
}
function code(x, eps) t_0 = Float64(Float64(x * x) * 5.0) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64(Float64(Float64(x * x) * t_0) * eps); elseif (x <= 9.5e-50) tmp = Float64(Float64(fma(5.0, x, eps) * Float64(eps * eps)) * Float64(eps * eps)); else tmp = Float64(Float64(x * Float64(x * t_0)) * eps); end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]}, If[LessEqual[x, -3.5e-52], N[(N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(N[(5.0 * x + eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot 5\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot t\_0\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\left(\mathsf{fma}\left(5, x, \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(x \cdot t\_0\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.7%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.5%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites97.6%
Applied rewrites97.3%
Applied rewrites97.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -3.5e-52) (not (<= x 9.5e-50))) (* (* x (* x (* (* x x) 5.0))) eps) (* (* eps (* eps eps)) (* eps eps))))
double code(double x, double eps) {
double tmp;
if ((x <= -3.5e-52) || !(x <= 9.5e-50)) {
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 <= (-3.5d-52)) .or. (.not. (x <= 9.5d-50))) 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 <= -3.5e-52) || !(x <= 9.5e-50)) {
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 <= -3.5e-52) or not (x <= 9.5e-50): 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 <= -3.5e-52) || !(x <= 9.5e-50)) tmp = Float64(Float64(x * Float64(x * Float64(Float64(x * x) * 5.0))) * eps); else tmp = Float64(Float64(eps * Float64(eps * eps)) * Float64(eps * eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -3.5e-52) || ~((x <= 9.5e-50))) 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, -3.5e-52], N[Not[LessEqual[x, 9.5e-50]], $MachinePrecision]], N[(N[(x * N[(x * N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision], N[(N[(eps * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52} \lor \neg \left(x \leq 9.5 \cdot 10^{-50}\right):\\
\;\;\;\;\left(x \cdot \left(x \cdot \left(\left(x \cdot x\right) \cdot 5\right)\right)\right) \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\end{array}
\end{array}
if x < -3.5e-52 or 9.4999999999999993e-50 < x Initial program 27.4%
Taylor expanded in x around inf
Applied rewrites98.7%
Applied rewrites98.5%
Applied rewrites98.6%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites99.5%
Final simplification99.4%
(FPCore (x eps) :precision binary64 (if (or (<= x -3.5e-52) (not (<= x 9.5e-50))) (* (* 5.0 eps) (* (* x x) (* x x))) (* (* eps (* eps eps)) (* eps eps))))
double code(double x, double eps) {
double tmp;
if ((x <= -3.5e-52) || !(x <= 9.5e-50)) {
tmp = (5.0 * eps) * ((x * x) * (x * 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 <= (-3.5d-52)) .or. (.not. (x <= 9.5d-50))) then
tmp = (5.0d0 * eps) * ((x * x) * (x * 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 <= -3.5e-52) || !(x <= 9.5e-50)) {
tmp = (5.0 * eps) * ((x * x) * (x * x));
} else {
tmp = (eps * (eps * eps)) * (eps * eps);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x <= -3.5e-52) or not (x <= 9.5e-50): tmp = (5.0 * eps) * ((x * x) * (x * x)) else: tmp = (eps * (eps * eps)) * (eps * eps) return tmp
function code(x, eps) tmp = 0.0 if ((x <= -3.5e-52) || !(x <= 9.5e-50)) tmp = Float64(Float64(5.0 * eps) * Float64(Float64(x * x) * Float64(x * x))); else tmp = Float64(Float64(eps * Float64(eps * eps)) * Float64(eps * eps)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x <= -3.5e-52) || ~((x <= 9.5e-50))) tmp = (5.0 * eps) * ((x * x) * (x * x)); else tmp = (eps * (eps * eps)) * (eps * eps); end tmp_2 = tmp; end
code[x_, eps_] := If[Or[LessEqual[x, -3.5e-52], N[Not[LessEqual[x, 9.5e-50]], $MachinePrecision]], N[(N[(5.0 * eps), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(eps * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52} \lor \neg \left(x \leq 9.5 \cdot 10^{-50}\right):\\
\;\;\;\;\left(5 \cdot \varepsilon\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\left(\varepsilon \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\end{array}
\end{array}
if x < -3.5e-52 or 9.4999999999999993e-50 < x Initial program 27.4%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.3%
Taylor expanded in x around inf
Applied rewrites98.4%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites99.5%
Final simplification99.3%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (* (* x x) 5.0)))
(if (<= x -3.5e-52)
(* (* (* x x) t_0) eps)
(if (<= x 9.5e-50)
(* (* eps (* eps eps)) (* eps eps))
(* (* x (* x t_0)) eps)))))
double code(double x, double eps) {
double t_0 = (x * x) * 5.0;
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * t_0) * eps;
} else if (x <= 9.5e-50) {
tmp = (eps * (eps * eps)) * (eps * eps);
} else {
tmp = (x * (x * t_0)) * 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) :: t_0
real(8) :: tmp
t_0 = (x * x) * 5.0d0
if (x <= (-3.5d-52)) then
tmp = ((x * x) * t_0) * eps
else if (x <= 9.5d-50) then
tmp = (eps * (eps * eps)) * (eps * eps)
else
tmp = (x * (x * t_0)) * eps
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = (x * x) * 5.0;
double tmp;
if (x <= -3.5e-52) {
tmp = ((x * x) * t_0) * eps;
} else if (x <= 9.5e-50) {
tmp = (eps * (eps * eps)) * (eps * eps);
} else {
tmp = (x * (x * t_0)) * eps;
}
return tmp;
}
def code(x, eps): t_0 = (x * x) * 5.0 tmp = 0 if x <= -3.5e-52: tmp = ((x * x) * t_0) * eps elif x <= 9.5e-50: tmp = (eps * (eps * eps)) * (eps * eps) else: tmp = (x * (x * t_0)) * eps return tmp
function code(x, eps) t_0 = Float64(Float64(x * x) * 5.0) tmp = 0.0 if (x <= -3.5e-52) tmp = Float64(Float64(Float64(x * x) * t_0) * eps); elseif (x <= 9.5e-50) tmp = Float64(Float64(eps * Float64(eps * eps)) * Float64(eps * eps)); else tmp = Float64(Float64(x * Float64(x * t_0)) * eps); end return tmp end
function tmp_2 = code(x, eps) t_0 = (x * x) * 5.0; tmp = 0.0; if (x <= -3.5e-52) tmp = ((x * x) * t_0) * eps; elseif (x <= 9.5e-50) tmp = (eps * (eps * eps)) * (eps * eps); else tmp = (x * (x * t_0)) * eps; end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(N[(x * x), $MachinePrecision] * 5.0), $MachinePrecision]}, If[LessEqual[x, -3.5e-52], N[(N[(N[(x * x), $MachinePrecision] * t$95$0), $MachinePrecision] * eps), $MachinePrecision], If[LessEqual[x, 9.5e-50], N[(N[(eps * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(x * t$95$0), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \left(x \cdot x\right) \cdot 5\\
\mathbf{if}\;x \leq -3.5 \cdot 10^{-52}:\\
\;\;\;\;\left(\left(x \cdot x\right) \cdot t\_0\right) \cdot \varepsilon\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{-50}:\\
\;\;\;\;\left(\varepsilon \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot \left(x \cdot t\_0\right)\right) \cdot \varepsilon\\
\end{array}
\end{array}
if x < -3.5e-52Initial program 38.5%
Taylor expanded in x around inf
Applied rewrites99.7%
Applied rewrites99.7%
if -3.5e-52 < x < 9.4999999999999993e-50Initial program 100.0%
Taylor expanded in eps around inf
Applied rewrites99.7%
Taylor expanded in x around 0
Applied rewrites99.7%
Applied rewrites99.5%
Taylor expanded in x around 0
Applied rewrites99.5%
if 9.4999999999999993e-50 < x Initial program 15.6%
Taylor expanded in x around inf
Applied rewrites97.6%
Applied rewrites97.3%
Applied rewrites97.4%
(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(eps * Float64(eps * eps)) * Float64(eps * eps)) end
function tmp = code(x, eps) tmp = (eps * (eps * eps)) * (eps * eps); end
code[x_, eps_] := N[(N[(eps * N[(eps * eps), $MachinePrecision]), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\varepsilon \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot \left(\varepsilon \cdot \varepsilon\right)
\end{array}
Initial program 90.1%
Taylor expanded in eps around inf
Applied rewrites89.6%
Taylor expanded in x around 0
Applied rewrites89.6%
Applied rewrites89.5%
Taylor expanded in x around 0
Applied rewrites89.4%
herbie shell --seed 2025018
(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)))