Data.Approximate.Numerics:blog from approximate-0.2.2.1

Percentage Accurate: 99.7% → 99.9%
Time: 7.7s
Alternatives: 9
Speedup: 1.0×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Accuracy vs Speed?

Herbie found 9 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: 99.7% accurate, 1.0× speedup?

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

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

Alternative 1: 99.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \frac{x + -1}{x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)} \cdot 6 \end{array} \]
(FPCore (x)
 :precision binary64
 (* (/ (+ x -1.0) (+ x (fma 4.0 (sqrt x) 1.0))) 6.0))
double code(double x) {
	return ((x + -1.0) / (x + fma(4.0, sqrt(x), 1.0))) * 6.0;
}
function code(x)
	return Float64(Float64(Float64(x + -1.0) / Float64(x + fma(4.0, sqrt(x), 1.0))) * 6.0)
end
code[x_] := N[(N[(N[(x + -1.0), $MachinePrecision] / N[(x + N[(4.0 * N[Sqrt[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 6.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{x + -1}{x + \mathsf{fma}\left(4, \sqrt{x}, 1\right)} \cdot 6
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. associate-/l*99.9%

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

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

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

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

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

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

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

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

Alternative 2: 98.2% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.078:\\
\;\;\;\;\left(x \cdot -78 - 6\right) \cdot \left(1 + \left(x + \sqrt{x} \cdot -4\right)\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{6}{1 + 4 \cdot {x}^{-0.5}}\\


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

    1. Initial program 99.9%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip-+99.9%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(6, x, -6\right)}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right)} \]
    5. Step-by-step derivation
      1. fma-define99.9%

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

        \[\leadsto \frac{\color{blue}{x \cdot 6} + -6}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
      3. fma-define99.9%

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

        \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{{\color{blue}{\left(1 + x\right)}}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
      5. associate-+l+99.9%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, 6, -6\right)}{{\left(1 + x\right)}^{2} - x \cdot 16} \cdot \left(x + \left(1 + \sqrt{x} \cdot -4\right)\right)} \]
    7. Taylor expanded in x around 0 99.6%

      \[\leadsto \color{blue}{\left(-78 \cdot x - 6\right)} \cdot \left(x + \left(1 + \sqrt{x} \cdot -4\right)\right) \]
    8. Taylor expanded in x around 0 99.6%

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

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

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

    if 0.0779999999999999999 < x

    1. Initial program 99.0%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 98.4%

      \[\leadsto \color{blue}{\frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity98.4%

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

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

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

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

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

        \[\leadsto \frac{6}{1 + 4 \cdot \color{blue}{{x}^{-0.5}}} \]
    7. Simplified98.4%

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

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

Alternative 3: 97.8% accurate, 1.0× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;\frac{6}{1 + 4 \cdot {x}^{-0.5}}\\


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

    1. Initial program 99.9%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 98.8%

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

    if 1 < x

    1. Initial program 99.0%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 98.4%

      \[\leadsto \color{blue}{\frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity98.4%

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

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

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

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

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

        \[\leadsto \frac{6}{1 + 4 \cdot \color{blue}{{x}^{-0.5}}} \]
    7. Simplified98.4%

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

Alternative 4: 97.8% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1:\\
\;\;\;\;\frac{-6}{1 + 4 \cdot \sqrt{x}}\\

\mathbf{else}:\\
\;\;\;\;\frac{6}{1 + 4 \cdot {x}^{-0.5}}\\


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

    1. Initial program 99.9%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 98.7%

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

    if 1 < x

    1. Initial program 99.0%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around inf 98.4%

      \[\leadsto \color{blue}{\frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}}} \]
    4. Step-by-step derivation
      1. *-un-lft-identity98.4%

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

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

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

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

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

        \[\leadsto \frac{6}{1 + 4 \cdot \color{blue}{{x}^{-0.5}}} \]
    7. Simplified98.4%

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

Alternative 5: 99.7% accurate, 1.0× speedup?

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

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

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
  2. Add Preprocessing
  3. Final simplification99.5%

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

Alternative 6: 97.7% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 14.2:\\
\;\;\;\;\frac{-6}{1 + 4 \cdot \sqrt{x}}\\

\mathbf{else}:\\
\;\;\;\;6 + \frac{-24}{\sqrt{x}}\\


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

    1. Initial program 99.9%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Taylor expanded in x around 0 98.7%

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

    if 14.199999999999999 < x

    1. Initial program 99.0%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip-+45.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(6, x, -6\right)}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right)} \]
    5. Step-by-step derivation
      1. fma-define45.5%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{{\color{blue}{\left(1 + x\right)}}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
      5. associate-+l+45.5%

        \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{{\left(1 + x\right)}^{2} - x \cdot 16} \cdot \color{blue}{\left(x + \left(1 + -4 \cdot \sqrt{x}\right)\right)} \]
      6. *-commutative45.5%

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, 6, -6\right)}{{\left(1 + x\right)}^{2} - x \cdot 16} \cdot \left(x + \left(1 + \sqrt{x} \cdot -4\right)\right)} \]
    7. Taylor expanded in x around inf 98.3%

      \[\leadsto \color{blue}{6 \cdot \left(1 + -4 \cdot \sqrt{\frac{1}{x}}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in98.3%

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

        \[\leadsto \color{blue}{6} + 6 \cdot \left(-4 \cdot \sqrt{\frac{1}{x}}\right) \]
      3. associate-*r*98.3%

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

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

      \[\leadsto \color{blue}{6 + -24 \cdot \sqrt{\frac{1}{x}}} \]
    10. Step-by-step derivation
      1. sqrt-div98.3%

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

        \[\leadsto 6 + -24 \cdot \frac{\color{blue}{1}}{\sqrt{x}} \]
      3. un-div-inv98.3%

        \[\leadsto 6 + \color{blue}{\frac{-24}{\sqrt{x}}} \]
    11. Applied egg-rr98.3%

      \[\leadsto 6 + \color{blue}{\frac{-24}{\sqrt{x}}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 7: 97.6% accurate, 1.0× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 16.5:\\
\;\;\;\;-6 + \sqrt{x} \cdot 24\\

\mathbf{else}:\\
\;\;\;\;6 + \frac{-24}{\sqrt{x}}\\


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

    1. Initial program 99.9%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip-+99.9%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(6, x, -6\right)}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right)} \]
    5. Step-by-step derivation
      1. fma-define99.9%

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

        \[\leadsto \frac{\color{blue}{x \cdot 6} + -6}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
      3. fma-define99.9%

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

        \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{{\color{blue}{\left(1 + x\right)}}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
      5. associate-+l+99.9%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, 6, -6\right)}{{\left(1 + x\right)}^{2} - x \cdot 16} \cdot \left(x + \left(1 + \sqrt{x} \cdot -4\right)\right)} \]
    7. Taylor expanded in x around 0 98.5%

      \[\leadsto \color{blue}{-6 \cdot \left(1 + -4 \cdot \sqrt{x}\right)} \]
    8. Step-by-step derivation
      1. metadata-eval98.5%

        \[\leadsto -6 \cdot \left(1 + \color{blue}{\left(-4\right)} \cdot \sqrt{x}\right) \]
      2. distribute-lft-neg-in98.5%

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

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

        \[\leadsto \color{blue}{-6} + -6 \cdot \left(-4 \cdot \sqrt{x}\right) \]
      5. distribute-lft-neg-in98.5%

        \[\leadsto -6 + -6 \cdot \color{blue}{\left(\left(-4\right) \cdot \sqrt{x}\right)} \]
      6. metadata-eval98.5%

        \[\leadsto -6 + -6 \cdot \left(\color{blue}{-4} \cdot \sqrt{x}\right) \]
      7. associate-*r*98.5%

        \[\leadsto -6 + \color{blue}{\left(-6 \cdot -4\right) \cdot \sqrt{x}} \]
      8. metadata-eval98.5%

        \[\leadsto -6 + \color{blue}{24} \cdot \sqrt{x} \]
    9. Simplified98.5%

      \[\leadsto \color{blue}{-6 + 24 \cdot \sqrt{x}} \]

    if 16.5 < x

    1. Initial program 99.0%

      \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
    2. Add Preprocessing
    3. Step-by-step derivation
      1. flip-+45.6%

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

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(6, x, -6\right)}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right)} \]
    5. Step-by-step derivation
      1. fma-define45.5%

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

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

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

        \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{{\color{blue}{\left(1 + x\right)}}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
      5. associate-+l+45.5%

        \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{{\left(1 + x\right)}^{2} - x \cdot 16} \cdot \color{blue}{\left(x + \left(1 + -4 \cdot \sqrt{x}\right)\right)} \]
      6. *-commutative45.5%

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

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, 6, -6\right)}{{\left(1 + x\right)}^{2} - x \cdot 16} \cdot \left(x + \left(1 + \sqrt{x} \cdot -4\right)\right)} \]
    7. Taylor expanded in x around inf 98.3%

      \[\leadsto \color{blue}{6 \cdot \left(1 + -4 \cdot \sqrt{\frac{1}{x}}\right)} \]
    8. Step-by-step derivation
      1. distribute-lft-in98.3%

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

        \[\leadsto \color{blue}{6} + 6 \cdot \left(-4 \cdot \sqrt{\frac{1}{x}}\right) \]
      3. associate-*r*98.3%

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

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

      \[\leadsto \color{blue}{6 + -24 \cdot \sqrt{\frac{1}{x}}} \]
    10. Step-by-step derivation
      1. sqrt-div98.3%

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

        \[\leadsto 6 + -24 \cdot \frac{\color{blue}{1}}{\sqrt{x}} \]
      3. un-div-inv98.3%

        \[\leadsto 6 + \color{blue}{\frac{-24}{\sqrt{x}}} \]
    11. Applied egg-rr98.3%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 16.5:\\ \;\;\;\;-6 + \sqrt{x} \cdot 24\\ \mathbf{else}:\\ \;\;\;\;6 + \frac{-24}{\sqrt{x}}\\ \end{array} \]
  5. Add Preprocessing

