Main:bigenough3 from C

Percentage Accurate: 52.6% → 99.8%
Time: 9.1s
Alternatives: 8
Speedup: 2.0×

Specification

?
\[\begin{array}{l} \\ \sqrt{x + 1} - \sqrt{x} \end{array} \]
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
	return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
	return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x):
	return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x)
	return Float64(sqrt(Float64(x + 1.0)) - sqrt(x))
end
function tmp = code(x)
	tmp = sqrt((x + 1.0)) - sqrt(x);
end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt{x + 1} - \sqrt{x}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 8 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 52.6% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \sqrt{x + 1} - \sqrt{x} \end{array} \]
(FPCore (x) :precision binary64 (- (sqrt (+ x 1.0)) (sqrt x)))
double code(double x) {
	return sqrt((x + 1.0)) - sqrt(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = sqrt((x + 1.0d0)) - sqrt(x)
end function
public static double code(double x) {
	return Math.sqrt((x + 1.0)) - Math.sqrt(x);
}
def code(x):
	return math.sqrt((x + 1.0)) - math.sqrt(x)
function code(x)
	return Float64(sqrt(Float64(x + 1.0)) - sqrt(x))
end
function tmp = code(x)
	tmp = sqrt((x + 1.0)) - sqrt(x);
end
code[x_] := N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\sqrt{x + 1} - \sqrt{x}
\end{array}

Alternative 1: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\sqrt{1 + x} + \sqrt{x}} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ 1.0 x)) (sqrt x))))
double code(double x) {
	return 1.0 / (sqrt((1.0 + x)) + sqrt(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 / (sqrt((1.0d0 + x)) + sqrt(x))
end function
public static double code(double x) {
	return 1.0 / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
}
def code(x):
	return 1.0 / (math.sqrt((1.0 + x)) + math.sqrt(x))
function code(x)
	return Float64(1.0 / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)))
end
function tmp = code(x)
	tmp = 1.0 / (sqrt((1.0 + x)) + sqrt(x));
end
code[x_] := N[(1.0 / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\sqrt{1 + x} + \sqrt{x}}
\end{array}
Derivation
  1. Initial program 49.1%

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--49.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
    2. div-inv49.0%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    3. add-sqr-sqrt49.3%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. add-sqr-sqrt49.6%

      \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    5. associate--l+49.6%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
  4. Applied egg-rr49.6%

    \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
  5. Step-by-step derivation
    1. associate-*r/49.6%

      \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
    2. *-rgt-identity49.6%

      \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
    3. +-commutative49.6%

      \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
    4. associate-+l-99.7%

      \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
    5. +-inverses99.7%

      \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
    6. metadata-eval99.7%

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
    7. +-commutative99.7%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
  6. Simplified99.7%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
  7. Final simplification99.7%

    \[\leadsto \frac{1}{\sqrt{1 + x} + \sqrt{x}} \]
  8. Add Preprocessing

Alternative 2: 99.4% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{1 + x} - \sqrt{x}\\ \mathbf{if}\;t_0 \leq 2 \cdot 10^{-6}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- (sqrt (+ 1.0 x)) (sqrt x))))
   (if (<= t_0 2e-6) (* 0.5 (sqrt (/ 1.0 x))) t_0)))
