exp2 (problem 3.3.7)

Percentage Accurate: 75.9% → 100.0%
Time: 7.2s
Alternatives: 10
Speedup: 1.9×

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: 75.9% 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 := e^{-x}\\ \mathbf{if}\;\left(e^{x} - 2\right) + t_0 \leq 0.0005:\\ \;\;\;\;0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(t_0 + -2\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (exp (- x))))
   (if (<= (+ (- (exp x) 2.0) t_0) 0.0005)
     (+
      (* 0.002777777777777778 (pow x 6.0))
      (+
       (pow x 2.0)
       (+
        (* 0.08333333333333333 (pow x 4.0))
        (* 4.96031746031746e-5 (pow x 8.0)))))
     (+ (exp x) (+ t_0 -2.0)))))
double code(double x) {
	double t_0 = exp(-x);
	double tmp;
	if (((exp(x) - 2.0) + t_0) <= 0.0005) {
		tmp = (0.002777777777777778 * pow(x, 6.0)) + (pow(x, 2.0) + ((0.08333333333333333 * pow(x, 4.0)) + (4.96031746031746e-5 * pow(x, 8.0))));
	} else {
		tmp = exp(x) + (t_0 + -2.0);
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    real(8) :: tmp
    t_0 = exp(-x)
    if (((exp(x) - 2.0d0) + t_0) <= 0.0005d0) then
        tmp = (0.002777777777777778d0 * (x ** 6.0d0)) + ((x ** 2.0d0) + ((0.08333333333333333d0 * (x ** 4.0d0)) + (4.96031746031746d-5 * (x ** 8.0d0))))
    else
        tmp = exp(x) + (t_0 + (-2.0d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double t_0 = Math.exp(-x);
	double tmp;
	if (((Math.exp(x) - 2.0) + t_0) <= 0.0005) {
		tmp = (0.002777777777777778 * Math.pow(x, 6.0)) + (Math.pow(x, 2.0) + ((0.08333333333333333 * Math.pow(x, 4.0)) + (4.96031746031746e-5 * Math.pow(x, 8.0))));
	} else {
		tmp = Math.exp(x) + (t_0 + -2.0);
	}
	return tmp;
}
def code(x):
	t_0 = math.exp(-x)
	tmp = 0
	if ((math.exp(x) - 2.0) + t_0) <= 0.0005:
		tmp = (0.002777777777777778 * math.pow(x, 6.0)) + (math.pow(x, 2.0) + ((0.08333333333333333 * math.pow(x, 4.0)) + (4.96031746031746e-5 * math.pow(x, 8.0))))
	else:
		tmp = math.exp(x) + (t_0 + -2.0)
	return tmp
function code(x)
	t_0 = exp(Float64(-x))
	tmp = 0.0
	if (Float64(Float64(exp(x) - 2.0) + t_0) <= 0.0005)
		tmp = Float64(Float64(0.002777777777777778 * (x ^ 6.0)) + Float64((x ^ 2.0) + Float64(Float64(0.08333333333333333 * (x ^ 4.0)) + Float64(4.96031746031746e-5 * (x ^ 8.0)))));
	else
		tmp = Float64(exp(x) + Float64(t_0 + -2.0));
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = exp(-x);
	tmp = 0.0;
	if (((exp(x) - 2.0) + t_0) <= 0.0005)
		tmp = (0.002777777777777778 * (x ^ 6.0)) + ((x ^ 2.0) + ((0.08333333333333333 * (x ^ 4.0)) + (4.96031746031746e-5 * (x ^ 8.0))));
	else
		tmp = exp(x) + (t_0 + -2.0);
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, If[LessEqual[N[(N[(N[Exp[x], $MachinePrecision] - 2.0), $MachinePrecision] + t$95$0), $MachinePrecision], 0.0005], N[(N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 2.0], $MachinePrecision] + N[(N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(4.96031746031746e-5 * N[Power[x, 8.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[Exp[x], $MachinePrecision] + N[(t$95$0 + -2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

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

\mathbf{else}:\\
\;\;\;\;e^{x} + \left(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))) < 5.0000000000000001e-4

    1. Initial program 52.9%

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

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

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

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

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

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

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

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

      \[\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({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)} \]

    if 5.0000000000000001e-4 < (+.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. +-commutative99.9%

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

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

        \[\leadsto e^{x} + \left(\color{blue}{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)} \]
  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 0.0005:\\ \;\;\;\;0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + \left(0.08333333333333333 \cdot {x}^{4} + 4.96031746031746 \cdot 10^{-5} \cdot {x}^{8}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\ \end{array} \]

Alternative 2: 100.0% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;e^{x} + \left(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))) < 5.0000000000000001e-4

    1. Initial program 52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto e^{\log \left(\color{blue}{2 \cdot \cosh x} - 2\right)} \]
      10. fma-neg52.9%

        \[\leadsto e^{\log \color{blue}{\left(\mathsf{fma}\left(2, \cosh x, -2\right)\right)}} \]
      11. metadata-eval52.9%

        \[\leadsto e^{\log \left(\mathsf{fma}\left(2, \cosh x, \color{blue}{-2}\right)\right)} \]
    5. Applied egg-rr52.9%

      \[\leadsto \color{blue}{e^{\log \left(\mathsf{fma}\left(2, \cosh x, -2\right)\right)}} \]
    6. Taylor expanded in x around 0 49.5%

      \[\leadsto e^{\color{blue}{-0.0006944444444444445 \cdot {x}^{4} + \left(0.08333333333333333 \cdot {x}^{2} + 2 \cdot \log x\right)}} \]
    7. Taylor expanded in x around inf 49.5%

      \[\leadsto \color{blue}{e^{\left(0.08333333333333333 \cdot {x}^{2} + 2 \cdot \log x\right) - 0.0006944444444444445 \cdot {x}^{4}}} \]
    8. Step-by-step derivation
      1. +-commutative49.5%

        \[\leadsto e^{\color{blue}{\left(2 \cdot \log x + 0.08333333333333333 \cdot {x}^{2}\right)} - 0.0006944444444444445 \cdot {x}^{4}} \]
      2. *-commutative49.5%

        \[\leadsto e^{\left(2 \cdot \log x + \color{blue}{{x}^{2} \cdot 0.08333333333333333}\right) - 0.0006944444444444445 \cdot {x}^{4}} \]
      3. unpow249.5%

        \[\leadsto e^{\left(2 \cdot \log x + \color{blue}{\left(x \cdot x\right)} \cdot 0.08333333333333333\right) - 0.0006944444444444445 \cdot {x}^{4}} \]
      4. associate--l+49.5%

        \[\leadsto e^{\color{blue}{2 \cdot \log x + \left(\left(x \cdot x\right) \cdot 0.08333333333333333 - 0.0006944444444444445 \cdot {x}^{4}\right)}} \]
      5. exp-sum49.5%

        \[\leadsto \color{blue}{e^{2 \cdot \log x} \cdot e^{\left(x \cdot x\right) \cdot 0.08333333333333333 - 0.0006944444444444445 \cdot {x}^{4}}} \]
      6. *-commutative49.5%

        \[\leadsto e^{\color{blue}{\log x \cdot 2}} \cdot e^{\left(x \cdot x\right) \cdot 0.08333333333333333 - 0.0006944444444444445 \cdot {x}^{4}} \]
      7. exp-to-pow99.9%

        \[\leadsto \color{blue}{{x}^{2}} \cdot e^{\left(x \cdot x\right) \cdot 0.08333333333333333 - 0.0006944444444444445 \cdot {x}^{4}} \]
      8. unpow299.9%

        \[\leadsto \color{blue}{\left(x \cdot x\right)} \cdot e^{\left(x \cdot x\right) \cdot 0.08333333333333333 - 0.0006944444444444445 \cdot {x}^{4}} \]
      9. cancel-sign-sub-inv99.9%

        \[\leadsto \left(x \cdot x\right) \cdot e^{\color{blue}{\left(x \cdot x\right) \cdot 0.08333333333333333 + \left(-0.0006944444444444445\right) \cdot {x}^{4}}} \]
      10. metadata-eval99.9%

        \[\leadsto \left(x \cdot x\right) \cdot e^{\left(x \cdot x\right) \cdot 0.08333333333333333 + \color{blue}{-0.0006944444444444445} \cdot {x}^{4}} \]
      11. *-commutative99.9%

        \[\leadsto \left(x \cdot x\right) \cdot e^{\left(x \cdot x\right) \cdot 0.08333333333333333 + \color{blue}{{x}^{4} \cdot -0.0006944444444444445}} \]
      12. +-commutative99.9%

        \[\leadsto \left(x \cdot x\right) \cdot e^{\color{blue}{{x}^{4} \cdot -0.0006944444444444445 + \left(x \cdot x\right) \cdot 0.08333333333333333}} \]
      13. fma-def99.9%

        \[\leadsto \left(x \cdot x\right) \cdot e^{\color{blue}{\mathsf{fma}\left({x}^{4}, -0.0006944444444444445, \left(x \cdot x\right) \cdot 0.08333333333333333\right)}} \]
      14. associate-*l*99.9%

        \[\leadsto \left(x \cdot x\right) \cdot e^{\mathsf{fma}\left({x}^{4}, -0.0006944444444444445, \color{blue}{x \cdot \left(x \cdot 0.08333333333333333\right)}\right)} \]
    9. Simplified99.9%

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

    if 5.0000000000000001e-4 < (+.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. +-commutative99.9%

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

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

        \[\leadsto e^{x} + \left(\color{blue}{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)} \]
  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 0.0005:\\ \;\;\;\;\left(x \cdot x\right) \cdot e^{\mathsf{fma}\left({x}^{4}, -0.0006944444444444445, x \cdot \left(x \cdot 0.08333333333333333\right)\right)}\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\ \end{array} \]

Alternative 3: 100.0% accurate, 0.4× speedup?

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

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

\mathbf{else}:\\
\;\;\;\;e^{x} + \left(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))) < 5.0000000000000001e-4

    1. Initial program 52.9%

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

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

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

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

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

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

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

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

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

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

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

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

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

    if 5.0000000000000001e-4 < (+.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. +-commutative99.9%

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

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

        \[\leadsto e^{x} + \left(\color{blue}{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)} \]
  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 0.0005:\\ \;\;\;\;\mathsf{fma}\left(0.002777777777777778, {x}^{6}, 0.08333333333333333 \cdot {x}^{4} + x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\ \end{array} \]

Alternative 4: 99.8% 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^{-10}:\\ \;\;\;\;0.08333333333333333 \cdot {x}^{4} + x \cdot x\\ \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-10) (+ (* 0.08333333333333333 (pow x 4.0)) (* x x)) t_0)))
double code(double x) {
	double t_0 = (exp(x) - 2.0) + exp(-x);
	double tmp;
	if (t_0 <= 5e-10) {
		tmp = (0.08333333333333333 * pow(x, 4.0)) + (x * x);
	} 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 <= 5d-10) then
        tmp = (0.08333333333333333d0 * (x ** 4.0d0)) + (x * x)
    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 <= 5e-10) {
		tmp = (0.08333333333333333 * Math.pow(x, 4.0)) + (x * x);
	} else {
		tmp = t_0;
	}
	return tmp;
}
def code(x):
	t_0 = (math.exp(x) - 2.0) + math.exp(-x)
	tmp = 0
	if t_0 <= 5e-10:
		tmp = (0.08333333333333333 * math.pow(x, 4.0)) + (x * x)
	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-10)
		tmp = Float64(Float64(0.08333333333333333 * (x ^ 4.0)) + Float64(x * x));
	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 <= 5e-10)
		tmp = (0.08333333333333333 * (x ^ 4.0)) + (x * x);
	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, 5e-10], N[(N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * x), $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^{-10}:\\
\;\;\;\;0.08333333333333333 \cdot {x}^{4} + x \cdot x\\

\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.00000000000000031e-10

    1. Initial program 52.6%

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

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

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

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

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

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

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

        \[\leadsto e^{x} + \left(e^{-x} + \color{blue}{-2}\right) \]
    3. Simplified52.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} + 0.08333333333333333 \cdot {x}^{4}} \]
    5. Step-by-step derivation
      1. unpow2100.0%

        \[\leadsto \color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4} \]
    6. Simplified100.0%

      \[\leadsto \color{blue}{x \cdot x + 0.08333333333333333 \cdot {x}^{4}} \]

    if 5.00000000000000031e-10 < (+.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^{-10}:\\ \;\;\;\;0.08333333333333333 \cdot {x}^{4} + x \cdot x\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array} \]

