Main:bigenough3 from C

Percentage Accurate: 54.0% → 99.8%
Time: 8.5s
Alternatives: 12
Speedup: 1.8×

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 12 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: 54.0% 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 + \left(x - x\right)}{\sqrt{1 + x} + \sqrt{x}} \end{array} \]
(FPCore (x)
 :precision binary64
 (/ (+ 1.0 (- x x)) (+ (sqrt (+ 1.0 x)) (sqrt x))))
double code(double x) {
	return (1.0 + (x - x)) / (sqrt((1.0 + x)) + sqrt(x));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (1.0d0 + (x - x)) / (sqrt((1.0d0 + x)) + sqrt(x))
end function
public static double code(double x) {
	return (1.0 + (x - x)) / (Math.sqrt((1.0 + x)) + Math.sqrt(x));
}
def code(x):
	return (1.0 + (x - x)) / (math.sqrt((1.0 + x)) + math.sqrt(x))
function code(x)
	return Float64(Float64(1.0 + Float64(x - x)) / Float64(sqrt(Float64(1.0 + x)) + sqrt(x)))
end
function tmp = code(x)
	tmp = (1.0 + (x - x)) / (sqrt((1.0 + x)) + sqrt(x));
end
code[x_] := N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1 + \left(x - x\right)}{\sqrt{1 + x} + \sqrt{x}}
\end{array}
Derivation
  1. Initial program 56.8%

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

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

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

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

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

      \[\leadsto \frac{\left(x + 1\right) - {\left(-\sqrt{x}\right)}^{1} \cdot \color{blue}{{\left(-\sqrt{x}\right)}^{1}}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
    6. pow-prod-up57.1%

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

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

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

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

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

      \[\leadsto \frac{\left(x + 1\right) - \color{blue}{x}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
    4. *-un-lft-identity57.4%

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

      \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - 1 \cdot x}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
    6. *-un-lft-identity57.4%

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

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

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

    \[\leadsto \frac{1 + \left(x - x\right)}{\sqrt{1 + x} + \sqrt{x}} \]
  8. Add Preprocessing

Alternative 2: 99.8% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{1 + x}\\ \mathbf{if}\;t\_0 - \sqrt{x} \leq 0:\\ \;\;\;\;\frac{1 + \left(x - x\right)}{\sqrt{x} + \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(1 - x\right)}{t\_0 + \sqrt{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (+ 1.0 x))))
   (if (<= (- t_0 (sqrt x)) 0.0)
     (/ (+ 1.0 (- x x)) (+ (sqrt x) (sqrt x)))
     (/ (+ x (- 1.0 x)) (+ t_0 (sqrt x))))))
double code(double x) {
	double t_0 = sqrt((1.0 + x));
	double tmp;
	if ((t_0 - sqrt(x)) <= 0.0) {
		tmp = (1.0 + (x - x)) / (sqrt(x) + sqrt(x));
	} else {
		tmp = (x + (1.0 - x)) / (t_0 + sqrt(x));
	}
	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))
    if ((t_0 - sqrt(x)) <= 0.0d0) then
        tmp = (1.0d0 + (x - x)) / (sqrt(x) + sqrt(x))
    else
        tmp = (x + (1.0d0 - x)) / (t_0 + sqrt(x))
    end if
    code = tmp
end function
public static double code(double x) {
	double t_0 = Math.sqrt((1.0 + x));
	double tmp;
	if ((t_0 - Math.sqrt(x)) <= 0.0) {
		tmp = (1.0 + (x - x)) / (Math.sqrt(x) + Math.sqrt(x));
	} else {
		tmp = (x + (1.0 - x)) / (t_0 + Math.sqrt(x));
	}
	return tmp;
}
def code(x):
	t_0 = math.sqrt((1.0 + x))
	tmp = 0
	if (t_0 - math.sqrt(x)) <= 0.0:
		tmp = (1.0 + (x - x)) / (math.sqrt(x) + math.sqrt(x))
	else:
		tmp = (x + (1.0 - x)) / (t_0 + math.sqrt(x))
	return tmp