double code(double x) {
	double t_0 = sqrt((1.0 + x)) - sqrt(x);
	double tmp;
	if (t_0 <= 2e-6) {
		tmp = 0.5 * sqrt((1.0 / x));
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = sqrt((1.0d0 + x)) - sqrt(x)
    if (t_0 <= 2d-6) then
        tmp = 0.5d0 * sqrt((1.0d0 / x))
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x) {
	double t_0 = Math.sqrt((1.0 + x)) - Math.sqrt(x);
	double tmp;
	if (t_0 <= 2e-6) {
		tmp = 0.5 * Math.sqrt((1.0 / x));
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x):
	t_0 = math.sqrt((1.0 + x)) - math.sqrt(x)
	tmp = 0
	if t_0 <= 2e-6:
		tmp = 0.5 * math.sqrt((1.0 / x))
	else:
		tmp = t_0
	return tmp
function code(x)
	t_0 = Float64(sqrt(Float64(1.0 + x)) - sqrt(x))
	tmp = 0.0
	if (t_0 <= 2e-6)
		tmp = Float64(0.5 * sqrt(Float64(1.0 / x)));
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = sqrt((1.0 + x)) - sqrt(x);
	tmp = 0.0;
	if (t_0 <= 2e-6)
		tmp = 0.5 * sqrt((1.0 / x));
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] - N[Sqrt[x], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 2e-6], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{1 + x} - \sqrt{x}\\
\mathbf{if}\;t_0 \leq 2 \cdot 10^{-6}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x)) < 1.99999999999999991e-6

    1. Initial program 4.3%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--4.3%

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. div-inv4.3%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
      3. add-sqr-sqrt4.7%

        \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      4. add-sqr-sqrt5.2%

        \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      5. associate--l+5.2%

        \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. Applied egg-rr5.2%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/5.2%

        \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. *-rgt-identity5.2%

        \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      3. +-commutative5.2%

        \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
      4. associate-+l-99.7%

        \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      5. +-inverses99.7%

        \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
      6. metadata-eval99.7%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
      7. +-commutative99.7%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
    6. Simplified99.7%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    7. Applied egg-rr50.6%

      \[\leadsto \color{blue}{\frac{1}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)} \]
    8. Step-by-step derivation
      1. associate-*l/50.7%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}}} \]
      2. *-lft-identity50.7%

        \[\leadsto \frac{\color{blue}{\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      3. associate-+r+50.7%

        \[\leadsto \frac{\color{blue}{\left(\left(x + x\right) + 1\right)} - \sqrt{\left(x + 1\right) \cdot x}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      4. associate--l+50.7%

        \[\leadsto \frac{\color{blue}{\left(x + x\right) + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      5. count-250.7%

        \[\leadsto \frac{\color{blue}{2 \cdot x} + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      6. distribute-lft1-in50.7%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{\color{blue}{x \cdot x + x}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      7. unpow150.7%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{1}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      8. sqr-pow50.7%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      9. hypot-def68.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \color{blue}{\mathsf{hypot}\left(x, {x}^{\left(\frac{1}{2}\right)}\right)}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      10. metadata-eval68.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, {x}^{\color{blue}{0.5}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      11. unpow1/268.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \color{blue}{\sqrt{x}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      12. +-commutative68.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\color{blue}{\left(1 + x\right)}}^{1.5} + {x}^{1.5}} \]
    9. Simplified68.1%

      \[\leadsto \color{blue}{\frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}} \]
    10. Taylor expanded in x around inf 99.6%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}} \]

    if 1.99999999999999991e-6 < (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x))

    1. Initial program 99.8%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{1 + x} - \sqrt{x} \leq 2 \cdot 10^{-6}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} - \sqrt{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 97.0% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.31:\\ \;\;\;\;{\left(\mathsf{fma}\left(x, 2, 1\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.31) (pow (fma x 2.0 1.0) -2.0) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
	double tmp;
	if (x <= 0.31) {
		tmp = pow(fma(x, 2.0, 1.0), -2.0);
	} else {
		tmp = 0.5 * sqrt((1.0 / x));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (x <= 0.31)
		tmp = fma(x, 2.0, 1.0) ^ -2.0;
	else
		tmp = Float64(0.5 * sqrt(Float64(1.0 / x)));
	end
	return tmp
end
code[x_] := If[LessEqual[x, 0.31], N[Power[N[(x * 2.0 + 1.0), $MachinePrecision], -2.0], $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.31:\\
\;\;\;\;{\left(\mathsf{fma}\left(x, 2, 1\right)\right)}^{-2}\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.309999999999999998

    1. Initial program 99.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--99.8%

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. div-inv99.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
      3. add-sqr-sqrt99.9%

        \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      4. add-sqr-sqrt99.9%

        \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      5. associate--l+99.9%

        \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/99.9%

        \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. *-rgt-identity99.9%

        \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      3. +-commutative99.9%

        \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
      4. associate-+l-99.9%

        \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      5. +-inverses99.9%

        \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
      6. metadata-eval99.9%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
      7. +-commutative99.9%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt99.9%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \cdot \sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      2. sqrt-unprod99.9%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}} \cdot \frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      3. frac-times99.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot 1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}}} \]
      4. metadata-eval99.9%

        \[\leadsto \sqrt{\frac{\color{blue}{1}}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}} \]
      5. +-commutative99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)}} \]
      6. +-commutative99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}} \]
      7. add-sqr-sqrt99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}} \]
      8. sqr-neg99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{x}\right)}}\right)}} \]
      9. sqrt-unprod0.0%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}}\right)}} \]
      10. add-sqr-sqrt94.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\left(-\sqrt{x}\right)}\right)}} \]
      11. sub-neg94.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right)}}} \]
      12. difference-of-squares94.8%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}}} \]
    8. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x + \left(x + 1\right)}}} \]
    9. Applied egg-rr94.8%

      \[\leadsto \color{blue}{{\left(\mathsf{fma}\left(x, 2, 1\right)\right)}^{-2}} \]

    if 0.309999999999999998 < x

    1. Initial program 4.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--4.9%

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. div-inv4.9%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
      3. add-sqr-sqrt5.3%

        \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      4. add-sqr-sqrt5.9%

        \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      5. associate--l+5.9%

        \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. Applied egg-rr5.9%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/5.9%

        \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. *-rgt-identity5.9%

        \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      3. +-commutative5.9%

        \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
      4. associate-+l-99.6%

        \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      5. +-inverses99.6%

        \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
      6. metadata-eval99.6%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
    6. Simplified99.6%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    7. Applied egg-rr50.9%

      \[\leadsto \color{blue}{\frac{1}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)} \]
    8. Step-by-step derivation
      1. associate-*l/51.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}}} \]
      2. *-lft-identity51.1%

        \[\leadsto \frac{\color{blue}{\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      3. associate-+r+51.1%

        \[\leadsto \frac{\color{blue}{\left(\left(x + x\right) + 1\right)} - \sqrt{\left(x + 1\right) \cdot x}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      4. associate--l+51.1%

        \[\leadsto \frac{\color{blue}{\left(x + x\right) + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      5. count-251.1%

        \[\leadsto \frac{\color{blue}{2 \cdot x} + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      6. distribute-lft1-in51.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{\color{blue}{x \cdot x + x}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      7. unpow151.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{1}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      8. sqr-pow51.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      9. hypot-def68.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \color{blue}{\mathsf{hypot}\left(x, {x}^{\left(\frac{1}{2}\right)}\right)}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      10. metadata-eval68.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, {x}^{\color{blue}{0.5}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      11. unpow1/268.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \color{blue}{\sqrt{x}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      12. +-commutative68.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\color{blue}{\left(1 + x\right)}}^{1.5} + {x}^{1.5}} \]
    9. Simplified68.3%

      \[\leadsto \color{blue}{\frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}} \]
    10. Taylor expanded in x around inf 99.2%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.31:\\ \;\;\;\;{\left(\mathsf{fma}\left(x, 2, 1\right)\right)}^{-2}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 4: 97.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.31:\\ \;\;\;\;1 + x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.31) (+ 1.0 (* x -2.0)) (* 0.5 (sqrt (/ 1.0 x)))))
double code(double x) {
	double tmp;
	if (x <= 0.31) {
		tmp = 1.0 + (x * -2.0);
	} else {
		tmp = 0.5 * sqrt((1.0 / x));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.31d0) then
        tmp = 1.0d0 + (x * (-2.0d0))
    else
        tmp = 0.5d0 * sqrt((1.0d0 / x))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.31) {
		tmp = 1.0 + (x * -2.0);
	} else {
		tmp = 0.5 * Math.sqrt((1.0 / x));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.31:
		tmp = 1.0 + (x * -2.0)
	else:
		tmp = 0.5 * math.sqrt((1.0 / x))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.31)
		tmp = Float64(1.0 + Float64(x * -2.0));
	else
		tmp = Float64(0.5 * sqrt(Float64(1.0 / x)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.31)
		tmp = 1.0 + (x * -2.0);
	else
		tmp = 0.5 * sqrt((1.0 / x));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.31], N[(1.0 + N[(x * -2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.31:\\
\;\;\;\;1 + x \cdot -2\\

\mathbf{else}:\\
\;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.309999999999999998

    1. Initial program 99.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--99.8%

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. div-inv99.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
      3. add-sqr-sqrt99.9%

        \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      4. add-sqr-sqrt99.9%

        \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      5. associate--l+99.9%

        \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/99.9%

        \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. *-rgt-identity99.9%

        \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      3. +-commutative99.9%

        \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
      4. associate-+l-99.9%

        \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      5. +-inverses99.9%

        \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
      6. metadata-eval99.9%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
      7. +-commutative99.9%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt99.9%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \cdot \sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      2. sqrt-unprod99.9%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}} \cdot \frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      3. frac-times99.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot 1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}}} \]
      4. metadata-eval99.9%

        \[\leadsto \sqrt{\frac{\color{blue}{1}}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}} \]
      5. +-commutative99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)}} \]
      6. +-commutative99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}} \]
      7. add-sqr-sqrt99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}} \]
      8. sqr-neg99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{x}\right)}}\right)}} \]
      9. sqrt-unprod0.0%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}}\right)}} \]
      10. add-sqr-sqrt94.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\left(-\sqrt{x}\right)}\right)}} \]
      11. sub-neg94.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right)}}} \]
      12. difference-of-squares94.8%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}}} \]
    8. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x + \left(x + 1\right)}}} \]
    9. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(x, 2, 1\right)}} \]
    10. Taylor expanded in x around 0 94.8%

      \[\leadsto \color{blue}{1 + -2 \cdot x} \]

    if 0.309999999999999998 < x

    1. Initial program 4.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--4.9%

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. div-inv4.9%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
      3. add-sqr-sqrt5.3%

        \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      4. add-sqr-sqrt5.9%

        \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      5. associate--l+5.9%

        \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. Applied egg-rr5.9%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/5.9%

        \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. *-rgt-identity5.9%

        \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      3. +-commutative5.9%

        \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
      4. associate-+l-99.6%

        \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      5. +-inverses99.6%

        \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
      6. metadata-eval99.6%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
    6. Simplified99.6%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    7. Applied egg-rr50.9%

      \[\leadsto \color{blue}{\frac{1}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)} \]
    8. Step-by-step derivation
      1. associate-*l/51.1%

        \[\leadsto \color{blue}{\frac{1 \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}}} \]
      2. *-lft-identity51.1%

        \[\leadsto \frac{\color{blue}{\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      3. associate-+r+51.1%

        \[\leadsto \frac{\color{blue}{\left(\left(x + x\right) + 1\right)} - \sqrt{\left(x + 1\right) \cdot x}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      4. associate--l+51.1%

        \[\leadsto \frac{\color{blue}{\left(x + x\right) + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      5. count-251.1%

        \[\leadsto \frac{\color{blue}{2 \cdot x} + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      6. distribute-lft1-in51.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{\color{blue}{x \cdot x + x}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      7. unpow151.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{1}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      8. sqr-pow51.1%

        \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      9. hypot-def68.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \color{blue}{\mathsf{hypot}\left(x, {x}^{\left(\frac{1}{2}\right)}\right)}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      10. metadata-eval68.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, {x}^{\color{blue}{0.5}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      11. unpow1/268.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \color{blue}{\sqrt{x}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
      12. +-commutative68.3%

        \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\color{blue}{\left(1 + x\right)}}^{1.5} + {x}^{1.5}} \]
    9. Simplified68.3%

      \[\leadsto \color{blue}{\frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}} \]
    10. Taylor expanded in x around inf 99.2%

      \[\leadsto \color{blue}{0.5 \cdot \sqrt{\frac{1}{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification97.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.31:\\ \;\;\;\;1 + x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 57.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.365:\\ \;\;\;\;1 + x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{0.5}{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.365) (+ 1.0 (* x -2.0)) (sqrt (/ 0.5 x))))
double code(double x) {
	double tmp;
	if (x <= 0.365) {
		tmp = 1.0 + (x * -2.0);
	} else {
		tmp = sqrt((0.5 / x));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.365d0) then
        tmp = 1.0d0 + (x * (-2.0d0))
    else
        tmp = sqrt((0.5d0 / x))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.365) {
		tmp = 1.0 + (x * -2.0);
	} else {
		tmp = Math.sqrt((0.5 / x));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.365:
		tmp = 1.0 + (x * -2.0)
	else:
		tmp = math.sqrt((0.5 / x))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.365)
		tmp = Float64(1.0 + Float64(x * -2.0));
	else
		tmp = sqrt(Float64(0.5 / x));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.365)
		tmp = 1.0 + (x * -2.0);
	else
		tmp = sqrt((0.5 / x));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.365], N[(1.0 + N[(x * -2.0), $MachinePrecision]), $MachinePrecision], N[Sqrt[N[(0.5 / x), $MachinePrecision]], $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.365:\\
\;\;\;\;1 + x \cdot -2\\

\mathbf{else}:\\
\;\;\;\;\sqrt{\frac{0.5}{x}}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < 0.36499999999999999

    1. Initial program 99.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--99.8%

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. div-inv99.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
      3. add-sqr-sqrt99.9%

        \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      4. add-sqr-sqrt99.9%

        \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      5. associate--l+99.9%

        \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/99.9%

        \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. *-rgt-identity99.9%

        \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      3. +-commutative99.9%

        \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
      4. associate-+l-99.9%

        \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      5. +-inverses99.9%

        \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
      6. metadata-eval99.9%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
      7. +-commutative99.9%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
    6. Simplified99.9%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt99.9%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \cdot \sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      2. sqrt-unprod99.9%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}} \cdot \frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      3. frac-times99.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot 1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}}} \]
      4. metadata-eval99.9%

        \[\leadsto \sqrt{\frac{\color{blue}{1}}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}} \]
      5. +-commutative99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)}} \]
      6. +-commutative99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}} \]
      7. add-sqr-sqrt99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}} \]
      8. sqr-neg99.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{x}\right)}}\right)}} \]
      9. sqrt-unprod0.0%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}}\right)}} \]
      10. add-sqr-sqrt94.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\left(-\sqrt{x}\right)}\right)}} \]
      11. sub-neg94.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right)}}} \]
      12. difference-of-squares94.8%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}}} \]
    8. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x + \left(x + 1\right)}}} \]
    9. Applied egg-rr94.8%

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(x, 2, 1\right)}} \]
    10. Taylor expanded in x around 0 94.8%

      \[\leadsto \color{blue}{1 + -2 \cdot x} \]

    if 0.36499999999999999 < x

    1. Initial program 4.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip--4.9%

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. div-inv4.9%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
      3. add-sqr-sqrt5.3%

        \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      4. add-sqr-sqrt5.9%

        \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
      5. associate--l+5.9%

        \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. Applied egg-rr5.9%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    5. Step-by-step derivation
      1. associate-*r/5.9%

        \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. *-rgt-identity5.9%

        \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      3. +-commutative5.9%

        \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
      4. associate-+l-99.6%

        \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
      5. +-inverses99.6%

        \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
      6. metadata-eval99.6%

        \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
      7. +-commutative99.6%

        \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
    6. Simplified99.6%

      \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
    7. Step-by-step derivation
      1. add-sqr-sqrt99.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \cdot \sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      2. sqrt-unprod99.6%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{\sqrt{1 + x} + \sqrt{x}} \cdot \frac{1}{\sqrt{1 + x} + \sqrt{x}}}} \]
      3. frac-times98.9%

        \[\leadsto \sqrt{\color{blue}{\frac{1 \cdot 1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}}} \]
      4. metadata-eval98.9%

        \[\leadsto \sqrt{\frac{\color{blue}{1}}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{1 + x} + \sqrt{x}\right)}} \]
      5. +-commutative98.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{1 + x} + \sqrt{x}\right) \cdot \left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right)}} \]
      6. +-commutative98.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{\color{blue}{x + 1}} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)}} \]
      7. add-sqr-sqrt98.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}\right)}} \]
      8. sqr-neg98.9%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \sqrt{\color{blue}{\left(-\sqrt{x}\right) \cdot \left(-\sqrt{x}\right)}}\right)}} \]
      9. sqrt-unprod0.0%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}}\right)}} \]
      10. add-sqr-sqrt2.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \left(\sqrt{x + 1} + \color{blue}{\left(-\sqrt{x}\right)}\right)}} \]
      11. sub-neg2.8%

        \[\leadsto \sqrt{\frac{1}{\left(\sqrt{x + 1} + \sqrt{x}\right) \cdot \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right)}}} \]
      12. difference-of-squares2.8%

        \[\leadsto \sqrt{\frac{1}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}}} \]
    8. Applied egg-rr20.3%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x + \left(x + 1\right)}}} \]
    9. Taylor expanded in x around inf 20.3%

      \[\leadsto \sqrt{\color{blue}{\frac{0.5}{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification54.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.365:\\ \;\;\;\;1 + x \cdot -2\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\frac{0.5}{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 3.5% accurate, 205.0× speedup?

\[\begin{array}{l} \\ 0 \end{array} \]
(FPCore (x) :precision binary64 0.0)
double code(double x) {
	return 0.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.0d0
end function
public static double code(double x) {
	return 0.0;
}
def code(x):
	return 0.0
function code(x)
	return 0.0
end
function tmp = code(x)
	tmp = 0.0;
end
code[x_] := 0.0
\begin{array}{l}

\\
0
\end{array}
Derivation
  1. Initial program 49.1%

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. add-cbrt-cube49.0%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\sqrt{x + 1} - \sqrt{x}\right) \cdot \left(\sqrt{x + 1} - \sqrt{x}\right)\right) \cdot \left(\sqrt{x + 1} - \sqrt{x}\right)}} \]
    2. pow349.0%

      \[\leadsto \sqrt[3]{\color{blue}{{\left(\sqrt{x + 1} - \sqrt{x}\right)}^{3}}} \]
  4. Applied egg-rr49.0%

    \[\leadsto \color{blue}{\sqrt[3]{{\left(\sqrt{x + 1} - \sqrt{x}\right)}^{3}}} \]
  5. Step-by-step derivation
    1. flip--49.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
    2. div-inv49.0%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    3. add-sqr-sqrt49.3%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. add-sqr-sqrt49.6%

      \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    5. associate--l+49.6%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
  6. Applied egg-rr49.6%

    \[\leadsto \sqrt[3]{{\color{blue}{\left(\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}\right)}}^{3}} \]
  7. Step-by-step derivation
    1. associate-*r/49.6%

      \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
    2. *-rgt-identity49.6%

      \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
    3. +-commutative49.6%

      \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
    4. associate-+l-99.7%

      \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
    5. +-inverses99.7%

      \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
    6. metadata-eval99.7%

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
    7. +-commutative99.7%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
  8. Simplified84.4%

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

    \[\leadsto \color{blue}{1} \]
  10. Simplified3.5%

    \[\leadsto \color{blue}{0} \]
  11. Final simplification3.5%

    \[\leadsto 0 \]
  12. Add Preprocessing

