2isqrt (example 3.6)

Percentage Accurate: 68.8% → 99.5%
Time: 12.7s
Alternatives: 12
Speedup: 1.9×

Specification

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

\\
\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}
\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: 68.8% accurate, 1.0× speedup?

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

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

Alternative 1: 99.5% accurate, 0.5× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;\frac{1}{\sqrt{x}} + \frac{-1}{\sqrt{x + 1}} \leq 10^{-13}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{x \cdot 2 + 1.5}\\

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} - \sqrt{\frac{1}{x + 1}}\\


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

    1. Initial program 34.5%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity34.6%

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity34.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity35.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      3. sub-neg35.7%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      6. *-lft-identity99.3%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      9. distribute-rgt-in99.3%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
      10. rem-square-sqrt99.4%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
      11. +-commutative99.4%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
    10. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    11. Taylor expanded in x around inf 99.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{1.5 + 2 \cdot x}} \]
    12. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{2 \cdot x + 1.5}} \]
      2. *-commutative99.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{x \cdot 2} + 1.5} \]
    13. Simplified99.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{x \cdot 2 + 1.5}} \]

    if 1e-13 < (-.f64 (/.f64 1 (sqrt.f64 x)) (/.f64 1 (sqrt.f64 (+.f64 x 1))))

    1. Initial program 99.2%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. add-sqr-sqrt99.2%

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \sqrt{\color{blue}{\frac{1 \cdot 1}{\sqrt{x + 1} \cdot \sqrt{x + 1}}}} \]
      4. metadata-eval99.2%

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

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

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

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\sqrt{\frac{1}{1 + x}}} \]
    5. Step-by-step derivation
      1. expm1-log1p-u92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-udef91.9%

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{x}^{0.5}}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      4. pow-flip91.9%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{x}^{\left(-0.5\right)}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      5. metadata-eval91.9%

        \[\leadsto \left(e^{\mathsf{log1p}\left({x}^{\color{blue}{-0.5}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
    6. Applied egg-rr91.9%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{-0.5}\right)} - 1\right)} - \sqrt{\frac{1}{1 + x}} \]
    7. Step-by-step derivation
      1. expm1-def92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-log1p99.7%

        \[\leadsto \color{blue}{{x}^{-0.5}} - \sqrt{\frac{1}{1 + x}} \]
    8. Simplified99.7%

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

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

Alternative 2: 99.7% accurate, 0.6× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity63.6%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity63.6%

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  7. Step-by-step derivation
    1. *-un-lft-identity64.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    9. distribute-rgt-in99.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
    10. rem-square-sqrt99.7%

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

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

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

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

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

Alternative 3: 99.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{1 + \left(x + \mathsf{hypot}\left(\sqrt{x}, x\right)\right)}{{x}^{-0.5}}} \end{array} \]
(FPCore (x)
 :precision binary64
 (/ 1.0 (/ (+ 1.0 (+ x (hypot (sqrt x) x))) (pow x -0.5))))
double code(double x) {
	return 1.0 / ((1.0 + (x + hypot(sqrt(x), x))) / pow(x, -0.5));
}
public static double code(double x) {
	return 1.0 / ((1.0 + (x + Math.hypot(Math.sqrt(x), x))) / Math.pow(x, -0.5));
}
def code(x):
	return 1.0 / ((1.0 + (x + math.hypot(math.sqrt(x), x))) / math.pow(x, -0.5))
function code(x)
	return Float64(1.0 / Float64(Float64(1.0 + Float64(x + hypot(sqrt(x), x))) / (x ^ -0.5)))
end
function tmp = code(x)
	tmp = 1.0 / ((1.0 + (x + hypot(sqrt(x), x))) / (x ^ -0.5));
