2isqrt (example 3.6)

Percentage Accurate: 40.1% → 99.9%
Time: 7.2s
Alternatives: 10
Speedup: 1.5×

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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    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 10 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: 40.1% 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)));
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(x)
use fmin_fmax_functions
    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.9% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{x - -1}\\ \mathbf{if}\;x \leq 4 \cdot 10^{+14}:\\ \;\;\;\;\frac{\left(x - -1\right) - x}{t\_0 \cdot \mathsf{fma}\left(\sqrt{x}, t\_0, x\right)}\\ \mathbf{else}:\\ \;\;\;\;{x}^{-1.5} \cdot 0.5\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (- x -1.0))))
   (if (<= x 4e+14)
     (/ (- (- x -1.0) x) (* t_0 (fma (sqrt x) t_0 x)))
     (* (pow x -1.5) 0.5))))
double code(double x) {
	double t_0 = sqrt((x - -1.0));
	double tmp;
	if (x <= 4e+14) {
		tmp = ((x - -1.0) - x) / (t_0 * fma(sqrt(x), t_0, x));
	} else {
		tmp = pow(x, -1.5) * 0.5;
	}
	return tmp;
}
function code(x)
	t_0 = sqrt(Float64(x - -1.0))
	tmp = 0.0
	if (x <= 4e+14)
		tmp = Float64(Float64(Float64(x - -1.0) - x) / Float64(t_0 * fma(sqrt(x), t_0, x)));
	else
		tmp = Float64((x ^ -1.5) * 0.5);
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[x, 4e+14], N[(N[(N[(x - -1.0), $MachinePrecision] - x), $MachinePrecision] / N[(t$95$0 * N[(N[Sqrt[x], $MachinePrecision] * t$95$0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Power[x, -1.5], $MachinePrecision] * 0.5), $MachinePrecision]]]
\begin{array}{l}

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

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


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

    1. Initial program 61.2%

      \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. lift--.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \]
      2. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
      3. lift-/.f64N/A

        \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
      4. frac-subN/A

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
      6. *-lft-identityN/A

        \[\leadsto \frac{\color{blue}{\sqrt{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      7. *-rgt-identityN/A

        \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      8. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      9. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      10. metadata-evalN/A

        \[\leadsto \frac{\sqrt{x + \color{blue}{1 \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      11. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{\sqrt{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      12. metadata-evalN/A

        \[\leadsto \frac{\sqrt{x - \color{blue}{-1} \cdot 1} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      13. metadata-evalN/A

        \[\leadsto \frac{\sqrt{x - \color{blue}{-1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      14. lower--.f64N/A

        \[\leadsto \frac{\sqrt{\color{blue}{x - -1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
      15. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x}} \cdot \sqrt{x + 1}} \]
      16. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{x + 1}}} \]
      17. sqrt-unprodN/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
      18. lower-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
      19. lower-*.f6463.4

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot \left(x + 1\right)}}} \]
      20. lift-+.f64N/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
      21. metadata-evalN/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x + \color{blue}{1 \cdot 1}\right)}} \]
      22. fp-cancel-sign-sub-invN/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1\right)}}} \]
      23. metadata-evalN/A

        \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - \color{blue}{-1} \cdot 1\right)}} \]
      24. metadata-evalN/A

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

      \[\leadsto \color{blue}{\frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - -1\right)}}} \]
    5. Step-by-step derivation
      1. lift-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - -1\right)}}} \]
      2. lift--.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{x - -1} - \sqrt{x}}}{\sqrt{x \cdot \left(x - -1\right)}} \]
      3. flip--N/A

        \[\leadsto \frac{\color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x - -1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x - -1\right)}} \]
      4. associate-/l/N/A

        \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}}} \]
      5. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}}} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{\color{blue}{\sqrt{x - -1}} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
      7. lift-sqrt.f64N/A

        \[\leadsto \frac{\sqrt{x - -1} \cdot \color{blue}{\sqrt{x - -1}} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
      8. rem-square-sqrtN/A

        \[\leadsto \frac{\color{blue}{\left(x - -1\right)} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - \color{blue}{\sqrt{x}} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
      10. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - \sqrt{x} \cdot \color{blue}{\sqrt{x}}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
      11. rem-square-sqrtN/A

        \[\leadsto \frac{\left(x - -1\right) - \color{blue}{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
      12. lower--.f64N/A

        \[\leadsto \frac{\color{blue}{\left(x - -1\right) - x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
      13. lower-*.f64N/A

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

      \[\leadsto \color{blue}{\frac{\left(x - -1\right) - x}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{\left(x - -1\right) \cdot x}}} \]
    7. Step-by-step derivation
      1. lift-*.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\color{blue}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{\left(x - -1\right) \cdot x}}} \]
      2. *-commutativeN/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\color{blue}{\sqrt{\left(x - -1\right) \cdot x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)}} \]
      3. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\color{blue}{\sqrt{\left(x - -1\right) \cdot x}} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)} \]
      4. lift-*.f64N/A

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

        \[\leadsto \frac{\left(x - -1\right) - x}{\color{blue}{\left(\sqrt{x - -1} \cdot \sqrt{x}\right)} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)} \]
      6. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\left(\color{blue}{\sqrt{x - -1}} \cdot \sqrt{x}\right) \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)} \]
      7. lift-sqrt.f64N/A

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

        \[\leadsto \frac{\left(x - -1\right) - x}{\color{blue}{\sqrt{x - -1} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)\right)}} \]
      9. lift-sqrt.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\color{blue}{\sqrt{x - -1}} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)\right)} \]
      10. lift--.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\sqrt{\color{blue}{x - -1}} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)\right)} \]
      11. metadata-evalN/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\sqrt{x - \color{blue}{1 \cdot -1}} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)\right)} \]
      12. fp-cancel-sub-signN/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\sqrt{\color{blue}{x + \left(\mathsf{neg}\left(1\right)\right) \cdot -1}} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)\right)} \]
      13. metadata-evalN/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\sqrt{x + \color{blue}{-1} \cdot -1} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)\right)} \]
      14. metadata-evalN/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\sqrt{x + \color{blue}{1}} \cdot \left(\sqrt{x} \cdot \left(\sqrt{x - -1} + \sqrt{x}\right)\right)} \]
      15. lift-+.f64N/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\sqrt{x + 1} \cdot \left(\sqrt{x} \cdot \color{blue}{\left(\sqrt{x - -1} + \sqrt{x}\right)}\right)} \]
      16. +-commutativeN/A

        \[\leadsto \frac{\left(x - -1\right) - x}{\sqrt{x + 1} \cdot \left(\sqrt{x} \cdot \color{blue}{\left(\sqrt{x} + \sqrt{x - -1}\right)}\right)} \]
      17. distribute-rgt-outN/A

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

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

    if 4e14 < x

    1. Initial program 37.5%

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

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \sqrt{\frac{1}{{x}^{3}}}} \]
    4. Step-by-step derivation
      1. Applied rewrites70.1%

        \[\leadsto \color{blue}{\sqrt{\frac{1}{{x}^{3}}} \cdot 0.5} \]
      2. Step-by-step derivation
        1. Applied rewrites100.0%

          \[\leadsto \color{blue}{{x}^{-1.5} \cdot 0.5} \]
      3. Recombined 2 regimes into one program.
      4. Add Preprocessing

      Alternative 2: 98.7% accurate, 0.6× speedup?

      \[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\frac{1}{x}}\\ \frac{-0.5 \cdot \left(\frac{0.75 \cdot t\_0}{x} - t\_0\right)}{x} \end{array} \end{array} \]
      (FPCore (x)
       :precision binary64
       (let* ((t_0 (sqrt (/ 1.0 x)))) (/ (* -0.5 (- (/ (* 0.75 t_0) x) t_0)) x)))
      double code(double x) {
      	double t_0 = sqrt((1.0 / x));
      	return (-0.5 * (((0.75 * t_0) / x) - t_0)) / x;
      }
      
      module fmin_fmax_functions
          implicit none
          private
          public fmax
          public fmin
      
          interface fmax
              module procedure fmax88
              module procedure fmax44
              module procedure fmax84
              module procedure fmax48
          end interface
          interface fmin
              module procedure fmin88
              module procedure fmin44
              module procedure fmin84
              module procedure fmin48
          end interface
      contains
          real(8) function fmax88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(4) function fmax44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
          end function
          real(8) function fmax84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmax48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
          end function
          real(8) function fmin88(x, y) result (res)
              real(8), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(4) function fmin44(x, y) result (res)
              real(4), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
          end function
          real(8) function fmin84(x, y) result(res)
              real(8), intent (in) :: x
              real(4), intent (in) :: y
              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
          end function
          real(8) function fmin48(x, y) result(res)
              real(4), intent (in) :: x
              real(8), intent (in) :: y
              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
          end function
      end module
      
      real(8) function code(x)
      use fmin_fmax_functions
          real(8), intent (in) :: x
          real(8) :: t_0
          t_0 = sqrt((1.0d0 / x))
          code = ((-0.5d0) * (((0.75d0 * t_0) / x) - t_0)) / x
      end function
      
      public static double code(double x) {
      	double t_0 = Math.sqrt((1.0 / x));
      	return (-0.5 * (((0.75 * t_0) / x) - t_0)) / x;
      }
      
      def code(x):
      	t_0 = math.sqrt((1.0 / x))
      	return (-0.5 * (((0.75 * t_0) / x) - t_0)) / x
      
      function code(x)
      	t_0 = sqrt(Float64(1.0 / x))
      	return Float64(Float64(-0.5 * Float64(Float64(Float64(0.75 * t_0) / x) - t_0)) / x)
      end
      
      function tmp = code(x)
      	t_0 = sqrt((1.0 / x));
      	tmp = (-0.5 * (((0.75 * t_0) / x) - t_0)) / x;
      end
      
      code[x_] := Block[{t$95$0 = N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]}, N[(N[(-0.5 * N[(N[(N[(0.75 * t$95$0), $MachinePrecision] / x), $MachinePrecision] - t$95$0), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision]]
      
      \begin{array}{l}
      
      \\
      \begin{array}{l}
      t_0 := \sqrt{\frac{1}{x}}\\
      \frac{-0.5 \cdot \left(\frac{0.75 \cdot t\_0}{x} - t\_0\right)}{x}
      \end{array}
      \end{array}
      
      Derivation
      1. Initial program 39.2%

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

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

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

        \[\leadsto \frac{\frac{-1}{2} \cdot \frac{\sqrt{\frac{1}{x}} - \frac{1}{4} \cdot \sqrt{\frac{1}{x}}}{x} + \frac{1}{2} \cdot \sqrt{\frac{1}{x}}}{\color{blue}{x}} \]
      6. Step-by-step derivation
        1. Applied rewrites98.3%

          \[\leadsto \frac{-0.5 \cdot \left(\frac{0.75 \cdot \sqrt{\frac{1}{x}}}{x} - \sqrt{\frac{1}{x}}\right)}{\color{blue}{x}} \]
        2. Add Preprocessing

        Alternative 3: 98.7% accurate, 0.7× speedup?

        \[\begin{array}{l} \\ \frac{\frac{\mathsf{fma}\left(-0.125, \sqrt{\frac{1}{x}}, 0.5 \cdot \sqrt{x}\right)}{x}}{0.5 + x} \end{array} \]
        (FPCore (x)
         :precision binary64
         (/ (/ (fma -0.125 (sqrt (/ 1.0 x)) (* 0.5 (sqrt x))) x) (+ 0.5 x)))
        double code(double x) {
        	return (fma(-0.125, sqrt((1.0 / x)), (0.5 * sqrt(x))) / x) / (0.5 + x);
        }
        
        function code(x)
        	return Float64(Float64(fma(-0.125, sqrt(Float64(1.0 / x)), Float64(0.5 * sqrt(x))) / x) / Float64(0.5 + x))
        end
        
        code[x_] := N[(N[(N[(-0.125 * N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] + N[(0.5 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / x), $MachinePrecision] / N[(0.5 + x), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{\frac{\mathsf{fma}\left(-0.125, \sqrt{\frac{1}{x}}, 0.5 \cdot \sqrt{x}\right)}{x}}{0.5 + x}
        \end{array}
        
        Derivation
        1. Initial program 39.2%

          \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift--.f64N/A

            \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \]
          2. lift-/.f64N/A

            \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
          3. lift-/.f64N/A

            \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
          4. frac-subN/A

            \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
          5. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
          6. *-lft-identityN/A

            \[\leadsto \frac{\color{blue}{\sqrt{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          7. *-rgt-identityN/A

            \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          8. lower--.f64N/A

            \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          9. lift-+.f64N/A

            \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          10. metadata-evalN/A

            \[\leadsto \frac{\sqrt{x + \color{blue}{1 \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          11. fp-cancel-sign-sub-invN/A

            \[\leadsto \frac{\sqrt{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          12. metadata-evalN/A

            \[\leadsto \frac{\sqrt{x - \color{blue}{-1} \cdot 1} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          13. metadata-evalN/A

            \[\leadsto \frac{\sqrt{x - \color{blue}{-1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          14. lower--.f64N/A

            \[\leadsto \frac{\sqrt{\color{blue}{x - -1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
          15. lift-sqrt.f64N/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x}} \cdot \sqrt{x + 1}} \]
          16. lift-sqrt.f64N/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{x + 1}}} \]
          17. sqrt-unprodN/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
          18. lower-sqrt.f64N/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
          19. lower-*.f6439.4

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot \left(x + 1\right)}}} \]
          20. lift-+.f64N/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
          21. metadata-evalN/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x + \color{blue}{1 \cdot 1}\right)}} \]
          22. fp-cancel-sign-sub-invN/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1\right)}}} \]
          23. metadata-evalN/A

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - \color{blue}{-1} \cdot 1\right)}} \]
          24. metadata-evalN/A

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

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

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

            \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{0.5 + x}} \]
          2. Taylor expanded in x around inf

            \[\leadsto \frac{\color{blue}{\frac{\frac{-1}{8} \cdot \sqrt{\frac{1}{x}} + \frac{1}{2} \cdot \sqrt{x}}{x}}}{\frac{1}{2} + x} \]
          3. Step-by-step derivation
            1. Applied rewrites98.3%

              \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(-0.125, \sqrt{\frac{1}{x}}, 0.5 \cdot \sqrt{x}\right)}{x}}}{0.5 + x} \]
            2. Add Preprocessing

            Alternative 4: 99.7% accurate, 0.7× speedup?

            \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2 \cdot 10^{+137}:\\ \;\;\;\;\frac{1}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{\left(x - -1\right) \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\frac{1}{x}} \cdot 0.5}{x}\\ \end{array} \end{array} \]
            (FPCore (x)
             :precision binary64
             (if (<= x 2e+137)
               (/ 1.0 (* (+ (sqrt (- x -1.0)) (sqrt x)) (sqrt (* (- x -1.0) x))))
               (/ (* (sqrt (/ 1.0 x)) 0.5) x)))
            double code(double x) {
            	double tmp;
            	if (x <= 2e+137) {
            		tmp = 1.0 / ((sqrt((x - -1.0)) + sqrt(x)) * sqrt(((x - -1.0) * x)));
            	} else {
            		tmp = (sqrt((1.0 / x)) * 0.5) / x;
            	}
            	return tmp;
            }
            
            module fmin_fmax_functions
                implicit none
                private
                public fmax
                public fmin
            
                interface fmax
                    module procedure fmax88
                    module procedure fmax44
                    module procedure fmax84
                    module procedure fmax48
                end interface
                interface fmin
                    module procedure fmin88
                    module procedure fmin44
                    module procedure fmin84
                    module procedure fmin48
                end interface
            contains
                real(8) function fmax88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(4) function fmax44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                end function
                real(8) function fmax84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmax48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                end function
                real(8) function fmin88(x, y) result (res)
                    real(8), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(4) function fmin44(x, y) result (res)
                    real(4), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                end function
                real(8) function fmin84(x, y) result(res)
                    real(8), intent (in) :: x
                    real(4), intent (in) :: y
                    res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                end function
                real(8) function fmin48(x, y) result(res)
                    real(4), intent (in) :: x
                    real(8), intent (in) :: y
                    res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                end function
            end module
            
            real(8) function code(x)
            use fmin_fmax_functions
                real(8), intent (in) :: x
                real(8) :: tmp
                if (x <= 2d+137) then
                    tmp = 1.0d0 / ((sqrt((x - (-1.0d0))) + sqrt(x)) * sqrt(((x - (-1.0d0)) * x)))
                else
                    tmp = (sqrt((1.0d0 / x)) * 0.5d0) / x
                end if
                code = tmp
            end function
            
            public static double code(double x) {
            	double tmp;
            	if (x <= 2e+137) {
            		tmp = 1.0 / ((Math.sqrt((x - -1.0)) + Math.sqrt(x)) * Math.sqrt(((x - -1.0) * x)));
            	} else {
            		tmp = (Math.sqrt((1.0 / x)) * 0.5) / x;
            	}
            	return tmp;
            }
            
            def code(x):
            	tmp = 0
            	if x <= 2e+137:
            		tmp = 1.0 / ((math.sqrt((x - -1.0)) + math.sqrt(x)) * math.sqrt(((x - -1.0) * x)))
            	else:
            		tmp = (math.sqrt((1.0 / x)) * 0.5) / x
            	return tmp
            
            function code(x)
            	tmp = 0.0
            	if (x <= 2e+137)
            		tmp = Float64(1.0 / Float64(Float64(sqrt(Float64(x - -1.0)) + sqrt(x)) * sqrt(Float64(Float64(x - -1.0) * x))));
            	else
            		tmp = Float64(Float64(sqrt(Float64(1.0 / x)) * 0.5) / x);
            	end
            	return tmp
            end
            
            function tmp_2 = code(x)
            	tmp = 0.0;
            	if (x <= 2e+137)
            		tmp = 1.0 / ((sqrt((x - -1.0)) + sqrt(x)) * sqrt(((x - -1.0) * x)));
            	else
            		tmp = (sqrt((1.0 / x)) * 0.5) / x;
            	end
            	tmp_2 = tmp;
            end
            
            code[x_] := If[LessEqual[x, 2e+137], N[(1.0 / N[(N[(N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision] + N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[Sqrt[N[(N[(x - -1.0), $MachinePrecision] * x), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] / x), $MachinePrecision]]
            
            \begin{array}{l}
            
            \\
            \begin{array}{l}
            \mathbf{if}\;x \leq 2 \cdot 10^{+137}:\\
            \;\;\;\;\frac{1}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{\left(x - -1\right) \cdot x}}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{\sqrt{\frac{1}{x}} \cdot 0.5}{x}\\
            
            
            \end{array}
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if x < 2.0000000000000001e137

              1. Initial program 11.9%

                \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
              2. Add Preprocessing
              3. Step-by-step derivation
                1. lift--.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \]
                2. lift-/.f64N/A

                  \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
                3. lift-/.f64N/A

                  \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
                4. frac-subN/A

                  \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                5. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                6. *-lft-identityN/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                7. *-rgt-identityN/A

                  \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                8. lower--.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                9. lift-+.f64N/A

                  \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                10. metadata-evalN/A

                  \[\leadsto \frac{\sqrt{x + \color{blue}{1 \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                11. fp-cancel-sign-sub-invN/A

                  \[\leadsto \frac{\sqrt{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                12. metadata-evalN/A

                  \[\leadsto \frac{\sqrt{x - \color{blue}{-1} \cdot 1} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                13. metadata-evalN/A

                  \[\leadsto \frac{\sqrt{x - \color{blue}{-1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                14. lower--.f64N/A

                  \[\leadsto \frac{\sqrt{\color{blue}{x - -1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                15. lift-sqrt.f64N/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x}} \cdot \sqrt{x + 1}} \]
                16. lift-sqrt.f64N/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{x + 1}}} \]
                17. sqrt-unprodN/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                18. lower-sqrt.f64N/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                19. lower-*.f6412.2

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot \left(x + 1\right)}}} \]
                20. lift-+.f64N/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
                21. metadata-evalN/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x + \color{blue}{1 \cdot 1}\right)}} \]
                22. fp-cancel-sign-sub-invN/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1\right)}}} \]
                23. metadata-evalN/A

                  \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - \color{blue}{-1} \cdot 1\right)}} \]
                24. metadata-evalN/A

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

                \[\leadsto \color{blue}{\frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - -1\right)}}} \]
              5. Step-by-step derivation
                1. lift-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - -1\right)}}} \]
                2. lift--.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x - -1} - \sqrt{x}}}{\sqrt{x \cdot \left(x - -1\right)}} \]
                3. flip--N/A

                  \[\leadsto \frac{\color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x - -1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x - -1\right)}} \]
                4. associate-/l/N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}}} \]
                5. lower-/.f64N/A

                  \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}}} \]
                6. lift-sqrt.f64N/A

                  \[\leadsto \frac{\color{blue}{\sqrt{x - -1}} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                7. lift-sqrt.f64N/A

                  \[\leadsto \frac{\sqrt{x - -1} \cdot \color{blue}{\sqrt{x - -1}} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                8. rem-square-sqrtN/A

                  \[\leadsto \frac{\color{blue}{\left(x - -1\right)} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                9. lift-sqrt.f64N/A

                  \[\leadsto \frac{\left(x - -1\right) - \color{blue}{\sqrt{x}} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                10. lift-sqrt.f64N/A

                  \[\leadsto \frac{\left(x - -1\right) - \sqrt{x} \cdot \color{blue}{\sqrt{x}}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                11. rem-square-sqrtN/A

                  \[\leadsto \frac{\left(x - -1\right) - \color{blue}{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                12. lower--.f64N/A

                  \[\leadsto \frac{\color{blue}{\left(x - -1\right) - x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                13. lower-*.f64N/A

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

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

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

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

                if 2.0000000000000001e137 < x

                1. Initial program 69.7%

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

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

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

                  \[\leadsto \frac{\frac{-1}{2} \cdot \frac{\sqrt{\frac{1}{x}} - \frac{1}{4} \cdot \sqrt{\frac{1}{x}}}{x} + \frac{1}{2} \cdot \sqrt{\frac{1}{x}}}{\color{blue}{x}} \]
                6. Step-by-step derivation
                  1. Applied rewrites99.9%

                    \[\leadsto \frac{-0.5 \cdot \left(\frac{0.75 \cdot \sqrt{\frac{1}{x}}}{x} - \sqrt{\frac{1}{x}}\right)}{\color{blue}{x}} \]
                  2. Taylor expanded in x around inf

                    \[\leadsto \frac{\frac{1}{2} \cdot \sqrt{\frac{1}{x}}}{x} \]
                  3. Step-by-step derivation
                    1. Applied rewrites99.9%

                      \[\leadsto \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{x} \]
                  4. Recombined 2 regimes into one program.
                  5. Add Preprocessing

                  Alternative 5: 97.6% accurate, 1.1× speedup?

                  \[\begin{array}{l} \\ \frac{1}{\left(\sqrt{x} + \sqrt{x - -1}\right) \cdot \left(0.5 + x\right)} \end{array} \]
                  (FPCore (x)
                   :precision binary64
                   (/ 1.0 (* (+ (sqrt x) (sqrt (- x -1.0))) (+ 0.5 x))))
                  double code(double x) {
                  	return 1.0 / ((sqrt(x) + sqrt((x - -1.0))) * (0.5 + x));
                  }
                  
                  module fmin_fmax_functions
                      implicit none
                      private
                      public fmax
                      public fmin
                  
                      interface fmax
                          module procedure fmax88
                          module procedure fmax44
                          module procedure fmax84
                          module procedure fmax48
                      end interface
                      interface fmin
                          module procedure fmin88
                          module procedure fmin44
                          module procedure fmin84
                          module procedure fmin48
                      end interface
                  contains
                      real(8) function fmax88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmax44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmax84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmax48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                      end function
                      real(8) function fmin88(x, y) result (res)
                          real(8), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(4) function fmin44(x, y) result (res)
                          real(4), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                      end function
                      real(8) function fmin84(x, y) result(res)
                          real(8), intent (in) :: x
                          real(4), intent (in) :: y
                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                      end function
                      real(8) function fmin48(x, y) result(res)
                          real(4), intent (in) :: x
                          real(8), intent (in) :: y
                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                      end function
                  end module
                  
                  real(8) function code(x)
                  use fmin_fmax_functions
                      real(8), intent (in) :: x
                      code = 1.0d0 / ((sqrt(x) + sqrt((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))) * (0.5 + x));
                  }
                  
                  def code(x):
                  	return 1.0 / ((math.sqrt(x) + math.sqrt((x - -1.0))) * (0.5 + x))
                  
                  function code(x)
                  	return Float64(1.0 / Float64(Float64(sqrt(x) + sqrt(Float64(x - -1.0))) * Float64(0.5 + x)))
                  end
                  
                  function tmp = code(x)
                  	tmp = 1.0 / ((sqrt(x) + sqrt((x - -1.0))) * (0.5 + x));
                  end
                  
                  code[x_] := N[(1.0 / N[(N[(N[Sqrt[x], $MachinePrecision] + N[Sqrt[N[(x - -1.0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(0.5 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
                  
                  \begin{array}{l}
                  
                  \\
                  \frac{1}{\left(\sqrt{x} + \sqrt{x - -1}\right) \cdot \left(0.5 + x\right)}
                  \end{array}
                  
                  Derivation
                  1. Initial program 39.2%

                    \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
                  2. Add Preprocessing
                  3. Step-by-step derivation
                    1. lift--.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \]
                    2. lift-/.f64N/A

                      \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
                    3. lift-/.f64N/A

                      \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
                    4. frac-subN/A

                      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                    5. lower-/.f64N/A

                      \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                    6. *-lft-identityN/A

                      \[\leadsto \frac{\color{blue}{\sqrt{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    7. *-rgt-identityN/A

                      \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    8. lower--.f64N/A

                      \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    9. lift-+.f64N/A

                      \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    10. metadata-evalN/A

                      \[\leadsto \frac{\sqrt{x + \color{blue}{1 \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    11. fp-cancel-sign-sub-invN/A

                      \[\leadsto \frac{\sqrt{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    12. metadata-evalN/A

                      \[\leadsto \frac{\sqrt{x - \color{blue}{-1} \cdot 1} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    13. metadata-evalN/A

                      \[\leadsto \frac{\sqrt{x - \color{blue}{-1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    14. lower--.f64N/A

                      \[\leadsto \frac{\sqrt{\color{blue}{x - -1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                    15. lift-sqrt.f64N/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x}} \cdot \sqrt{x + 1}} \]
                    16. lift-sqrt.f64N/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{x + 1}}} \]
                    17. sqrt-unprodN/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                    18. lower-sqrt.f64N/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                    19. lower-*.f6439.4

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot \left(x + 1\right)}}} \]
                    20. lift-+.f64N/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
                    21. metadata-evalN/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x + \color{blue}{1 \cdot 1}\right)}} \]
                    22. fp-cancel-sign-sub-invN/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1\right)}}} \]
                    23. metadata-evalN/A

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - \color{blue}{-1} \cdot 1\right)}} \]
                    24. metadata-evalN/A

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

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

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

                      \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{0.5 + x}} \]
                    2. Step-by-step derivation
                      1. lift-/.f64N/A

                        \[\leadsto \color{blue}{\frac{\sqrt{x - -1} - \sqrt{x}}{\frac{1}{2} + x}} \]
                      2. lift--.f64N/A

                        \[\leadsto \frac{\color{blue}{\sqrt{x - -1} - \sqrt{x}}}{\frac{1}{2} + x} \]
                      3. flip--N/A

                        \[\leadsto \frac{\color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x - -1} + \sqrt{x}}}}{\frac{1}{2} + x} \]
                      4. lift-+.f64N/A

                        \[\leadsto \frac{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\color{blue}{\sqrt{x - -1} + \sqrt{x}}}}{\frac{1}{2} + x} \]
                      5. associate-/l/N/A

                        \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)}} \]
                      6. lift-sqrt.f64N/A

                        \[\leadsto \frac{\color{blue}{\sqrt{x - -1}} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)} \]
                      7. lift-sqrt.f64N/A

                        \[\leadsto \frac{\sqrt{x - -1} \cdot \color{blue}{\sqrt{x - -1}} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)} \]
                      8. rem-square-sqrtN/A

                        \[\leadsto \frac{\color{blue}{\left(x - -1\right)} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)} \]
                      9. lift-sqrt.f64N/A

                        \[\leadsto \frac{\left(x - -1\right) - \color{blue}{\sqrt{x}} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)} \]
                      10. lift-sqrt.f64N/A

                        \[\leadsto \frac{\left(x - -1\right) - \sqrt{x} \cdot \color{blue}{\sqrt{x}}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)} \]
                      11. rem-square-sqrtN/A

                        \[\leadsto \frac{\left(x - -1\right) - \color{blue}{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)} \]
                      12. lift--.f64N/A

                        \[\leadsto \frac{\color{blue}{\left(x - -1\right) - x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \left(\frac{1}{2} + x\right)} \]
                      13. lower-/.f64N/A

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

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

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

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

                      Alternative 6: 97.9% accurate, 1.2× speedup?

                      \[\begin{array}{l} \\ \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{0.5 + x} \end{array} \]
                      (FPCore (x) :precision binary64 (/ (* (sqrt (/ 1.0 x)) 0.5) (+ 0.5 x)))
                      double code(double x) {
                      	return (sqrt((1.0 / x)) * 0.5) / (0.5 + x);
                      }
                      
                      module fmin_fmax_functions
                          implicit none
                          private
                          public fmax
                          public fmin
                      
                          interface fmax
                              module procedure fmax88
                              module procedure fmax44
                              module procedure fmax84
                              module procedure fmax48
                          end interface
                          interface fmin
                              module procedure fmin88
                              module procedure fmin44
                              module procedure fmin84
                              module procedure fmin48
                          end interface
                      contains
                          real(8) function fmax88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmax44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmax84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmax48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                          end function
                          real(8) function fmin88(x, y) result (res)
                              real(8), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(4) function fmin44(x, y) result (res)
                              real(4), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                          end function
                          real(8) function fmin84(x, y) result(res)
                              real(8), intent (in) :: x
                              real(4), intent (in) :: y
                              res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                          end function
                          real(8) function fmin48(x, y) result(res)
                              real(4), intent (in) :: x
                              real(8), intent (in) :: y
                              res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                          end function
                      end module
                      
                      real(8) function code(x)
                      use fmin_fmax_functions
                          real(8), intent (in) :: x
                          code = (sqrt((1.0d0 / x)) * 0.5d0) / (0.5d0 + x)
                      end function
                      
                      public static double code(double x) {
                      	return (Math.sqrt((1.0 / x)) * 0.5) / (0.5 + x);
                      }
                      
                      def code(x):
                      	return (math.sqrt((1.0 / x)) * 0.5) / (0.5 + x)
                      
                      function code(x)
                      	return Float64(Float64(sqrt(Float64(1.0 / x)) * 0.5) / Float64(0.5 + x))
                      end
                      
                      function tmp = code(x)
                      	tmp = (sqrt((1.0 / x)) * 0.5) / (0.5 + x);
                      end
                      
                      code[x_] := N[(N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] / N[(0.5 + x), $MachinePrecision]), $MachinePrecision]
                      
                      \begin{array}{l}
                      
                      \\
                      \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{0.5 + x}
                      \end{array}
                      
                      Derivation
                      1. Initial program 39.2%

                        \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
                      2. Add Preprocessing
                      3. Step-by-step derivation
                        1. lift--.f64N/A

                          \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \]
                        2. lift-/.f64N/A

                          \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
                        3. lift-/.f64N/A

                          \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
                        4. frac-subN/A

                          \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                        5. lower-/.f64N/A

                          \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                        6. *-lft-identityN/A

                          \[\leadsto \frac{\color{blue}{\sqrt{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        7. *-rgt-identityN/A

                          \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        8. lower--.f64N/A

                          \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        9. lift-+.f64N/A

                          \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        10. metadata-evalN/A

                          \[\leadsto \frac{\sqrt{x + \color{blue}{1 \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        11. fp-cancel-sign-sub-invN/A

                          \[\leadsto \frac{\sqrt{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        12. metadata-evalN/A

                          \[\leadsto \frac{\sqrt{x - \color{blue}{-1} \cdot 1} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        13. metadata-evalN/A

                          \[\leadsto \frac{\sqrt{x - \color{blue}{-1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        14. lower--.f64N/A

                          \[\leadsto \frac{\sqrt{\color{blue}{x - -1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                        15. lift-sqrt.f64N/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x}} \cdot \sqrt{x + 1}} \]
                        16. lift-sqrt.f64N/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{x + 1}}} \]
                        17. sqrt-unprodN/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                        18. lower-sqrt.f64N/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                        19. lower-*.f6439.4

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot \left(x + 1\right)}}} \]
                        20. lift-+.f64N/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
                        21. metadata-evalN/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x + \color{blue}{1 \cdot 1}\right)}} \]
                        22. fp-cancel-sign-sub-invN/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1\right)}}} \]
                        23. metadata-evalN/A

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - \color{blue}{-1} \cdot 1\right)}} \]
                        24. metadata-evalN/A

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

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

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

                          \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{0.5 + x}} \]
                        2. Taylor expanded in x around inf

                          \[\leadsto \frac{\color{blue}{\frac{1}{2} \cdot \sqrt{\frac{1}{x}}}}{\frac{1}{2} + x} \]
                        3. Step-by-step derivation
                          1. Applied rewrites96.9%

                            \[\leadsto \frac{\color{blue}{\sqrt{\frac{1}{x}} \cdot 0.5}}{0.5 + x} \]
                          2. Add Preprocessing

                          Alternative 7: 97.8% accurate, 1.3× speedup?

                          \[\begin{array}{l} \\ \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{x} \end{array} \]
                          (FPCore (x) :precision binary64 (/ (* (sqrt (/ 1.0 x)) 0.5) x))
                          double code(double x) {
                          	return (sqrt((1.0 / x)) * 0.5) / x;
                          }
                          
                          module fmin_fmax_functions
                              implicit none
                              private
                              public fmax
                              public fmin
                          
                              interface fmax
                                  module procedure fmax88
                                  module procedure fmax44
                                  module procedure fmax84
                                  module procedure fmax48
                              end interface
                              interface fmin
                                  module procedure fmin88
                                  module procedure fmin44
                                  module procedure fmin84
                                  module procedure fmin48
                              end interface
                          contains
                              real(8) function fmax88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmax44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmax84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmax48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                              end function
                              real(8) function fmin88(x, y) result (res)
                                  real(8), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(4) function fmin44(x, y) result (res)
                                  real(4), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                              end function
                              real(8) function fmin84(x, y) result(res)
                                  real(8), intent (in) :: x
                                  real(4), intent (in) :: y
                                  res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                              end function
                              real(8) function fmin48(x, y) result(res)
                                  real(4), intent (in) :: x
                                  real(8), intent (in) :: y
                                  res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                              end function
                          end module
                          
                          real(8) function code(x)
                          use fmin_fmax_functions
                              real(8), intent (in) :: x
                              code = (sqrt((1.0d0 / x)) * 0.5d0) / x
                          end function
                          
                          public static double code(double x) {
                          	return (Math.sqrt((1.0 / x)) * 0.5) / x;
                          }
                          
                          def code(x):
                          	return (math.sqrt((1.0 / x)) * 0.5) / x
                          
                          function code(x)
                          	return Float64(Float64(sqrt(Float64(1.0 / x)) * 0.5) / x)
                          end
                          
                          function tmp = code(x)
                          	tmp = (sqrt((1.0 / x)) * 0.5) / x;
                          end
                          
                          code[x_] := N[(N[(N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision] / x), $MachinePrecision]
                          
                          \begin{array}{l}
                          
                          \\
                          \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{x}
                          \end{array}
                          
                          Derivation
                          1. Initial program 39.2%

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

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

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

                            \[\leadsto \frac{\frac{-1}{2} \cdot \frac{\sqrt{\frac{1}{x}} - \frac{1}{4} \cdot \sqrt{\frac{1}{x}}}{x} + \frac{1}{2} \cdot \sqrt{\frac{1}{x}}}{\color{blue}{x}} \]
                          6. Step-by-step derivation
                            1. Applied rewrites98.3%

                              \[\leadsto \frac{-0.5 \cdot \left(\frac{0.75 \cdot \sqrt{\frac{1}{x}}}{x} - \sqrt{\frac{1}{x}}\right)}{\color{blue}{x}} \]
                            2. Taylor expanded in x around inf

                              \[\leadsto \frac{\frac{1}{2} \cdot \sqrt{\frac{1}{x}}}{x} \]
                            3. Step-by-step derivation
                              1. Applied rewrites96.7%

                                \[\leadsto \frac{\sqrt{\frac{1}{x}} \cdot 0.5}{x} \]
                              2. Add Preprocessing

                              Alternative 8: 81.3% accurate, 1.5× speedup?

                              \[\begin{array}{l} \\ \frac{0.5 \cdot \sqrt{x}}{x \cdot x} \end{array} \]
                              (FPCore (x) :precision binary64 (/ (* 0.5 (sqrt x)) (* x x)))
                              double code(double x) {
                              	return (0.5 * sqrt(x)) / (x * x);
                              }
                              
                              module fmin_fmax_functions
                                  implicit none
                                  private
                                  public fmax
                                  public fmin
                              
                                  interface fmax
                                      module procedure fmax88
                                      module procedure fmax44
                                      module procedure fmax84
                                      module procedure fmax48
                                  end interface
                                  interface fmin
                                      module procedure fmin88
                                      module procedure fmin44
                                      module procedure fmin84
                                      module procedure fmin48
                                  end interface
                              contains
                                  real(8) function fmax88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmax44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmax84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmax48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin88(x, y) result (res)
                                      real(8), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(4) function fmin44(x, y) result (res)
                                      real(4), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                  end function
                                  real(8) function fmin84(x, y) result(res)
                                      real(8), intent (in) :: x
                                      real(4), intent (in) :: y
                                      res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                  end function
                                  real(8) function fmin48(x, y) result(res)
                                      real(4), intent (in) :: x
                                      real(8), intent (in) :: y
                                      res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                  end function
                              end module
                              
                              real(8) function code(x)
                              use fmin_fmax_functions
                                  real(8), intent (in) :: x
                                  code = (0.5d0 * sqrt(x)) / (x * x)
                              end function
                              
                              public static double code(double x) {
                              	return (0.5 * Math.sqrt(x)) / (x * x);
                              }
                              
                              def code(x):
                              	return (0.5 * math.sqrt(x)) / (x * x)
                              
                              function code(x)
                              	return Float64(Float64(0.5 * sqrt(x)) / Float64(x * x))
                              end
                              
                              function tmp = code(x)
                              	tmp = (0.5 * sqrt(x)) / (x * x);
                              end
                              
                              code[x_] := N[(N[(0.5 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] / N[(x * x), $MachinePrecision]), $MachinePrecision]
                              
                              \begin{array}{l}
                              
                              \\
                              \frac{0.5 \cdot \sqrt{x}}{x \cdot x}
                              \end{array}
                              
                              Derivation
                              1. Initial program 39.2%

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

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

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

                                \[\leadsto \frac{\frac{1}{2} \cdot \sqrt{x}}{\color{blue}{x} \cdot x} \]
                              6. Step-by-step derivation
                                1. Applied rewrites85.0%

                                  \[\leadsto \frac{0.5 \cdot \sqrt{x}}{\color{blue}{x} \cdot x} \]
                                2. Add Preprocessing

                                Alternative 9: 37.8% accurate, 1.6× speedup?

                                \[\begin{array}{l} \\ \frac{\left(x - -1\right) - x}{\sqrt{x} + x} \end{array} \]
                                (FPCore (x) :precision binary64 (/ (- (- x -1.0) x) (+ (sqrt x) x)))
                                double code(double x) {
                                	return ((x - -1.0) - x) / (sqrt(x) + x);
                                }
                                
                                module fmin_fmax_functions
                                    implicit none
                                    private
                                    public fmax
                                    public fmin
                                
                                    interface fmax
                                        module procedure fmax88
                                        module procedure fmax44
                                        module procedure fmax84
                                        module procedure fmax48
                                    end interface
                                    interface fmin
                                        module procedure fmin88
                                        module procedure fmin44
                                        module procedure fmin84
                                        module procedure fmin48
                                    end interface
                                contains
                                    real(8) function fmax88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmax44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmax84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmax48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin88(x, y) result (res)
                                        real(8), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(4) function fmin44(x, y) result (res)
                                        real(4), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                    end function
                                    real(8) function fmin84(x, y) result(res)
                                        real(8), intent (in) :: x
                                        real(4), intent (in) :: y
                                        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                    end function
                                    real(8) function fmin48(x, y) result(res)
                                        real(4), intent (in) :: x
                                        real(8), intent (in) :: y
                                        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                    end function
                                end module
                                
                                real(8) function code(x)
                                use fmin_fmax_functions
                                    real(8), intent (in) :: x
                                    code = ((x - (-1.0d0)) - x) / (sqrt(x) + x)
                                end function
                                
                                public static double code(double x) {
                                	return ((x - -1.0) - x) / (Math.sqrt(x) + x);
                                }
                                
                                def code(x):
                                	return ((x - -1.0) - x) / (math.sqrt(x) + x)
                                
                                function code(x)
                                	return Float64(Float64(Float64(x - -1.0) - x) / Float64(sqrt(x) + x))
                                end
                                
                                function tmp = code(x)
                                	tmp = ((x - -1.0) - x) / (sqrt(x) + x);
                                end
                                
                                code[x_] := N[(N[(N[(x - -1.0), $MachinePrecision] - x), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
                                
                                \begin{array}{l}
                                
                                \\
                                \frac{\left(x - -1\right) - x}{\sqrt{x} + x}
                                \end{array}
                                
                                Derivation
                                1. Initial program 39.2%

                                  \[\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}} \]
                                2. Add Preprocessing
                                3. Step-by-step derivation
                                  1. lift--.f64N/A

                                    \[\leadsto \color{blue}{\frac{1}{\sqrt{x}} - \frac{1}{\sqrt{x + 1}}} \]
                                  2. lift-/.f64N/A

                                    \[\leadsto \color{blue}{\frac{1}{\sqrt{x}}} - \frac{1}{\sqrt{x + 1}} \]
                                  3. lift-/.f64N/A

                                    \[\leadsto \frac{1}{\sqrt{x}} - \color{blue}{\frac{1}{\sqrt{x + 1}}} \]
                                  4. frac-subN/A

                                    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                                  5. lower-/.f64N/A

                                    \[\leadsto \color{blue}{\frac{1 \cdot \sqrt{x + 1} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}}} \]
                                  6. *-lft-identityN/A

                                    \[\leadsto \frac{\color{blue}{\sqrt{x + 1}} - \sqrt{x} \cdot 1}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  7. *-rgt-identityN/A

                                    \[\leadsto \frac{\sqrt{x + 1} - \color{blue}{\sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  8. lower--.f64N/A

                                    \[\leadsto \frac{\color{blue}{\sqrt{x + 1} - \sqrt{x}}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  9. lift-+.f64N/A

                                    \[\leadsto \frac{\sqrt{\color{blue}{x + 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  10. metadata-evalN/A

                                    \[\leadsto \frac{\sqrt{x + \color{blue}{1 \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  11. fp-cancel-sign-sub-invN/A

                                    \[\leadsto \frac{\sqrt{\color{blue}{x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  12. metadata-evalN/A

                                    \[\leadsto \frac{\sqrt{x - \color{blue}{-1} \cdot 1} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  13. metadata-evalN/A

                                    \[\leadsto \frac{\sqrt{x - \color{blue}{-1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  14. lower--.f64N/A

                                    \[\leadsto \frac{\sqrt{\color{blue}{x - -1}} - \sqrt{x}}{\sqrt{x} \cdot \sqrt{x + 1}} \]
                                  15. lift-sqrt.f64N/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x}} \cdot \sqrt{x + 1}} \]
                                  16. lift-sqrt.f64N/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x} \cdot \color{blue}{\sqrt{x + 1}}} \]
                                  17. sqrt-unprodN/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                                  18. lower-sqrt.f64N/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\color{blue}{\sqrt{x \cdot \left(x + 1\right)}}} \]
                                  19. lower-*.f6439.4

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{\color{blue}{x \cdot \left(x + 1\right)}}} \]
                                  20. lift-+.f64N/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x + 1\right)}}} \]
                                  21. metadata-evalN/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x + \color{blue}{1 \cdot 1}\right)}} \]
                                  22. fp-cancel-sign-sub-invN/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \color{blue}{\left(x - \left(\mathsf{neg}\left(1\right)\right) \cdot 1\right)}}} \]
                                  23. metadata-evalN/A

                                    \[\leadsto \frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - \color{blue}{-1} \cdot 1\right)}} \]
                                  24. metadata-evalN/A

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

                                  \[\leadsto \color{blue}{\frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - -1\right)}}} \]
                                5. Step-by-step derivation
                                  1. lift-/.f64N/A

                                    \[\leadsto \color{blue}{\frac{\sqrt{x - -1} - \sqrt{x}}{\sqrt{x \cdot \left(x - -1\right)}}} \]
                                  2. lift--.f64N/A

                                    \[\leadsto \frac{\color{blue}{\sqrt{x - -1} - \sqrt{x}}}{\sqrt{x \cdot \left(x - -1\right)}} \]
                                  3. flip--N/A

                                    \[\leadsto \frac{\color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\sqrt{x - -1} + \sqrt{x}}}}{\sqrt{x \cdot \left(x - -1\right)}} \]
                                  4. associate-/l/N/A

                                    \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}}} \]
                                  5. lower-/.f64N/A

                                    \[\leadsto \color{blue}{\frac{\sqrt{x - -1} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}}} \]
                                  6. lift-sqrt.f64N/A

                                    \[\leadsto \frac{\color{blue}{\sqrt{x - -1}} \cdot \sqrt{x - -1} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                                  7. lift-sqrt.f64N/A

                                    \[\leadsto \frac{\sqrt{x - -1} \cdot \color{blue}{\sqrt{x - -1}} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                                  8. rem-square-sqrtN/A

                                    \[\leadsto \frac{\color{blue}{\left(x - -1\right)} - \sqrt{x} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                                  9. lift-sqrt.f64N/A

                                    \[\leadsto \frac{\left(x - -1\right) - \color{blue}{\sqrt{x}} \cdot \sqrt{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                                  10. lift-sqrt.f64N/A

                                    \[\leadsto \frac{\left(x - -1\right) - \sqrt{x} \cdot \color{blue}{\sqrt{x}}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                                  11. rem-square-sqrtN/A

                                    \[\leadsto \frac{\left(x - -1\right) - \color{blue}{x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                                  12. lower--.f64N/A

                                    \[\leadsto \frac{\color{blue}{\left(x - -1\right) - x}}{\left(\sqrt{x - -1} + \sqrt{x}\right) \cdot \sqrt{x \cdot \left(x - -1\right)}} \]
                                  13. lower-*.f64N/A

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

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

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

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

                                  Alternative 10: 5.6% accurate, 2.2× speedup?

                                  \[\begin{array}{l} \\ \sqrt{\frac{1}{x}} \end{array} \]
                                  (FPCore (x) :precision binary64 (sqrt (/ 1.0 x)))
                                  double code(double x) {
                                  	return sqrt((1.0 / x));
                                  }
                                  
                                  module fmin_fmax_functions
                                      implicit none
                                      private
                                      public fmax
                                      public fmin
                                  
                                      interface fmax
                                          module procedure fmax88
                                          module procedure fmax44
                                          module procedure fmax84
                                          module procedure fmax48
                                      end interface
                                      interface fmin
                                          module procedure fmin88
                                          module procedure fmin44
                                          module procedure fmin84
                                          module procedure fmin48
                                      end interface
                                  contains
                                      real(8) function fmax88(x, y) result (res)
                                          real(8), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                      end function
                                      real(4) function fmax44(x, y) result (res)
                                          real(4), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                      end function
                                      real(8) function fmax84(x, y) result(res)
                                          real(8), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                      end function
                                      real(8) function fmax48(x, y) result(res)
                                          real(4), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                      end function
                                      real(8) function fmin88(x, y) result (res)
                                          real(8), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                      end function
                                      real(4) function fmin44(x, y) result (res)
                                          real(4), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                      end function
                                      real(8) function fmin84(x, y) result(res)
                                          real(8), intent (in) :: x
                                          real(4), intent (in) :: y
                                          res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                      end function
                                      real(8) function fmin48(x, y) result(res)
                                          real(4), intent (in) :: x
                                          real(8), intent (in) :: y
                                          res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                      end function
                                  end module
                                  
                                  real(8) function code(x)
                                  use fmin_fmax_functions
                                      real(8), intent (in) :: x
                                      code = sqrt((1.0d0 / x))
                                  end function
                                  
                                  public static double code(double x) {
                                  	return Math.sqrt((1.0 / x));
                                  }
                                  
                                  def code(x):
                                  	return math.sqrt((1.0 / x))
                                  
                                  function code(x)
                                  	return sqrt(Float64(1.0 / x))
                                  end
                                  
                                  function tmp = code(x)
                                  	tmp = sqrt((1.0 / x));
                                  end
                                  
                                  code[x_] := N[Sqrt[N[(1.0 / x), $MachinePrecision]], $MachinePrecision]
                                  
                                  \begin{array}{l}
                                  
                                  \\
                                  \sqrt{\frac{1}{x}}
                                  \end{array}
                                  
                                  Derivation
                                  1. Initial program 39.2%

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

                                    \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
                                  4. Step-by-step derivation
                                    1. Applied rewrites5.8%

                                      \[\leadsto \color{blue}{\sqrt{\frac{1}{x}}} \]
                                    2. Add Preprocessing

                                    Developer Target 1: 40.1% accurate, 0.2× speedup?

                                    \[\begin{array}{l} \\ {x}^{-0.5} - {\left(x + 1\right)}^{-0.5} \end{array} \]
                                    (FPCore (x) :precision binary64 (- (pow x -0.5) (pow (+ x 1.0) -0.5)))
                                    double code(double x) {
                                    	return pow(x, -0.5) - pow((x + 1.0), -0.5);
                                    }
                                    
                                    module fmin_fmax_functions
                                        implicit none
                                        private
                                        public fmax
                                        public fmin
                                    
                                        interface fmax
                                            module procedure fmax88
                                            module procedure fmax44
                                            module procedure fmax84
                                            module procedure fmax48
                                        end interface
                                        interface fmin
                                            module procedure fmin88
                                            module procedure fmin44
                                            module procedure fmin84
                                            module procedure fmin48
                                        end interface
                                    contains
                                        real(8) function fmax88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmax44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, max(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmax84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmax48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin88(x, y) result (res)
                                            real(8), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(4) function fmin44(x, y) result (res)
                                            real(4), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(y, merge(x, min(x, y), y /= y), x /= x)
                                        end function
                                        real(8) function fmin84(x, y) result(res)
                                            real(8), intent (in) :: x
                                            real(4), intent (in) :: y
                                            res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
                                        end function
                                        real(8) function fmin48(x, y) result(res)
                                            real(4), intent (in) :: x
                                            real(8), intent (in) :: y
                                            res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
                                        end function
                                    end module
                                    
                                    real(8) function code(x)
                                    use fmin_fmax_functions
                                        real(8), intent (in) :: x
                                        code = (x ** (-0.5d0)) - ((x + 1.0d0) ** (-0.5d0))
                                    end function
                                    
                                    public static double code(double x) {
                                    	return Math.pow(x, -0.5) - Math.pow((x + 1.0), -0.5);
                                    }
                                    
                                    def code(x):
                                    	return math.pow(x, -0.5) - math.pow((x + 1.0), -0.5)
                                    
                                    function code(x)
                                    	return Float64((x ^ -0.5) - (Float64(x + 1.0) ^ -0.5))
                                    end
                                    
                                    function tmp = code(x)
                                    	tmp = (x ^ -0.5) - ((x + 1.0) ^ -0.5);
                                    end
                                    
                                    code[x_] := N[(N[Power[x, -0.5], $MachinePrecision] - N[Power[N[(x + 1.0), $MachinePrecision], -0.5], $MachinePrecision]), $MachinePrecision]
                                    
                                    \begin{array}{l}
                                    
                                    \\
                                    {x}^{-0.5} - {\left(x + 1\right)}^{-0.5}
                                    \end{array}
                                    

                                    Reproduce

                                    ?
                                    herbie shell --seed 2025019 
                                    (FPCore (x)
                                      :name "2isqrt (example 3.6)"
                                      :precision binary64
                                      :pre (and (> x 1.0) (< x 1e+308))
                                    
                                      :alt
                                      (! :herbie-platform default (- (pow x -1/2) (pow (+ x 1) -1/2)))
                                    
                                      (- (/ 1.0 (sqrt x)) (/ 1.0 (sqrt (+ x 1.0)))))