Average Error: 0.5 → 0.4
Time: 1.6s
Precision: binary64
\[\sqrt{x - 1} \cdot \sqrt{x}\]
\[x - \left(0.5 + \frac{0.125}{x}\right)\]
\sqrt{x - 1} \cdot \sqrt{x}
x - \left(0.5 + \frac{0.125}{x}\right)
(FPCore (x) :precision binary64 (* (sqrt (- x 1.0)) (sqrt x)))
(FPCore (x) :precision binary64 (- x (+ 0.5 (/ 0.125 x))))
double code(double x) {
	return sqrt(x - 1.0) * sqrt(x);
}
double code(double x) {
	return x - (0.5 + (0.125 / x));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 0.5

    \[\sqrt{x - 1} \cdot \sqrt{x}\]
  2. Taylor expanded around inf 0.4

    \[\leadsto \color{blue}{x - \left(0.5 + 0.125 \cdot \frac{1}{x}\right)}\]
  3. Simplified0.4

    \[\leadsto \color{blue}{x - \left(0.5 + \frac{0.125}{x}\right)}\]
  4. Final simplification0.4

    \[\leadsto x - \left(0.5 + \frac{0.125}{x}\right)\]

Reproduce

herbie shell --seed 2020232 
(FPCore (x)
  :name "sqrt times"
  :precision binary64
  (* (sqrt (- x 1.0)) (sqrt x)))