exp2 (problem 3.3.7)

Percentage Accurate: 76.4% → 100.0%
Time: 6.4s
Alternatives: 10
Speedup: 2.0×

Specification

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

\\
\left(e^{x} - 2\right) + e^{-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 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: 76.4% accurate, 1.0× speedup?

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

\\
\left(e^{x} - 2\right) + e^{-x}
\end{array}

Alternative 1: 100.0% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \sqrt{\cosh x}\\ \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \leq 4 \cdot 10^{-5}:\\ \;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot t_0, t_0, -2\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (sqrt (cosh x))))
   (if (<= (+ (- (exp x) 2.0) (exp (- x))) 4e-5)
     (+
      (* 0.002777777777777778 (pow x 6.0))
      (fma x x (* 0.08333333333333333 (pow x 4.0))))
     (fma (* 2.0 t_0) t_0 -2.0))))
double code(double x) {
	double t_0 = sqrt(cosh(x));
	double tmp;
	if (((exp(x) - 2.0) + exp(-x)) <= 4e-5) {
		tmp = (0.002777777777777778 * pow(x, 6.0)) + fma(x, x, (0.08333333333333333 * pow(x, 4.0)));
	} else {
		tmp = fma((2.0 * t_0), t_0, -2.0);
	}
	return tmp;
}
function code(x)
	t_0 = sqrt(cosh(x))
	tmp = 0.0
	if (Float64(Float64(exp(x) - 2.0) + exp(Float64(-x))) <= 4e-5)
		tmp = Float64(Float64(0.002777777777777778 * (x ^ 6.0)) + fma(x, x, Float64(0.08333333333333333 * (x ^ 4.0))));
	else
		tmp = fma(Float64(2.0 * t_0), t_0, -2.0);
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[Sqrt[N[Cosh[x], $MachinePrecision]], $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision], 4e-5], N[(N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * t$95$0), $MachinePrecision] * t$95$0 + -2.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \sqrt{\cosh x}\\
\mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \leq 4 \cdot 10^{-5}:\\
\;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(2 \cdot t_0, t_0, -2\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 4.00000000000000033e-5

    1. Initial program 58.0%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-58.0%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg58.0%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg58.0%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in58.0%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg58.0%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative58.0%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval58.0%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified58.0%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{0.002777777777777778 \cdot {x}^{6} + \left(0.08333333333333333 \cdot {x}^{4} + {x}^{2}\right)} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)} \]
      2. unpow2100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \left(\color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4}\right) \]
      3. fma-def100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)} \]
    6. Applied egg-rr100.0%

      \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)} \]

    if 4.00000000000000033e-5 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x)))

    1. Initial program 99.9%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-99.9%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg99.9%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg99.9%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in99.9%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg99.9%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative99.9%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval99.9%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified99.9%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Step-by-step derivation
      1. +-commutative99.9%

        \[\leadsto e^{x} + \color{blue}{\left(-2 + e^{-x}\right)} \]
      2. associate-+r+99.9%

        \[\leadsto \color{blue}{\left(e^{x} + -2\right) + e^{-x}} \]
      3. metadata-eval99.9%

        \[\leadsto \left(e^{x} + \color{blue}{\left(-2\right)}\right) + e^{-x} \]
      4. sub-neg99.9%

        \[\leadsto \color{blue}{\left(e^{x} - 2\right)} + e^{-x} \]
      5. +-commutative99.9%

        \[\leadsto \color{blue}{e^{-x} + \left(e^{x} - 2\right)} \]
      6. associate-+r-99.9%

        \[\leadsto \color{blue}{\left(e^{-x} + e^{x}\right) - 2} \]
      7. +-commutative99.9%

        \[\leadsto \color{blue}{\left(e^{x} + e^{-x}\right)} - 2 \]
      8. cosh-undef99.9%

        \[\leadsto \color{blue}{2 \cdot \cosh x} - 2 \]
    5. Applied egg-rr99.9%

      \[\leadsto \color{blue}{2 \cdot \cosh x - 2} \]
    6. Step-by-step derivation
      1. sub-neg99.9%

        \[\leadsto \color{blue}{2 \cdot \cosh x + \left(-2\right)} \]
      2. add-sqr-sqrt99.9%

        \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{\cosh x} \cdot \sqrt{\cosh x}\right)} + \left(-2\right) \]
      3. associate-*r*99.9%

        \[\leadsto \color{blue}{\left(2 \cdot \sqrt{\cosh x}\right) \cdot \sqrt{\cosh x}} + \left(-2\right) \]
      4. fma-def99.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2 \cdot \sqrt{\cosh x}, \sqrt{\cosh x}, -2\right)} \]
      5. metadata-eval99.9%

        \[\leadsto \mathsf{fma}\left(2 \cdot \sqrt{\cosh x}, \sqrt{\cosh x}, \color{blue}{-2}\right) \]
    7. Applied egg-rr99.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(2 \cdot \sqrt{\cosh x}, \sqrt{\cosh x}, -2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \leq 4 \cdot 10^{-5}:\\ \;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(2 \cdot \sqrt{\cosh x}, \sqrt{\cosh x}, -2\right)\\ \end{array} \]

