
(FPCore (x eps) :precision binary64 (- x (sqrt (- (* x x) eps))))
double code(double x, double eps) {
return x - sqrt(((x * x) - 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 = x - sqrt(((x * x) - eps))
end function
public static double code(double x, double eps) {
return x - Math.sqrt(((x * x) - eps));
}
def code(x, eps): return x - math.sqrt(((x * x) - eps))
function code(x, eps) return Float64(x - sqrt(Float64(Float64(x * x) - eps))) end
function tmp = code(x, eps) tmp = x - sqrt(((x * x) - eps)); end
code[x_, eps_] := N[(x - N[Sqrt[N[(N[(x * x), $MachinePrecision] - eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
x - \sqrt{x \cdot x - \varepsilon}
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x eps) :precision binary64 (- x (sqrt (- (* x x) eps))))
double code(double x, double eps) {
return x - sqrt(((x * x) - 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 = x - sqrt(((x * x) - eps))
end function
public static double code(double x, double eps) {
return x - Math.sqrt(((x * x) - eps));
}
def code(x, eps): return x - math.sqrt(((x * x) - eps))
function code(x, eps) return Float64(x - sqrt(Float64(Float64(x * x) - eps))) end
function tmp = code(x, eps) tmp = x - sqrt(((x * x) - eps)); end
code[x_, eps_] := N[(x - N[Sqrt[N[(N[(x * x), $MachinePrecision] - eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
x - \sqrt{x \cdot x - \varepsilon}
(FPCore (x eps) :precision binary64 (/ eps (+ x (sqrt (- (* x x) eps)))))
double code(double x, double eps) {
return eps / (x + sqrt(((x * x) - 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 / (x + sqrt(((x * x) - eps)))
end function
public static double code(double x, double eps) {
return eps / (x + Math.sqrt(((x * x) - eps)));
}
def code(x, eps): return eps / (x + math.sqrt(((x * x) - eps)))
function code(x, eps) return Float64(eps / Float64(x + sqrt(Float64(Float64(x * x) - eps)))) end
function tmp = code(x, eps) tmp = eps / (x + sqrt(((x * x) - eps))); end
code[x_, eps_] := N[(eps / N[(x + N[Sqrt[N[(N[(x * x), $MachinePrecision] - eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\varepsilon}{x + \sqrt{x \cdot x - \varepsilon}}
Initial program 60.7%
lift--.f64N/A
flip--N/A
lower-unsound-/.f64N/A
Applied rewrites60.4%
Taylor expanded in x around 0
Applied rewrites99.6%
(FPCore (x eps)
:precision binary64
(let* ((t_0 (- x (sqrt (- (* x x) eps)))))
(if (<=
t_0
-4717453031026927/943490606205385338060388645247067222729230305104110107094051575061406040598037213021531681294414691885367093757690961224942646157481198158140358562858174010912348831744)
t_0
(* 1/2 (/ eps x)))))double code(double x, double eps) {
double t_0 = x - sqrt(((x * x) - eps));
double tmp;
if (t_0 <= -5e-153) {
tmp = t_0;
} else {
tmp = 0.5 * (eps / 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) :: t_0
real(8) :: tmp
t_0 = x - sqrt(((x * x) - eps))
if (t_0 <= (-5d-153)) then
tmp = t_0
else
tmp = 0.5d0 * (eps / x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double t_0 = x - Math.sqrt(((x * x) - eps));
double tmp;
if (t_0 <= -5e-153) {
tmp = t_0;
} else {
tmp = 0.5 * (eps / x);
}
return tmp;
}
def code(x, eps): t_0 = x - math.sqrt(((x * x) - eps)) tmp = 0 if t_0 <= -5e-153: tmp = t_0 else: tmp = 0.5 * (eps / x) return tmp
function code(x, eps) t_0 = Float64(x - sqrt(Float64(Float64(x * x) - eps))) tmp = 0.0 if (t_0 <= -5e-153) tmp = t_0; else tmp = Float64(0.5 * Float64(eps / x)); end return tmp end
function tmp_2 = code(x, eps) t_0 = x - sqrt(((x * x) - eps)); tmp = 0.0; if (t_0 <= -5e-153) tmp = t_0; else tmp = 0.5 * (eps / x); end tmp_2 = tmp; end
code[x_, eps_] := Block[{t$95$0 = N[(x - N[Sqrt[N[(N[(x * x), $MachinePrecision] - eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, -4717453031026927/943490606205385338060388645247067222729230305104110107094051575061406040598037213021531681294414691885367093757690961224942646157481198158140358562858174010912348831744], t$95$0, N[(1/2 * N[(eps / x), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
t_0 := x - \sqrt{x \cdot x - \varepsilon}\\
\mathbf{if}\;t\_0 \leq \frac{-4717453031026927}{943490606205385338060388645247067222729230305104110107094051575061406040598037213021531681294414691885367093757690961224942646157481198158140358562858174010912348831744}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\varepsilon}{x}\\
\end{array}
if (-.f64 x (sqrt.f64 (-.f64 (*.f64 x x) eps))) < -5.0000000000000003e-153Initial program 60.7%
if -5.0000000000000003e-153 < (-.f64 x (sqrt.f64 (-.f64 (*.f64 x x) eps))) Initial program 60.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6445.6%
Applied rewrites45.6%
(FPCore (x eps)
:precision binary64
(if (<=
(- x (sqrt (- (* x x) eps)))
-4717453031026927/943490606205385338060388645247067222729230305104110107094051575061406040598037213021531681294414691885367093757690961224942646157481198158140358562858174010912348831744)
(- x (sqrt (fabs eps)))
(* 1/2 (/ eps x))))double code(double x, double eps) {
double tmp;
if ((x - sqrt(((x * x) - eps))) <= -5e-153) {
tmp = x - sqrt(fabs(eps));
} else {
tmp = 0.5 * (eps / 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 - sqrt(((x * x) - eps))) <= (-5d-153)) then
tmp = x - sqrt(abs(eps))
else
tmp = 0.5d0 * (eps / x)
end if
code = tmp
end function
public static double code(double x, double eps) {
double tmp;
if ((x - Math.sqrt(((x * x) - eps))) <= -5e-153) {
tmp = x - Math.sqrt(Math.abs(eps));
} else {
tmp = 0.5 * (eps / x);
}
return tmp;
}
def code(x, eps): tmp = 0 if (x - math.sqrt(((x * x) - eps))) <= -5e-153: tmp = x - math.sqrt(math.fabs(eps)) else: tmp = 0.5 * (eps / x) return tmp
function code(x, eps) tmp = 0.0 if (Float64(x - sqrt(Float64(Float64(x * x) - eps))) <= -5e-153) tmp = Float64(x - sqrt(abs(eps))); else tmp = Float64(0.5 * Float64(eps / x)); end return tmp end
function tmp_2 = code(x, eps) tmp = 0.0; if ((x - sqrt(((x * x) - eps))) <= -5e-153) tmp = x - sqrt(abs(eps)); else tmp = 0.5 * (eps / x); end tmp_2 = tmp; end
code[x_, eps_] := If[LessEqual[N[(x - N[Sqrt[N[(N[(x * x), $MachinePrecision] - eps), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], -4717453031026927/943490606205385338060388645247067222729230305104110107094051575061406040598037213021531681294414691885367093757690961224942646157481198158140358562858174010912348831744], N[(x - N[Sqrt[N[Abs[eps], $MachinePrecision]], $MachinePrecision]), $MachinePrecision], N[(1/2 * N[(eps / x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\mathbf{if}\;x - \sqrt{x \cdot x - \varepsilon} \leq \frac{-4717453031026927}{943490606205385338060388645247067222729230305104110107094051575061406040598037213021531681294414691885367093757690961224942646157481198158140358562858174010912348831744}:\\
\;\;\;\;x - \sqrt{\left|\varepsilon\right|}\\
\mathbf{else}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{\varepsilon}{x}\\
\end{array}
if (-.f64 x (sqrt.f64 (-.f64 (*.f64 x x) eps))) < -5.0000000000000003e-153Initial program 60.7%
Taylor expanded in x around 0
lower-sqrt.f64N/A
lower-neg.f6456.1%
Applied rewrites56.1%
rem-square-sqrtN/A
sqrt-unprodN/A
lift-neg.f64N/A
lift-neg.f64N/A
sqr-neg-revN/A
rem-sqrt-square-revN/A
lower-fabs.f6457.5%
Applied rewrites57.5%
if -5.0000000000000003e-153 < (-.f64 x (sqrt.f64 (-.f64 (*.f64 x x) eps))) Initial program 60.7%
Taylor expanded in x around inf
lower-*.f64N/A
lower-/.f6445.6%
Applied rewrites45.6%
(FPCore (x eps) :precision binary64 (- x (sqrt (fabs eps))))
double code(double x, double eps) {
return x - sqrt(fabs(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 = x - sqrt(abs(eps))
end function
public static double code(double x, double eps) {
return x - Math.sqrt(Math.abs(eps));
}
def code(x, eps): return x - math.sqrt(math.fabs(eps))
function code(x, eps) return Float64(x - sqrt(abs(eps))) end
function tmp = code(x, eps) tmp = x - sqrt(abs(eps)); end
code[x_, eps_] := N[(x - N[Sqrt[N[Abs[eps], $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
x - \sqrt{\left|\varepsilon\right|}
Initial program 60.7%
Taylor expanded in x around 0
lower-sqrt.f64N/A
lower-neg.f6456.1%
Applied rewrites56.1%
rem-square-sqrtN/A
sqrt-unprodN/A
lift-neg.f64N/A
lift-neg.f64N/A
sqr-neg-revN/A
rem-sqrt-square-revN/A
lower-fabs.f6457.5%
Applied rewrites57.5%
(FPCore (x eps) :precision binary64 (+ x x))
double code(double x, double eps) {
return 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 = x + x
end function
public static double code(double x, double eps) {
return x + x;
}
def code(x, eps): return x + x
function code(x, eps) return Float64(x + x) end
function tmp = code(x, eps) tmp = x + x; end
code[x_, eps_] := N[(x + x), $MachinePrecision]
x + x
Initial program 60.7%
Taylor expanded in x around -inf
lower-*.f643.5%
Applied rewrites3.5%
lift-*.f64N/A
count-2-revN/A
lower-+.f643.5%
Applied rewrites3.5%
herbie shell --seed 2025271 -o generate:evaluate
(FPCore (x eps)
:name "ENA, Section 1.4, Exercise 4d"
:precision binary64
:pre (and (and (<= 0 x) (<= x 1000000000)) (and (<= -1 eps) (<= eps 1)))
(- x (sqrt (- (* x x) eps))))