Average Error: 29.6 → 0.2
Time: 2.6s
Precision: binary64
\[\sqrt{x + 1} - \sqrt{x} \]
\[\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right) \]
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
(FPCore (x)
 :precision binary64
 (expm1 (log1p (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))))
double code(double x) {
	return sqrt((x + 1.0)) - sqrt(x);
}
double code(double x) {
	return expm1(log1p((1.0 / (sqrt((1.0 + x)) + sqrt(x)))));
}
public static double code(double x) {
	return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
public static double code(double x) {
	return Math.expm1(Math.log1p((1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x)))));
}
def code(x):
	return math.sqrt((x + 1.0)) - math.sqrt(x)
def code(x):
	return math.expm1(math.log1p((1.0 / (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 expm1(log1p(Float64(1.0 / Float64(sqrt(Float64(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[(Exp[N[Log[1 + N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]] - 1), $MachinePrecision]
\sqrt{x + 1} - \sqrt{x}
\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right)

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original29.6
Target0.2
Herbie0.2
\[\frac{1}{\sqrt{x + 1} + \sqrt{x}} \]

Derivation

  1. Initial program 29.6

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Applied egg-rr28.9

    \[\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{\sqrt{x + 1} + \sqrt{x}}} \]
  3. Taylor expanded in x around 0 0.2

    \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
  4. Applied egg-rr0.2

    \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right)} \]
  5. Final simplification0.2

    \[\leadsto \mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{1 + x} + \sqrt{x}}\right)\right) \]

Reproduce

herbie shell --seed 2022162 
(FPCore (x)
  :name "Main:bigenough3 from C"
  :precision binary64

  :herbie-target
  (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x)))

  (- (sqrt (+ x 1.0)) (sqrt x)))