2isqrt (example 3.6)

Percentage Accurate: 39.3% → 99.7%
Time: 13.6s
Alternatives: 8
Speedup: 2.0×

Specification

?
\[x > 1 \land x < 10^{+308}\]
\[\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 8 alternatives:

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

Initial Program: 39.3% 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.7% accurate, 0.7× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\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. add-sqr-sqrt38.1%

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left(1 + x\right) - x}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  7. Step-by-step derivation
    1. associate--l+85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\sqrt{1 + x}}} \]
  11. Step-by-step derivation
    1. associate-/l/99.3%

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

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

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

    \[\leadsto \color{blue}{\frac{{x}^{-0.5}}{\sqrt{1 + x} \cdot \left(\sqrt{x} + \sqrt{1 + x}\right)}} \]
  13. Step-by-step derivation
    1. distribute-rgt-in99.4%

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

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

      \[\leadsto \frac{{x}^{-0.5}}{\sqrt{\color{blue}{1 \cdot x + x \cdot x}} + \sqrt{1 + x} \cdot \sqrt{1 + x}} \]
    4. *-un-lft-identity85.5%

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

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

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

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

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

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

Alternative 2: 98.7% accurate, 1.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

      \[\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. add-sqr-sqrt38.1%

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left(1 + x\right) - x}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  7. Step-by-step derivation
    1. associate--l+85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 3: 97.8% accurate, 1.8× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{\color{blue}{x \cdot \left(1 + \frac{0.5}{x}\right)}} \]
  11. Final simplification97.6%

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

Alternative 4: 97.7% accurate, 2.0× speedup?

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto 1 \cdot \left(\frac{\color{blue}{\frac{1}{{x}^{0.5}}}}{\sqrt{x}} \cdot \frac{0.5}{\sqrt{1 + x}}\right) \]
    11. pow1/297.2%

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

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

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

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

      \[\leadsto \color{blue}{\frac{1}{x} \cdot \frac{0.5}{\sqrt{1 + x}}} \]
    2. associate-*r/97.5%

      \[\leadsto \color{blue}{\frac{\frac{1}{x} \cdot 0.5}{\sqrt{1 + x}}} \]
    3. associate-*l/97.5%

      \[\leadsto \frac{\color{blue}{\frac{1 \cdot 0.5}{x}}}{\sqrt{1 + x}} \]
    4. metadata-eval97.5%

      \[\leadsto \frac{\frac{\color{blue}{0.5}}{x}}{\sqrt{1 + x}} \]
  11. Simplified97.5%

    \[\leadsto \color{blue}{\frac{\frac{0.5}{x}}{\sqrt{1 + x}}} \]
  12. Final simplification97.5%

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

Alternative 5: 97.7% accurate, 2.0× speedup?

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

\\
\frac{{x}^{-0.5}}{x \cdot 2}
\end{array}
Derivation
  1. Initial program 35.3%

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

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

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

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

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

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

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

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

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

      \[\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. add-sqr-sqrt38.1%

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

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

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

    \[\leadsto \frac{\color{blue}{\frac{\left(1 + x\right) - x}{\mathsf{hypot}\left(1, \sqrt{x}\right) + \sqrt{x}}}}{\sqrt{x \cdot \left(1 + x\right)}} \]
  7. Step-by-step derivation
    1. associate--l+85.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{x}^{-0.5} \cdot \frac{\frac{1}{\sqrt{x} + \sqrt{1 + x}}}{\sqrt{1 + x}}} \]
  11. Step-by-step derivation
    1. associate-/l/99.3%

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

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

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

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

    \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{2 \cdot x}} \]
  14. Step-by-step derivation
    1. *-commutative97.5%

      \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{x \cdot 2}} \]
  15. Simplified97.5%

    \[\leadsto \frac{{x}^{-0.5}}{\color{blue}{x \cdot 2}} \]
  16. Final simplification97.5%

    \[\leadsto \frac{{x}^{-0.5}}{x \cdot 2} \]
  17. Add Preprocessing

Alternative 6: 96.4% accurate, 2.0× speedup?

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

