Data.Approximate.Numerics:blog from approximate-0.2.2.1

Percentage Accurate: 99.7% → 99.9%
Time: 3.6s
Alternatives: 10
Speedup: 1.1×

Specification

?
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
(FPCore (x)
  :precision binary64
  :pre TRUE
  (/ (* 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)
use fmin_fmax_functions
    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]
f(x):
	x in [-inf, +inf]
code: THEORY
BEGIN
f(x: real): real =
	((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))
END code
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}

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

\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
(FPCore (x)
  :precision binary64
  :pre TRUE
  (/ (* 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)
use fmin_fmax_functions
    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]
f(x):
	x in [-inf, +inf]
code: THEORY
BEGIN
f(x: real): real =
	((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))
END code
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}

Alternative 1: 99.9% accurate, 1.0× speedup?

\[-6 \cdot \frac{1 - x}{\mathsf{fma}\left(\sqrt{x}, 4, 1 + x\right)} \]
(FPCore (x)
  :precision binary64
  :pre TRUE
  (* -6.0 (/ (- 1.0 x) (fma (sqrt x) 4.0 (+ 1.0 x)))))
double code(double x) {
	return -6.0 * ((1.0 - x) / fma(sqrt(x), 4.0, (1.0 + x)));
}
function code(x)
	return Float64(-6.0 * Float64(Float64(1.0 - x) / fma(sqrt(x), 4.0, Float64(1.0 + x))))