Alternative 5: 99.8% 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^{-10}:\\ \;\;\;\;\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-10) (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-10) {
		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-10)
		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-10], 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^{-10}:\\
\;\;\;\;\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.00000000000000031e-10

    1. Initial program 52.6%

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

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

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

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

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

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

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

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

      \[\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({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)} \]
    5. Step-by-step derivation
      1. fma-def100.0%

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.002777777777777778, {x}^{6}, x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)} \]
    7. Taylor expanded in x around 0 100.0%

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

        \[\leadsto \color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4} \]
      2. fma-udef100.0%

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

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

    if 5.00000000000000031e-10 < (+.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^{-10}:\\ \;\;\;\;\mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)\\ \mathbf{else}:\\ \;\;\;\;\left(e^{x} - 2\right) + e^{-x}\\ \end{array} \]

Alternative 6: 94.1% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.0058:\\ \;\;\;\;0.08333333333333333 \cdot {x}^{4} + x \cdot x\\ \mathbf{else}:\\ \;\;\;\;e^{x} + \left(e^{-x} + -2\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.0058)
   (+ (* 0.08333333333333333 (pow x 4.0)) (* x x))
   (+ (exp x) (+ (exp (- x)) -2.0))))
double code(double x) {
	double tmp;
	if (x <= 0.0058) {
		tmp = (0.08333333333333333 * pow(x, 4.0)) + (x * x);
	} 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.0058d0) then
        tmp = (0.08333333333333333d0 * (x ** 4.0d0)) + (x * x)
    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.0058) {
		tmp = (0.08333333333333333 * Math.pow(x, 4.0)) + (x * x);
	} else {
		tmp = Math.exp(x) + (Math.exp(-x) + -2.0);
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.0058:
		tmp = (0.08333333333333333 * math.pow(x, 4.0)) + (x * x)
	else:
		tmp = math.exp(x) + (math.exp(-x) + -2.0)
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.0058)
		tmp = Float64(Float64(0.08333333333333333 * (x ^ 4.0)) + Float64(x * x));
	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.0058)
		tmp = (0.08333333333333333 * (x ^ 4.0)) + (x * x);
	else
		tmp = exp(x) + (exp(-x) + -2.0);
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.0058], N[(N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $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.0058:\\
\;\;\;\;0.08333333333333333 \cdot {x}^{4} + x \cdot x\\

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


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

    1. Initial program 69.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4} \]
    6. Simplified89.1%

      \[\leadsto \color{blue}{x \cdot x + 0.08333333333333333 \cdot {x}^{4}} \]

    if 0.0058 < x

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