Alternative 2: 100.0% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{x} - 2\right) + e^{-x}\\ \mathbf{if}\;t_0 \leq 4 \cdot 10^{-5}:\\ \;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (+ (- (exp x) 2.0) (exp (- x)))))
   (if (<= t_0 4e-5)
     (+
      (* 0.002777777777777778 (pow x 6.0))
      (fma x x (* 0.08333333333333333 (pow x 4.0))))
     t_0)))
double code(double x) {
	double t_0 = (exp(x) - 2.0) + exp(-x);
	double tmp;
	if (t_0 <= 4e-5) {
		tmp = (0.002777777777777778 * pow(x, 6.0)) + fma(x, x, (0.08333333333333333 * pow(x, 4.0)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x)
	t_0 = Float64(Float64(exp(x) - 2.0) + exp(Float64(-x)))
	tmp = 0.0
	if (t_0 <= 4e-5)
		tmp = Float64(Float64(0.002777777777777778 * (x ^ 6.0)) + fma(x, x, Float64(0.08333333333333333 * (x ^ 4.0))));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 4e-5], N[(N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{x} - 2\right) + e^{-x}\\
\mathbf{if}\;t_0 \leq 4 \cdot 10^{-5}:\\
\;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 4.00000000000000033e-5

    1. Initial program 58.0%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-58.0%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg58.0%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg58.0%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in58.0%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg58.0%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative58.0%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval58.0%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified58.0%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{0.002777777777777778 \cdot {x}^{6} + \left(0.08333333333333333 \cdot {x}^{4} + {x}^{2}\right)} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)} \]
      2. unpow2100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \left(\color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4}\right) \]
      3. fma-def100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)} \]
    6. Applied egg-rr100.0%

      \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)} \]

    if 4.00000000000000033e-5 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x)))

    1. Initial program 99.9%

      \[\left(e^{x} - 2\right) + e^{-x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \leq 4 \cdot 10^{-5}:\\ \;\;\;\;0.002777777777777778 \cdot {x}^{6} + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array} \]

Alternative 3: 99.3% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{x} - 2\right) + e^{-x}\\ \mathbf{if}\;t_0 \leq 0:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (+ (- (exp x) 2.0) (exp (- x)))))
   (if (<= t_0 0.0) (pow x 2.0) t_0)))
double code(double x) {
	double t_0 = (exp(x) - 2.0) + exp(-x);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = pow(x, 2.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = (exp(x) - 2.0d0) + exp(-x)
    if (t_0 <= 0.0d0) then
        tmp = x ** 2.0d0
    else
        tmp = t_0
    end if
    code = tmp
end function
public static double code(double x) {
	double t_0 = (Math.exp(x) - 2.0) + Math.exp(-x);
	double tmp;
	if (t_0 <= 0.0) {
		tmp = Math.pow(x, 2.0);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x):
	t_0 = (math.exp(x) - 2.0) + math.exp(-x)
	tmp = 0
	if t_0 <= 0.0:
		tmp = math.pow(x, 2.0)
	else:
		tmp = t_0
	return tmp
function code(x)
	t_0 = Float64(Float64(exp(x) - 2.0) + exp(Float64(-x)))
	tmp = 0.0
	if (t_0 <= 0.0)
		tmp = x ^ 2.0;
	else
		tmp = t_0;
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = (exp(x) - 2.0) + exp(-x);
	tmp = 0.0;
	if (t_0 <= 0.0)
		tmp = x ^ 2.0;
	else
		tmp = t_0;
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 0.0], N[Power[x, 2.0], $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{x} - 2\right) + e^{-x}\\
\mathbf{if}\;t_0 \leq 0:\\
\;\;\;\;{x}^{2}\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 0.0

    1. Initial program 57.7%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-57.7%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg57.7%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg57.7%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in57.7%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg57.7%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative57.7%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval57.7%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified57.7%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto \color{blue}{{x}^{2}} \]

    if 0.0 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x)))

    1. Initial program 99.7%

      \[\left(e^{x} - 2\right) + e^{-x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \leq 0:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array} \]

