(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt (- x 1.0))))
double code(double x) { return sqrt((x + 1.0)) - sqrt((x - 1.0)); }
real(8) function code(x) real(8), intent (in) :: x code = sqrt((x + 1.0d0)) - sqrt((x - 1.0d0)) end function
public static double code(double x) { return Math.sqrt((x + 1.0)) - Math.sqrt((x - 1.0)); }
def code(x): return math.sqrt((x + 1.0)) - math.sqrt((x - 1.0))
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(Float64(x - 1.0))) end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt((x - 1.0)); end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \sqrt{x + 1} - \sqrt{x - 1} \end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
Alternative | Accuracy | Speedup |
---|
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt (- x 1.0))))
double code(double x) { return sqrt((x + 1.0)) - sqrt((x - 1.0)); }
real(8) function code(x) real(8), intent (in) :: x code = sqrt((x + 1.0d0)) - sqrt((x - 1.0d0)) end function
public static double code(double x) { return Math.sqrt((x + 1.0)) - Math.sqrt((x - 1.0)); }
def code(x): return math.sqrt((x + 1.0)) - math.sqrt((x - 1.0))
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(Float64(x - 1.0))) end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt((x - 1.0)); end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \sqrt{x + 1} - \sqrt{x - 1} \end{array}
(FPCore (x) :precision binary64 (/ 2.0 (+ (sqrt (- x 1.0)) (sqrt (- x -1.0)))))
double code(double x) { return 2.0 / (sqrt((x - 1.0)) + sqrt((x - -1.0))); }
real(8) function code(x) real(8), intent (in) :: x code = 2.0d0 / (sqrt((x - 1.0d0)) + sqrt((x - (-1.0d0)))) end function
public static double code(double x) { return 2.0 / (Math.sqrt((x - 1.0)) + Math.sqrt((x - -1.0))); }
def code(x): return 2.0 / (math.sqrt((x - 1.0)) + math.sqrt((x - -1.0)))
function code(x) return Float64(2.0 / Float64(sqrt(Float64(x - 1.0)) + sqrt(Float64(x - -1.0)))) end
function tmp = code(x) tmp = 2.0 / (sqrt((x - 1.0)) + sqrt((x - -1.0))); end
code[x_] := N[(2.0 / N[(N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ \frac{2}{\sqrt{x - 1} + \sqrt{x - -1}} \end{array}
Initial program 5.8%
lift--.f64
N/A
flip--
N/A
lower-/.f64
N/A
Applied rewrites7.6%
Taylor expanded in x around 0
Applied rewrites99.6%
(FPCore (x) :precision binary64 (sqrt (pow x -1.0)))
double code(double x) { return sqrt(pow(x, -1.0)); }
real(8) function code(x) real(8), intent (in) :: x code = sqrt((x ** (-1.0d0))) end function
public static double code(double x) { return Math.sqrt(Math.pow(x, -1.0)); }
def code(x): return math.sqrt(math.pow(x, -1.0))
function code(x) return sqrt((x ^ -1.0)) end
function tmp = code(x) tmp = sqrt((x ^ -1.0)); end
code[x_] := N[Sqrt[N[Power[x, -1.0], $MachinePrecision]], $MachinePrecision]
\begin{array}{l} \\ \sqrt{{x}^{-1}} \end{array}
Initial program 5.8%
Taylor expanded in x around inf
distribute-rgt-out--
N/A
metadata-eval
N/A
*-rgt-identity
N/A
lower-/.f64
N/A
lower-sqrt.f64
98.9
Applied rewrites98.9%
Taylor expanded in x around 0
Applied rewrites99.1%
Final simplification99.1%
(FPCore (x) :precision binary64 (- 1.0 (sqrt (- x 1.0))))
double code(double x) { return 1.0 - sqrt((x - 1.0)); }
real(8) function code(x) real(8), intent (in) :: x code = 1.0d0 - sqrt((x - 1.0d0)) end function
public static double code(double x) { return 1.0 - Math.sqrt((x - 1.0)); }
def code(x): return 1.0 - math.sqrt((x - 1.0))
function code(x) return Float64(1.0 - sqrt(Float64(x - 1.0))) end
function tmp = code(x) tmp = 1.0 - sqrt((x - 1.0)); end
code[x_] := N[(1.0 - N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \sqrt{x - 1} \end{array}
Initial program 5.8%
Taylor expanded in x around 0
Applied rewrites1.6%
(FPCore (x) :precision binary64 (- 1.0 (sqrt -1.0)))
double code(double x) { return 1.0 - sqrt(-1.0); }
real(8) function code(x) real(8), intent (in) :: x code = 1.0d0 - sqrt((-1.0d0)) end function
public static double code(double x) { return 1.0 - Math.sqrt(-1.0); }
def code(x): return 1.0 - math.sqrt(-1.0)
function code(x) return Float64(1.0 - sqrt(-1.0)) end
function tmp = code(x) tmp = 1.0 - sqrt(-1.0); end
code[x_] := N[(1.0 - N[Sqrt[-1.0], $MachinePrecision]), $MachinePrecision]
\begin{array}{l} \\ 1 - \sqrt{-1} \end{array}
Initial program 5.8%
Taylor expanded in x around 0
lower--.f64
N/A
lower-sqrt.f64
0.0
Applied rewrites0.0%
herbie shell --seed 1
(FPCore (x)
:name "sqrt(x+1) - sqrt(x-1)"
:precision binary64
:pre (and (<= -1.79e+308 x) (<= x 1.79e+308))
(- (sqrt (+ x 1.0)) (sqrt (- x 1.0))))