function code(x)
	t_0 = sqrt(Float64(1.0 + x))
	tmp = 0.0
	if (Float64(t_0 - sqrt(x)) <= 0.0)
		tmp = Float64(Float64(1.0 + Float64(x - x)) / Float64(sqrt(x) + sqrt(x)));
	else
		tmp = Float64(Float64(x + Float64(1.0 - x)) / Float64(t_0 + sqrt(x)));
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = sqrt((1.0 + x));
	tmp = 0.0;
	if ((t_0 - sqrt(x)) <= 0.0)
		tmp = (1.0 + (x - x)) / (sqrt(x) + sqrt(x));
	else
		tmp = (x + (1.0 - x)) / (t_0 + sqrt(x));
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], 0.0], N[(N[(1.0 + N[(x - x), $MachinePrecision]), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(1.0 - x), $MachinePrecision]), $MachinePrecision] / N[(t$95$0 + N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;t\_0 - \sqrt{x} \leq 0:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\sqrt{x} + \sqrt{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{x + \left(1 - x\right)}{t\_0 + \sqrt{x}}\\


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

    1. Initial program 3.8%

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

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

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

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

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

        \[\leadsto \frac{\left(x + 1\right) - {\left(-\sqrt{x}\right)}^{1} \cdot \color{blue}{{\left(-\sqrt{x}\right)}^{1}}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
      6. pow-prod-up3.5%

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

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

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

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

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

        \[\leadsto \frac{\left(x + 1\right) - \color{blue}{x}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
      4. *-un-lft-identity3.8%

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

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - 1 \cdot x}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
      6. *-un-lft-identity3.8%

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

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

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

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

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

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

        \[\leadsto \frac{1 + \left(x - x\right)}{{\color{blue}{\left({\left(x + 1\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} - \left(-\sqrt{x}\right)} \]
      5. metadata-eval99.3%

        \[\leadsto \frac{1 + \left(x - x\right)}{{\left({\left(x + 1\right)}^{\color{blue}{0.25}}\right)}^{2} - \left(-\sqrt{x}\right)} \]
    8. Applied egg-rr99.3%

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

      \[\leadsto \frac{1 + \left(x - x\right)}{\color{blue}{\sqrt{x}} - \left(-\sqrt{x}\right)} \]

    if 0.0 < (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x))

    1. Initial program 98.8%

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

        \[\leadsto \color{blue}{\frac{\sqrt{x + 1} \cdot \sqrt{x + 1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x + 1} + \sqrt{x}}} \]
      2. add-sqr-sqrt99.3%

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

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

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

      \[\leadsto \color{blue}{\frac{x + \left(1 - x\right)}{\sqrt{x + 1} + \sqrt{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{1 + x} - \sqrt{x} \leq 0:\\ \;\;\;\;\frac{1 + \left(x - x\right)}{\sqrt{x} + \sqrt{x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{x + \left(1 - x\right)}{\sqrt{1 + x} + \sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 99.2% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;t\_0 - \sqrt{x} \leq 2 \cdot 10^{-7}:\\
\;\;\;\;\frac{1 + \left(x - x\right)}{\sqrt{x} + \sqrt{x}}\\

\mathbf{else}:\\
\;\;\;\;t\_0 - \frac{x}{\sqrt{x}}\\


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

    1. Initial program 4.2%

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

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

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

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

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

        \[\leadsto \frac{\left(x + 1\right) - {\left(-\sqrt{x}\right)}^{1} \cdot \color{blue}{{\left(-\sqrt{x}\right)}^{1}}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
      6. pow-prod-up4.6%

        \[\leadsto \frac{\left(x + 1\right) - \color{blue}{{\left(-\sqrt{x}\right)}^{\left(1 + 1\right)}}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
      7. metadata-eval4.6%

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

      \[\leadsto \color{blue}{\frac{\left(x + 1\right) - {\left(-\sqrt{x}\right)}^{2}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)}} \]
    5. Step-by-step derivation
      1. unpow24.6%

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

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

        \[\leadsto \frac{\left(x + 1\right) - \color{blue}{x}}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
      4. *-un-lft-identity5.4%

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

        \[\leadsto \frac{\color{blue}{\left(1 + x\right)} - 1 \cdot x}{\sqrt{x + 1} - \left(-\sqrt{x}\right)} \]
      6. *-un-lft-identity5.4%

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

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

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

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

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

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

        \[\leadsto \frac{1 + \left(x - x\right)}{{\color{blue}{\left({\left(x + 1\right)}^{\left(\frac{0.5}{2}\right)}\right)}}^{2} - \left(-\sqrt{x}\right)} \]
      5. metadata-eval99.3%

        \[\leadsto \frac{1 + \left(x - x\right)}{{\left({\left(x + 1\right)}^{\color{blue}{0.25}}\right)}^{2} - \left(-\sqrt{x}\right)} \]
    8. Applied egg-rr99.3%

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

      \[\leadsto \frac{1 + \left(x - x\right)}{\color{blue}{\sqrt{x}} - \left(-\sqrt{x}\right)} \]

    if 1.9999999999999999e-7 < (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x))

    1. Initial program 99.7%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
    4. Step-by-step derivation
      1. sub-neg99.7%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
      2. associate-+l+99.7%

        \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
      3. fma-undefine99.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
      4. +-commutative99.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
      5. *-commutative99.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
      6. distribute-rgt-neg-out99.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
      7. distribute-lft-neg-out99.7%

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

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

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      10. unsub-neg99.7%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      11. +-inverses99.7%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      12. +-commutative99.7%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
      13. +-rgt-identity99.7%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
      14. distribute-lft-neg-out99.7%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
      15. unsub-neg99.7%

        \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
      16. *-commutative99.7%

        \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    5. Simplified99.7%

      \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    6. Step-by-step derivation
      1. pow1/399.7%

        \[\leadsto \sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \color{blue}{{x}^{0.3333333333333333}} \]
      2. pow-prod-up99.7%

        \[\leadsto \sqrt{1 + x} - \color{blue}{{x}^{\left(0.16666666666666666 + 0.3333333333333333\right)}} \]
      3. metadata-eval99.7%

        \[\leadsto \sqrt{1 + x} - {x}^{\color{blue}{0.5}} \]
      4. pow1/299.7%

        \[\leadsto \sqrt{1 + x} - \color{blue}{\sqrt{x}} \]
      5. add-sqr-sqrt99.7%

        \[\leadsto \sqrt{1 + x} - \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}} \]
      6. sqr-neg99.7%

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

        \[\leadsto \sqrt{1 + x} - \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}} \]
      8. add-sqr-sqrt91.8%

        \[\leadsto \sqrt{1 + x} - \color{blue}{\left(-\sqrt{x}\right)} \]
      9. neg-sub091.8%

        \[\leadsto \sqrt{1 + x} - \color{blue}{\left(0 - \sqrt{x}\right)} \]
      10. flip--91.8%

        \[\leadsto \sqrt{1 + x} - \color{blue}{\frac{0 \cdot 0 - \sqrt{x} \cdot \sqrt{x}}{0 + \sqrt{x}}} \]
      11. metadata-eval91.8%

        \[\leadsto \sqrt{1 + x} - \frac{\color{blue}{0} - \sqrt{x} \cdot \sqrt{x}}{0 + \sqrt{x}} \]
      12. add-sqr-sqrt91.8%

        \[\leadsto \sqrt{1 + x} - \frac{0 - \color{blue}{x}}{0 + \sqrt{x}} \]
      13. neg-sub091.8%

        \[\leadsto \sqrt{1 + x} - \frac{\color{blue}{-x}}{0 + \sqrt{x}} \]
      14. add-sqr-sqrt91.8%

        \[\leadsto \sqrt{1 + x} - \frac{-\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{0 + \sqrt{x}} \]
      15. distribute-lft-neg-in91.8%

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

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

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

        \[\leadsto \sqrt{1 + x} - \frac{\sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}} \cdot \sqrt{x}}{0 + \sqrt{x}} \]
      19. add-sqr-sqrt99.8%

        \[\leadsto \sqrt{1 + x} - \frac{\sqrt{\color{blue}{x}} \cdot \sqrt{x}}{0 + \sqrt{x}} \]
      20. add-sqr-sqrt99.8%

        \[\leadsto \sqrt{1 + x} - \frac{\color{blue}{x}}{0 + \sqrt{x}} \]
      21. add-sqr-sqrt99.8%

        \[\leadsto \sqrt{1 + x} - \frac{x}{0 + \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}} \]
      22. sqr-neg99.8%

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

        \[\leadsto \sqrt{1 + x} - \frac{x}{0 + \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}}} \]
      24. add-sqr-sqrt91.8%

        \[\leadsto \sqrt{1 + x} - \frac{x}{0 + \color{blue}{\left(-\sqrt{x}\right)}} \]
      25. sub-neg91.8%

        \[\leadsto \sqrt{1 + x} - \frac{x}{\color{blue}{0 - \sqrt{x}}} \]
      26. neg-sub091.8%

        \[\leadsto \sqrt{1 + x} - \frac{x}{\color{blue}{-\sqrt{x}}} \]
      27. add-sqr-sqrt0.0%

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

      \[\leadsto \sqrt{1 + x} - \color{blue}{\frac{x}{\sqrt{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.6%

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

Alternative 4: 61.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{1 + x}\\ \mathbf{if}\;t\_0 - \sqrt{x} \leq 0:\\ \;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\ \mathbf{else}:\\ \;\;\;\;t\_0 - \frac{x}{\sqrt{x}}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (+ 1.0 x))))
   (if (<= (- t_0 (sqrt x)) 0.0)
     (/ -1.0 (- (sqrt (+ 1.0 (+ x x)))))
     (- t_0 (/ x (sqrt x))))))
double code(double x) {
	double t_0 = sqrt((1.0 + x));
	double tmp;
	if ((t_0 - sqrt(x)) <= 0.0) {
		tmp = -1.0 / -sqrt((1.0 + (x + x)));
	} else {
		tmp = t_0 - (x / sqrt(x));
	}
	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))
    if ((t_0 - sqrt(x)) <= 0.0d0) then
        tmp = (-1.0d0) / -sqrt((1.0d0 + (x + x)))
    else
        tmp = t_0 - (x / sqrt(x))
    end if
    code = tmp
end function
public static double code(double x) {
	double t_0 = Math.sqrt((1.0 + x));
	double tmp;
	if ((t_0 - Math.sqrt(x)) <= 0.0) {
		tmp = -1.0 / -Math.sqrt((1.0 + (x + x)));
	} else {
		tmp = t_0 - (x / Math.sqrt(x));
	}
	return tmp;
}
def code(x):
	t_0 = math.sqrt((1.0 + x))
	tmp = 0
	if (t_0 - math.sqrt(x)) <= 0.0:
		tmp = -1.0 / -math.sqrt((1.0 + (x + x)))
	else:
		tmp = t_0 - (x / math.sqrt(x))
	return tmp
function code(x)
	t_0 = sqrt(Float64(1.0 + x))
	tmp = 0.0
	if (Float64(t_0 - sqrt(x)) <= 0.0)
		tmp = Float64(-1.0 / Float64(-sqrt(Float64(1.0 + Float64(x + x)))));
	else
		tmp = Float64(t_0 - Float64(x / sqrt(x)));
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = sqrt((1.0 + x));
	tmp = 0.0;
	if ((t_0 - sqrt(x)) <= 0.0)
		tmp = -1.0 / -sqrt((1.0 + (x + x)));
	else
		tmp = t_0 - (x / sqrt(x));
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 + x), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(t$95$0 - N[Sqrt[x], $MachinePrecision]), $MachinePrecision], 0.0], N[(-1.0 / (-N[Sqrt[N[(1.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], N[(t$95$0 - N[(x / N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{1 + x}\\
\mathbf{if}\;t\_0 - \sqrt{x} \leq 0:\\
\;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\

\mathbf{else}:\\
\;\;\;\;t\_0 - \frac{x}{\sqrt{x}}\\


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

    1. Initial program 3.8%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr5.8%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
    4. Step-by-step derivation
      1. sub-neg5.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
      2. associate-+l+5.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
      3. fma-undefine5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
      4. +-commutative5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
      5. *-commutative5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
      6. distribute-rgt-neg-out5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
      7. distribute-lft-neg-out5.8%

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

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

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      10. unsub-neg5.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      11. +-inverses5.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      12. +-commutative5.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
      13. +-rgt-identity5.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
      14. distribute-lft-neg-out5.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
      15. unsub-neg5.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
      16. *-commutative5.8%

        \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    5. Simplified5.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    6. Applied egg-rr3.8%

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

      \[\leadsto \frac{\color{blue}{-1}}{-\sqrt{1 + \left(x + x\right)}} \]

    if 0.0 < (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x))

    1. Initial program 98.8%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr98.7%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
    4. Step-by-step derivation
      1. sub-neg98.7%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
      2. associate-+l+98.7%

        \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
      3. fma-undefine98.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
      4. +-commutative98.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
      5. *-commutative98.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
      6. distribute-rgt-neg-out98.7%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
      7. distribute-lft-neg-out98.7%

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

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(\left(-\sqrt{x}\right) + \sqrt{x}\right) + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right)} \]
      9. +-commutative98.7%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      10. unsub-neg98.7%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      11. +-inverses98.7%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      12. +-commutative98.7%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
      13. +-rgt-identity98.7%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
      14. distribute-lft-neg-out98.7%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
      15. unsub-neg98.7%

        \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
      16. *-commutative98.7%

        \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    5. Simplified98.7%

      \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    6. Step-by-step derivation
      1. pow1/398.7%

        \[\leadsto \sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \color{blue}{{x}^{0.3333333333333333}} \]
      2. pow-prod-up98.8%

        \[\leadsto \sqrt{1 + x} - \color{blue}{{x}^{\left(0.16666666666666666 + 0.3333333333333333\right)}} \]
      3. metadata-eval98.8%

        \[\leadsto \sqrt{1 + x} - {x}^{\color{blue}{0.5}} \]
      4. pow1/298.8%

        \[\leadsto \sqrt{1 + x} - \color{blue}{\sqrt{x}} \]
      5. add-sqr-sqrt98.8%

        \[\leadsto \sqrt{1 + x} - \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}} \]
      6. sqr-neg98.8%

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

        \[\leadsto \sqrt{1 + x} - \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}} \]
      8. add-sqr-sqrt90.6%

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

        \[\leadsto \sqrt{1 + x} - \color{blue}{\left(0 - \sqrt{x}\right)} \]
      10. flip--90.6%

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

        \[\leadsto \sqrt{1 + x} - \frac{\color{blue}{0} - \sqrt{x} \cdot \sqrt{x}}{0 + \sqrt{x}} \]
      12. add-sqr-sqrt90.6%

        \[\leadsto \sqrt{1 + x} - \frac{0 - \color{blue}{x}}{0 + \sqrt{x}} \]
      13. neg-sub090.6%

        \[\leadsto \sqrt{1 + x} - \frac{\color{blue}{-x}}{0 + \sqrt{x}} \]
      14. add-sqr-sqrt90.6%

        \[\leadsto \sqrt{1 + x} - \frac{-\color{blue}{\sqrt{x} \cdot \sqrt{x}}}{0 + \sqrt{x}} \]
      15. distribute-lft-neg-in90.6%

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

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

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

        \[\leadsto \sqrt{1 + x} - \frac{\sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}} \cdot \sqrt{x}}{0 + \sqrt{x}} \]
      19. add-sqr-sqrt98.8%

        \[\leadsto \sqrt{1 + x} - \frac{\sqrt{\color{blue}{x}} \cdot \sqrt{x}}{0 + \sqrt{x}} \]
      20. add-sqr-sqrt98.8%

        \[\leadsto \sqrt{1 + x} - \frac{\color{blue}{x}}{0 + \sqrt{x}} \]
      21. add-sqr-sqrt98.8%

        \[\leadsto \sqrt{1 + x} - \frac{x}{0 + \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}}}} \]
      22. sqr-neg98.8%

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

        \[\leadsto \sqrt{1 + x} - \frac{x}{0 + \color{blue}{\sqrt{-\sqrt{x}} \cdot \sqrt{-\sqrt{x}}}} \]
      24. add-sqr-sqrt90.6%

        \[\leadsto \sqrt{1 + x} - \frac{x}{0 + \color{blue}{\left(-\sqrt{x}\right)}} \]
      25. sub-neg90.6%

        \[\leadsto \sqrt{1 + x} - \frac{x}{\color{blue}{0 - \sqrt{x}}} \]
      26. neg-sub090.6%

        \[\leadsto \sqrt{1 + x} - \frac{x}{\color{blue}{-\sqrt{x}}} \]
      27. add-sqr-sqrt0.0%

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

      \[\leadsto \sqrt{1 + x} - \color{blue}{\frac{x}{\sqrt{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification64.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{1 + x} - \sqrt{x} \leq 0:\\ \;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} - \frac{x}{\sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 5: 61.7% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{1 + x} - \sqrt{x}\\ \mathbf{if}\;t\_0 \leq 0:\\ \;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\ \mathbf{else}:\\ \;\;\;\;t\_0\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- (sqrt (+ 1.0 x)) (sqrt x))))
   (if (<= t_0 0.0) (/ -1.0 (- (sqrt (+ 1.0 (+ x x))))) t_0)))
double code(double x) {
	double t_0 = sqrt((1.0 + x)) - sqrt(x);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = -1.0 / -sqrt((1.0 + (x + 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 <= 0.0d0) then
        tmp = (-1.0d0) / -sqrt((1.0d0 + (x + 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 <= 0.0) {
		tmp = -1.0 / -Math.sqrt((1.0 + (x + 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 <= 0.0:
		tmp = -1.0 / -math.sqrt((1.0 + (x + 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 <= 0.0)
		tmp = Float64(-1.0 / Float64(-sqrt(Float64(1.0 + Float64(x + 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 <= 0.0)
		tmp = -1.0 / -sqrt((1.0 + (x + 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, 0.0], N[(-1.0 / (-N[Sqrt[N[(1.0 + N[(x + x), $MachinePrecision]), $MachinePrecision]], $MachinePrecision])), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{1 + x} - \sqrt{x}\\
\mathbf{if}\;t\_0 \leq 0:\\
\;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\

\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)) < 0.0

    1. Initial program 3.8%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr5.8%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
    4. Step-by-step derivation
      1. sub-neg5.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
      2. associate-+l+5.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
      3. fma-undefine5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
      4. +-commutative5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
      5. *-commutative5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
      6. distribute-rgt-neg-out5.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
      7. distribute-lft-neg-out5.8%

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

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

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      10. unsub-neg5.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      11. +-inverses5.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      12. +-commutative5.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
      13. +-rgt-identity5.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
      14. distribute-lft-neg-out5.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
      15. unsub-neg5.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
      16. *-commutative5.8%

        \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    5. Simplified5.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    6. Applied egg-rr3.8%

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

      \[\leadsto \frac{\color{blue}{-1}}{-\sqrt{1 + \left(x + x\right)}} \]

    if 0.0 < (-.f64 (sqrt.f64 (+.f64 x 1)) (sqrt.f64 x))

    1. Initial program 98.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;\sqrt{1 + x} - \sqrt{x} \leq 0:\\ \;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{1 + x} - \sqrt{x}\\ \end{array} \]
  5. Add Preprocessing

Alternative 6: 60.4% accurate, 1.7× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4:\\
\;\;\;\;\frac{x + \left(1 - x\right)}{\sqrt{x} + \left(1 + x \cdot \left(0.5 + x \cdot -0.125\right)\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\


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

    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. add-sqr-sqrt99.9%

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

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

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

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

      \[\leadsto \frac{x + \left(1 - x\right)}{\color{blue}{\left(1 + \left(-0.125 \cdot {x}^{2} + 0.5 \cdot x\right)\right)} + \sqrt{x}} \]
    6. Step-by-step derivation
      1. +-commutative97.4%

        \[\leadsto \left(1 + \color{blue}{\left(0.5 \cdot x + -0.125 \cdot {x}^{2}\right)}\right) - \sqrt{x} \]
      2. unpow297.4%

        \[\leadsto \left(1 + \left(0.5 \cdot x + -0.125 \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - \sqrt{x} \]
      3. associate-*r*97.4%

        \[\leadsto \left(1 + \left(0.5 \cdot x + \color{blue}{\left(-0.125 \cdot x\right) \cdot x}\right)\right) - \sqrt{x} \]
      4. distribute-rgt-out97.4%

        \[\leadsto \left(1 + \color{blue}{x \cdot \left(0.5 + -0.125 \cdot x\right)}\right) - \sqrt{x} \]
      5. *-commutative97.4%

        \[\leadsto \left(1 + x \cdot \left(0.5 + \color{blue}{x \cdot -0.125}\right)\right) - \sqrt{x} \]
    7. Simplified97.4%

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

    if 4 < x

    1. Initial program 4.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr6.8%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
    4. Step-by-step derivation
      1. sub-neg6.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
      2. associate-+l+6.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
      3. fma-undefine6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
      4. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
      5. *-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
      6. distribute-rgt-neg-out6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
      7. distribute-lft-neg-out6.8%

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

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(\left(-\sqrt{x}\right) + \sqrt{x}\right) + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right)} \]
      9. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      10. unsub-neg6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      11. +-inverses6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      12. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
      13. +-rgt-identity6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
      14. distribute-lft-neg-out6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
      15. unsub-neg6.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
      16. *-commutative6.8%

        \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    5. Simplified6.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    6. Applied egg-rr4.2%

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

      \[\leadsto \frac{\color{blue}{-1}}{-\sqrt{1 + \left(x + x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4:\\ \;\;\;\;\frac{x + \left(1 - x\right)}{\sqrt{x} + \left(1 + x \cdot \left(0.5 + x \cdot -0.125\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 7: 60.5% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.55:\\
\;\;\;\;\left(1 + x \cdot \left(0.5 + x \cdot -0.125\right)\right) - \sqrt{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\


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

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(1 + \left(-0.125 \cdot {x}^{2} + 0.5 \cdot x\right)\right)} - \sqrt{x} \]
    4. Step-by-step derivation
      1. +-commutative97.4%

        \[\leadsto \left(1 + \color{blue}{\left(0.5 \cdot x + -0.125 \cdot {x}^{2}\right)}\right) - \sqrt{x} \]
      2. unpow297.4%

        \[\leadsto \left(1 + \left(0.5 \cdot x + -0.125 \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) - \sqrt{x} \]
      3. associate-*r*97.4%

        \[\leadsto \left(1 + \left(0.5 \cdot x + \color{blue}{\left(-0.125 \cdot x\right) \cdot x}\right)\right) - \sqrt{x} \]
      4. distribute-rgt-out97.4%

        \[\leadsto \left(1 + \color{blue}{x \cdot \left(0.5 + -0.125 \cdot x\right)}\right) - \sqrt{x} \]
      5. *-commutative97.4%

        \[\leadsto \left(1 + x \cdot \left(0.5 + \color{blue}{x \cdot -0.125}\right)\right) - \sqrt{x} \]
    5. Simplified97.4%

      \[\leadsto \color{blue}{\left(1 + x \cdot \left(0.5 + x \cdot -0.125\right)\right)} - \sqrt{x} \]

    if 1.55000000000000004 < x

    1. Initial program 4.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr6.8%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
    4. Step-by-step derivation
      1. sub-neg6.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
      2. associate-+l+6.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
      3. fma-undefine6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
      4. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
      5. *-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
      6. distribute-rgt-neg-out6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
      7. distribute-lft-neg-out6.8%

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

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(\left(-\sqrt{x}\right) + \sqrt{x}\right) + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right)} \]
      9. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      10. unsub-neg6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      11. +-inverses6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      12. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
      13. +-rgt-identity6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
      14. distribute-lft-neg-out6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
      15. unsub-neg6.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
      16. *-commutative6.8%

        \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    5. Simplified6.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    6. Applied egg-rr4.2%

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

      \[\leadsto \frac{\color{blue}{-1}}{-\sqrt{1 + \left(x + x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.55:\\ \;\;\;\;\left(1 + x \cdot \left(0.5 + x \cdot -0.125\right)\right) - \sqrt{x}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 60.3% accurate, 1.8× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.4:\\
\;\;\;\;\left(1 + x \cdot 0.5\right) - \sqrt{x}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{-\sqrt{1 + \left(x + x\right)}}\\


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

    1. Initial program 99.9%

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

      \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} - \sqrt{x} \]

    if 1.3999999999999999 < x

    1. Initial program 4.9%

      \[\sqrt{x + 1} - \sqrt{x} \]
    2. Add Preprocessing
    3. Applied egg-rr6.8%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
    4. Step-by-step derivation
      1. sub-neg6.8%

        \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
      2. associate-+l+6.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
      3. fma-undefine6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
      4. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
      5. *-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
      6. distribute-rgt-neg-out6.8%

        \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
      7. distribute-lft-neg-out6.8%

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

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(\left(-\sqrt{x}\right) + \sqrt{x}\right) + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right)} \]
      9. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      10. unsub-neg6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      11. +-inverses6.8%

        \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
      12. +-commutative6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
      13. +-rgt-identity6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
      14. distribute-lft-neg-out6.8%

        \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
      15. unsub-neg6.8%

        \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
      16. *-commutative6.8%

        \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    5. Simplified6.8%

      \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
    6. Applied egg-rr4.2%

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

      \[\leadsto \frac{\color{blue}{-1}}{-\sqrt{1 + \left(x + x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification62.2%

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

Alternative 9: 52.5% accurate, 1.9× speedup?

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

\\
\left(1 + x \cdot 0.5\right) - \sqrt{x}
\end{array}
Derivation
  1. Initial program 56.8%

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

    \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} - \sqrt{x} \]
  4. Final simplification55.0%

    \[\leadsto \left(1 + x \cdot 0.5\right) - \sqrt{x} \]
  5. Add Preprocessing

Alternative 10: 52.1% accurate, 29.3× speedup?

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

\\
\frac{1}{1 + x \cdot 1.5}
\end{array}
Derivation
  1. Initial program 56.8%

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

      \[\leadsto \color{blue}{{\left(x + 1\right)}^{0.5}} - \sqrt{x} \]
    2. pow156.8%

      \[\leadsto {\color{blue}{\left({\left(x + 1\right)}^{1}\right)}}^{0.5} - \sqrt{x} \]
    3. pow-to-exp56.7%

      \[\leadsto {\color{blue}{\left(e^{\log \left(x + 1\right) \cdot 1}\right)}}^{0.5} - \sqrt{x} \]
    4. pow-exp56.7%

      \[\leadsto \color{blue}{e^{\left(\log \left(x + 1\right) \cdot 1\right) \cdot 0.5}} - \sqrt{x} \]
    5. log1p-expm1-u56.7%

      \[\leadsto e^{\color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\log \left(x + 1\right) \cdot 1\right)\right)} \cdot 0.5} - \sqrt{x} \]
    6. expm1-define56.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{e^{\log \left(x + 1\right) \cdot 1} - 1}\right) \cdot 0.5} - \sqrt{x} \]
    7. pow-exp56.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{\left(e^{\log \left(x + 1\right)}\right)}^{1}} - 1\right) \cdot 0.5} - \sqrt{x} \]
    8. pow156.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{e^{\log \left(x + 1\right)}} - 1\right) \cdot 0.5} - \sqrt{x} \]
    9. expm1-undefine56.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{\mathsf{expm1}\left(\log \left(x + 1\right)\right)}\right) \cdot 0.5} - \sqrt{x} \]
    10. log1p-expm1-u56.7%

      \[\leadsto e^{\color{blue}{\log \left(x + 1\right)} \cdot 0.5} - \sqrt{x} \]
    11. +-commutative56.7%

      \[\leadsto e^{\log \color{blue}{\left(1 + x\right)} \cdot 0.5} - \sqrt{x} \]
    12. log1p-define56.7%

      \[\leadsto e^{\color{blue}{\mathsf{log1p}\left(x\right)} \cdot 0.5} - \sqrt{x} \]
  4. Applied egg-rr56.7%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(x\right) \cdot 0.5}} - \sqrt{x} \]
  5. Taylor expanded in x around 0 55.0%

    \[\leadsto \color{blue}{\left(1 + 0.5 \cdot x\right)} - \sqrt{x} \]
  6. Step-by-step derivation
    1. *-commutative55.0%

      \[\leadsto \left(1 + \color{blue}{x \cdot 0.5}\right) - \sqrt{x} \]
  7. Simplified55.0%

    \[\leadsto \color{blue}{\left(1 + x \cdot 0.5\right)} - \sqrt{x} \]
  8. Applied egg-rr53.8%

    \[\leadsto \color{blue}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x, 0.5, x\right)\right) \cdot -1}} \]
  9. Step-by-step derivation
    1. exp-prod53.8%

      \[\leadsto \color{blue}{{\left(e^{\mathsf{log1p}\left(\mathsf{fma}\left(x, 0.5, x\right)\right)}\right)}^{-1}} \]
    2. unpow-153.8%

      \[\leadsto \color{blue}{\frac{1}{e^{\mathsf{log1p}\left(\mathsf{fma}\left(x, 0.5, x\right)\right)}}} \]
    3. log1p-undefine53.8%

      \[\leadsto \frac{1}{e^{\color{blue}{\log \left(1 + \mathsf{fma}\left(x, 0.5, x\right)\right)}}} \]
    4. rem-exp-log53.8%

      \[\leadsto \frac{1}{\color{blue}{1 + \mathsf{fma}\left(x, 0.5, x\right)}} \]
    5. fma-undefine53.8%

      \[\leadsto \frac{1}{1 + \color{blue}{\left(x \cdot 0.5 + x\right)}} \]
    6. *-commutative53.8%

      \[\leadsto \frac{1}{1 + \left(\color{blue}{0.5 \cdot x} + x\right)} \]
    7. distribute-lft1-in53.8%

      \[\leadsto \frac{1}{1 + \color{blue}{\left(0.5 + 1\right) \cdot x}} \]
    8. metadata-eval53.8%

      \[\leadsto \frac{1}{1 + \color{blue}{1.5} \cdot x} \]
  10. Simplified53.8%

    \[\leadsto \color{blue}{\frac{1}{1 + 1.5 \cdot x}} \]
  11. Final simplification53.8%

    \[\leadsto \frac{1}{1 + x \cdot 1.5} \]
  12. Add Preprocessing