Alternative 4: 100.0% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(e^{x} - 2\right) + e^{-x}\\ \mathbf{if}\;t_0 \leq 5 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (+ (- (exp x) 2.0) (exp (- x)))))
   (if (<= t_0 5e-6) (fma x x (* 0.08333333333333333 (pow x 4.0))) t_0)))
double code(double x) {
	double t_0 = (exp(x) - 2.0) + exp(-x);
	double tmp;
	if (t_0 <= 5e-6) {
		tmp = fma(x, x, (0.08333333333333333 * pow(x, 4.0)));
	} else {
		tmp = t_0;
	}
	return tmp;
}
function code(x)
	t_0 = Float64(Float64(exp(x) - 2.0) + exp(Float64(-x)))
	tmp = 0.0
	if (t_0 <= 5e-6)
		tmp = fma(x, x, Float64(0.08333333333333333 * (x ^ 4.0)));
	else
		tmp = t_0;
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$0, 5e-6], N[(x * x + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(e^{x} - 2\right) + e^{-x}\\
\mathbf{if}\;t_0 \leq 5 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\

\mathbf{else}:\\
\;\;\;\;t_0\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x))) < 5.00000000000000041e-6

    1. Initial program 57.8%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-57.8%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg57.8%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg57.8%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in57.8%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg57.8%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative57.8%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval57.8%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified57.8%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 99.9%

      \[\leadsto \color{blue}{0.08333333333333333 \cdot {x}^{4} + {x}^{2}} \]
    5. Step-by-step derivation
      1. +-commutative100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \color{blue}{\left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)} \]
      2. unpow2100.0%

        \[\leadsto 0.002777777777777778 \cdot {x}^{6} + \left(\color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4}\right) \]
      3. fma-def100.0%

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)} \]

    if 5.00000000000000041e-6 < (+.f64 (-.f64 (exp.f64 x) 2) (exp.f64 (neg.f64 x)))

    1. Initial program 99.8%

      \[\left(e^{x} - 2\right) + e^{-x} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\left(e^{x} - 2\right) + e^{-x} \leq 5 \cdot 10^{-6}:\\ \;\;\;\;\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array} \]