Alternative 8: 51.0% accurate, 1.1× speedup?

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

\\
-6 + \sqrt{x} \cdot 24
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
  2. Add Preprocessing
  3. Step-by-step derivation
    1. flip-+73.0%

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(6, x, -6\right)}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right)} \]
  5. Step-by-step derivation
    1. fma-define73.0%

      \[\leadsto \frac{\color{blue}{6 \cdot x + -6}}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
    2. *-commutative73.0%

      \[\leadsto \frac{\color{blue}{x \cdot 6} + -6}{{\left(x + 1\right)}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
    3. fma-define72.9%

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

      \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{{\color{blue}{\left(1 + x\right)}}^{2} - x \cdot 16} \cdot \left(\left(x + 1\right) + -4 \cdot \sqrt{x}\right) \]
    5. associate-+l+72.9%

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

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(x, 6, -6\right)}{{\left(1 + x\right)}^{2} - x \cdot 16} \cdot \left(x + \left(1 + \sqrt{x} \cdot -4\right)\right)} \]
  7. Taylor expanded in x around 0 53.0%

    \[\leadsto \color{blue}{-6 \cdot \left(1 + -4 \cdot \sqrt{x}\right)} \]
  8. Step-by-step derivation
    1. metadata-eval53.0%

      \[\leadsto -6 \cdot \left(1 + \color{blue}{\left(-4\right)} \cdot \sqrt{x}\right) \]
    2. distribute-lft-neg-in53.0%

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

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

      \[\leadsto \color{blue}{-6} + -6 \cdot \left(-4 \cdot \sqrt{x}\right) \]
    5. distribute-lft-neg-in53.0%

      \[\leadsto -6 + -6 \cdot \color{blue}{\left(\left(-4\right) \cdot \sqrt{x}\right)} \]
    6. metadata-eval53.0%

      \[\leadsto -6 + -6 \cdot \left(\color{blue}{-4} \cdot \sqrt{x}\right) \]
    7. associate-*r*53.0%

      \[\leadsto -6 + \color{blue}{\left(-6 \cdot -4\right) \cdot \sqrt{x}} \]
    8. metadata-eval53.0%

      \[\leadsto -6 + \color{blue}{24} \cdot \sqrt{x} \]
  9. Simplified53.0%

    \[\leadsto \color{blue}{-6 + 24 \cdot \sqrt{x}} \]
  10. Final simplification53.0%

    \[\leadsto -6 + \sqrt{x} \cdot 24 \]
  11. Add Preprocessing