end
code[x_] := N[(1.0 / N[(N[(1.0 + N[(x + N[Sqrt[N[Sqrt[x], $MachinePrecision] ^ 2 + x ^ 2], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[Power[x, -0.5], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{1 + \left(x + \mathsf{hypot}\left(\sqrt{x}, x\right)\right)}{{x}^{-0.5}}}
\end{array}
Derivation
  1. Initial program 63.6%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity63.6%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity63.6%

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  7. Step-by-step derivation
    1. *-un-lft-identity64.3%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
    9. distribute-rgt-in99.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
    10. rem-square-sqrt99.7%

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

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

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

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

      \[\leadsto \color{blue}{\frac{{x}^{-0.5} \cdot \left(1 + x \cdot 0\right)}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    2. clear-num99.0%

      \[\leadsto \color{blue}{\frac{1}{\frac{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}{{x}^{-0.5} \cdot \left(1 + x \cdot 0\right)}}} \]
    3. sqrt-prod88.1%

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

      \[\leadsto \frac{1}{\frac{\color{blue}{1 + \left(x + \sqrt{x \cdot \left(1 + x\right)}\right)}}{{x}^{-0.5} \cdot \left(1 + x \cdot 0\right)}} \]
    5. distribute-rgt-in88.1%

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

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

      \[\leadsto \frac{1}{\frac{1 + \left(x + \sqrt{\color{blue}{\sqrt{x} \cdot \sqrt{x}} + x \cdot x}\right)}{{x}^{-0.5} \cdot \left(1 + x \cdot 0\right)}} \]
    8. hypot-def99.1%

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

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

      \[\leadsto \frac{1}{\frac{1 + \left(x + \mathsf{hypot}\left(\sqrt{x}, x\right)\right)}{{x}^{-0.5} \cdot \color{blue}{1}}} \]
    11. *-rgt-identity99.1%

      \[\leadsto \frac{1}{\frac{1 + \left(x + \mathsf{hypot}\left(\sqrt{x}, x\right)\right)}{\color{blue}{{x}^{-0.5}}}} \]
  12. Applied egg-rr99.1%

    \[\leadsto \color{blue}{\frac{1}{\frac{1 + \left(x + \mathsf{hypot}\left(\sqrt{x}, x\right)\right)}{{x}^{-0.5}}}} \]
  13. Final simplification99.1%

    \[\leadsto \frac{1}{\frac{1 + \left(x + \mathsf{hypot}\left(\sqrt{x}, x\right)\right)}{{x}^{-0.5}}} \]
  14. Add Preprocessing

Alternative 4: 99.7% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{x \cdot 2 + 1.5}\\


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

    1. Initial program 99.2%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity99.2%

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.2%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.2%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity99.2%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg99.2%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. inv-pow99.2%

        \[\leadsto \left(1 \cdot \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. *-un-lft-identity99.2%

        \[\leadsto \left(\color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      9. sqrt-pow299.7%

        \[\leadsto \left(\color{blue}{{x}^{\left(\frac{-1}{2}\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      10. metadata-eval99.7%

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. inv-pow99.7%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(\sqrt{x + 1}\right)}^{-1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. sqrt-pow299.7%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative99.7%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval99.7%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    4. Applied egg-rr99.7%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    5. Step-by-step derivation
      1. +-commutative99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right) + \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right)} \]
      2. sub-neg99.7%

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

        \[\leadsto \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. distribute-lft1-in99.7%

        \[\leadsto \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      5. metadata-eval99.7%

        \[\leadsto \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      6. mul0-lft99.7%

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

        \[\leadsto 0 + \color{blue}{\left(\left(-{\left(1 + x\right)}^{-0.5}\right) + {x}^{-0.5}\right)} \]
      8. associate-+r+99.7%

        \[\leadsto \color{blue}{\left(0 + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) + {x}^{-0.5}} \]
      9. sub-neg99.7%

        \[\leadsto \color{blue}{\left(0 - {\left(1 + x\right)}^{-0.5}\right)} + {x}^{-0.5} \]
      10. neg-sub099.7%

        \[\leadsto \color{blue}{\left(-{\left(1 + x\right)}^{-0.5}\right)} + {x}^{-0.5} \]
      11. +-commutative99.7%

        \[\leadsto \color{blue}{{x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)} \]
      12. sub-neg99.7%

        \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Simplified99.7%

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

    if 84000 < x

    1. Initial program 34.5%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity34.6%

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity34.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity35.7%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      3. sub-neg35.7%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      6. *-lft-identity99.3%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      9. distribute-rgt-in99.3%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
      10. rem-square-sqrt99.4%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
      11. +-commutative99.4%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
    10. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    11. Taylor expanded in x around inf 99.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{1.5 + 2 \cdot x}} \]
    12. Step-by-step derivation
      1. +-commutative99.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{2 \cdot x + 1.5}} \]
      2. *-commutative99.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{x \cdot 2} + 1.5} \]
    13. Simplified99.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{x \cdot 2 + 1.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.7%

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

Alternative 5: 99.2% accurate, 1.6× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{1.5 + \left(x \cdot 2 - \frac{0.125}{x}\right)}\\


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

    1. Initial program 99.5%

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{\left(x \cdot x\right)} \cdot 0.375\right)\right) \]
      4. associate-*l*99.1%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{x \cdot \left(x \cdot 0.375\right)}\right)\right) \]
      5. distribute-lft-out99.1%

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

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(1 + x \cdot \left(-0.5 + x \cdot 0.375\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-udef92.1%

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{x}^{0.5}}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      4. pow-flip92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{x}^{\left(-0.5\right)}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      5. metadata-eval92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left({x}^{\color{blue}{-0.5}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
    7. Applied egg-rr91.8%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{-0.5}\right)} - 1\right)} - \left(1 + x \cdot \left(-0.5 + x \cdot 0.375\right)\right) \]
    8. Step-by-step derivation
      1. expm1-def92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-log1p100.0%

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

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

    if 0.5 < x

    1. Initial program 35.6%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity35.7%

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity35.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity37.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      3. sub-neg37.0%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      6. *-lft-identity99.3%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      9. distribute-rgt-in99.3%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
      10. rem-square-sqrt99.4%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
      11. +-commutative99.4%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
    10. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    11. Taylor expanded in x around inf 98.8%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(1.5 + 2 \cdot x\right) - 0.125 \cdot \frac{1}{x}}} \]
    12. Step-by-step derivation
      1. associate--l+98.8%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{1.5 + \left(2 \cdot x - 0.125 \cdot \frac{1}{x}\right)}} \]
      2. *-commutative98.8%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{1.5 + \left(\color{blue}{x \cdot 2} - 0.125 \cdot \frac{1}{x}\right)} \]
      3. associate-*r/98.8%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{1.5 + \left(x \cdot 2 - \color{blue}{\frac{0.125 \cdot 1}{x}}\right)} \]
      4. metadata-eval98.8%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{1.5 + \left(x \cdot 2 - \frac{\color{blue}{0.125}}{x}\right)} \]
    13. Simplified98.8%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{1.5 + \left(x \cdot 2 - \frac{0.125}{x}\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.2%

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

Alternative 6: 99.0% accurate, 1.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{x \cdot 2 + 1.5}\\


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

    1. Initial program 99.5%

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{\left(x \cdot x\right)} \cdot 0.375\right)\right) \]
      4. associate-*l*99.1%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{x \cdot \left(x \cdot 0.375\right)}\right)\right) \]
      5. distribute-lft-out99.1%

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

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(1 + x \cdot \left(-0.5 + x \cdot 0.375\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-udef92.1%

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{x}^{0.5}}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      4. pow-flip92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{x}^{\left(-0.5\right)}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      5. metadata-eval92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left({x}^{\color{blue}{-0.5}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
    7. Applied egg-rr91.8%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{-0.5}\right)} - 1\right)} - \left(1 + x \cdot \left(-0.5 + x \cdot 0.375\right)\right) \]
    8. Step-by-step derivation
      1. expm1-def92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-log1p100.0%

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

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

    if 0.5 < x

    1. Initial program 35.6%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity35.7%

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity35.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity37.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      3. sub-neg37.0%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      6. *-lft-identity99.3%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      9. distribute-rgt-in99.3%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
      10. rem-square-sqrt99.4%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
      11. +-commutative99.4%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
    10. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    11. Taylor expanded in x around inf 98.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{1.5 + 2 \cdot x}} \]
    12. Step-by-step derivation
      1. +-commutative98.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{2 \cdot x + 1.5}} \]
      2. *-commutative98.6%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{x \cdot 2} + 1.5} \]
    13. Simplified98.6%

      \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{x \cdot 2 + 1.5}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.0%

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

