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

    \[\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.3

    \[\leadsto \color{blue}{x + \left(-0.5 + \frac{-0.125 + \frac{-0.0625}{x}}{x}\right)} \]
    Proof
    (+.f64 x (+.f64 -1/2 (/.f64 (+.f64 -1/8 (/.f64 -1/16 x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (Rewrite<= metadata-eval (neg.f64 1/2)) (/.f64 (+.f64 -1/8 (/.f64 -1/16 x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (Rewrite<= metadata-eval (*.f64 -1 1/8)) (/.f64 -1/16 x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (*.f64 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 -1) (sqrt.f64 -1))) 1/8) (/.f64 -1/16 x)) x))): 256 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 (sqrt.f64 -1) 2)) 1/8) (/.f64 -1/16 x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (Rewrite<= *-commutative_binary64 (*.f64 1/8 (pow.f64 (sqrt.f64 -1) 2))) (/.f64 -1/16 x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (*.f64 1/8 (pow.f64 (sqrt.f64 -1) 2)) (/.f64 (Rewrite<= metadata-eval (*.f64 -1 1/16)) x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (*.f64 1/8 (pow.f64 (sqrt.f64 -1) 2)) (/.f64 (*.f64 (Rewrite<= rem-square-sqrt_binary64 (*.f64 (sqrt.f64 -1) (sqrt.f64 -1))) 1/16) x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (*.f64 1/8 (pow.f64 (sqrt.f64 -1) 2)) (/.f64 (*.f64 (Rewrite<= unpow2_binary64 (pow.f64 (sqrt.f64 -1) 2)) 1/16) x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (*.f64 1/8 (pow.f64 (sqrt.f64 -1) 2)) (/.f64 (Rewrite<= *-commutative_binary64 (*.f64 1/16 (pow.f64 (sqrt.f64 -1) 2))) x)) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (+.f64 (*.f64 1/8 (pow.f64 (sqrt.f64 -1) 2)) (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1/16 x) (pow.f64 (sqrt.f64 -1) 2)))) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (/.f64 (Rewrite<= distribute-rgt-in_binary64 (*.f64 (pow.f64 (sqrt.f64 -1) 2) (+.f64 1/8 (/.f64 1/16 x)))) x))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 (pow.f64 (sqrt.f64 -1) 2) x) (+.f64 1/8 (/.f64 1/16 x)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (Rewrite<= distribute-rgt-out_binary64 (+.f64 (*.f64 1/8 (/.f64 (pow.f64 (sqrt.f64 -1) 2) x)) (*.f64 (/.f64 1/16 x) (/.f64 (pow.f64 (sqrt.f64 -1) 2) x)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (Rewrite=> associate-*r/_binary64 (/.f64 (*.f64 1/8 (pow.f64 (sqrt.f64 -1) 2)) x)) (*.f64 (/.f64 1/16 x) (/.f64 (pow.f64 (sqrt.f64 -1) 2) x))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1/8 x) (pow.f64 (sqrt.f64 -1) 2))) (*.f64 (/.f64 1/16 x) (/.f64 (pow.f64 (sqrt.f64 -1) 2) x))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (*.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 1/8 1)) x) (pow.f64 (sqrt.f64 -1) 2)) (*.f64 (/.f64 1/16 x) (/.f64 (pow.f64 (sqrt.f64 -1) 2) x))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (*.f64 (Rewrite<= associate-*r/_binary64 (*.f64 1/8 (/.f64 1 x))) (pow.f64 (sqrt.f64 -1) 2)) (*.f64 (/.f64 1/16 x) (/.f64 (pow.f64 (sqrt.f64 -1) 2) x))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (*.f64 (*.f64 1/8 (/.f64 1 x)) (pow.f64 (sqrt.f64 -1) 2)) (Rewrite<= times-frac_binary64 (/.f64 (*.f64 1/16 (pow.f64 (sqrt.f64 -1) 2)) (*.f64 x x)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (*.f64 (*.f64 1/8 (/.f64 1 x)) (pow.f64 (sqrt.f64 -1) 2)) (/.f64 (*.f64 1/16 (pow.f64 (sqrt.f64 -1) 2)) (Rewrite<= unpow2_binary64 (pow.f64 x 2)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (*.f64 (*.f64 1/8 (/.f64 1 x)) (pow.f64 (sqrt.f64 -1) 2)) (Rewrite<= associate-*l/_binary64 (*.f64 (/.f64 1/16 (pow.f64 x 2)) (pow.f64 (sqrt.f64 -1) 2)))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (*.f64 (*.f64 1/8 (/.f64 1 x)) (pow.f64 (sqrt.f64 -1) 2)) (*.f64 (/.f64 (Rewrite<= metadata-eval (*.f64 1/16 1)) (pow.f64 x 2)) (pow.f64 (sqrt.f64 -1) 2))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (+.f64 (*.f64 (*.f64 1/8 (/.f64 1 x)) (pow.f64 (sqrt.f64 -1) 2)) (*.f64 (Rewrite<= associate-*r/_binary64 (*.f64 1/16 (/.f64 1 (pow.f64 x 2)))) (pow.f64 (sqrt.f64 -1) 2))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (Rewrite=> distribute-rgt-out_binary64 (*.f64 (pow.f64 (sqrt.f64 -1) 2) (+.f64 (*.f64 1/8 (/.f64 1 x)) (*.f64 1/16 (/.f64 1 (pow.f64 x 2)))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (*.f64 (Rewrite=> unpow2_binary64 (*.f64 (sqrt.f64 -1) (sqrt.f64 -1))) (+.f64 (*.f64 1/8 (/.f64 1 x)) (*.f64 1/16 (/.f64 1 (pow.f64 x 2))))))): 0 points increase in error, 0 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (*.f64 (Rewrite=> rem-square-sqrt_binary64 -1) (+.f64 (*.f64 1/8 (/.f64 1 x)) (*.f64 1/16 (/.f64 1 (pow.f64 x 2))))))): 0 points increase in error, 256 points decrease in error
    (+.f64 x (+.f64 (neg.f64 1/2) (*.f64 -1 (Rewrite<= +-commutative_binary64 (+.f64 (*.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 (+.f64 (neg.f64 1/2) (Rewrite<= neg-mul-1_binary64 (neg.f64 (+.f64 (*.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<= distribute-neg-in_binary64 (neg.f64 (+.f64 1/2 (+.f64 (*.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
    (Rewrite<= sub-neg_binary64 (-.f64 x (+.f64 1/2 (+.f64 (*.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
  4. Final simplification0.3

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

Alternatives

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

Error

Reproduce

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