
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
Herbie found 11 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- (pow (+ x eps) 5.0) (pow x 5.0)))
double code(double x, double eps) {
return pow((x + eps), 5.0) - pow(x, 5.0);
}
module fmin_fmax_functions
implicit none
private
public fmax
public fmin
interface fmax
module procedure fmax88
module procedure fmax44
module procedure fmax84
module procedure fmax48
end interface
interface fmin
module procedure fmin88
module procedure fmin44
module procedure fmin84
module procedure fmin48
end interface
contains
real(8) function fmax88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(4) function fmax44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, max(x, y), y /= y), x /= x)
end function
real(8) function fmax84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmax48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
end function
real(8) function fmin88(x, y) result (res)
real(8), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(4) function fmin44(x, y) result (res)
real(4), intent (in) :: x
real(4), intent (in) :: y
res = merge(y, merge(x, min(x, y), y /= y), x /= x)
end function
real(8) function fmin84(x, y) result(res)
real(8), intent (in) :: x
real(4), intent (in) :: y
res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
end function
real(8) function fmin48(x, y) result(res)
real(4), intent (in) :: x
real(8), intent (in) :: y
res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
end function
end module
real(8) function code(x, eps)
use fmin_fmax_functions
real(8), intent (in) :: x
real(8), intent (in) :: eps
code = ((x + eps) ** 5.0d0) - (x ** 5.0d0)
end function
public static double code(double x, double eps) {
return Math.pow((x + eps), 5.0) - Math.pow(x, 5.0);
}
def code(x, eps): return math.pow((x + eps), 5.0) - math.pow(x, 5.0)
function code(x, eps) return Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) end
function tmp = code(x, eps) tmp = ((x + eps) ^ 5.0) - (x ^ 5.0); end
code[x_, eps_] := N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
{\left(x + \varepsilon\right)}^{5} - {x}^{5}
\end{array}
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -1e-284)
t_0
(if (<= t_0 0.0)
(*
(fma
(pow x 4.0)
4.0
(fma (fma (* (* x x) 6.0) x (* (pow x 3.0) 4.0)) eps (pow x 4.0)))
eps)
t_0))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if (t_0 <= -1e-284) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = fma(pow(x, 4.0), 4.0, fma(fma(((x * x) * 6.0), x, (pow(x, 3.0) * 4.0)), eps, pow(x, 4.0))) * eps;
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if (t_0 <= -1e-284) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(fma((x ^ 4.0), 4.0, fma(fma(Float64(Float64(x * x) * 6.0), x, Float64((x ^ 3.0) * 4.0)), eps, (x ^ 4.0))) * eps); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-284], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(N[Power[x, 4.0], $MachinePrecision] * 4.0 + N[(N[(N[(N[(x * x), $MachinePrecision] * 6.0), $MachinePrecision] * x + N[(N[Power[x, 3.0], $MachinePrecision] * 4.0), $MachinePrecision]), $MachinePrecision] * eps + N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * eps), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-284}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left({x}^{4}, 4, \mathsf{fma}\left(\mathsf{fma}\left(\left(x \cdot x\right) \cdot 6, x, {x}^{3} \cdot 4\right), \varepsilon, {x}^{4}\right)\right) \cdot \varepsilon\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -1.00000000000000004e-284 or -0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.8%
if -1.00000000000000004e-284 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -0.0Initial program 86.2%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -1e-284)
t_0
(if (<= t_0 0.0)
(* (fma (* eps eps) 10.0 (* (* 5.0 eps) x)) (pow x 3.0))
t_0))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if (t_0 <= -1e-284) {
tmp = t_0;
} else if (t_0 <= 0.0) {
tmp = fma((eps * eps), 10.0, ((5.0 * eps) * x)) * pow(x, 3.0);
} else {
tmp = t_0;
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if (t_0 <= -1e-284) tmp = t_0; elseif (t_0 <= 0.0) tmp = Float64(fma(Float64(eps * eps), 10.0, Float64(Float64(5.0 * eps) * x)) * (x ^ 3.0)); else tmp = t_0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-284], t$95$0, If[LessEqual[t$95$0, 0.0], N[(N[(N[(eps * eps), $MachinePrecision] * 10.0 + N[(N[(5.0 * eps), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], t$95$0]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-284}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon \cdot \varepsilon, 10, \left(5 \cdot \varepsilon\right) \cdot x\right) \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -1.00000000000000004e-284 or -0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.8%
if -1.00000000000000004e-284 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -0.0Initial program 86.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
associate-+r+N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lower-pow.f6498.9
Applied rewrites98.9%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -1e-284)
(fma (* 5.0 (* (* eps eps) (* eps eps))) x (pow eps 5.0))
(if (<= t_0 0.0)
(* (fma (* eps eps) 10.0 (* (* 5.0 eps) x)) (pow x 3.0))
(pow eps 5.0)))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if (t_0 <= -1e-284) {
tmp = fma((5.0 * ((eps * eps) * (eps * eps))), x, pow(eps, 5.0));
} else if (t_0 <= 0.0) {
tmp = fma((eps * eps), 10.0, ((5.0 * eps) * x)) * pow(x, 3.0);
} else {
tmp = pow(eps, 5.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if (t_0 <= -1e-284) tmp = fma(Float64(5.0 * Float64(Float64(eps * eps) * Float64(eps * eps))), x, (eps ^ 5.0)); elseif (t_0 <= 0.0) tmp = Float64(fma(Float64(eps * eps), 10.0, Float64(Float64(5.0 * eps) * x)) * (x ^ 3.0)); else tmp = eps ^ 5.0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-284], N[(N[(5.0 * N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[(eps * eps), $MachinePrecision] * 10.0 + N[(N[(5.0 * eps), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-284}:\\
\;\;\;\;\mathsf{fma}\left(5 \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right), x, {\varepsilon}^{5}\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon \cdot \varepsilon, 10, \left(5 \cdot \varepsilon\right) \cdot x\right) \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -1.00000000000000004e-284Initial program 97.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f6493.4
Applied rewrites93.4%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6493.4
Applied rewrites93.4%
if -1.00000000000000004e-284 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -0.0Initial program 86.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
associate-+r+N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lower-pow.f6498.9
Applied rewrites98.9%
if -0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.8%
Taylor expanded in x around 0
lower-pow.f6492.7
Applied rewrites92.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -1e-284)
(* (fma 5.0 (/ x eps) 1.0) (pow eps 5.0))
(if (<= t_0 0.0)
(* (fma (* eps eps) 10.0 (* (* 5.0 eps) x)) (pow x 3.0))
(pow eps 5.0)))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if (t_0 <= -1e-284) {
tmp = fma(5.0, (x / eps), 1.0) * pow(eps, 5.0);
} else if (t_0 <= 0.0) {
tmp = fma((eps * eps), 10.0, ((5.0 * eps) * x)) * pow(x, 3.0);
} else {
tmp = pow(eps, 5.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if (t_0 <= -1e-284) tmp = Float64(fma(5.0, Float64(x / eps), 1.0) * (eps ^ 5.0)); elseif (t_0 <= 0.0) tmp = Float64(fma(Float64(eps * eps), 10.0, Float64(Float64(5.0 * eps) * x)) * (x ^ 3.0)); else tmp = eps ^ 5.0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-284], N[(N[(5.0 * N[(x / eps), $MachinePrecision] + 1.0), $MachinePrecision] * N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[(eps * eps), $MachinePrecision] * 10.0 + N[(N[(5.0 * eps), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-284}:\\
\;\;\;\;\mathsf{fma}\left(5, \frac{x}{\varepsilon}, 1\right) \cdot {\varepsilon}^{5}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon \cdot \varepsilon, 10, \left(5 \cdot \varepsilon\right) \cdot x\right) \cdot {x}^{3}\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -1.00000000000000004e-284Initial program 97.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6493.4
Applied rewrites93.4%
if -1.00000000000000004e-284 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -0.0Initial program 86.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
associate-+r+N/A
distribute-rgt-outN/A
metadata-evalN/A
lower-fma.f64N/A
pow2N/A
lift-*.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
lower-*.f64N/A
lift-*.f64N/A
lower-pow.f6498.9
Applied rewrites98.9%
if -0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.8%
Taylor expanded in x around 0
lower-pow.f6492.7
Applied rewrites92.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -1e-284)
(* (fma 5.0 (/ x eps) 1.0) (pow eps 5.0))
(if (<= t_0 0.0)
(* (* (fma (/ eps x) 10.0 5.0) eps) (* (* x x) (* x x)))
(pow eps 5.0)))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if (t_0 <= -1e-284) {
tmp = fma(5.0, (x / eps), 1.0) * pow(eps, 5.0);
} else if (t_0 <= 0.0) {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * ((x * x) * (x * x));
} else {
tmp = pow(eps, 5.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if (t_0 <= -1e-284) tmp = Float64(fma(5.0, Float64(x / eps), 1.0) * (eps ^ 5.0)); elseif (t_0 <= 0.0) tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(Float64(x * x) * Float64(x * x))); else tmp = eps ^ 5.0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-284], N[(N[(5.0 * N[(x / eps), $MachinePrecision] + 1.0), $MachinePrecision] * N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-284}:\\
\;\;\;\;\mathsf{fma}\left(5, \frac{x}{\varepsilon}, 1\right) \cdot {\varepsilon}^{5}\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -1.00000000000000004e-284Initial program 97.9%
Taylor expanded in eps around inf
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
distribute-lft1-inN/A
metadata-evalN/A
lower-fma.f64N/A
lower-/.f64N/A
lower-pow.f6493.4
Applied rewrites93.4%
if -1.00000000000000004e-284 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -0.0Initial program 86.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.9
Applied rewrites98.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6498.8
Applied rewrites98.8%
if -0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.8%
Taylor expanded in x around 0
lower-pow.f6492.7
Applied rewrites92.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0))))
(if (<= t_0 -1e-284)
(*
(- (fma (- eps (- (* 5.0 x))) eps (* (* x x) 6.0)) (* (* x x) -4.0))
(* (* eps eps) eps))
(if (<= t_0 0.0)
(* (* (fma (/ eps x) 10.0 5.0) eps) (* (* x x) (* x x)))
(pow eps 5.0)))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double tmp;
if (t_0 <= -1e-284) {
tmp = (fma((eps - -(5.0 * x)), eps, ((x * x) * 6.0)) - ((x * x) * -4.0)) * ((eps * eps) * eps);
} else if (t_0 <= 0.0) {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * ((x * x) * (x * x));
} else {
tmp = pow(eps, 5.0);
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) tmp = 0.0 if (t_0 <= -1e-284) tmp = Float64(Float64(fma(Float64(eps - Float64(-Float64(5.0 * x))), eps, Float64(Float64(x * x) * 6.0)) - Float64(Float64(x * x) * -4.0)) * Float64(Float64(eps * eps) * eps)); elseif (t_0 <= 0.0) tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(Float64(x * x) * Float64(x * x))); else tmp = eps ^ 5.0; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-284], N[(N[(N[(N[(eps - (-N[(5.0 * x), $MachinePrecision])), $MachinePrecision] * eps + N[(N[(x * x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x * x), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[Power[eps, 5.0], $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-284}:\\
\;\;\;\;\left(\mathsf{fma}\left(\varepsilon - \left(-5 \cdot x\right), \varepsilon, \left(x \cdot x\right) \cdot 6\right) - \left(x \cdot x\right) \cdot -4\right) \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right)\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;{\varepsilon}^{5}\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -1.00000000000000004e-284Initial program 97.9%
Taylor expanded in eps around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites94.0%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.5%
lift-pow.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lower-*.f6493.3
Applied rewrites93.3%
if -1.00000000000000004e-284 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -0.0Initial program 86.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.9
Applied rewrites98.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6498.8
Applied rewrites98.8%
if -0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.8%
Taylor expanded in x around 0
lower-pow.f6492.7
Applied rewrites92.7%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- (pow (+ x eps) 5.0) (pow x 5.0)))
(t_1
(*
(- (fma (- eps (- (* 5.0 x))) eps (* (* x x) 6.0)) (* (* x x) -4.0))
(* (* eps eps) eps))))
(if (<= t_0 -1e-284)
t_1
(if (<= t_0 0.0)
(* (* (fma (/ eps x) 10.0 5.0) eps) (* (* x x) (* x x)))
t_1))))
double code(double x, double eps) {
double t_0 = pow((x + eps), 5.0) - pow(x, 5.0);
double t_1 = (fma((eps - -(5.0 * x)), eps, ((x * x) * 6.0)) - ((x * x) * -4.0)) * ((eps * eps) * eps);
double tmp;
if (t_0 <= -1e-284) {
tmp = t_1;
} else if (t_0 <= 0.0) {
tmp = (fma((eps / x), 10.0, 5.0) * eps) * ((x * x) * (x * x));
} else {
tmp = t_1;
}
return tmp;
}
function code(x, eps) t_0 = Float64((Float64(x + eps) ^ 5.0) - (x ^ 5.0)) t_1 = Float64(Float64(fma(Float64(eps - Float64(-Float64(5.0 * x))), eps, Float64(Float64(x * x) * 6.0)) - Float64(Float64(x * x) * -4.0)) * Float64(Float64(eps * eps) * eps)) tmp = 0.0 if (t_0 <= -1e-284) tmp = t_1; elseif (t_0 <= 0.0) tmp = Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(Float64(x * x) * Float64(x * x))); else tmp = t_1; end return tmp end
code[x_, eps_] := Block[{t$95$0 = N[(N[Power[N[(x + eps), $MachinePrecision], 5.0], $MachinePrecision] - N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(N[(N[(eps - (-N[(5.0 * x), $MachinePrecision])), $MachinePrecision] * eps + N[(N[(x * x), $MachinePrecision] * 6.0), $MachinePrecision]), $MachinePrecision] - N[(N[(x * x), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision] * N[(N[(eps * eps), $MachinePrecision] * eps), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -1e-284], t$95$1, If[LessEqual[t$95$0, 0.0], N[(N[(N[(N[(eps / x), $MachinePrecision] * 10.0 + 5.0), $MachinePrecision] * eps), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := {\left(x + \varepsilon\right)}^{5} - {x}^{5}\\
t_1 := \left(\mathsf{fma}\left(\varepsilon - \left(-5 \cdot x\right), \varepsilon, \left(x \cdot x\right) \cdot 6\right) - \left(x \cdot x\right) \cdot -4\right) \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \varepsilon\right)\\
\mathbf{if}\;t\_0 \leq -1 \cdot 10^{-284}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_0 \leq 0:\\
\;\;\;\;\left(\mathsf{fma}\left(\frac{\varepsilon}{x}, 10, 5\right) \cdot \varepsilon\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -1.00000000000000004e-284 or -0.0 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) Initial program 97.8%
Taylor expanded in eps around -inf
mul-1-negN/A
lower-neg.f64N/A
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites93.5%
lift-pow.f64N/A
unpow3N/A
pow2N/A
lower-*.f64N/A
pow2N/A
lower-*.f6493.2
Applied rewrites93.2%
if -1.00000000000000004e-284 < (-.f64 (pow.f64 (+.f64 x eps) #s(literal 5 binary64)) (pow.f64 x #s(literal 5 binary64))) < -0.0Initial program 86.2%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites98.9%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6498.9
Applied rewrites98.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6498.8
Applied rewrites98.8%
(FPCore (x eps)
:precision binary64
(if (<= x -2.75e-53)
(*
(fma
10.0
(pow eps 3.0)
(* (fma (* 5.0 eps) x (- (* -10.0 (* eps eps)))) x))
(* x x))
(if (<= x 1.55e-92)
(fma (* 5.0 (* (* eps eps) (* eps eps))) x (pow eps 5.0))
(* (fma (* eps eps) 10.0 (* (* eps x) 5.0)) (pow x 3.0)))))
double code(double x, double eps) {
double tmp;
if (x <= -2.75e-53) {
tmp = fma(10.0, pow(eps, 3.0), (fma((5.0 * eps), x, -(-10.0 * (eps * eps))) * x)) * (x * x);
} else if (x <= 1.55e-92) {
tmp = fma((5.0 * ((eps * eps) * (eps * eps))), x, pow(eps, 5.0));
} else {
tmp = fma((eps * eps), 10.0, ((eps * x) * 5.0)) * pow(x, 3.0);
}
return tmp;
}
function code(x, eps) tmp = 0.0 if (x <= -2.75e-53) tmp = Float64(fma(10.0, (eps ^ 3.0), Float64(fma(Float64(5.0 * eps), x, Float64(-Float64(-10.0 * Float64(eps * eps)))) * x)) * Float64(x * x)); elseif (x <= 1.55e-92) tmp = fma(Float64(5.0 * Float64(Float64(eps * eps) * Float64(eps * eps))), x, (eps ^ 5.0)); else tmp = Float64(fma(Float64(eps * eps), 10.0, Float64(Float64(eps * x) * 5.0)) * (x ^ 3.0)); end return tmp end
code[x_, eps_] := If[LessEqual[x, -2.75e-53], N[(N[(10.0 * N[Power[eps, 3.0], $MachinePrecision] + N[(N[(N[(5.0 * eps), $MachinePrecision] * x + (-N[(-10.0 * N[(eps * eps), $MachinePrecision]), $MachinePrecision])), $MachinePrecision] * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 1.55e-92], N[(N[(5.0 * N[(N[(eps * eps), $MachinePrecision] * N[(eps * eps), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + N[Power[eps, 5.0], $MachinePrecision]), $MachinePrecision], N[(N[(N[(eps * eps), $MachinePrecision] * 10.0 + N[(N[(eps * x), $MachinePrecision] * 5.0), $MachinePrecision]), $MachinePrecision] * N[Power[x, 3.0], $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.75 \cdot 10^{-53}:\\
\;\;\;\;\mathsf{fma}\left(10, {\varepsilon}^{3}, \mathsf{fma}\left(5 \cdot \varepsilon, x, --10 \cdot \left(\varepsilon \cdot \varepsilon\right)\right) \cdot x\right) \cdot \left(x \cdot x\right)\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-92}:\\
\;\;\;\;\mathsf{fma}\left(5 \cdot \left(\left(\varepsilon \cdot \varepsilon\right) \cdot \left(\varepsilon \cdot \varepsilon\right)\right), x, {\varepsilon}^{5}\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\varepsilon \cdot \varepsilon, 10, \left(\varepsilon \cdot x\right) \cdot 5\right) \cdot {x}^{3}\\
\end{array}
\end{array}
if x < -2.75000000000000011e-53Initial program 41.5%
Taylor expanded in x around -inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites90.1%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
Applied rewrites89.9%
if -2.75000000000000011e-53 < x < 1.55e-92Initial program 99.9%
Taylor expanded in x around 0
*-commutativeN/A
lower-fma.f64N/A
distribute-lft1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f64N/A
lower-pow.f6499.8
Applied rewrites99.8%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6499.8
Applied rewrites99.8%
if 1.55e-92 < x Initial program 63.1%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites87.8%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6487.8
Applied rewrites87.8%
Taylor expanded in x around 0
*-commutativeN/A
lower-*.f64N/A
associate-+r+N/A
distribute-rgt-outN/A
metadata-evalN/A
distribute-rgt1-inN/A
metadata-evalN/A
*-commutativeN/A
associate-*r*N/A
lower-fma.f64N/A
pow2N/A
lower-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
lower-*.f64N/A
lower-pow.f6487.8
Applied rewrites87.8%
(FPCore (x eps) :precision binary64 (* (* (fma (/ eps x) 10.0 5.0) eps) (* (* x x) (* x x))))
double code(double x, double eps) {
return (fma((eps / x), 10.0, 5.0) * eps) * ((x * x) * (x * x));
}
function code(x, eps) return Float64(Float64(fma(Float64(eps / x), 10.0, 5.0) * eps) * Float64(Float64(x * x) * Float64(x * x))) end
code[x_, eps_] := 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}
\\
\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}
Initial program 88.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
Applied rewrites83.1%
Taylor expanded in eps around 0
*-commutativeN/A
lower-*.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower-/.f6483.1
Applied rewrites83.1%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6483.1
Applied rewrites83.1%
(FPCore (x eps) :precision binary64 (* (* (* 5.0 eps) (* x x)) (* x x)))
double code(double x, double eps) {
return ((5.0 * eps) * (x * x)) * (x * x);
}
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 = ((5.0d0 * eps) * (x * x)) * (x * x)
end function
public static double code(double x, double eps) {
return ((5.0 * eps) * (x * x)) * (x * x);
}
def code(x, eps): return ((5.0 * eps) * (x * x)) * (x * x)
function code(x, eps) return Float64(Float64(Float64(5.0 * eps) * Float64(x * x)) * Float64(x * x)) end
function tmp = code(x, eps) tmp = ((5.0 * eps) * (x * x)) * (x * x); end
code[x_, eps_] := N[(N[(N[(5.0 * eps), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(5 \cdot \varepsilon\right) \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot x\right)
\end{array}
Initial program 88.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6482.9
Applied rewrites82.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.9
Applied rewrites82.9%
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
lift-*.f64N/A
pow2N/A
pow2N/A
associate-*r*N/A
lower-*.f64N/A
lower-*.f64N/A
lift-*.f64N/A
pow2N/A
lift-*.f64N/A
pow2N/A
lift-*.f6482.9
Applied rewrites82.9%
(FPCore (x eps) :precision binary64 (* (* 5.0 eps) (* (* x x) (* x x))))
double code(double x, double eps) {
return (5.0 * eps) * ((x * x) * (x * x));
}
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 = (5.0d0 * eps) * ((x * x) * (x * x))
end function
public static double code(double x, double eps) {
return (5.0 * eps) * ((x * x) * (x * x));
}
def code(x, eps): return (5.0 * eps) * ((x * x) * (x * x))
function code(x, eps) return Float64(Float64(5.0 * eps) * Float64(Float64(x * x) * Float64(x * x))) end
function tmp = code(x, eps) tmp = (5.0 * eps) * ((x * x) * (x * x)); end
code[x_, eps_] := N[(N[(5.0 * eps), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(5 \cdot \varepsilon\right) \cdot \left(\left(x \cdot x\right) \cdot \left(x \cdot x\right)\right)
\end{array}
Initial program 88.3%
Taylor expanded in x around inf
*-commutativeN/A
lower-*.f64N/A
distribute-rgt1-inN/A
metadata-evalN/A
lower-*.f64N/A
lower-pow.f6482.9
Applied rewrites82.9%
lift-pow.f64N/A
metadata-evalN/A
pow-prod-upN/A
lower-*.f64N/A
unpow2N/A
lower-*.f64N/A
unpow2N/A
lower-*.f6482.9
Applied rewrites82.9%
herbie shell --seed 2025105
(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)))