Alternative 7: 13.2% accurate, 205.0× speedup?

\[\begin{array}{l} \\ 0.6666666666666666 \end{array} \]
(FPCore (x) :precision binary64 0.6666666666666666)
double code(double x) {
	return 0.6666666666666666;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 0.6666666666666666d0
end function
public static double code(double x) {
	return 0.6666666666666666;
}
def code(x):
	return 0.6666666666666666
function code(x)
	return 0.6666666666666666
end
function tmp = code(x)
	tmp = 0.6666666666666666;
end
code[x_] := 0.6666666666666666
\begin{array}{l}

\\
0.6666666666666666
\end{array}
Derivation
  1. Initial program 49.1%

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip--49.0%

      \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
    2. div-inv49.0%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
    3. add-sqr-sqrt49.3%

      \[\leadsto \left(\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    4. add-sqr-sqrt49.6%

      \[\leadsto \left(\left(x + 1\right) - \color{blue}{x}\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
    5. associate--l+49.6%

      \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right)} \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}} \]
  4. Applied egg-rr49.6%

    \[\leadsto \color{blue}{\left(x + \left(1 - x\right)\right) \cdot \frac{1}{\sqrt{x + 1} + \sqrt{x}}} \]
  5. Step-by-step derivation
    1. associate-*r/49.6%

      \[\leadsto \color{blue}{\frac{\left(x + \left(1 - x\right)\right) \cdot 1}{\sqrt{x + 1} + \sqrt{x}}} \]
    2. *-rgt-identity49.6%

      \[\leadsto \frac{\color{blue}{x + \left(1 - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
    3. +-commutative49.6%

      \[\leadsto \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} + \sqrt{x}} \]
    4. associate-+l-99.7%

      \[\leadsto \frac{\color{blue}{1 - \left(x - x\right)}}{\sqrt{x + 1} + \sqrt{x}} \]
    5. +-inverses99.7%

      \[\leadsto \frac{1 - \color{blue}{0}}{\sqrt{x + 1} + \sqrt{x}} \]
    6. metadata-eval99.7%

      \[\leadsto \frac{\color{blue}{1}}{\sqrt{x + 1} + \sqrt{x}} \]
    7. +-commutative99.7%

      \[\leadsto \frac{1}{\sqrt{\color{blue}{1 + x}} + \sqrt{x}} \]
  6. Simplified99.7%

    \[\leadsto \color{blue}{\frac{1}{\sqrt{1 + x} + \sqrt{x}}} \]
  7. Applied egg-rr73.7%

    \[\leadsto \color{blue}{\frac{1}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)} \]
  8. Step-by-step derivation
    1. associate-*l/73.8%

      \[\leadsto \color{blue}{\frac{1 \cdot \left(\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}}} \]
    2. *-lft-identity73.8%

      \[\leadsto \frac{\color{blue}{\left(x + \left(x + 1\right)\right) - \sqrt{\left(x + 1\right) \cdot x}}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    3. associate-+r+73.8%

      \[\leadsto \frac{\color{blue}{\left(\left(x + x\right) + 1\right)} - \sqrt{\left(x + 1\right) \cdot x}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    4. associate--l+73.8%

      \[\leadsto \frac{\color{blue}{\left(x + x\right) + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    5. count-273.8%

      \[\leadsto \frac{\color{blue}{2 \cdot x} + \left(1 - \sqrt{\left(x + 1\right) \cdot x}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    6. distribute-lft1-in73.8%

      \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{\color{blue}{x \cdot x + x}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    7. unpow173.8%

      \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{1}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    8. sqr-pow73.8%

      \[\leadsto \frac{2 \cdot x + \left(1 - \sqrt{x \cdot x + \color{blue}{{x}^{\left(\frac{1}{2}\right)} \cdot {x}^{\left(\frac{1}{2}\right)}}}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    9. hypot-def83.0%

      \[\leadsto \frac{2 \cdot x + \left(1 - \color{blue}{\mathsf{hypot}\left(x, {x}^{\left(\frac{1}{2}\right)}\right)}\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    10. metadata-eval83.0%

      \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, {x}^{\color{blue}{0.5}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    11. unpow1/283.0%

      \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \color{blue}{\sqrt{x}}\right)\right)}{{\left(x + 1\right)}^{1.5} + {x}^{1.5}} \]
    12. +-commutative83.0%

      \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\color{blue}{\left(1 + x\right)}}^{1.5} + {x}^{1.5}} \]
  9. Simplified83.0%

    \[\leadsto \color{blue}{\frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{{\left(1 + x\right)}^{1.5} + {x}^{1.5}}} \]
  10. Taylor expanded in x around 0 53.3%

    \[\leadsto \frac{2 \cdot x + \left(1 - \mathsf{hypot}\left(x, \sqrt{x}\right)\right)}{\color{blue}{\left(1 + 1.5 \cdot x\right)} + {x}^{1.5}} \]
  11. Taylor expanded in x around inf 12.7%

    \[\leadsto \color{blue}{0.6666666666666666} \]
  12. Final simplification12.7%

    \[\leadsto 0.6666666666666666 \]
  13. Add Preprocessing

Alternative 8: 50.8% accurate, 205.0× speedup?

\[\begin{array}{l} \\ 1 \end{array} \]
(FPCore (x) :precision binary64 1.0)
double code(double x) {
	return 1.0;
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0
end function
public static double code(double x) {
	return 1.0;
}
def code(x):
	return 1.0
function code(x)
	return 1.0
end
function tmp = code(x)
	tmp = 1.0;
end
code[x_] := 1.0
\begin{array}{l}

\\
1
\end{array}
Derivation
  1. Initial program 49.1%

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Add Preprocessing
  3. Taylor expanded in x around 0 47.6%

    \[\leadsto \color{blue}{1} \]
  4. Final simplification47.6%

    \[\leadsto 1 \]
  5. Add Preprocessing

Developer target: 99.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{1}{\sqrt{x + 1} + \sqrt{x}} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (+ (sqrt (+ x 1.0)) (sqrt x))))
double code(double x) {
	return 1.0 / (sqrt((x + 1.0)) + sqrt(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 / (sqrt((x + 1.0d0)) + sqrt(x))
end function
public static double code(double x) {
	return 1.0 / (Math.sqrt((x + 1.0)) + Math.sqrt(x));
}
def code(x):
	return 1.0 / (math.sqrt((x + 1.0)) + math.sqrt(x))
function code(x)
	return Float64(1.0 / Float64(sqrt(Float64(x + 1.0)) + sqrt(x)))
end
function tmp = code(x)
	tmp = 1.0 / (sqrt((x + 1.0)) + sqrt(x));
end
code[x_] := N[(1.0 / N[(N[Sqrt[N[(x + 1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\sqrt{x + 1} + \sqrt{x}}
\end{array}

Reproduce

?
herbie shell --seed 2024019 
(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)))