Alternative 11: 52.1% accurate, 41.0× speedup?

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

\\
\frac{-1}{-1 - x}
\end{array}
Derivation
  1. Initial program 56.8%

    \[\sqrt{x + 1} - \sqrt{x} \]
  2. Add Preprocessing
  3. Applied egg-rr57.7%

    \[\leadsto \color{blue}{\left(\sqrt{x + 1} - \sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)} \]
  4. Step-by-step derivation
    1. sub-neg57.7%

      \[\leadsto \color{blue}{\left(\sqrt{x + 1} + \left(-\sqrt{x}\right)\right)} + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right) \]
    2. associate-+l+57.7%

      \[\leadsto \color{blue}{\sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \mathsf{fma}\left(-{x}^{0.16666666666666666}, \sqrt[3]{x}, \sqrt{x}\right)\right)} \]
    3. fma-undefine57.7%

      \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x} + \sqrt{x}\right)}\right) \]
    4. +-commutative57.7%

      \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \color{blue}{\left(\sqrt{x} + \left(-{x}^{0.16666666666666666}\right) \cdot \sqrt[3]{x}\right)}\right) \]
    5. *-commutative57.7%

      \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\sqrt[3]{x} \cdot \left(-{x}^{0.16666666666666666}\right)}\right)\right) \]
    6. distribute-rgt-neg-out57.7%

      \[\leadsto \sqrt{x + 1} + \left(\left(-\sqrt{x}\right) + \left(\sqrt{x} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)}\right)\right) \]
    7. distribute-lft-neg-out57.7%

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

      \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(\left(-\sqrt{x}\right) + \sqrt{x}\right) + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right)} \]
    9. +-commutative57.7%

      \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} + \left(-\sqrt{x}\right)\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
    10. unsub-neg57.7%

      \[\leadsto \sqrt{x + 1} + \left(\color{blue}{\left(\sqrt{x} - \sqrt{x}\right)} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
    11. +-inverses57.7%

      \[\leadsto \sqrt{x + 1} + \left(\color{blue}{0} + \left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}\right) \]
    12. +-commutative57.7%

      \[\leadsto \sqrt{x + 1} + \color{blue}{\left(\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666} + 0\right)} \]
    13. +-rgt-identity57.7%

      \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x}\right) \cdot {x}^{0.16666666666666666}} \]
    14. distribute-lft-neg-out57.7%

      \[\leadsto \sqrt{x + 1} + \color{blue}{\left(-\sqrt[3]{x} \cdot {x}^{0.16666666666666666}\right)} \]
    15. unsub-neg57.7%

      \[\leadsto \color{blue}{\sqrt{x + 1} - \sqrt[3]{x} \cdot {x}^{0.16666666666666666}} \]
    16. *-commutative57.7%

      \[\leadsto \sqrt{x + 1} - \color{blue}{{x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
  5. Simplified57.7%

    \[\leadsto \color{blue}{\sqrt{1 + x} - {x}^{0.16666666666666666} \cdot \sqrt[3]{x}} \]
  6. Applied egg-rr52.5%

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

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

    \[\leadsto \frac{-1}{-\color{blue}{\left(1 + x\right)}} \]
  9. Final simplification53.8%

    \[\leadsto \frac{-1}{-1 - x} \]
  10. Add Preprocessing

Alternative 12: 52.0% 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 56.8%

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

    \[\leadsto \color{blue}{1} \]
  4. Final simplification53.7%

    \[\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 2024039 
(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)))