Alternative 1 | |
---|---|
Accuracy | 99.9% |
Cost | 13248 |
\[\frac{1}{\sqrt{1 + x} + \sqrt{x}}
\]
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x) :precision binary64 (/ (- (+ 1.0 x) x) (+ (sqrt (+ 1.0 x)) (sqrt x))))
double code(double x) { return sqrt((x + 1.0)) - sqrt(x); }
double code(double x) { return ((1.0 + x) - x) / (sqrt((1.0 + x)) + sqrt(x)); }
real(8) function code(x) real(8), intent (in) :: x code = sqrt((x + 1.0d0)) - sqrt(x) end function
real(8) function code(x) real(8), intent (in) :: x code = ((1.0d0 + x) - x) / (sqrt((1.0d0 + x)) + sqrt(x)) end function
public static double code(double x) { return Math.sqrt((x + 1.0)) - Math.sqrt(x); }
public static double code(double x) { return ((1.0 + x) - x) / (Math.sqrt((1.0 + x)) + Math.sqrt(x)); }
def code(x): return math.sqrt((x + 1.0)) - math.sqrt(x)
def code(x): return ((1.0 + x) - x) / (math.sqrt((1.0 + x)) + math.sqrt(x))
function code(x) return Float64(sqrt(Float64(x + 1.0)) - sqrt(x)) end
function code(x) return Float64(Float64(Float64(1.0 + x) - x) / Float64(sqrt(Float64(1.0 + x)) + sqrt(x))) end
function tmp = code(x) tmp = sqrt((x + 1.0)) - sqrt(x); end
function tmp = code(x) tmp = ((1.0 + x) - x) / (sqrt((1.0 + x)) + sqrt(x)); end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(N[(1.0 + x), $MachinePrecision] - x), $MachinePrecision] / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sqrt{x + 1} - \sqrt{x}
\frac{\left(1 + x\right) - x}{\sqrt{1 + x} + \sqrt{x}}
Results
Initial program 99.3%
Applied egg-rr99.9%
[Start]99.3 | \[ \sqrt{x + 1} - \sqrt{x}
\] |
---|---|
flip-- [=>]99.4 | \[ \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}}
\] |
div-inv [=>]99.4 | \[ \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}}
\] |
add-sqr-sqrt [<=]99.6 | \[ \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}
\] |
add-sqr-sqrt [<=]99.9 | \[ \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}
\] |
associate--l+ [=>]99.9 | \[ \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}
\] |
Simplified99.9%
[Start]99.9 | \[ \left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}
\] |
---|---|
associate-*r/ [=>]99.9 | \[ \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}}
\] |
*-rgt-identity [=>]99.9 | \[ \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}}
\] |
associate-+r- [=>]99.9 | \[ \frac{\color{blue}{\left(x + 1\right) - x}}{\sqrt{x + 1} + \sqrt{x}}
\] |
+-commutative [=>]99.9 | \[ \frac{\color{blue}{\left(1 + x\right)} - x}{\sqrt{x + 1} + \sqrt{x}}
\] |
+-commutative [=>]99.9 | \[ \frac{\left(1 + x\right) - x}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}}
\] |
Final simplification99.9%
Alternative 1 | |
---|---|
Accuracy | 99.9% |
Cost | 13248 |
Alternative 2 | |
---|---|
Accuracy | 99.3% |
Cost | 13120 |
Alternative 3 | |
---|---|
Accuracy | 96.5% |
Cost | 6976 |
Alternative 4 | |
---|---|
Accuracy | 96.5% |
Cost | 6848 |
Alternative 5 | |
---|---|
Accuracy | 93.4% |
Cost | 64 |
herbie shell --seed 1
(FPCore (x)
:name "sqrt(x+1) - sqrt(x)"
:precision binary64
:pre (and (<= 0.0 x) (<= x 1000000000.0))
(- (sqrt (+ x 1.0)) (sqrt x)))