2isqrt (example 3.6)

Percentage Accurate: 68.4% → 99.6%
Time: 10.3s
Alternatives: 12
Speedup: 1.0×

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.4% 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.6% accurate, 0.4× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. frac-sub71.2%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)} - \sqrt{x}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    3. flip--71.5%

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right) - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    4. hypot-1-def71.7%

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{1 + \sqrt{x} \cdot \sqrt{x}}} \cdot \mathsf{hypot}\left(1, \sqrt{x}\right) - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    5. add-sqr-sqrt71.7%

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

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

      \[\leadsto \frac{\frac{\sqrt{1 + x} \cdot \sqrt{1 + \color{blue}{x}} - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    8. add-sqr-sqrt71.5%

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

      \[\leadsto \frac{\frac{\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    10. add-sqr-sqrt72.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{x + \left(1 - x\right)}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{x + 1}\right)}} \]
    2. associate-*r/72.5%

      \[\leadsto \color{blue}{\frac{1 \cdot \left(x + \left(1 - x\right)\right)}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{x + 1}\right)}} \]
    3. associate-/l*72.5%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{\left(\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}} \]
  10. Step-by-step derivation
    1. inv-pow98.9%

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

      \[\leadsto {\color{blue}{\left(\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}\right)\right)}}^{-1} \]
    3. unpow-prod-down99.6%

      \[\leadsto \color{blue}{{\left(\mathsf{hypot}\left(x, \sqrt{x}\right)\right)}^{-1} \cdot {\left(\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}\right)}^{-1}} \]
    4. inv-pow99.6%

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

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

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

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

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

    \[\leadsto {\left(\mathsf{hypot}\left(x, \sqrt{x}\right)\right)}^{-1} \cdot \frac{1}{\sqrt{x} + \sqrt{x + 1}} \]

Alternative 2: 98.9% accurate, 0.5× speedup?

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