Alternative 7: 94.1% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.006:\\ \;\;\;\;0.08333333333333333 \cdot {x}^{4} + x \cdot x\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \cosh x - 2\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.006)
   (+ (* 0.08333333333333333 (pow x 4.0)) (* x x))
   (- (* 2.0 (cosh x)) 2.0)))
double code(double x) {
	double tmp;
	if (x <= 0.006) {
		tmp = (0.08333333333333333 * pow(x, 4.0)) + (x * x);
	} 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.006d0) then
        tmp = (0.08333333333333333d0 * (x ** 4.0d0)) + (x * x)
    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.006) {
		tmp = (0.08333333333333333 * Math.pow(x, 4.0)) + (x * x);
	} else {
		tmp = (2.0 * Math.cosh(x)) - 2.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.006:
		tmp = (0.08333333333333333 * math.pow(x, 4.0)) + (x * x)
	else:
		tmp = (2.0 * math.cosh(x)) - 2.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.006)
		tmp = Float64(Float64(0.08333333333333333 * (x ^ 4.0)) + Float64(x * x));
	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.006)
		tmp = (0.08333333333333333 * (x ^ 4.0)) + (x * x);
	else
		tmp = (2.0 * cosh(x)) - 2.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.006], N[(N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision], N[(N[(2.0 * N[Cosh[x], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.006:\\
\;\;\;\;0.08333333333333333 \cdot {x}^{4} + x \cdot x\\

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


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

    1. Initial program 69.3%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4} \]
    6. Simplified89.1%

      \[\leadsto \color{blue}{x \cdot x + 0.08333333333333333 \cdot {x}^{4}} \]

    if 0.0060000000000000001 < x

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{2 \cdot \cosh x} + -2 \]
      3. fma-def99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, \cosh x, -2\right)} \]
      4. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(2, \cosh x, \color{blue}{-2}\right) \]
      5. fma-neg99.7%

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

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

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