end
code[x_] := N[(-6.0 * N[(N[(1.0 - x), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] * 4.0 + N[(1.0 + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
f(x):
	x in [-inf, +inf]
code: THEORY
BEGIN
f(x: real): real =
	(-6) * (((1) - x) / (((sqrt(x)) * (4)) + ((1) + x)))
END code
-6 \cdot \frac{1 - x}{\mathsf{fma}\left(\sqrt{x}, 4, 1 + x\right)}
Derivation
  1. Initial program 99.7%

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

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

    Alternative 2: 99.7% accurate, 1.1× speedup?

    \[\frac{\mathsf{fma}\left(-6, x, 6\right)}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)} \]
    (FPCore (x)
      :precision binary64
      :pre TRUE
      (/ (fma -6.0 x 6.0) (fma -4.0 (sqrt x) (- -1.0 x))))
    double code(double x) {
    	return fma(-6.0, x, 6.0) / fma(-4.0, sqrt(x), (-1.0 - x));
    }
    
    function code(x)
    	return Float64(fma(-6.0, x, 6.0) / fma(-4.0, sqrt(x), Float64(-1.0 - x)))
    end
    
    code[x_] := N[(N[(-6.0 * x + 6.0), $MachinePrecision] / N[(-4.0 * N[Sqrt[x], $MachinePrecision] + N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    f(x):
    	x in [-inf, +inf]
    code: THEORY
    BEGIN
    f(x: real): real =
    	(((-6) * x) + (6)) / (((-4) * (sqrt(x))) + ((-1) - x))
    END code
    \frac{\mathsf{fma}\left(-6, x, 6\right)}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)}
    
    Derivation
    1. Initial program 99.7%

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

        \[\leadsto \frac{\mathsf{fma}\left(-6, x, 6\right)}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)} \]
      2. Add Preprocessing

      Alternative 3: 97.6% accurate, 0.5× speedup?

      \[\begin{array}{l} t_0 := 6 \cdot \left(x - 1\right)\\ \mathbf{if}\;\frac{t\_0}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\ \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(4, \sqrt{x}, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\ \end{array} \]
      (FPCore (x)
        :precision binary64
        :pre TRUE
        (let* ((t_0 (* 6.0 (- x 1.0))))
        (if (<= (/ t_0 (+ (+ x 1.0) (* 4.0 (sqrt x)))) -1.0)
          (/ t_0 (fma 4.0 (sqrt x) 1.0))
          (/ 6.0 (- (/ 4.0 (sqrt x)) -1.0)))))
      double code(double x) {
      	double t_0 = 6.0 * (x - 1.0);
      	double tmp;
      	if ((t_0 / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0) {
      		tmp = t_0 / fma(4.0, sqrt(x), 1.0);
      	} else {
      		tmp = 6.0 / ((4.0 / sqrt(x)) - -1.0);
      	}
      	return tmp;
      }
      
      function code(x)
      	t_0 = Float64(6.0 * Float64(x - 1.0))
      	tmp = 0.0
      	if (Float64(t_0 / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x)))) <= -1.0)
      		tmp = Float64(t_0 / fma(4.0, sqrt(x), 1.0));
      	else
      		tmp = Float64(6.0 / Float64(Float64(4.0 / sqrt(x)) - -1.0));
      	end
      	return tmp
      end
      
      code[x_] := Block[{t$95$0 = N[(6.0 * N[(x - 1.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(t$95$0 / N[(N[(x + 1.0), $MachinePrecision] + N[(4.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1.0], N[(t$95$0 / N[(4.0 * N[Sqrt[x], $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(N[(4.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]]
      
      f(x):
      	x in [-inf, +inf]
      code: THEORY
      BEGIN
      f(x: real): real =
      	LET t_0 = ((6) * (x - (1))) IN
      		LET tmp = IF ((t_0 / ((x + (1)) + ((4) * (sqrt(x))))) <= (-1)) THEN (t_0 / (((4) * (sqrt(x))) + (1))) ELSE ((6) / (((4) / (sqrt(x))) - (-1))) ENDIF IN
      	tmp
      END code
      \begin{array}{l}
      t_0 := 6 \cdot \left(x - 1\right)\\
      \mathbf{if}\;\frac{t\_0}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\
      \;\;\;\;\frac{t\_0}{\mathsf{fma}\left(4, \sqrt{x}, 1\right)}\\
      
      \mathbf{else}:\\
      \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\
      
      
      \end{array}
      
      Derivation
      1. Split input into 2 regimes
      2. if (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x)))) < -1

        1. Initial program 99.7%

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

          \[\leadsto \frac{6 \cdot \left(x - 1\right)}{1 + 4 \cdot \sqrt{x}} \]
        3. Step-by-step derivation
          1. Applied rewrites51.7%

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

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

            if -1 < (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x))))

            1. Initial program 99.7%

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

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

                \[\leadsto \frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}} \]
              2. Applied rewrites50.4%

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

            Alternative 4: 97.6% accurate, 0.5× speedup?

            \[\begin{array}{l} \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\ \;\;\;\;\frac{\mathsf{fma}\left(x, 6, -6\right)}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\ \end{array} \]
            (FPCore (x)
              :precision binary64
              :pre TRUE
              (if (<= (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))) -1.0)
              (/ (fma x 6.0 -6.0) (fma (sqrt x) 4.0 1.0))
              (/ 6.0 (- (/ 4.0 (sqrt x)) -1.0))))
            double code(double x) {
            	double tmp;
            	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0) {
            		tmp = fma(x, 6.0, -6.0) / fma(sqrt(x), 4.0, 1.0);
            	} else {
            		tmp = 6.0 / ((4.0 / sqrt(x)) - -1.0);
            	}
            	return tmp;
            }
            
            function code(x)
            	tmp = 0.0
            	if (Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x)))) <= -1.0)
            		tmp = Float64(fma(x, 6.0, -6.0) / fma(sqrt(x), 4.0, 1.0));
            	else
            		tmp = Float64(6.0 / Float64(Float64(4.0 / sqrt(x)) - -1.0));
            	end
            	return tmp
            end
            
            code[x_] := If[LessEqual[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], -1.0], N[(N[(x * 6.0 + -6.0), $MachinePrecision] / N[(N[Sqrt[x], $MachinePrecision] * 4.0 + 1.0), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(N[(4.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]
            
            f(x):
            	x in [-inf, +inf]
            code: THEORY
            BEGIN
            f(x: real): real =
            	LET tmp = IF ((((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))) <= (-1)) THEN (((x * (6)) + (-6)) / (((sqrt(x)) * (4)) + (1))) ELSE ((6) / (((4) / (sqrt(x))) - (-1))) ENDIF IN
            	tmp
            END code
            \begin{array}{l}
            \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\
            \;\;\;\;\frac{\mathsf{fma}\left(x, 6, -6\right)}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)}\\
            
            \mathbf{else}:\\
            \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\
            
            
            \end{array}
            
            Derivation
            1. Split input into 2 regimes
            2. if (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x)))) < -1

              1. Initial program 99.7%

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

                \[\leadsto \frac{6 \cdot \left(x - 1\right)}{1 + 4 \cdot \sqrt{x}} \]
              3. Step-by-step derivation
                1. Applied rewrites51.7%

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

                    \[\leadsto \frac{\mathsf{fma}\left(x, 6, -6\right)}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)} \]

                  if -1 < (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x))))

                  1. Initial program 99.7%

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

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

                      \[\leadsto \frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}} \]
                    2. Applied rewrites50.4%

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

                  Alternative 5: 97.6% accurate, 0.5× speedup?

                  \[\begin{array}{l} \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\ \;\;\;\;\frac{6}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\ \end{array} \]
                  (FPCore (x)
                    :precision binary64
                    :pre TRUE
                    (if (<= (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))) -1.0)
                    (/ 6.0 (fma -4.0 (sqrt x) (- -1.0 x)))
                    (/ 6.0 (- (/ 4.0 (sqrt x)) -1.0))))
                  double code(double x) {
                  	double tmp;
                  	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0) {
                  		tmp = 6.0 / fma(-4.0, sqrt(x), (-1.0 - x));
                  	} else {
                  		tmp = 6.0 / ((4.0 / sqrt(x)) - -1.0);
                  	}
                  	return tmp;
                  }
                  
                  function code(x)
                  	tmp = 0.0
                  	if (Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x)))) <= -1.0)
                  		tmp = Float64(6.0 / fma(-4.0, sqrt(x), Float64(-1.0 - x)));
                  	else
                  		tmp = Float64(6.0 / Float64(Float64(4.0 / sqrt(x)) - -1.0));
                  	end
                  	return tmp
                  end
                  
                  code[x_] := If[LessEqual[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], -1.0], N[(6.0 / N[(-4.0 * N[Sqrt[x], $MachinePrecision] + N[(-1.0 - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(N[(4.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]
                  
                  f(x):
                  	x in [-inf, +inf]
                  code: THEORY
                  BEGIN
                  f(x: real): real =
                  	LET tmp = IF ((((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))) <= (-1)) THEN ((6) / (((-4) * (sqrt(x))) + ((-1) - x))) ELSE ((6) / (((4) / (sqrt(x))) - (-1))) ENDIF IN
                  	tmp
                  END code
                  \begin{array}{l}
                  \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\
                  \;\;\;\;\frac{6}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)}\\
                  
                  \mathbf{else}:\\
                  \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\
                  
                  
                  \end{array}
                  
                  Derivation
                  1. Split input into 2 regimes
                  2. if (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x)))) < -1

                    1. Initial program 99.7%

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

                        \[\leadsto \frac{\mathsf{fma}\left(-6, x, 6\right)}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)} \]
                      2. Taylor expanded in x around 0

                        \[\leadsto \frac{6}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)} \]
                      3. Step-by-step derivation
                        1. Applied rewrites49.3%

                          \[\leadsto \frac{6}{\mathsf{fma}\left(-4, \sqrt{x}, -1 - x\right)} \]

                        if -1 < (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x))))

                        1. Initial program 99.7%

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

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

                            \[\leadsto \frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}} \]
                          2. Applied rewrites50.4%

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

                        Alternative 6: 97.6% accurate, 0.6× speedup?

                        \[\begin{array}{l} \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt{x}, -0.6666666666666666, -0.16666666666666666\right)}\\ \mathbf{else}:\\ \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\ \end{array} \]
                        (FPCore (x)
                          :precision binary64
                          :pre TRUE
                          (if (<= (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))) -1.0)
                          (/ 1.0 (fma (sqrt x) -0.6666666666666666 -0.16666666666666666))
                          (/ 6.0 (- (/ 4.0 (sqrt x)) -1.0))))
                        double code(double x) {
                        	double tmp;
                        	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0) {
                        		tmp = 1.0 / fma(sqrt(x), -0.6666666666666666, -0.16666666666666666);
                        	} else {
                        		tmp = 6.0 / ((4.0 / sqrt(x)) - -1.0);
                        	}
                        	return tmp;
                        }
                        
                        function code(x)
                        	tmp = 0.0
                        	if (Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x)))) <= -1.0)
                        		tmp = Float64(1.0 / fma(sqrt(x), -0.6666666666666666, -0.16666666666666666));
                        	else
                        		tmp = Float64(6.0 / Float64(Float64(4.0 / sqrt(x)) - -1.0));
                        	end
                        	return tmp
                        end
                        
                        code[x_] := If[LessEqual[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], -1.0], N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] * -0.6666666666666666 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision], N[(6.0 / N[(N[(4.0 / N[Sqrt[x], $MachinePrecision]), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]]
                        
                        f(x):
                        	x in [-inf, +inf]
                        code: THEORY
                        BEGIN
                        f(x: real): real =
                        	LET tmp = IF ((((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))) <= (-1)) THEN ((1) / (((sqrt(x)) * (-66666666666666662965923251249478198587894439697265625e-53)) + (-1666666666666666574148081281236954964697360992431640625e-55))) ELSE ((6) / (((4) / (sqrt(x))) - (-1))) ENDIF IN
                        	tmp
                        END code
                        \begin{array}{l}
                        \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\
                        \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt{x}, -0.6666666666666666, -0.16666666666666666\right)}\\
                        
                        \mathbf{else}:\\
                        \;\;\;\;\frac{6}{\frac{4}{\sqrt{x}} - -1}\\
                        
                        
                        \end{array}
                        
                        Derivation
                        1. Split input into 2 regimes
                        2. if (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x)))) < -1

                          1. Initial program 99.7%

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

                            \[\leadsto \frac{-6}{1 + 4 \cdot \sqrt{x}} \]
                          3. Step-by-step derivation
                            1. Applied rewrites49.0%

                              \[\leadsto \frac{-6}{1 + 4 \cdot \sqrt{x}} \]
                            2. Applied rewrites49.0%

                              \[\leadsto \frac{-6}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)} \]
                            3. Step-by-step derivation
                              1. Applied rewrites49.0%

                                \[\leadsto \frac{1}{\mathsf{fma}\left(\sqrt{x}, -0.6666666666666666, -0.16666666666666666\right)} \]

                              if -1 < (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x))))

                              1. Initial program 99.7%

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

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

                                  \[\leadsto \frac{6}{1 + 4 \cdot \sqrt{\frac{1}{x}}} \]
                                2. Applied rewrites50.4%

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

                              Alternative 7: 96.4% accurate, 0.6× speedup?

                              \[\begin{array}{l} \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\ \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt{x}, -0.6666666666666666, -0.16666666666666666\right)}\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
                              (FPCore (x)
                                :precision binary64
                                :pre TRUE
                                (if (<= (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))) -1.0)
                                (/ 1.0 (fma (sqrt x) -0.6666666666666666 -0.16666666666666666))
                                6.0))
                              double code(double x) {
                              	double tmp;
                              	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0) {
                              		tmp = 1.0 / fma(sqrt(x), -0.6666666666666666, -0.16666666666666666);
                              	} else {
                              		tmp = 6.0;
                              	}
                              	return tmp;
                              }
                              
                              function code(x)
                              	tmp = 0.0
                              	if (Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x)))) <= -1.0)
                              		tmp = Float64(1.0 / fma(sqrt(x), -0.6666666666666666, -0.16666666666666666));
                              	else
                              		tmp = 6.0;
                              	end
                              	return tmp
                              end
                              
                              code[x_] := If[LessEqual[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], -1.0], N[(1.0 / N[(N[Sqrt[x], $MachinePrecision] * -0.6666666666666666 + -0.16666666666666666), $MachinePrecision]), $MachinePrecision], 6.0]
                              
                              f(x):
                              	x in [-inf, +inf]
                              code: THEORY
                              BEGIN
                              f(x: real): real =
                              	LET tmp = IF ((((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))) <= (-1)) THEN ((1) / (((sqrt(x)) * (-66666666666666662965923251249478198587894439697265625e-53)) + (-1666666666666666574148081281236954964697360992431640625e-55))) ELSE (6) ENDIF IN
                              	tmp
                              END code
                              \begin{array}{l}
                              \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\
                              \;\;\;\;\frac{1}{\mathsf{fma}\left(\sqrt{x}, -0.6666666666666666, -0.16666666666666666\right)}\\
                              
                              \mathbf{else}:\\
                              \;\;\;\;6\\
                              
                              
                              \end{array}
                              
                              Derivation
                              1. Split input into 2 regimes
                              2. if (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x)))) < -1

                                1. Initial program 99.7%

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

                                  \[\leadsto \frac{-6}{1 + 4 \cdot \sqrt{x}} \]
                                3. Step-by-step derivation
                                  1. Applied rewrites49.0%

                                    \[\leadsto \frac{-6}{1 + 4 \cdot \sqrt{x}} \]
                                  2. Applied rewrites49.0%

                                    \[\leadsto \frac{-6}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)} \]
                                  3. Step-by-step derivation
                                    1. Applied rewrites49.0%

                                      \[\leadsto \frac{1}{\mathsf{fma}\left(\sqrt{x}, -0.6666666666666666, -0.16666666666666666\right)} \]

                                    if -1 < (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x))))

                                    1. Initial program 99.7%

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

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

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

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

                                          \[\leadsto 1.5 \cdot \frac{x}{\sqrt{x}} \]
                                        2. Step-by-step derivation
                                          1. Applied rewrites4.5%

                                            \[\leadsto 1.5 \cdot \sqrt{x} \]
                                          2. Taylor expanded in x around inf

                                            \[\leadsto 6 \]
                                          3. Step-by-step derivation
                                            1. Applied rewrites49.1%

                                              \[\leadsto 6 \]
                                          4. Recombined 2 regimes into one program.
                                          5. Add Preprocessing

                                          Alternative 8: 96.4% accurate, 0.6× speedup?

                                          \[\begin{array}{l} \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\ \;\;\;\;\frac{-6}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)}\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
                                          (FPCore (x)
                                            :precision binary64
                                            :pre TRUE
                                            (if (<= (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))) -1.0)
                                            (/ -6.0 (fma (sqrt x) 4.0 1.0))
                                            6.0))
                                          double code(double x) {
                                          	double tmp;
                                          	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0) {
                                          		tmp = -6.0 / fma(sqrt(x), 4.0, 1.0);
                                          	} else {
                                          		tmp = 6.0;
                                          	}
                                          	return tmp;
                                          }
                                          
                                          function code(x)
                                          	tmp = 0.0
                                          	if (Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x)))) <= -1.0)
                                          		tmp = Float64(-6.0 / fma(sqrt(x), 4.0, 1.0));
                                          	else
                                          		tmp = 6.0;
                                          	end
                                          	return tmp
                                          end
                                          
                                          code[x_] := If[LessEqual[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], -1.0], N[(-6.0 / N[(N[Sqrt[x], $MachinePrecision] * 4.0 + 1.0), $MachinePrecision]), $MachinePrecision], 6.0]
                                          
                                          f(x):
                                          	x in [-inf, +inf]
                                          code: THEORY
                                          BEGIN
                                          f(x: real): real =
                                          	LET tmp = IF ((((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))) <= (-1)) THEN ((-6) / (((sqrt(x)) * (4)) + (1))) ELSE (6) ENDIF IN
                                          	tmp
                                          END code
                                          \begin{array}{l}
                                          \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\
                                          \;\;\;\;\frac{-6}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)}\\
                                          
                                          \mathbf{else}:\\
                                          \;\;\;\;6\\
                                          
                                          
                                          \end{array}
                                          
                                          Derivation
                                          1. Split input into 2 regimes
                                          2. if (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x)))) < -1

                                            1. Initial program 99.7%

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

                                              \[\leadsto \frac{-6}{1 + 4 \cdot \sqrt{x}} \]
                                            3. Step-by-step derivation
                                              1. Applied rewrites49.0%

                                                \[\leadsto \frac{-6}{1 + 4 \cdot \sqrt{x}} \]
                                              2. Applied rewrites49.0%

                                                \[\leadsto \frac{-6}{\mathsf{fma}\left(\sqrt{x}, 4, 1\right)} \]

                                              if -1 < (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x))))

                                              1. Initial program 99.7%

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

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

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

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

                                                    \[\leadsto 1.5 \cdot \frac{x}{\sqrt{x}} \]
                                                  2. Step-by-step derivation
                                                    1. Applied rewrites4.5%

                                                      \[\leadsto 1.5 \cdot \sqrt{x} \]
                                                    2. Taylor expanded in x around inf

                                                      \[\leadsto 6 \]
                                                    3. Step-by-step derivation
                                                      1. Applied rewrites49.1%

                                                        \[\leadsto 6 \]
                                                    4. Recombined 2 regimes into one program.
                                                    5. Add Preprocessing

                                                    Alternative 9: 51.7% accurate, 0.7× speedup?

                                                    \[\begin{array}{l} \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\ \;\;\;\;\sqrt{x} \cdot -1.5\\ \mathbf{else}:\\ \;\;\;\;6\\ \end{array} \]
                                                    (FPCore (x)
                                                      :precision binary64
                                                      :pre TRUE
                                                      (if (<= (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))) -1.0)
                                                      (* (sqrt x) -1.5)
                                                      6.0))
                                                    double code(double x) {
                                                    	double tmp;
                                                    	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0) {
                                                    		tmp = sqrt(x) * -1.5;
                                                    	} else {
                                                    		tmp = 6.0;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    real(8) function code(x)
                                                    use fmin_fmax_functions
                                                        real(8), intent (in) :: x
                                                        real(8) :: tmp
                                                        if (((6.0d0 * (x - 1.0d0)) / ((x + 1.0d0) + (4.0d0 * sqrt(x)))) <= (-1.0d0)) then
                                                            tmp = sqrt(x) * (-1.5d0)
                                                        else
                                                            tmp = 6.0d0
                                                        end if
                                                        code = tmp
                                                    end function
                                                    
                                                    public static double code(double x) {
                                                    	double tmp;
                                                    	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * Math.sqrt(x)))) <= -1.0) {
                                                    		tmp = Math.sqrt(x) * -1.5;
                                                    	} else {
                                                    		tmp = 6.0;
                                                    	}
                                                    	return tmp;
                                                    }
                                                    
                                                    def code(x):
                                                    	tmp = 0
                                                    	if ((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * math.sqrt(x)))) <= -1.0:
                                                    		tmp = math.sqrt(x) * -1.5
                                                    	else:
                                                    		tmp = 6.0
                                                    	return tmp
                                                    
                                                    function code(x)
                                                    	tmp = 0.0
                                                    	if (Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x)))) <= -1.0)
                                                    		tmp = Float64(sqrt(x) * -1.5);
                                                    	else
                                                    		tmp = 6.0;
                                                    	end
                                                    	return tmp
                                                    end
                                                    
                                                    function tmp_2 = code(x)
                                                    	tmp = 0.0;
                                                    	if (((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)))) <= -1.0)
                                                    		tmp = sqrt(x) * -1.5;
                                                    	else
                                                    		tmp = 6.0;
                                                    	end
                                                    	tmp_2 = tmp;
                                                    end
                                                    
                                                    code[x_] := If[LessEqual[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], -1.0], N[(N[Sqrt[x], $MachinePrecision] * -1.5), $MachinePrecision], 6.0]
                                                    
                                                    f(x):
                                                    	x in [-inf, +inf]
                                                    code: THEORY
                                                    BEGIN
                                                    f(x: real): real =
                                                    	LET tmp = IF ((((6) * (x - (1))) / ((x + (1)) + ((4) * (sqrt(x))))) <= (-1)) THEN ((sqrt(x)) * (-15e-1)) ELSE (6) ENDIF IN
                                                    	tmp
                                                    END code
                                                    \begin{array}{l}
                                                    \mathbf{if}\;\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \leq -1:\\
                                                    \;\;\;\;\sqrt{x} \cdot -1.5\\
                                                    
                                                    \mathbf{else}:\\
                                                    \;\;\;\;6\\
                                                    
                                                    
                                                    \end{array}
                                                    
                                                    Derivation
                                                    1. Split input into 2 regimes
                                                    2. if (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x)))) < -1

                                                      1. Initial program 99.7%

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

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

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

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

                                                            \[\leadsto 1.5 \cdot \frac{x}{\sqrt{x}} \]
                                                          2. Taylor expanded in x around -inf

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

                                                              \[\leadsto \frac{-1.5}{\sqrt{\frac{1}{x}}} \]
                                                            2. Step-by-step derivation
                                                              1. Applied rewrites4.1%

                                                                \[\leadsto \sqrt{x} \cdot -1.5 \]

                                                              if -1 < (/.f64 (*.f64 #s(literal 6 binary64) (-.f64 x #s(literal 1 binary64))) (+.f64 (+.f64 x #s(literal 1 binary64)) (*.f64 #s(literal 4 binary64) (sqrt.f64 x))))

                                                              1. Initial program 99.7%

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

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

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

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

                                                                    \[\leadsto 1.5 \cdot \frac{x}{\sqrt{x}} \]
                                                                  2. Step-by-step derivation
                                                                    1. Applied rewrites4.5%

                                                                      \[\leadsto 1.5 \cdot \sqrt{x} \]
                                                                    2. Taylor expanded in x around inf

                                                                      \[\leadsto 6 \]
                                                                    3. Step-by-step derivation
                                                                      1. Applied rewrites49.1%

                                                                        \[\leadsto 6 \]
                                                                    4. Recombined 2 regimes into one program.
                                                                    5. Add Preprocessing

                                                                    Alternative 10: 49.1% accurate, 20.6× speedup?

                                                                    \[6 \]
                                                                    (FPCore (x)
                                                                      :precision binary64
                                                                      :pre TRUE
                                                                      6.0)
                                                                    double code(double x) {
                                                                    	return 6.0;
                                                                    }
                                                                    
                                                                    real(8) function code(x)
                                                                    use fmin_fmax_functions
                                                                        real(8), intent (in) :: x
                                                                        code = 6.0d0
                                                                    end function
                                                                    
                                                                    public static double code(double x) {
                                                                    	return 6.0;
                                                                    }
                                                                    
                                                                    def code(x):
                                                                    	return 6.0
                                                                    
                                                                    function code(x)
                                                                    	return 6.0
                                                                    end
                                                                    
                                                                    function tmp = code(x)
                                                                    	tmp = 6.0;
                                                                    end
                                                                    
                                                                    code[x_] := 6.0
                                                                    
                                                                    f(x):
                                                                    	x in [-inf, +inf]
                                                                    code: THEORY
                                                                    BEGIN
                                                                    f(x: real): real =
                                                                    	6
                                                                    END code
                                                                    6
                                                                    
                                                                    Derivation
                                                                    1. Initial program 99.7%

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

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

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

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

                                                                          \[\leadsto 1.5 \cdot \frac{x}{\sqrt{x}} \]
                                                                        2. Step-by-step derivation
                                                                          1. Applied rewrites4.5%

                                                                            \[\leadsto 1.5 \cdot \sqrt{x} \]
                                                                          2. Taylor expanded in x around inf

                                                                            \[\leadsto 6 \]
                                                                          3. Step-by-step derivation
                                                                            1. Applied rewrites49.1%

                                                                              \[\leadsto 6 \]
                                                                            2. Add Preprocessing

                                                                            Reproduce

                                                                            ?
                                                                            herbie shell --seed 2026092 
                                                                            (FPCore (x)
                                                                              :name "Data.Approximate.Numerics:blog from approximate-0.2.2.1"
                                                                              :precision binary64
                                                                              (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))