\\
\frac{0.5}{{x}^{1.5}}
\end{array}
Derivation
  1. Initial program 35.3%

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

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{{\left(\sqrt{x}\right)}^{-1}} + \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. sqrt-pow235.3%

      \[\leadsto \frac{1}{\frac{\color{blue}{{x}^{\left(\frac{-1}{2}\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-eval35.3%

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

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

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

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

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

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

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

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

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

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

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

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

    \[\leadsto \frac{1}{\color{blue}{2 \cdot \sqrt{{x}^{3}}}} \]
  6. Step-by-step derivation
    1. *-un-lft-identity67.6%

      \[\leadsto \color{blue}{1 \cdot \frac{1}{2 \cdot \sqrt{{x}^{3}}}} \]
    2. associate-/r*67.6%

      \[\leadsto 1 \cdot \color{blue}{\frac{\frac{1}{2}}{\sqrt{{x}^{3}}}} \]
    3. metadata-eval67.6%

      \[\leadsto 1 \cdot \frac{\color{blue}{0.5}}{\sqrt{{x}^{3}}} \]
    4. sqrt-pow196.2%

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

      \[\leadsto 1 \cdot \frac{0.5}{{x}^{\color{blue}{1.5}}} \]
  7. Applied egg-rr96.2%

    \[\leadsto \color{blue}{1 \cdot \frac{0.5}{{x}^{1.5}}} \]
  8. Step-by-step derivation
    1. *-lft-identity96.2%

      \[\leadsto \color{blue}{\frac{0.5}{{x}^{1.5}}} \]
  9. Simplified96.2%

    \[\leadsto \color{blue}{\frac{0.5}{{x}^{1.5}}} \]
  10. Final simplification96.2%

    \[\leadsto \frac{0.5}{{x}^{1.5}} \]
  11. Add Preprocessing

Alternative 7: 38.5% accurate, 26.1× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 6.4 \cdot 10^{+153}:\\ \;\;\;\;\frac{0.5}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x 6.4e+153) (/ 0.5 x) 0.0))
double code(double x) {
	double tmp;
	if (x <= 6.4e+153) {
		tmp = 0.5 / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 6.4d+153) then
        tmp = 0.5d0 / x
    else
        tmp = 0.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 6.4e+153) {
		tmp = 0.5 / x;
	} else {
		tmp = 0.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 6.4e+153:
		tmp = 0.5 / x
	else:
		tmp = 0.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 6.4e+153)
		tmp = Float64(0.5 / x);
	else
		tmp = 0.0;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 6.4e+153)
		tmp = 0.5 / x;
	else
		tmp = 0.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 6.4e+153], N[(0.5 / x), $MachinePrecision], 0.0]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.4 \cdot 10^{+153}:\\
\;\;\;\;\frac{0.5}{x}\\

\mathbf{else}:\\
\;\;\;\;0\\


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

    1. Initial program 10.1%

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{\frac{0.5}{x}} \]

    if 6.4000000000000003e153 < x

    1. Initial program 67.7%

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

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

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

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(-\sqrt[3]{\frac{1}{\sqrt{x + 1}}} \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}, \sqrt[3]{\frac{1}{\sqrt{x + 1}}}, \frac{1}{\sqrt{x}}\right)} \]
    4. Applied egg-rr4.5%

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

      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}} + -1 \cdot \sqrt{\frac{1}{x}}} \]
    6. Step-by-step derivation
      1. distribute-rgt1-in67.7%

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

        \[\leadsto \color{blue}{0} \cdot \sqrt{\frac{1}{x}} \]
      3. mul0-lft67.7%

        \[\leadsto \color{blue}{0} \]
    7. Simplified67.7%

      \[\leadsto \color{blue}{0} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification34.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 6.4 \cdot 10^{+153}:\\ \;\;\;\;\frac{0.5}{x}\\ \mathbf{else}:\\ \;\;\;\;0\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 36.5% accurate, 209.0× speedup?

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

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

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

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

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

      \[\leadsto \left(-\color{blue}{\left(\sqrt[3]{\frac{1}{\sqrt{x + 1}}} \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}\right) \cdot \sqrt[3]{\frac{1}{\sqrt{x + 1}}}}\right) + \frac{1}{\sqrt{x}} \]
    4. distribute-lft-neg-in10.9%

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

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

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

    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}} + -1 \cdot \sqrt{\frac{1}{x}}} \]
  6. Step-by-step derivation
    1. distribute-rgt1-in32.0%

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

      \[\leadsto \color{blue}{0} \cdot \sqrt{\frac{1}{x}} \]
    3. mul0-lft32.0%

      \[\leadsto \color{blue}{0} \]
  7. Simplified32.0%

    \[\leadsto \color{blue}{0} \]
  8. Final simplification32.0%

    \[\leadsto 0 \]
  9. Add Preprocessing

Developer target: 98.3% 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 2024071 
(FPCore (x)
  :name "2isqrt (example 3.6)"
  :precision binary64
  :pre (and (> x 1.0) (< x 1e+308))

  :alt
  (/ 1.0 (+ (* (+ x 1.0) (sqrt x)) (* x (sqrt (+ x 1.0)))))

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