Alternative 5: 87.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.00015:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.00015) (pow x 2.0) (+ (exp x) (+ (exp (- x)) -2.0))))
double code(double x) {
	double tmp;
	if (x <= 0.00015) {
		tmp = pow(x, 2.0);
	} else {
		tmp = exp(x) + (exp(-x) + -2.0);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.00015d0) then
        tmp = x ** 2.0d0
    else
        tmp = exp(x) + (exp(-x) + (-2.0d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.00015) {
		tmp = Math.pow(x, 2.0);
	} else {
		tmp = Math.exp(x) + (Math.exp(-x) + -2.0);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.00015:
		tmp = math.pow(x, 2.0)
	else:
		tmp = math.exp(x) + (math.exp(-x) + -2.0)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.00015)
		tmp = x ^ 2.0;
	else
		tmp = Float64(exp(x) + Float64(exp(Float64(-x)) + -2.0));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.00015)
		tmp = x ^ 2.0;
	else
		tmp = exp(x) + (exp(-x) + -2.0);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.00015], N[Power[x, 2.0], $MachinePrecision], N[(N[Exp[x], $MachinePrecision] + N[(N[Exp[(-x)], $MachinePrecision] + -2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00015:\\
\;\;\;\;{x}^{2}\\

\mathbf{else}:\\
\;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\


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

    1. Initial program 72.1%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-72.1%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg72.1%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg72.1%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in72.1%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg72.1%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative72.1%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval72.1%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified72.1%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 86.1%

      \[\leadsto \color{blue}{{x}^{2}} \]

    if 1.49999999999999987e-4 < x

    1. Initial program 99.5%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-99.4%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg99.4%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg99.4%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in99.4%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg99.4%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative99.4%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval99.4%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.00015:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\ \end{array} \]

Alternative 6: 87.7% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.000175:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \cosh x - 2\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.000175) (pow x 2.0) (- (* 2.0 (cosh x)) 2.0)))
double code(double x) {
	double tmp;
	if (x <= 0.000175) {
		tmp = pow(x, 2.0);
	} else {
		tmp = (2.0 * cosh(x)) - 2.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 0.000175d0) then
        tmp = x ** 2.0d0
    else
        tmp = (2.0d0 * cosh(x)) - 2.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 0.000175) {
		tmp = Math.pow(x, 2.0);
	} else {
		tmp = (2.0 * Math.cosh(x)) - 2.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.000175:
		tmp = math.pow(x, 2.0)
	else:
		tmp = (2.0 * math.cosh(x)) - 2.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.000175)
		tmp = x ^ 2.0;
	else
		tmp = Float64(Float64(2.0 * cosh(x)) - 2.0);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 0.000175)
		tmp = x ^ 2.0;
	else
		tmp = (2.0 * cosh(x)) - 2.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.000175], N[Power[x, 2.0], $MachinePrecision], N[(N[(2.0 * N[Cosh[x], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.000175:\\
\;\;\;\;{x}^{2}\\

\mathbf{else}:\\
\;\;\;\;2 \cdot \cosh x - 2\\


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

    1. Initial program 72.1%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-72.1%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg72.1%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg72.1%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in72.1%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg72.1%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative72.1%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval72.1%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified72.1%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 86.1%

      \[\leadsto \color{blue}{{x}^{2}} \]

    if 1.74999999999999998e-4 < x

    1. Initial program 99.5%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-99.4%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg99.4%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg99.4%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in99.4%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg99.4%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative99.4%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval99.4%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified99.4%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Step-by-step derivation
      1. +-commutative99.4%

        \[\leadsto e^{x} + \color{blue}{\left(-2 + e^{-x}\right)} \]
      2. associate-+r+99.5%

        \[\leadsto \color{blue}{\left(e^{x} + -2\right) + e^{-x}} \]
      3. metadata-eval99.5%

        \[\leadsto \left(e^{x} + \color{blue}{\left(-2\right)}\right) + e^{-x} \]
      4. sub-neg99.5%

        \[\leadsto \color{blue}{\left(e^{x} - 2\right)} + e^{-x} \]
      5. +-commutative99.5%

        \[\leadsto \color{blue}{e^{-x} + \left(e^{x} - 2\right)} \]
      6. associate-+r-99.3%

        \[\leadsto \color{blue}{\left(e^{-x} + e^{x}\right) - 2} \]
      7. +-commutative99.3%

        \[\leadsto \color{blue}{\left(e^{x} + e^{-x}\right)} - 2 \]
      8. cosh-undef99.3%

        \[\leadsto \color{blue}{2 \cdot \cosh x} - 2 \]
    5. Applied egg-rr99.3%

      \[\leadsto \color{blue}{2 \cdot \cosh x - 2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification90.3%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 0.000175:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \cosh x - 2\\ \end{array} \]

Alternative 7: 87.6% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 1.65:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(x\right)\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x 1.65) (pow x 2.0) (expm1 x)))
double code(double x) {
	double tmp;
	if (x <= 1.65) {
		tmp = pow(x, 2.0);
	} else {
		tmp = expm1(x);
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 1.65) {
		tmp = Math.pow(x, 2.0);
	} else {
		tmp = Math.expm1(x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 1.65:
		tmp = math.pow(x, 2.0)
	else:
		tmp = math.expm1(x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 1.65)
		tmp = x ^ 2.0;
	else
		tmp = expm1(x);
	end
	return tmp
end
code[x_] := If[LessEqual[x, 1.65], N[Power[x, 2.0], $MachinePrecision], N[(Exp[x] - 1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 1.65:\\
\;\;\;\;{x}^{2}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\


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

    1. Initial program 72.3%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-72.2%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg72.2%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg72.2%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in72.2%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg72.2%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative72.2%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval72.2%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified72.2%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 85.4%

      \[\leadsto \color{blue}{{x}^{2}} \]

    if 1.6499999999999999 < x

    1. Initial program 100.0%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-100.0%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg100.0%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg100.0%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in100.0%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg100.0%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative100.0%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval100.0%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified100.0%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 100.0%

      \[\leadsto e^{x} + \color{blue}{-1} \]
    5. Taylor expanded in x around inf 100.0%

      \[\leadsto \color{blue}{e^{x} - 1} \]
    6. Step-by-step derivation
      1. expm1-def100.0%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(x\right)} \]
    7. Simplified100.0%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.8%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 1.65:\\ \;\;\;\;{x}^{2}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(x\right)\\ \end{array} \]

Alternative 8: 50.9% accurate, 2.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(x\right)\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x 2.25e-103) 0.0 (expm1 x)))
double code(double x) {
	double tmp;
	if (x <= 2.25e-103) {
		tmp = 0.0;
	} else {
		tmp = expm1(x);
	}
	return tmp;
}
public static double code(double x) {
	double tmp;
	if (x <= 2.25e-103) {
		tmp = 0.0;
	} else {
		tmp = Math.expm1(x);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 2.25e-103:
		tmp = 0.0
	else:
		tmp = math.expm1(x)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 2.25e-103)
		tmp = 0.0;
	else
		tmp = expm1(x);
	end
	return tmp
end
code[x_] := If[LessEqual[x, 2.25e-103], 0.0, N[(Exp[x] - 1), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\
\;\;\;\;0\\

\mathbf{else}:\\
\;\;\;\;\mathsf{expm1}\left(x\right)\\


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

    1. Initial program 77.0%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-77.0%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg77.0%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg77.0%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in77.0%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg77.0%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative77.0%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval77.0%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified77.0%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Step-by-step derivation
      1. +-commutative77.0%

        \[\leadsto e^{x} + \color{blue}{\left(-2 + e^{-x}\right)} \]
      2. associate-+r+77.0%

        \[\leadsto \color{blue}{\left(e^{x} + -2\right) + e^{-x}} \]
      3. metadata-eval77.0%

        \[\leadsto \left(e^{x} + \color{blue}{\left(-2\right)}\right) + e^{-x} \]
      4. sub-neg77.0%

        \[\leadsto \color{blue}{\left(e^{x} - 2\right)} + e^{-x} \]
      5. add-log-exp77.0%

        \[\leadsto \color{blue}{\log \left(e^{\left(e^{x} - 2\right) + e^{-x}}\right)} \]
      6. sub-neg77.0%

        \[\leadsto \log \left(e^{\color{blue}{\left(e^{x} + \left(-2\right)\right)} + e^{-x}}\right) \]
      7. metadata-eval77.0%

        \[\leadsto \log \left(e^{\left(e^{x} + \color{blue}{-2}\right) + e^{-x}}\right) \]
      8. associate-+r+77.0%

        \[\leadsto \log \left(e^{\color{blue}{e^{x} + \left(-2 + e^{-x}\right)}}\right) \]
      9. +-commutative77.0%

        \[\leadsto \log \left(e^{e^{x} + \color{blue}{\left(e^{-x} + -2\right)}}\right) \]
      10. associate-+r+77.0%

        \[\leadsto \log \left(e^{\color{blue}{\left(e^{x} + e^{-x}\right) + -2}}\right) \]
      11. +-commutative77.0%

        \[\leadsto \log \left(e^{\color{blue}{-2 + \left(e^{x} + e^{-x}\right)}}\right) \]
      12. cosh-undef77.0%

        \[\leadsto \log \left(e^{-2 + \color{blue}{2 \cdot \cosh x}}\right) \]
    5. Applied egg-rr77.0%

      \[\leadsto \color{blue}{\log \left(e^{-2 + 2 \cdot \cosh x}\right)} \]
    6. Step-by-step derivation
      1. +-commutative77.0%

        \[\leadsto \log \left(e^{\color{blue}{2 \cdot \cosh x + -2}}\right) \]
      2. add-log-exp77.0%

        \[\leadsto \color{blue}{2 \cdot \cosh x + -2} \]
      3. add-sqr-sqrt77.0%

        \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{\cosh x} \cdot \sqrt{\cosh x}\right)} + -2 \]
      4. associate-*r*77.0%

        \[\leadsto \color{blue}{\left(2 \cdot \sqrt{\cosh x}\right) \cdot \sqrt{\cosh x}} + -2 \]
      5. add-sqr-sqrt38.9%

        \[\leadsto \color{blue}{\left(\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{2 \cdot \sqrt{\cosh x}}\right)} \cdot \sqrt{\cosh x} + -2 \]
      6. associate-*l*38.9%

        \[\leadsto \color{blue}{\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \left(\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{\cosh x}\right)} + -2 \]
      7. fma-def38.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{\cosh x}, -2\right)} \]
      8. pow1/238.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{{\left(2 \cdot \sqrt{\cosh x}\right)}^{0.5}} \cdot \sqrt{\cosh x}, -2\right) \]
      9. pow1/238.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, {\left(2 \cdot \sqrt{\cosh x}\right)}^{0.5} \cdot \color{blue}{{\cosh x}^{0.5}}, -2\right) \]
      10. pow-prod-down38.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{{\left(\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x\right)}^{0.5}}, -2\right) \]
    7. Applied egg-rr38.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, {\left(\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x\right)}^{0.5}, -2\right)} \]
    8. Step-by-step derivation
      1. unpow1/238.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{\sqrt{\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x}}, -2\right) \]
      2. associate-*l*38.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{\color{blue}{2 \cdot \left(\sqrt{\cosh x} \cdot \cosh x\right)}}, -2\right) \]
    9. Simplified38.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{2 \cdot \left(\sqrt{\cosh x} \cdot \cosh x\right)}, -2\right)} \]
    10. Taylor expanded in x around 0 3.5%

      \[\leadsto \color{blue}{{\left(\sqrt{2}\right)}^{2} - 2} \]
    11. Step-by-step derivation
      1. unpow23.5%

        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{2}} - 2 \]
      2. rem-square-sqrt41.1%

        \[\leadsto \color{blue}{2} - 2 \]
      3. metadata-eval41.1%

        \[\leadsto \color{blue}{0} \]
    12. Simplified41.1%

      \[\leadsto \color{blue}{0} \]

    if 2.25e-103 < x

    1. Initial program 87.1%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-87.0%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg87.0%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg87.0%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in87.0%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg87.0%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative87.0%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval87.0%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified87.0%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 84.8%

      \[\leadsto e^{x} + \color{blue}{-1} \]
    5. Taylor expanded in x around inf 84.8%

      \[\leadsto \color{blue}{e^{x} - 1} \]
    6. Step-by-step derivation
      1. expm1-def85.1%

        \[\leadsto \color{blue}{\mathsf{expm1}\left(x\right)} \]
    7. Simplified85.1%

      \[\leadsto \color{blue}{\mathsf{expm1}\left(x\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification56.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;\mathsf{expm1}\left(x\right)\\ \end{array} \]

Alternative 9: 27.9% accurate, 67.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x) :precision binary64 (if (<= x 2.25e-103) 0.0 x))
double code(double x) {
	double tmp;
	if (x <= 2.25e-103) {
		tmp = 0.0;
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= 2.25d-103) then
        tmp = 0.0d0
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= 2.25e-103) {
		tmp = 0.0;
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 2.25e-103:
		tmp = 0.0
	else:
		tmp = x
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 2.25e-103)
		tmp = 0.0;
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= 2.25e-103)
		tmp = 0.0;
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 2.25e-103], 0.0, x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\
\;\;\;\;0\\

