Average Error: 0.5 → 0.2
Time: 2.3s
Precision: binary64
Cost: 832
\[\sqrt{x - 1} \cdot \sqrt{x} \]
\[x + \left(\frac{-0.125}{x} + \left(-0.5 - \frac{0.0625}{x \cdot x}\right)\right) \]
(FPCore (x) :precision binary64 (* (sqrt (- x 1.0)) (sqrt x)))
(FPCore (x)
 :precision binary64
 (+ x (+ (/ -0.125 x) (- -0.5 (/ 0.0625 (* x x))))))
double code(double x) {
	return sqrt((x - 1.0)) * sqrt(x);
}
double code(double x) {
	return x + ((-0.125 / x) + (-0.5 - (0.0625 / (x * 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 = x + (((-0.125d0) / x) + ((-0.5d0) - (0.0625d0 / (x * 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 x + ((-0.125 / x) + (-0.5 - (0.0625 / (x * x))));
}
def code(x):
	return math.sqrt((x - 1.0)) * math.sqrt(x)
def code(x):
	return x + ((-0.125 / x) + (-0.5 - (0.0625 / (x * x))))
function code(x)
	return Float64(sqrt(Float64(x - 1.0)) * sqrt(x))
end
function code(x)
	return Float64(x + Float64(Float64(-0.125 / x) + Float64(-0.5 - Float64(0.0625 / Float64(x * x)))))
end
function tmp = code(x)
	tmp = sqrt((x - 1.0)) * sqrt(x);
end
function tmp = code(x)
	tmp = x + ((-0.125 / x) + (-0.5 - (0.0625 / (x * x))));
end
code[x_] := N[(N[Sqrt[N[(x - 1.0), $MachinePrecision]], $MachinePrecision] * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
code[x_] := N[(x + N[(N[(-0.125 / x), $MachinePrecision] + N[(-0.5 - N[(0.0625 / N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\sqrt{x - 1} \cdot \sqrt{x}
x + \left(\frac{-0.125}{x} + \left(-0.5 - \frac{0.0625}{x \cdot x}\right)\right)

Error

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 in x around inf 0.2

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

    \[\leadsto \color{blue}{x - \left(\frac{0.125}{x} + \left(0.5 + \frac{0.0625}{x \cdot x}\right)\right)} \]
    Proof
    (-.f64 x (+.f64 (/.f64 1/8 x) (+.f64 1/2 (/.f64 1/16 (*.f64 x x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (+.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 1/8 1)) x) (+.f64 1/2 (/.f64 1/16 (*.f64 x x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (+.f64 (Rewrite<= associate-*r/_binary64 (*.f64 1/8 (/.f64 1 x))) (+.f64 1/2 (/.f64 1/16 (*.f64 x x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (+.f64 (*.f64 1/8 (/.f64 1 x)) (+.f64 1/2 (/.f64 (Rewrite<= metadata-eval (*.f64 1/16 1)) (*.f64 x x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (+.f64 (*.f64 1/8 (/.f64 1 x)) (+.f64 1/2 (/.f64 (*.f64 1/16 1) (Rewrite<= unpow2_binary64 (pow.f64 x 2)))))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (+.f64 (*.f64 1/8 (/.f64 1 x)) (+.f64 1/2 (Rewrite<= associate-*r/_binary64 (*.f64 1/16 (/.f64 1 (pow.f64 x 2))))))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 1/2 (*.f64 1/16 (/.f64 1 (pow.f64 x 2)))) (*.f64 1/8 (/.f64 1 x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 x (Rewrite<= associate-+r+_binary64 (+.f64 1/2 (+.f64 (*.f64 1/16 (/.f64 1 (pow.f64 x 2))) (*.f64 1/8 (/.f64 1 x)))))): 1 points increase in error, 0 points decrease in error
  4. Final simplification0.2

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

Alternatives

Alternative 1
Error0.3
Cost448
\[\left(x + -0.5\right) + \frac{-0.125}{x} \]
Alternative 2
Error0.5
Cost192
\[x + -0.5 \]
Alternative 3
Error1.3
Cost64
\[x \]

Error

Reproduce

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