sqrtexp (problem 3.4.4)

Percentage Accurate: 36.5% → 99.9%
Time: 6.7s
Alternatives: 5
Speedup: 21.2×

Specification

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

\\
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

\\
\sqrt{\frac{e^{2 \cdot x} - 1}{e^{x} - 1}}
\end{array}

Alternative 1: 99.9% accurate, 2.0× speedup?

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

\\
\sqrt{e^{x} - -1}
\end{array}
Derivation
  1. Initial program 40.3%

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

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

      \[\leadsto \sqrt{\frac{\color{blue}{e^{2 \cdot x} - 1}}{e^{x} - 1}} \]
    3. lift-exp.f64N/A

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

      \[\leadsto \sqrt{\frac{e^{\color{blue}{2 \cdot x}} - 1}{e^{x} - 1}} \]
    5. *-commutativeN/A

      \[\leadsto \sqrt{\frac{e^{\color{blue}{x \cdot 2}} - 1}{e^{x} - 1}} \]
    6. exp-prodN/A

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

      \[\leadsto \sqrt{\frac{{\color{blue}{\left(e^{x}\right)}}^{2} - 1}{e^{x} - 1}} \]
    8. pow2N/A

      \[\leadsto \sqrt{\frac{\color{blue}{e^{x} \cdot e^{x}} - 1}{e^{x} - 1}} \]
    9. metadata-evalN/A

      \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - \color{blue}{1 \cdot 1}}{e^{x} - 1}} \]
    10. lift--.f64N/A

      \[\leadsto \sqrt{\frac{e^{x} \cdot e^{x} - 1 \cdot 1}{\color{blue}{e^{x} - 1}}} \]
    11. flip-+N/A

      \[\leadsto \sqrt{\color{blue}{e^{x} + 1}} \]
    12. metadata-evalN/A

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

      \[\leadsto \sqrt{e^{x} + \left(\mathsf{neg}\left(\color{blue}{\left(\mathsf{neg}\left(1\right)\right)}\right)\right)} \]
    14. sub-negN/A

      \[\leadsto \sqrt{\color{blue}{e^{x} - \left(\mathsf{neg}\left(1\right)\right)}} \]
    15. lower--.f64N/A

      \[\leadsto \sqrt{\color{blue}{e^{x} - \left(\mathsf{neg}\left(1\right)\right)}} \]
    16. metadata-eval100.0

      \[\leadsto \sqrt{e^{x} - \color{blue}{-1}} \]
  4. Applied rewrites100.0%

    \[\leadsto \sqrt{\color{blue}{e^{x} - -1}} \]
  5. Add Preprocessing

Alternative 2: 72.3% accurate, 0.8× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{e^{2 \cdot x} - 1}{e^{x} - 1} \leq 1.5:\\ \;\;\;\;\sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.036458333333333336, x, 0.1875\right), x, 0.5\right), \frac{x}{\sqrt{2}}, \sqrt{2}\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0)) 1.5)
   (sqrt 2.0)
   (fma
    (fma (fma 0.036458333333333336 x 0.1875) x 0.5)
    (/ x (sqrt 2.0))
    (sqrt 2.0))))
double code(double x) {
	double tmp;
	if (((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)) <= 1.5) {
		tmp = sqrt(2.0);
	} else {
		tmp = fma(fma(fma(0.036458333333333336, x, 0.1875), x, 0.5), (x / sqrt(2.0)), sqrt(2.0));
	}
	return tmp;
}
function code(x)
	tmp = 0.0
	if (Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0)) <= 1.5)
		tmp = sqrt(2.0);
	else
		tmp = fma(fma(fma(0.036458333333333336, x, 0.1875), x, 0.5), Float64(x / sqrt(2.0)), sqrt(2.0));
	end
	return tmp