Alternative 9: 4.5% accurate, 1.1× speedup?

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

\\
\sqrt{x \cdot 2.25}
\end{array}
Derivation
  1. Initial program 99.5%

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
  2. Add Preprocessing
  3. Taylor expanded in x around inf 49.8%

    \[\leadsto \color{blue}{\frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}}} \]
  4. Taylor expanded in x around 0 4.3%

    \[\leadsto \color{blue}{1.5 \cdot \sqrt{x}} \]
  5. Step-by-step derivation
    1. *-commutative4.3%

      \[\leadsto \color{blue}{\sqrt{x} \cdot 1.5} \]
  6. Simplified4.3%

    \[\leadsto \color{blue}{\sqrt{x} \cdot 1.5} \]
  7. Step-by-step derivation
    1. add-sqr-sqrt4.3%

      \[\leadsto \color{blue}{\sqrt{\sqrt{x} \cdot 1.5} \cdot \sqrt{\sqrt{x} \cdot 1.5}} \]
    2. sqrt-unprod4.3%

      \[\leadsto \color{blue}{\sqrt{\left(\sqrt{x} \cdot 1.5\right) \cdot \left(\sqrt{x} \cdot 1.5\right)}} \]
    3. swap-sqr4.3%

      \[\leadsto \sqrt{\color{blue}{\left(\sqrt{x} \cdot \sqrt{x}\right) \cdot \left(1.5 \cdot 1.5\right)}} \]
    4. add-sqr-sqrt4.3%

      \[\leadsto \sqrt{\color{blue}{x} \cdot \left(1.5 \cdot 1.5\right)} \]
    5. metadata-eval4.3%

      \[\leadsto \sqrt{x \cdot \color{blue}{2.25}} \]
  8. Applied egg-rr4.3%

    \[\leadsto \color{blue}{\sqrt{x \cdot 2.25}} \]
  9. Add Preprocessing

Developer target: 99.9% accurate, 1.0× speedup?

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

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

Reproduce

?
herbie shell --seed 2024087 
(FPCore (x)
  :name "Data.Approximate.Numerics:blog from approximate-0.2.2.1"
  :precision binary64

  :alt
  (/ 6.0 (/ (+ (+ x 1.0) (* 4.0 (sqrt x))) (- x 1.0)))

  (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))