Alternative 7: 98.5% accurate, 1.7× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{0.5}{x}\\


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

    1. Initial program 99.5%

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

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

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

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

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{\left(x \cdot x\right)} \cdot 0.375\right)\right) \]
      4. associate-*l*99.1%

        \[\leadsto \frac{1}{\sqrt{x}} - \left(1 + \left(x \cdot -0.5 + \color{blue}{x \cdot \left(x \cdot 0.375\right)}\right)\right) \]
      5. distribute-lft-out99.1%

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

      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\left(1 + x \cdot \left(-0.5 + x \cdot 0.375\right)\right)} \]
    6. Step-by-step derivation
      1. expm1-log1p-u92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(\frac{1}{\sqrt{x}}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-udef92.1%

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

        \[\leadsto \left(e^{\mathsf{log1p}\left(\frac{1}{\color{blue}{{x}^{0.5}}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      4. pow-flip92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left(\color{blue}{{x}^{\left(-0.5\right)}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
      5. metadata-eval92.1%

        \[\leadsto \left(e^{\mathsf{log1p}\left({x}^{\color{blue}{-0.5}}\right)} - 1\right) - \sqrt{\frac{1}{1 + x}} \]
    7. Applied egg-rr91.8%

      \[\leadsto \color{blue}{\left(e^{\mathsf{log1p}\left({x}^{-0.5}\right)} - 1\right)} - \left(1 + x \cdot \left(-0.5 + x \cdot 0.375\right)\right) \]
    8. Step-by-step derivation
      1. expm1-def92.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5}\right)\right)} - \sqrt{\frac{1}{1 + x}} \]
      2. expm1-log1p100.0%

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

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

    if 0.94999999999999996 < x

    1. Initial program 35.6%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity35.7%

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity35.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity37.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      3. sub-neg37.0%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      6. *-lft-identity99.3%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      9. distribute-rgt-in99.3%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
      10. rem-square-sqrt99.4%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
      11. +-commutative99.4%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
    10. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    11. Taylor expanded in x around inf 97.6%

      \[\leadsto {x}^{-0.5} \cdot \color{blue}{\frac{0.5}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.5%

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

Alternative 8: 98.3% accurate, 1.8× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{0.5}{x}\\


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

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity99.5%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.5%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.5%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity99.5%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg99.5%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. inv-pow99.5%

        \[\leadsto \left(1 \cdot \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. *-un-lft-identity99.5%

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

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

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. inv-pow100.0%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(\sqrt{x + 1}\right)}^{-1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. sqrt-pow2100.0%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative100.0%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right) + \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right)} \]
      2. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right)} \]
      3. fma-udef100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. distribute-lft1-in100.0%

        \[\leadsto \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      5. metadata-eval100.0%

        \[\leadsto \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      6. mul0-lft100.0%

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

        \[\leadsto 0 + \color{blue}{\left(\left(-{\left(1 + x\right)}^{-0.5}\right) + {x}^{-0.5}\right)} \]
      8. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0 + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) + {x}^{-0.5}} \]
      9. sub-neg100.0%

        \[\leadsto \color{blue}{\left(0 - {\left(1 + x\right)}^{-0.5}\right)} + {x}^{-0.5} \]
      10. neg-sub0100.0%

        \[\leadsto \color{blue}{\left(-{\left(1 + x\right)}^{-0.5}\right)} + {x}^{-0.5} \]
      11. +-commutative100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)} \]
      12. sub-neg100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Simplified100.0%

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

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

    if 1 < x

    1. Initial program 35.6%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity35.7%

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity35.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity37.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      3. sub-neg37.0%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      6. *-lft-identity99.3%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      9. distribute-rgt-in99.3%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
      10. rem-square-sqrt99.4%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
      11. +-commutative99.4%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
    10. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    11. Taylor expanded in x around inf 97.6%

      \[\leadsto {x}^{-0.5} \cdot \color{blue}{\frac{0.5}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.4%

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

Alternative 9: 98.0% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.66:\\
\;\;\;\;{x}^{-0.5} + -1\\

\mathbf{else}:\\
\;\;\;\;{x}^{-0.5} \cdot \frac{0.5}{x}\\


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

    1. Initial program 99.5%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. *-un-lft-identity99.5%

        \[\leadsto \color{blue}{1 \cdot \frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      2. clear-num99.5%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
      3. associate-/r/99.5%

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
      5. *-un-lft-identity99.5%

        \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      6. fma-neg99.5%

        \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      7. inv-pow99.5%

        \[\leadsto \left(1 \cdot \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      8. *-un-lft-identity99.5%

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

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

        \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      11. inv-pow100.0%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(\sqrt{x + 1}\right)}^{-1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      12. sqrt-pow2100.0%

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      13. +-commutative100.0%

        \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
      14. metadata-eval100.0%

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    4. Applied egg-rr100.0%

      \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto \color{blue}{\mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right) + \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right)} \]
      2. sub-neg100.0%

        \[\leadsto \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{\left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right)} \]
      3. fma-udef100.0%

        \[\leadsto \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      4. distribute-lft1-in100.0%

        \[\leadsto \color{blue}{\left(-1 + 1\right) \cdot {\left(1 + x\right)}^{-0.5}} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      5. metadata-eval100.0%

        \[\leadsto \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
      6. mul0-lft100.0%

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

        \[\leadsto 0 + \color{blue}{\left(\left(-{\left(1 + x\right)}^{-0.5}\right) + {x}^{-0.5}\right)} \]
      8. associate-+r+100.0%

        \[\leadsto \color{blue}{\left(0 + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) + {x}^{-0.5}} \]
      9. sub-neg100.0%

        \[\leadsto \color{blue}{\left(0 - {\left(1 + x\right)}^{-0.5}\right)} + {x}^{-0.5} \]
      10. neg-sub0100.0%

        \[\leadsto \color{blue}{\left(-{\left(1 + x\right)}^{-0.5}\right)} + {x}^{-0.5} \]
      11. +-commutative100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)} \]
      12. sub-neg100.0%

        \[\leadsto \color{blue}{{x}^{-0.5} - {\left(1 + x\right)}^{-0.5}} \]
    6. Simplified100.0%

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

      \[\leadsto \color{blue}{{x}^{-0.5} - 1} \]

    if 0.660000000000000031 < x

    1. Initial program 35.6%

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

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      2. *-un-lft-identity35.7%

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

        \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      4. *-rgt-identity35.7%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\frac{\left(x + 1\right) - x}{\sqrt{x + 1} + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    7. Step-by-step derivation
      1. *-un-lft-identity37.0%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{\color{blue}{\left(1 - x\right) + x}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      3. sub-neg37.0%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + \left(\color{blue}{-1 \cdot x} + x\right)}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      6. *-lft-identity99.3%

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

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot \color{blue}{0}}{\sqrt{x + 1} \cdot \left(\sqrt{x + 1} + \sqrt{x}\right)} \]
      9. distribute-rgt-in99.3%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\sqrt{x + 1} \cdot \sqrt{x + 1} + \sqrt{x} \cdot \sqrt{x + 1}}} \]
      10. rem-square-sqrt99.4%

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\color{blue}{\left(x + 1\right)} + \sqrt{x} \cdot \sqrt{x + 1}} \]
      11. +-commutative99.4%

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

        \[\leadsto {x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{\color{blue}{1 + x}}} \]
    10. Simplified99.4%

      \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{1 + x \cdot 0}{\left(1 + x\right) + \sqrt{x} \cdot \sqrt{1 + x}}} \]
    11. Taylor expanded in x around inf 97.6%

      \[\leadsto {x}^{-0.5} \cdot \color{blue}{\frac{0.5}{x}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.3%

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

Alternative 10: 51.0% accurate, 2.0× speedup?

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

\\
{x}^{-0.5} + -1
\end{array}
Derivation
  1. Initial program 63.6%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. *-un-lft-identity63.6%

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

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\frac{\sqrt{x + 1}}{1}}} \]
    3. associate-/r/63.6%

      \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
    4. prod-diff63.6%

      \[\leadsto \color{blue}{\mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -1 \cdot \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right)} \]
    5. *-un-lft-identity63.6%

      \[\leadsto \mathsf{fma}\left(1, \frac{1}{\sqrt{x}}, -\color{blue}{\frac{1}{\sqrt{x + 1}}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    6. fma-neg63.6%

      \[\leadsto \color{blue}{\left(1 \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}\right)} + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    7. inv-pow63.2%

      \[\leadsto \left(1 \cdot \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    8. *-un-lft-identity63.2%

      \[\leadsto \left(\color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    9. sqrt-pow260.6%

      \[\leadsto \left(\color{blue}{{x}^{\left(\frac{-1}{2}\right)}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    10. metadata-eval60.6%

      \[\leadsto \left({x}^{\color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    11. inv-pow60.2%

      \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(\sqrt{x + 1}\right)}^{-1}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    12. sqrt-pow263.8%

      \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(\frac{-1}{2}\right)}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    13. +-commutative63.8%

      \[\leadsto \left({x}^{-0.5} - {\color{blue}{\left(1 + x\right)}}^{\left(\frac{-1}{2}\right)}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
    14. metadata-eval63.8%

      \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{\color{blue}{-0.5}}\right) + \mathsf{fma}\left(-1, \frac{1}{\sqrt{x + 1}}, 1 \cdot \frac{1}{\sqrt{x + 1}}\right) \]
  4. Applied egg-rr63.8%

    \[\leadsto \color{blue}{\left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right)} \]
  5. Step-by-step derivation
    1. +-commutative63.8%

      \[\leadsto \color{blue}{\mathsf{fma}\left(-1, {\left(1 + x\right)}^{-0.5}, {\left(1 + x\right)}^{-0.5}\right) + \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right)} \]
    2. sub-neg63.8%

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

      \[\leadsto \color{blue}{\left(-1 \cdot {\left(1 + x\right)}^{-0.5} + {\left(1 + x\right)}^{-0.5}\right)} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
    4. distribute-lft1-in63.8%

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

      \[\leadsto \color{blue}{0} \cdot {\left(1 + x\right)}^{-0.5} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
    6. mul0-lft63.8%

      \[\leadsto \color{blue}{0} + \left({x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) \]
    7. +-commutative63.8%

      \[\leadsto 0 + \color{blue}{\left(\left(-{\left(1 + x\right)}^{-0.5}\right) + {x}^{-0.5}\right)} \]
    8. associate-+r+63.8%

      \[\leadsto \color{blue}{\left(0 + \left(-{\left(1 + x\right)}^{-0.5}\right)\right) + {x}^{-0.5}} \]
    9. sub-neg63.8%

      \[\leadsto \color{blue}{\left(0 - {\left(1 + x\right)}^{-0.5}\right)} + {x}^{-0.5} \]
    10. neg-sub063.8%

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

      \[\leadsto \color{blue}{{x}^{-0.5} + \left(-{\left(1 + x\right)}^{-0.5}\right)} \]
    12. sub-neg63.8%

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

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

    \[\leadsto \color{blue}{{x}^{-0.5} - 1} \]
  8. Final simplification44.9%

    \[\leadsto {x}^{-0.5} + -1 \]
  9. Add Preprocessing

Alternative 11: 1.9% accurate, 217.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 63.6%

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

    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{1} \]
  4. Taylor expanded in x around inf 2.0%

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification2.0%

    \[\leadsto -1 \]
  6. Add Preprocessing

Alternative 12: 5.9% accurate, 217.0× speedup?

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

\\
2
\end{array}
Derivation
  1. Initial program 63.6%

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

      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
    2. *-un-lft-identity63.6%

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

      \[\leadsto \frac{\sqrt{\color{blue}{1 + x}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
    4. *-rgt-identity63.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{2} \]
  11. Final simplification5.5%

    \[\leadsto 2 \]
  12. Add Preprocessing

Developer target: 99.0% accurate, 1.0× speedup?

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

\\
\frac{1}{\left(x + 1\right) \cdot \sqrt{x} + x \cdot \sqrt{x + 1}}
\end{array}

Reproduce

?
herbie shell --seed 2024011 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64

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

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