(FPCore (R x) :precision binary64 (- R (sqrt x)))
double code(double R, double x) { return R - sqrt(x); }
real(8) function code(r, x) real(8), intent (in) :: r real(8), intent (in) :: x code = r - sqrt(x) end function
public static double code(double R, double x) { return R - Math.sqrt(x); }
def code(R, x): return R - math.sqrt(x)
function code(R, x) return Float64(R - sqrt(x)) end
function tmp = code(R, x) tmp = R - sqrt(x); end
code[R_, x_] := N[(R - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ R - \sqrt{x} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 2 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (R x) :precision binary64 (- R (sqrt x)))
double code(double R, double x) { return R - sqrt(x); }
real(8) function code(r, x) real(8), intent (in) :: r real(8), intent (in) :: x code = r - sqrt(x) end function
public static double code(double R, double x) { return R - Math.sqrt(x); }
def code(R, x): return R - math.sqrt(x)
function code(R, x) return Float64(R - sqrt(x)) end
function tmp = code(R, x) tmp = R - sqrt(x); end
code[R_, x_] := N[(R - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ R - \sqrt{x} \end{array}
(FPCore (R x) :precision binary64 (- R (sqrt x)))
double code(double R, double x) { return R - sqrt(x); }
real(8) function code(r, x) real(8), intent (in) :: r real(8), intent (in) :: x code = r - sqrt(x) end function
public static double code(double R, double x) { return R - Math.sqrt(x); }
def code(R, x): return R - math.sqrt(x)
function code(R, x) return Float64(R - sqrt(x)) end
function tmp = code(R, x) tmp = R - sqrt(x); end
code[R_, x_] := N[(R - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ R - \sqrt{x} \end{array}
Initial program 99.7%
(FPCore (R x) :precision binary64 (- (sqrt x)))
double code(double R, double x) { return -sqrt(x); }
real(8) function code(r, x) real(8), intent (in) :: r real(8), intent (in) :: x code = -sqrt(x) end function
public static double code(double R, double x) { return -Math.sqrt(x); }
def code(R, x): return -math.sqrt(x)
function code(R, x) return Float64(-sqrt(x)) end
function tmp = code(R, x) tmp = -sqrt(x); end
code[R_, x_] := (-N[Sqrt[x], $MachinePrecision])
\begin{array}{l} \\ -\sqrt{x} \end{array}
Initial program 99.7%
Taylor expanded in R around 0
mul-1-neg
N/A
lower-neg.f64
N/A
lower-sqrt.f64
21.0
Applied rewrites21.0%
herbie shell --seed 1
(FPCore (R x)
:name "R-sqrt(x)"
:precision binary64
:pre (and (and (<= 1e-6 R) (<= R 1000000.0)) (and (<= 1e-12 x) (<= x 1000000000000.0)))
(- R (sqrt x)))