\mathbf{else}:\\
\;\;\;\;x\\


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

    1. Initial program 77.0%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-77.0%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg77.0%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg77.0%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in77.0%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg77.0%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative77.0%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval77.0%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified77.0%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Step-by-step derivation
      1. +-commutative77.0%

        \[\leadsto e^{x} + \color{blue}{\left(-2 + e^{-x}\right)} \]
      2. associate-+r+77.0%

        \[\leadsto \color{blue}{\left(e^{x} + -2\right) + e^{-x}} \]
      3. metadata-eval77.0%

        \[\leadsto \left(e^{x} + \color{blue}{\left(-2\right)}\right) + e^{-x} \]
      4. sub-neg77.0%

        \[\leadsto \color{blue}{\left(e^{x} - 2\right)} + e^{-x} \]
      5. add-log-exp77.0%

        \[\leadsto \color{blue}{\log \left(e^{\left(e^{x} - 2\right) + e^{-x}}\right)} \]
      6. sub-neg77.0%

        \[\leadsto \log \left(e^{\color{blue}{\left(e^{x} + \left(-2\right)\right)} + e^{-x}}\right) \]
      7. metadata-eval77.0%

        \[\leadsto \log \left(e^{\left(e^{x} + \color{blue}{-2}\right) + e^{-x}}\right) \]
      8. associate-+r+77.0%

        \[\leadsto \log \left(e^{\color{blue}{e^{x} + \left(-2 + e^{-x}\right)}}\right) \]
      9. +-commutative77.0%

        \[\leadsto \log \left(e^{e^{x} + \color{blue}{\left(e^{-x} + -2\right)}}\right) \]
      10. associate-+r+77.0%

        \[\leadsto \log \left(e^{\color{blue}{\left(e^{x} + e^{-x}\right) + -2}}\right) \]
      11. +-commutative77.0%

        \[\leadsto \log \left(e^{\color{blue}{-2 + \left(e^{x} + e^{-x}\right)}}\right) \]
      12. cosh-undef77.0%

        \[\leadsto \log \left(e^{-2 + \color{blue}{2 \cdot \cosh x}}\right) \]
    5. Applied egg-rr77.0%

      \[\leadsto \color{blue}{\log \left(e^{-2 + 2 \cdot \cosh x}\right)} \]
    6. Step-by-step derivation
      1. +-commutative77.0%

        \[\leadsto \log \left(e^{\color{blue}{2 \cdot \cosh x + -2}}\right) \]
      2. add-log-exp77.0%

        \[\leadsto \color{blue}{2 \cdot \cosh x + -2} \]
      3. add-sqr-sqrt77.0%

        \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{\cosh x} \cdot \sqrt{\cosh x}\right)} + -2 \]
      4. associate-*r*77.0%

        \[\leadsto \color{blue}{\left(2 \cdot \sqrt{\cosh x}\right) \cdot \sqrt{\cosh x}} + -2 \]
      5. add-sqr-sqrt38.9%

        \[\leadsto \color{blue}{\left(\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{2 \cdot \sqrt{\cosh x}}\right)} \cdot \sqrt{\cosh x} + -2 \]
      6. associate-*l*38.9%

        \[\leadsto \color{blue}{\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \left(\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{\cosh x}\right)} + -2 \]
      7. fma-def38.9%

        \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{\cosh x}, -2\right)} \]
      8. pow1/238.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{{\left(2 \cdot \sqrt{\cosh x}\right)}^{0.5}} \cdot \sqrt{\cosh x}, -2\right) \]
      9. pow1/238.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, {\left(2 \cdot \sqrt{\cosh x}\right)}^{0.5} \cdot \color{blue}{{\cosh x}^{0.5}}, -2\right) \]
      10. pow-prod-down38.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{{\left(\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x\right)}^{0.5}}, -2\right) \]
    7. Applied egg-rr38.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, {\left(\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x\right)}^{0.5}, -2\right)} \]
    8. Step-by-step derivation
      1. unpow1/238.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{\sqrt{\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x}}, -2\right) \]
      2. associate-*l*38.9%

        \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{\color{blue}{2 \cdot \left(\sqrt{\cosh x} \cdot \cosh x\right)}}, -2\right) \]
    9. Simplified38.9%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{2 \cdot \left(\sqrt{\cosh x} \cdot \cosh x\right)}, -2\right)} \]
    10. Taylor expanded in x around 0 3.5%

      \[\leadsto \color{blue}{{\left(\sqrt{2}\right)}^{2} - 2} \]
    11. Step-by-step derivation
      1. unpow23.5%

        \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{2}} - 2 \]
      2. rem-square-sqrt41.1%

        \[\leadsto \color{blue}{2} - 2 \]
      3. metadata-eval41.1%

        \[\leadsto \color{blue}{0} \]
    12. Simplified41.1%

      \[\leadsto \color{blue}{0} \]

    if 2.25e-103 < x

    1. Initial program 87.1%

      \[\left(e^{x} - 2\right) + e^{-x} \]
    2. Step-by-step derivation
      1. associate-+l-87.0%

        \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
      2. sub-neg87.0%

        \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
      3. sub-neg87.0%

        \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
      4. distribute-neg-in87.0%

        \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
      5. remove-double-neg87.0%

        \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
      6. +-commutative87.0%

        \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
      7. metadata-eval87.0%

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified87.0%

      \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
    4. Taylor expanded in x around 0 84.8%

      \[\leadsto e^{x} + \color{blue}{-1} \]
    5. Taylor expanded in x around 0 5.8%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 2.25 \cdot 10^{-103}:\\ \;\;\;\;0\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 10: 26.6% accurate, 206.0× speedup?

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

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

    \[\left(e^{x} - 2\right) + e^{-x} \]
  2. Step-by-step derivation
    1. associate-+l-80.6%

      \[\leadsto \color{blue}{e^{x} - \left(2 - e^{-x}\right)} \]
    2. sub-neg80.6%

      \[\leadsto \color{blue}{e^{x} + \left(-\left(2 - e^{-x}\right)\right)} \]
    3. sub-neg80.6%

      \[\leadsto e^{x} + \left(-\color{blue}{\left(2 + \left(-e^{-x}\right)\right)}\right) \]
    4. distribute-neg-in80.6%

      \[\leadsto e^{x} + \color{blue}{\left(\left(-2\right) + \left(-\left(-e^{-x}\right)\right)\right)} \]
    5. remove-double-neg80.6%

      \[\leadsto e^{x} + \left(\left(-2\right) + \color{blue}{e^{-x}}\right) \]
    6. +-commutative80.6%

      \[\leadsto e^{x} + \color{blue}{\left(e^{-x} + \left(-2\right)\right)} \]
    7. metadata-eval80.6%

      \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
  3. Simplified80.6%

    \[\leadsto \color{blue}{e^{x} + \left(e^{-x} + -2\right)} \]
  4. Step-by-step derivation
    1. +-commutative80.6%

      \[\leadsto e^{x} + \color{blue}{\left(-2 + e^{-x}\right)} \]
    2. associate-+r+80.6%

      \[\leadsto \color{blue}{\left(e^{x} + -2\right) + e^{-x}} \]
    3. metadata-eval80.6%

      \[\leadsto \left(e^{x} + \color{blue}{\left(-2\right)}\right) + e^{-x} \]
    4. sub-neg80.6%

      \[\leadsto \color{blue}{\left(e^{x} - 2\right)} + e^{-x} \]
    5. add-log-exp79.9%

      \[\leadsto \color{blue}{\log \left(e^{\left(e^{x} - 2\right) + e^{-x}}\right)} \]
    6. sub-neg79.9%

      \[\leadsto \log \left(e^{\color{blue}{\left(e^{x} + \left(-2\right)\right)} + e^{-x}}\right) \]
    7. metadata-eval79.9%

      \[\leadsto \log \left(e^{\left(e^{x} + \color{blue}{-2}\right) + e^{-x}}\right) \]
    8. associate-+r+79.8%

      \[\leadsto \log \left(e^{\color{blue}{e^{x} + \left(-2 + e^{-x}\right)}}\right) \]
    9. +-commutative79.8%

      \[\leadsto \log \left(e^{e^{x} + \color{blue}{\left(e^{-x} + -2\right)}}\right) \]
    10. associate-+r+79.8%

      \[\leadsto \log \left(e^{\color{blue}{\left(e^{x} + e^{-x}\right) + -2}}\right) \]
    11. +-commutative79.8%

      \[\leadsto \log \left(e^{\color{blue}{-2 + \left(e^{x} + e^{-x}\right)}}\right) \]
    12. cosh-undef79.8%

      \[\leadsto \log \left(e^{-2 + \color{blue}{2 \cdot \cosh x}}\right) \]
  5. Applied egg-rr79.8%

    \[\leadsto \color{blue}{\log \left(e^{-2 + 2 \cdot \cosh x}\right)} \]
  6. Step-by-step derivation
    1. +-commutative79.8%

      \[\leadsto \log \left(e^{\color{blue}{2 \cdot \cosh x + -2}}\right) \]
    2. add-log-exp80.6%

      \[\leadsto \color{blue}{2 \cdot \cosh x + -2} \]
    3. add-sqr-sqrt80.5%

      \[\leadsto 2 \cdot \color{blue}{\left(\sqrt{\cosh x} \cdot \sqrt{\cosh x}\right)} + -2 \]
    4. associate-*r*80.5%

      \[\leadsto \color{blue}{\left(2 \cdot \sqrt{\cosh x}\right) \cdot \sqrt{\cosh x}} + -2 \]
    5. add-sqr-sqrt56.2%

      \[\leadsto \color{blue}{\left(\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{2 \cdot \sqrt{\cosh x}}\right)} \cdot \sqrt{\cosh x} + -2 \]
    6. associate-*l*56.2%

      \[\leadsto \color{blue}{\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \left(\sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{\cosh x}\right)} + -2 \]
    7. fma-def56.2%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{2 \cdot \sqrt{\cosh x}} \cdot \sqrt{\cosh x}, -2\right)} \]
    8. pow1/256.2%

      \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{{\left(2 \cdot \sqrt{\cosh x}\right)}^{0.5}} \cdot \sqrt{\cosh x}, -2\right) \]
    9. pow1/256.2%

      \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, {\left(2 \cdot \sqrt{\cosh x}\right)}^{0.5} \cdot \color{blue}{{\cosh x}^{0.5}}, -2\right) \]
    10. pow-prod-down55.9%

      \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{{\left(\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x\right)}^{0.5}}, -2\right) \]
  7. Applied egg-rr55.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, {\left(\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x\right)}^{0.5}, -2\right)} \]
  8. Step-by-step derivation
    1. unpow1/255.9%

      \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \color{blue}{\sqrt{\left(2 \cdot \sqrt{\cosh x}\right) \cdot \cosh x}}, -2\right) \]
    2. associate-*l*55.9%

      \[\leadsto \mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{\color{blue}{2 \cdot \left(\sqrt{\cosh x} \cdot \cosh x\right)}}, -2\right) \]
  9. Simplified55.9%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\sqrt{2 \cdot \sqrt{\cosh x}}, \sqrt{2 \cdot \left(\sqrt{\cosh x} \cdot \cosh x\right)}, -2\right)} \]
  10. Taylor expanded in x around 0 3.6%

    \[\leadsto \color{blue}{{\left(\sqrt{2}\right)}^{2} - 2} \]
  11. Step-by-step derivation
    1. unpow23.6%

      \[\leadsto \color{blue}{\sqrt{2} \cdot \sqrt{2}} - 2 \]
    2. rem-square-sqrt27.0%

      \[\leadsto \color{blue}{2} - 2 \]
    3. metadata-eval27.0%

      \[\leadsto \color{blue}{0} \]
  12. Simplified27.0%

    \[\leadsto \color{blue}{0} \]
  13. Final simplification27.0%

    \[\leadsto 0 \]

Developer target: 100.0% accurate, 1.0× speedup?

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

\\
4 \cdot {\sinh \left(\frac{x}{2}\right)}^{2}
\end{array}

Reproduce

?
herbie shell --seed 2023319 
(FPCore (x)
  :name "exp2 (problem 3.3.7)"
  :precision binary64

  :herbie-target
  (* 4.0 (pow (sinh (/ x 2.0)) 2.0))

  (+ (- (exp x) 2.0) (exp (- x))))