end
code[x_] := If[LessEqual[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], 1.5], N[Sqrt[2.0], $MachinePrecision], N[(N[(N[(0.036458333333333336 * x + 0.1875), $MachinePrecision] * x + 0.5), $MachinePrecision] * N[(x / N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision] + N[Sqrt[2.0], $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{e^{2 \cdot x} - 1}{e^{x} - 1} \leq 1.5:\\
\;\;\;\;\sqrt{2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.036458333333333336, x, 0.1875\right), x, 0.5\right), \frac{x}{\sqrt{2}}, \sqrt{2}\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (-.f64 (exp.f64 (*.f64 #s(literal 2 binary64) x)) #s(literal 1 binary64)) (-.f64 (exp.f64 x) #s(literal 1 binary64))) < 1.5

    1. Initial program 100.0%

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

      \[\leadsto \sqrt{\color{blue}{2}} \]
    4. Step-by-step derivation
      1. Applied rewrites20.7%

        \[\leadsto \sqrt{\color{blue}{2}} \]

      if 1.5 < (/.f64 (-.f64 (exp.f64 (*.f64 #s(literal 2 binary64) x)) #s(literal 1 binary64)) (-.f64 (exp.f64 x) #s(literal 1 binary64)))

      1. Initial program 6.3%

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

        \[\leadsto \sqrt{\color{blue}{2}} \]
      4. Step-by-step derivation
        1. Applied rewrites96.1%

          \[\leadsto \sqrt{\color{blue}{2}} \]
        2. Taylor expanded in x around 0

          \[\leadsto \color{blue}{\sqrt{2} + x \cdot \left(\frac{1}{2} \cdot \frac{x \cdot \left(\frac{1}{2} - \frac{1}{4} \cdot \frac{1}{{\left(\sqrt{2}\right)}^{2}}\right)}{\sqrt{2}} + \frac{1}{2} \cdot \frac{1}{\sqrt{2}}\right)} \]
        3. Step-by-step derivation
          1. +-commutativeN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{x}{\sqrt{2}}, \mathsf{fma}\left(0.1875, x, 0.5\right), \sqrt{2}\right)} \]
        5. Taylor expanded in x around 0

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{1}{\sqrt{2}} \cdot \mathsf{fma}\left(x, \mathsf{fma}\left(0.036458333333333336, x, 0.1875\right), 0.5\right), x, \sqrt{2}\right)} \]
        7. Step-by-step derivation
          1. Applied rewrites98.9%

            \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.036458333333333336, x, 0.1875\right), x, 0.5\right), \color{blue}{\frac{x}{\sqrt{2}}}, \sqrt{2}\right) \]
        8. Recombined 2 regimes into one program.
        9. Add Preprocessing

        Alternative 3: 72.3% accurate, 0.9× speedup?

        \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{e^{2 \cdot x} - 1}{e^{x} - 1} \leq 1.5:\\ \;\;\;\;\sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 2\right)}\\ \end{array} \end{array} \]
        (FPCore (x)
         :precision binary64
         (if (<= (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0)) 1.5)
           (sqrt 2.0)
           (sqrt (fma (fma (fma 0.16666666666666666 x 0.5) x 1.0) x 2.0))))
        double code(double x) {
        	double tmp;
        	if (((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)) <= 1.5) {
        		tmp = sqrt(2.0);
        	} else {
        		tmp = sqrt(fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 2.0));
        	}
        	return tmp;
        }
        
        function code(x)
        	tmp = 0.0
        	if (Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0)) <= 1.5)
        		tmp = sqrt(2.0);
        	else
        		tmp = sqrt(fma(fma(fma(0.16666666666666666, x, 0.5), x, 1.0), x, 2.0));
        	end
        	return tmp
        end
        
        code[x_] := If[LessEqual[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], 1.5], N[Sqrt[2.0], $MachinePrecision], N[Sqrt[N[(N[(N[(0.16666666666666666 * x + 0.5), $MachinePrecision] * x + 1.0), $MachinePrecision] * x + 2.0), $MachinePrecision]], $MachinePrecision]]
        
        \begin{array}{l}
        
        \\
        \begin{array}{l}
        \mathbf{if}\;\frac{e^{2 \cdot x} - 1}{e^{x} - 1} \leq 1.5:\\
        \;\;\;\;\sqrt{2}\\
        
        \mathbf{else}:\\
        \;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 2\right)}\\
        
        
        \end{array}
        \end{array}
        
        Derivation
        1. Split input into 2 regimes
        2. if (/.f64 (-.f64 (exp.f64 (*.f64 #s(literal 2 binary64) x)) #s(literal 1 binary64)) (-.f64 (exp.f64 x) #s(literal 1 binary64))) < 1.5

          1. Initial program 100.0%

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

            \[\leadsto \sqrt{\color{blue}{2}} \]
          4. Step-by-step derivation
            1. Applied rewrites20.7%

              \[\leadsto \sqrt{\color{blue}{2}} \]

            if 1.5 < (/.f64 (-.f64 (exp.f64 (*.f64 #s(literal 2 binary64) x)) #s(literal 1 binary64)) (-.f64 (exp.f64 x) #s(literal 1 binary64)))

            1. Initial program 6.3%

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

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

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

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

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

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

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

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

                \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\frac{1}{6} \cdot x + \frac{1}{2}}, x, 1\right), x, 2\right)} \]
              8. lower-fma.f6498.9

                \[\leadsto \sqrt{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.16666666666666666, x, 0.5\right)}, x, 1\right), x, 2\right)} \]
            5. Applied rewrites98.9%

              \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(0.16666666666666666, x, 0.5\right), x, 1\right), x, 2\right)}} \]
          5. Recombined 2 regimes into one program.
          6. Add Preprocessing

          Alternative 4: 72.2% accurate, 0.9× speedup?

          \[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{e^{2 \cdot x} - 1}{e^{x} - 1} \leq 1.5:\\ \;\;\;\;\sqrt{2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 2\right)}\\ \end{array} \end{array} \]
          (FPCore (x)
           :precision binary64
           (if (<= (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0)) 1.5)
             (sqrt 2.0)
             (sqrt (fma (fma 0.5 x 1.0) x 2.0))))
          double code(double x) {
          	double tmp;
          	if (((exp((2.0 * x)) - 1.0) / (exp(x) - 1.0)) <= 1.5) {
          		tmp = sqrt(2.0);
          	} else {
          		tmp = sqrt(fma(fma(0.5, x, 1.0), x, 2.0));
          	}
          	return tmp;
          }
          
          function code(x)
          	tmp = 0.0
          	if (Float64(Float64(exp(Float64(2.0 * x)) - 1.0) / Float64(exp(x) - 1.0)) <= 1.5)
          		tmp = sqrt(2.0);
          	else
          		tmp = sqrt(fma(fma(0.5, x, 1.0), x, 2.0));
          	end
          	return tmp
          end
          
          code[x_] := If[LessEqual[N[(N[(N[Exp[N[(2.0 * x), $MachinePrecision]], $MachinePrecision] - 1.0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision], 1.5], N[Sqrt[2.0], $MachinePrecision], N[Sqrt[N[(N[(0.5 * x + 1.0), $MachinePrecision] * x + 2.0), $MachinePrecision]], $MachinePrecision]]
          
          \begin{array}{l}
          
          \\
          \begin{array}{l}
          \mathbf{if}\;\frac{e^{2 \cdot x} - 1}{e^{x} - 1} \leq 1.5:\\
          \;\;\;\;\sqrt{2}\\
          
          \mathbf{else}:\\
          \;\;\;\;\sqrt{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 2\right)}\\
          
          
          \end{array}
          \end{array}
          
          Derivation
          1. Split input into 2 regimes
          2. if (/.f64 (-.f64 (exp.f64 (*.f64 #s(literal 2 binary64) x)) #s(literal 1 binary64)) (-.f64 (exp.f64 x) #s(literal 1 binary64))) < 1.5

            1. Initial program 100.0%

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

              \[\leadsto \sqrt{\color{blue}{2}} \]
            4. Step-by-step derivation
              1. Applied rewrites20.7%

                \[\leadsto \sqrt{\color{blue}{2}} \]

              if 1.5 < (/.f64 (-.f64 (exp.f64 (*.f64 #s(literal 2 binary64) x)) #s(literal 1 binary64)) (-.f64 (exp.f64 x) #s(literal 1 binary64)))

              1. Initial program 6.3%

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

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

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

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

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

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

                  \[\leadsto \sqrt{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(0.5, x, 1\right)}, x, 2\right)} \]
              5. Applied rewrites98.6%

                \[\leadsto \sqrt{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(0.5, x, 1\right), x, 2\right)}} \]
            5. Recombined 2 regimes into one program.
            6. Add Preprocessing

            Alternative 5: 71.2% accurate, 21.2× speedup?

            \[\begin{array}{l} \\ \sqrt{2} \end{array} \]
            (FPCore (x) :precision binary64 (sqrt 2.0))
            double code(double x) {
            	return sqrt(2.0);
            }
            
            real(8) function code(x)
                real(8), intent (in) :: x
                code = sqrt(2.0d0)
            end function
            
            public static double code(double x) {
            	return Math.sqrt(2.0);
            }
            
            def code(x):
            	return math.sqrt(2.0)
            
            function code(x)
            	return sqrt(2.0)
            end
            
            function tmp = code(x)
            	tmp = sqrt(2.0);
            end
            
            code[x_] := N[Sqrt[2.0], $MachinePrecision]
            
            \begin{array}{l}
            
            \\
            \sqrt{2}
            \end{array}
            
            Derivation
            1. Initial program 40.3%

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

              \[\leadsto \sqrt{\color{blue}{2}} \]
            4. Step-by-step derivation
              1. Applied rewrites68.7%

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

              Reproduce

              ?
              herbie shell --seed 2024235 
              (FPCore (x)
                :name "sqrtexp (problem 3.4.4)"
                :precision binary64
                (sqrt (/ (- (exp (* 2.0 x)) 1.0) (- (exp x) 1.0))))