\\
\frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{x + 1}\right)}
\end{array}
Derivation
  1. Initial program 71.2%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. frac-sub71.2%

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\color{blue}{\mathsf{hypot}\left(1, \sqrt{x}\right)} - \sqrt{x}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    3. flip--71.5%

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{hypot}\left(1, \sqrt{x}\right) \cdot \mathsf{hypot}\left(1, \sqrt{x}\right) - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    4. hypot-1-def71.7%

      \[\leadsto \frac{\frac{\color{blue}{\sqrt{1 + \sqrt{x} \cdot \sqrt{x}}} \cdot \mathsf{hypot}\left(1, \sqrt{x}\right) - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    5. add-sqr-sqrt71.7%

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

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

      \[\leadsto \frac{\frac{\sqrt{1 + x} \cdot \sqrt{1 + \color{blue}{x}} - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    8. add-sqr-sqrt71.5%

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

      \[\leadsto \frac{\frac{\color{blue}{\left(x + 1\right)} - \sqrt{x} \cdot \sqrt{x}}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
    10. add-sqr-sqrt72.5%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{x + \left(1 - x\right)}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{x + 1}\right)}} \]
    2. associate-*r/72.5%

      \[\leadsto \color{blue}{\frac{1 \cdot \left(x + \left(1 - x\right)\right)}{\sqrt{x + x \cdot x} \cdot \left(\sqrt{x} + \sqrt{x + 1}\right)}} \]
    3. associate-/l*72.5%

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{\left(\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)}} \]
  10. Step-by-step derivation
    1. expm1-log1p-u97.5%

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

      \[\leadsto \frac{1}{\left(\color{blue}{\left(e^{\mathsf{log1p}\left(\mathsf{hypot}\left(1, \sqrt{x}\right)\right)} - 1\right)} + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    3. hypot-1-def97.5%

      \[\leadsto \frac{1}{\left(\left(e^{\mathsf{log1p}\left(\color{blue}{\sqrt{1 + \sqrt{x} \cdot \sqrt{x}}}\right)} - 1\right) + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
    4. add-sqr-sqrt97.5%

      \[\leadsto \frac{1}{\left(\left(e^{\mathsf{log1p}\left(\sqrt{1 + \color{blue}{x}}\right)} - 1\right) + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
  11. Applied egg-rr97.5%

    \[\leadsto \frac{1}{\left(\color{blue}{\left(e^{\mathsf{log1p}\left(\sqrt{1 + x}\right)} - 1\right)} + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
  12. Step-by-step derivation
    1. expm1-def97.5%

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

      \[\leadsto \frac{1}{\left(\color{blue}{\sqrt{1 + x}} + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
  13. Simplified98.9%

    \[\leadsto \frac{1}{\left(\color{blue}{\sqrt{1 + x}} + \sqrt{x}\right) \cdot \mathsf{hypot}\left(x, \sqrt{x}\right)} \]
  14. Final simplification98.9%

    \[\leadsto \frac{1}{\mathsf{hypot}\left(x, \sqrt{x}\right) \cdot \left(\sqrt{x} + \sqrt{x + 1}\right)} \]

Alternative 3: 90.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 98.9%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. add-log-exp8.0%

        \[\leadsto \color{blue}{\log \left(e^{\frac{1}{\sqrt{x}}}\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. *-un-lft-identity8.0%

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

        \[\leadsto \color{blue}{\left(\log 1 + \log \left(e^{\frac{1}{\sqrt{x}}}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      4. metadata-eval8.0%

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x}}}\right)\right) - \frac{1}{\sqrt{x + 1}} \]
      5. add-log-exp98.9%

        \[\leadsto \left(0 + \color{blue}{\frac{1}{\sqrt{x}}}\right) - \frac{1}{\sqrt{x + 1}} \]
      6. pow1/298.9%

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

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

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

      \[\leadsto \color{blue}{\left(0 + {x}^{-0.5}\right)} - \frac{1}{\sqrt{x + 1}} \]
    4. Step-by-step derivation
      1. +-lft-identity99.3%

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

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

    if 1.15e8 < x

    1. Initial program 43.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. flip--43.1%

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

        \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
      3. pow1/243.1%

        \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      4. pow-flip43.1%

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

        \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
      6. inv-pow43.1%

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{1}{x} - \frac{1}{\color{blue}{x + 1}}}} \]
    3. Applied egg-rr43.3%

      \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{1}{x} - \frac{1}{1 + x}}}} \]
    4. Taylor expanded in x around inf 85.9%

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

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

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

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

Alternative 4: 91.5% accurate, 1.0× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. flip--71.2%

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

      \[\leadsto \color{blue}{\frac{1}{\frac{\frac{1}{\sqrt{x}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}}} \]
    3. pow1/271.1%

      \[\leadsto \frac{1}{\frac{\frac{1}{\color{blue}{{x}^{0.5}}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
    4. pow-flip71.0%

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

      \[\leadsto \frac{1}{\frac{{x}^{\color{blue}{-0.5}} + \frac{1}{\sqrt{x + 1}}}{\frac{1}{\sqrt{x}} \cdot \frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \cdot \frac{1}{\sqrt{x + 1}}}} \]
    6. inv-pow71.0%

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{\frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{1}{x} - \frac{1}{1 + x}}}} \]
  4. Step-by-step derivation
    1. frac-sub72.4%

      \[\leadsto \frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\color{blue}{\frac{1 \cdot \left(1 + x\right) - x \cdot 1}{x \cdot \left(1 + x\right)}}}} \]
    2. *-un-lft-identity72.4%

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

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

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

      \[\leadsto \frac{1}{\frac{{x}^{-0.5} + {\left(1 + x\right)}^{-0.5}}{\frac{\frac{\left(1 + x\right) - \color{blue}{x}}{x}}{1 + x}}} \]
    3. associate--l+93.7%

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

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

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

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

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

Alternative 5: 82.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 98.9%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. add-log-exp8.0%

        \[\leadsto \color{blue}{\log \left(e^{\frac{1}{\sqrt{x}}}\right)} - \frac{1}{\sqrt{x + 1}} \]
      2. *-un-lft-identity8.0%

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

        \[\leadsto \color{blue}{\left(\log 1 + \log \left(e^{\frac{1}{\sqrt{x}}}\right)\right)} - \frac{1}{\sqrt{x + 1}} \]
      4. metadata-eval8.0%

        \[\leadsto \left(\color{blue}{0} + \log \left(e^{\frac{1}{\sqrt{x}}}\right)\right) - \frac{1}{\sqrt{x + 1}} \]
      5. add-log-exp98.9%

        \[\leadsto \left(0 + \color{blue}{\frac{1}{\sqrt{x}}}\right) - \frac{1}{\sqrt{x + 1}} \]
      6. pow1/298.9%

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

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

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

      \[\leadsto \color{blue}{\left(0 + {x}^{-0.5}\right)} - \frac{1}{\sqrt{x + 1}} \]
    4. Step-by-step derivation
      1. +-lft-identity99.3%

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

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

    if 9e7 < x

    1. Initial program 43.1%

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

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

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

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

        \[\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-identity43.1%

        \[\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-neg43.1%

        \[\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. *-un-lft-identity43.1%

        \[\leadsto \left(\color{blue}{\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) \]
      8. inv-pow43.1%

        \[\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-pow234.4%

        \[\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-eval34.4%

        \[\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. pow1/234.4%

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

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

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

        \[\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) \]
    3. Applied egg-rr43.1%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef43.1%

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

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

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

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 90000000:\\ \;\;\;\;{x}^{-0.5} + \frac{-1}{\sqrt{x + 1}}\\ \mathbf{else}:\\ \;\;\;\;0.5 \cdot \sqrt{\frac{1}{{x}^{3}}}\\ \end{array} \]

Alternative 6: 82.5% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 98.9%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. *-un-lft-identity98.9%

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

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

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

        \[\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-identity98.9%

        \[\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-neg98.9%

        \[\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. *-un-lft-identity98.9%

        \[\leadsto \left(\color{blue}{\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) \]
      8. inv-pow98.9%

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

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

        \[\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. pow1/299.3%

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

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

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

        \[\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) \]
    3. Applied egg-rr99.2%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef99.2%

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

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

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

        \[\leadsto \left({x}^{-0.5} - {\left(1 + x\right)}^{-0.5}\right) + \color{blue}{0} \]
      5. +-rgt-identity99.2%

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

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

    if 9.5e7 < x

    1. Initial program 43.1%

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

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

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

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

        \[\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-identity43.1%

        \[\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-neg43.1%

        \[\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. *-un-lft-identity43.1%

        \[\leadsto \left(\color{blue}{\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) \]
      8. inv-pow43.1%

        \[\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-pow234.4%

        \[\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-eval34.4%

        \[\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. pow1/234.4%

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

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

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

        \[\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) \]
    3. Applied egg-rr43.1%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef43.1%

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

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

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

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

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

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

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

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

Alternative 7: 81.6% accurate, 1.0× speedup?

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

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

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


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

    1. Initial program 99.6%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.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-identity99.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-neg99.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. *-un-lft-identity99.6%

        \[\leadsto \left(\color{blue}{\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) \]
      8. inv-pow99.6%

        \[\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. pow1/2100.0%

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

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\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(-0.5\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) \]
    3. 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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

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

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

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

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

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

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

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

    if 1 < x

    1. Initial program 44.1%

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

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

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

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

        \[\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-identity44.1%

        \[\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-neg44.1%

        \[\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. *-un-lft-identity44.1%

        \[\leadsto \left(\color{blue}{\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) \]
      8. inv-pow44.1%

        \[\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-pow235.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-eval35.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. pow1/235.7%

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

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

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

        \[\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) \]
    3. Applied egg-rr44.1%

      \[\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)} \]
    4. Step-by-step derivation
      1. fma-udef44.1%

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

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

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

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

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

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

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

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

Alternative 8: 67.3% accurate, 1.9× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\


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

    1. Initial program 99.6%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.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-identity99.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-neg99.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. *-un-lft-identity99.6%

        \[\leadsto \left(\color{blue}{\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) \]
      8. inv-pow99.6%

        \[\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. pow1/2100.0%

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

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\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(-0.5\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) \]
    3. 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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

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

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

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

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

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

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

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

    if 2 < x

    1. Initial program 44.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. inv-pow44.1%

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

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

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

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

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

        \[\leadsto e^{\log x \cdot \color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}} \]
    3. Applied egg-rr7.5%

      \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around inf 5.7%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    5. Step-by-step derivation
      1. pow1/25.7%

        \[\leadsto \color{blue}{{\left(\frac{1}{x}\right)}^{0.5}} \]
      2. inv-pow5.7%

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

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

        \[\leadsto {x}^{\color{blue}{-0.5}} \]
      5. metadata-eval5.7%

        \[\leadsto {x}^{\color{blue}{\left(-0.25 + -0.25\right)}} \]
      6. pow-prod-up5.7%

        \[\leadsto \color{blue}{{x}^{-0.25} \cdot {x}^{-0.25}} \]
      7. pow-prod-down42.0%

        \[\leadsto \color{blue}{{\left(x \cdot x\right)}^{-0.25}} \]
    6. Applied egg-rr42.0%

      \[\leadsto \color{blue}{{\left(x \cdot x\right)}^{-0.25}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2:\\ \;\;\;\;{x}^{-0.5} + \left(-1 - x \cdot -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\ \end{array} \]

Alternative 9: 67.1% accurate, 2.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\


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

    1. Initial program 99.6%

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

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

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

        \[\leadsto 1 \cdot \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}} \cdot 1} \]
      4. prod-diff99.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-identity99.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-neg99.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. *-un-lft-identity99.6%

        \[\leadsto \left(\color{blue}{\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) \]
      8. inv-pow99.6%

        \[\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. pow1/2100.0%

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

        \[\leadsto \left({x}^{-0.5} - \color{blue}{{\left(x + 1\right)}^{\left(-0.5\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(-0.5\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) \]
    3. 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)} \]
    4. Step-by-step derivation
      1. fma-udef100.0%

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

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

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

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

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

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

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

    if 0.80000000000000004 < x

    1. Initial program 44.1%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Step-by-step derivation
      1. inv-pow44.1%

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

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

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

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

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

        \[\leadsto e^{\log x \cdot \color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}} \]
    3. Applied egg-rr7.5%

      \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
    4. Taylor expanded in x around inf 5.7%

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
    5. Step-by-step derivation
      1. pow1/25.7%

        \[\leadsto \color{blue}{{\left(\frac{1}{x}\right)}^{0.5}} \]
      2. inv-pow5.7%

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

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

        \[\leadsto {x}^{\color{blue}{-0.5}} \]
      5. metadata-eval5.7%

        \[\leadsto {x}^{\color{blue}{\left(-0.25 + -0.25\right)}} \]
      6. pow-prod-up5.7%

        \[\leadsto \color{blue}{{x}^{-0.25} \cdot {x}^{-0.25}} \]
      7. pow-prod-down42.0%

        \[\leadsto \color{blue}{{\left(x \cdot x\right)}^{-0.25}} \]
    6. Applied egg-rr42.0%

      \[\leadsto \color{blue}{{\left(x \cdot x\right)}^{-0.25}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification69.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.8:\\ \;\;\;\;{x}^{-0.5} + -1\\ \mathbf{else}:\\ \;\;\;\;{\left(x \cdot x\right)}^{-0.25}\\ \end{array} \]

Alternative 10: 50.4% accurate, 2.0× speedup?

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

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. inv-pow71.2%

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

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

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

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

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

      \[\leadsto e^{\log x \cdot \color{blue}{-0.5}} - \frac{1}{\sqrt{x + 1}} \]
  3. Applied egg-rr49.1%

    \[\leadsto \color{blue}{e^{\log x \cdot -0.5}} - \frac{1}{\sqrt{x + 1}} \]
  4. Taylor expanded in x around inf 49.8%

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

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

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

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{\left(\frac{1}{x}\right)}^{0.5}}\right)} - 1 \]
    4. inv-pow64.7%

      \[\leadsto e^{\mathsf{log1p}\left({\color{blue}{\left({x}^{-1}\right)}}^{0.5}\right)} - 1 \]
    5. pow-pow64.7%

      \[\leadsto e^{\mathsf{log1p}\left(\color{blue}{{x}^{\left(-1 \cdot 0.5\right)}}\right)} - 1 \]
    6. metadata-eval64.7%

      \[\leadsto e^{\mathsf{log1p}\left({x}^{\color{blue}{-0.5}}\right)} - 1 \]
  6. Applied egg-rr64.7%

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

      \[\leadsto \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left({x}^{-0.5}\right)\right)} \]
    2. expm1-log1p49.9%

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

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

    \[\leadsto {x}^{-0.5} \]

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

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. inv-pow71.2%

      \[\leadsto \color{blue}{{\left(\sqrt{x}\right)}^{-1}} - \frac{1}{\sqrt{x + 1}} \]
    2. add-cube-cbrt55.0%

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

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

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

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

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

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt[3]{x}}, \color{blue}{\frac{1}{\sqrt[3]{\sqrt{x}}}}, -\frac{1}{\sqrt{x + 1}}\right) \]
    9. metadata-eval52.3%

      \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt[3]{x}}, \frac{\color{blue}{\sqrt[3]{1}}}{\sqrt[3]{\sqrt{x}}}, -\frac{1}{\sqrt{x + 1}}\right) \]
    10. cbrt-div52.1%

      \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt[3]{x}}, \color{blue}{\sqrt[3]{\frac{1}{\sqrt{x}}}}, -\frac{1}{\sqrt{x + 1}}\right) \]
    11. pow1/252.1%

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

      \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt[3]{x}}, \sqrt[3]{\color{blue}{{x}^{\left(-0.5\right)}}}, -\frac{1}{\sqrt{x + 1}}\right) \]
    13. metadata-eval52.1%

      \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt[3]{x}}, \sqrt[3]{{x}^{\color{blue}{-0.5}}}, -\frac{1}{\sqrt{x + 1}}\right) \]
    14. distribute-neg-frac52.1%

      \[\leadsto \mathsf{fma}\left(\frac{1}{\sqrt[3]{x}}, \sqrt[3]{{x}^{-0.5}}, \color{blue}{\frac{-1}{\sqrt{x + 1}}}\right) \]
    15. metadata-eval52.1%

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

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt[3]{x}}, \sqrt[3]{{x}^{-0.5}}, \frac{-1}{\sqrt{1 + x}}\right)} \]
  4. Taylor expanded in x around 0 1.9%

    \[\leadsto \color{blue}{-1} \]
  5. Final simplification1.9%

    \[\leadsto -1 \]

Alternative 12: 5.8% accurate, 209.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 71.2%

    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
  2. Step-by-step derivation
    1. frac-sub71.2%

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{0.5 + x}} \]
  5. Step-by-step derivation
    1. +-commutative25.8%

      \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{x + 0.5}} \]
  6. Simplified25.8%

    \[\leadsto \frac{\sqrt{1 + x} - \sqrt{x}}{\color{blue}{x + 0.5}} \]
  7. Taylor expanded in x around 0 5.8%

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

    \[\leadsto 2 \]

Developer target: 98.9% 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 2023192 
(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)))))