Alternative 8: 88.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq 0.00019:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;2 \cdot \cosh x - 2\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x 0.00019) (* x x) (- (* 2.0 (cosh x)) 2.0)))
double code(double x) {
	double tmp;
	if (x <= 0.00019) {
		tmp = x * x;
	} 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.00019d0) then
        tmp = x * x
    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.00019) {
		tmp = x * x;
	} else {
		tmp = (2.0 * Math.cosh(x)) - 2.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= 0.00019:
		tmp = x * x
	else:
		tmp = (2.0 * math.cosh(x)) - 2.0
	return tmp
function code(x)
	tmp = 0.0
	if (x <= 0.00019)
		tmp = Float64(x * x);
	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.00019)
		tmp = x * x;
	else
		tmp = (2.0 * cosh(x)) - 2.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, 0.00019], N[(x * x), $MachinePrecision], N[(N[(2.0 * N[Cosh[x], $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.00019:\\
\;\;\;\;x \cdot x\\

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


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

    1. Initial program 69.3%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    5. Step-by-step derivation
      1. unpow281.8%

        \[\leadsto \color{blue}{x \cdot x} \]
    6. Simplified81.8%

      \[\leadsto \color{blue}{x \cdot x} \]

    if 1.9000000000000001e-4 < x

    1. Initial program 99.8%

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \color{blue}{2 \cdot \cosh x} + -2 \]
      3. fma-def99.7%

        \[\leadsto \color{blue}{\mathsf{fma}\left(2, \cosh x, -2\right)} \]
      4. metadata-eval99.7%

        \[\leadsto \mathsf{fma}\left(2, \cosh x, \color{blue}{-2}\right) \]
      5. fma-neg99.7%

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

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

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

Alternative 9: 83.6% accurate, 1.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;x \leq 4.4:\\
\;\;\;\;x \cdot x\\

\mathbf{else}:\\
\;\;\;\;0.002777777777777778 \cdot {x}^{6}\\


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

    1. Initial program 69.6%

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

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

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

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

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

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

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

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

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

      \[\leadsto \color{blue}{{x}^{2}} \]
    5. Step-by-step derivation
      1. unpow281.3%

        \[\leadsto \color{blue}{x \cdot x} \]
    6. Simplified81.3%

      \[\leadsto \color{blue}{x \cdot x} \]

    if 4.4000000000000004 < 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. +-commutative100.0%

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

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

        \[\leadsto e^{x} + \left(\color{blue}{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 85.9%

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

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.002777777777777778, {x}^{6}, x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)} \]
    7. Taylor expanded in x around inf 85.9%

      \[\leadsto \color{blue}{0.002777777777777778 \cdot {x}^{6}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification82.5%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 4.4:\\ \;\;\;\;x \cdot x\\ \mathbf{else}:\\ \;\;\;\;0.002777777777777778 \cdot {x}^{6}\\ \end{array} \]

Alternative 10: 75.6% accurate, 68.7× speedup?

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

\\
x \cdot x
\end{array}
Derivation
  1. Initial program 77.5%

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

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

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

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

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

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

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

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

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

    \[\leadsto \color{blue}{{x}^{2}} \]
  5. Step-by-step derivation
    1. unpow276.2%

      \[\leadsto \color{blue}{x \cdot x} \]
  6. Simplified76.2%

    \[\leadsto \color{blue}{x \cdot x} \]
  7. Final simplification76.2%

    \[\leadsto x \cdot x \]

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 2023192 
(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))))