Hyperbolic tangent

Percentage Accurate: 9.5% → 97.3%
Time: 7.4s
Alternatives: 11
Speedup: 409.0×

Specification

?
\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-x}\\ \frac{e^{x} - t_0}{e^{x} + t_0} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (exp (- x)))) (/ (- (exp x) t_0) (+ (exp x) t_0))))
double code(double x) {
	double t_0 = exp(-x);
	return (exp(x) - t_0) / (exp(x) + t_0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = exp(-x)
    code = (exp(x) - t_0) / (exp(x) + t_0)
end function
public static double code(double x) {
	double t_0 = Math.exp(-x);
	return (Math.exp(x) - t_0) / (Math.exp(x) + t_0);
}
def code(x):
	t_0 = math.exp(-x)
	return (math.exp(x) - t_0) / (math.exp(x) + t_0)
function code(x)
	t_0 = exp(Float64(-x))
	return Float64(Float64(exp(x) - t_0) / Float64(exp(x) + t_0))
end
function tmp = code(x)
	t_0 = exp(-x);
	tmp = (exp(x) - t_0) / (exp(x) + t_0);
end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, N[(N[(N[Exp[x], $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-x}\\
\frac{e^{x} - t_0}{e^{x} + t_0}
\end{array}
\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 11 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: 9.5% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{-x}\\ \frac{e^{x} - t_0}{e^{x} + t_0} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (exp (- x)))) (/ (- (exp x) t_0) (+ (exp x) t_0))))
double code(double x) {
	double t_0 = exp(-x);
	return (exp(x) - t_0) / (exp(x) + t_0);
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: t_0
    t_0 = exp(-x)
    code = (exp(x) - t_0) / (exp(x) + t_0)
end function
public static double code(double x) {
	double t_0 = Math.exp(-x);
	return (Math.exp(x) - t_0) / (Math.exp(x) + t_0);
}
def code(x):
	t_0 = math.exp(-x)
	return (math.exp(x) - t_0) / (math.exp(x) + t_0)
function code(x)
	t_0 = exp(Float64(-x))
	return Float64(Float64(exp(x) - t_0) / Float64(exp(x) + t_0))
end
function tmp = code(x)
	t_0 = exp(-x);
	tmp = (exp(x) - t_0) / (exp(x) + t_0);
end
code[x_] := Block[{t$95$0 = N[Exp[(-x)], $MachinePrecision]}, N[(N[(N[Exp[x], $MachinePrecision] - t$95$0), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + t$95$0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{-x}\\
\frac{e^{x} - t_0}{e^{x} + t_0}
\end{array}
\end{array}

Alternative 1: 97.3% accurate, 0.4× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{2 + \mathsf{fma}\left(0.002777777777777778, {x}^{6}, x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/
  (fma
   0.016666666666666666
   (pow x 5.0)
   (fma
    0.3333333333333333
    (pow x 3.0)
    (fma 0.0003968253968253968 (pow x 7.0) (+ x x))))
  (+
   2.0
   (fma
    0.002777777777777778
    (pow x 6.0)
    (+ (* x x) (* 0.08333333333333333 (pow x 4.0)))))))
double code(double x) {
	return fma(0.016666666666666666, pow(x, 5.0), fma(0.3333333333333333, pow(x, 3.0), fma(0.0003968253968253968, pow(x, 7.0), (x + x)))) / (2.0 + fma(0.002777777777777778, pow(x, 6.0), ((x * x) + (0.08333333333333333 * pow(x, 4.0)))));
}
function code(x)
	return Float64(fma(0.016666666666666666, (x ^ 5.0), fma(0.3333333333333333, (x ^ 3.0), fma(0.0003968253968253968, (x ^ 7.0), Float64(x + x)))) / Float64(2.0 + fma(0.002777777777777778, (x ^ 6.0), Float64(Float64(x * x) + Float64(0.08333333333333333 * (x ^ 4.0))))))
end
code[x_] := N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision] + N[(0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision] + N[(0.0003968253968253968 * N[Power[x, 7.0], $MachinePrecision] + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(2.0 + N[(0.002777777777777778 * N[Power[x, 6.0], $MachinePrecision] + N[(N[(x * x), $MachinePrecision] + N[(0.08333333333333333 * N[Power[x, 4.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{2 + \mathsf{fma}\left(0.002777777777777778, {x}^{6}, x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 97.1%

    \[\leadsto \frac{\color{blue}{2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}}{e^{x} + e^{-x}} \]
  3. Step-by-step derivation
    1. associate-+r+97.1%

      \[\leadsto \frac{2 \cdot x + \color{blue}{\left(\left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right) + 0.016666666666666666 \cdot {x}^{5}\right)}}{e^{x} + e^{-x}} \]
    2. associate-+r+97.1%

      \[\leadsto \frac{\color{blue}{\left(2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right) + 0.016666666666666666 \cdot {x}^{5}}}{e^{x} + e^{-x}} \]
    3. +-commutative97.1%

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right)}}{e^{x} + e^{-x}} \]
    4. fma-def97.1%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, 2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right)}}{e^{x} + e^{-x}} \]
    5. associate-+r+97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right) + 0.0003968253968253968 \cdot {x}^{7}}\right)}{e^{x} + e^{-x}} \]
    6. +-commutative97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)} + 0.0003968253968253968 \cdot {x}^{7}\right)}{e^{x} + e^{-x}} \]
    7. associate-+l+97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{0.3333333333333333 \cdot {x}^{3} + \left(2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{e^{x} + e^{-x}} \]
    8. fma-def97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, 2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{e^{x} + e^{-x}} \]
    9. +-commutative97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{0.0003968253968253968 \cdot {x}^{7} + 2 \cdot x}\right)\right)}{e^{x} + e^{-x}} \]
    10. fma-def97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)}\right)\right)}{e^{x} + e^{-x}} \]
    11. count-297.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \color{blue}{x + x}\right)\right)\right)}{e^{x} + e^{-x}} \]
  4. Simplified97.1%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}}{e^{x} + e^{-x}} \]
  5. Taylor expanded in x around 0 97.3%

    \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{\color{blue}{2 + \left(0.002777777777777778 \cdot {x}^{6} + \left({x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)\right)}} \]
  6. Step-by-step derivation
    1. fma-def97.3%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{2 + \color{blue}{\mathsf{fma}\left(0.002777777777777778, {x}^{6}, {x}^{2} + 0.08333333333333333 \cdot {x}^{4}\right)}} \]
    2. unpow297.3%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{2 + \mathsf{fma}\left(0.002777777777777778, {x}^{6}, \color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4}\right)} \]
  7. Simplified97.3%

    \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{\color{blue}{2 + \mathsf{fma}\left(0.002777777777777778, {x}^{6}, x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)}} \]
  8. Final simplification97.3%

    \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{2 + \mathsf{fma}\left(0.002777777777777778, {x}^{6}, x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)} \]

Alternative 2: 97.1% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{e^{x} + e^{-x}} \end{array} \]
(FPCore (x)
 :precision binary64
 (/
  (fma
   0.016666666666666666
   (pow x 5.0)
   (fma
    0.3333333333333333
    (pow x 3.0)
    (fma 0.0003968253968253968 (pow x 7.0) (+ x x))))
  (+ (exp x) (exp (- x)))))
double code(double x) {
	return fma(0.016666666666666666, pow(x, 5.0), fma(0.3333333333333333, pow(x, 3.0), fma(0.0003968253968253968, pow(x, 7.0), (x + x)))) / (exp(x) + exp(-x));
}
function code(x)
	return Float64(fma(0.016666666666666666, (x ^ 5.0), fma(0.3333333333333333, (x ^ 3.0), fma(0.0003968253968253968, (x ^ 7.0), Float64(x + x)))) / Float64(exp(x) + exp(Float64(-x))))
end
code[x_] := N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision] + N[(0.3333333333333333 * N[Power[x, 3.0], $MachinePrecision] + N[(0.0003968253968253968 * N[Power[x, 7.0], $MachinePrecision] + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(N[Exp[x], $MachinePrecision] + N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{e^{x} + e^{-x}}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 97.1%

    \[\leadsto \frac{\color{blue}{2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}}{e^{x} + e^{-x}} \]
  3. Step-by-step derivation
    1. associate-+r+97.1%

      \[\leadsto \frac{2 \cdot x + \color{blue}{\left(\left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right) + 0.016666666666666666 \cdot {x}^{5}\right)}}{e^{x} + e^{-x}} \]
    2. associate-+r+97.1%

      \[\leadsto \frac{\color{blue}{\left(2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right) + 0.016666666666666666 \cdot {x}^{5}}}{e^{x} + e^{-x}} \]
    3. +-commutative97.1%

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right)}}{e^{x} + e^{-x}} \]
    4. fma-def97.1%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, 2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right)}}{e^{x} + e^{-x}} \]
    5. associate-+r+97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right) + 0.0003968253968253968 \cdot {x}^{7}}\right)}{e^{x} + e^{-x}} \]
    6. +-commutative97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)} + 0.0003968253968253968 \cdot {x}^{7}\right)}{e^{x} + e^{-x}} \]
    7. associate-+l+97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{0.3333333333333333 \cdot {x}^{3} + \left(2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{e^{x} + e^{-x}} \]
    8. fma-def97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, 2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{e^{x} + e^{-x}} \]
    9. +-commutative97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{0.0003968253968253968 \cdot {x}^{7} + 2 \cdot x}\right)\right)}{e^{x} + e^{-x}} \]
    10. fma-def97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)}\right)\right)}{e^{x} + e^{-x}} \]
    11. count-297.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \color{blue}{x + x}\right)\right)\right)}{e^{x} + e^{-x}} \]
  4. Simplified97.1%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}}{e^{x} + e^{-x}} \]
  5. Final simplification97.1%

    \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}{e^{x} + e^{-x}} \]

Alternative 3: 97.1% accurate, 0.7× speedup?

\[\begin{array}{l} \\ \left(0.016666666666666666 \cdot {x}^{5} + \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right) \cdot \frac{0.5}{\cosh x} \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (+
   (* 0.016666666666666666 (pow x 5.0))
   (fma
    (pow x 3.0)
    0.3333333333333333
    (fma (pow x 7.0) 0.0003968253968253968 (+ x x))))
  (/ 0.5 (cosh x))))
double code(double x) {
	return ((0.016666666666666666 * pow(x, 5.0)) + fma(pow(x, 3.0), 0.3333333333333333, fma(pow(x, 7.0), 0.0003968253968253968, (x + x)))) * (0.5 / cosh(x));
}
function code(x)
	return Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + fma((x ^ 3.0), 0.3333333333333333, fma((x ^ 7.0), 0.0003968253968253968, Float64(x + x)))) * Float64(0.5 / cosh(x)))
end
code[x_] := N[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(N[Power[x, 3.0], $MachinePrecision] * 0.3333333333333333 + N[(N[Power[x, 7.0], $MachinePrecision] * 0.0003968253968253968 + N[(x + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(0.5 / N[Cosh[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(0.016666666666666666 \cdot {x}^{5} + \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right) \cdot \frac{0.5}{\cosh x}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 97.1%

    \[\leadsto \frac{\color{blue}{2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + \left(0.0003968253968253968 \cdot {x}^{7} + 0.016666666666666666 \cdot {x}^{5}\right)\right)}}{e^{x} + e^{-x}} \]
  3. Step-by-step derivation
    1. associate-+r+97.1%

      \[\leadsto \frac{2 \cdot x + \color{blue}{\left(\left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right) + 0.016666666666666666 \cdot {x}^{5}\right)}}{e^{x} + e^{-x}} \]
    2. associate-+r+97.1%

      \[\leadsto \frac{\color{blue}{\left(2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right) + 0.016666666666666666 \cdot {x}^{5}}}{e^{x} + e^{-x}} \]
    3. +-commutative97.1%

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right)}}{e^{x} + e^{-x}} \]
    4. fma-def97.1%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, 2 \cdot x + \left(0.3333333333333333 \cdot {x}^{3} + 0.0003968253968253968 \cdot {x}^{7}\right)\right)}}{e^{x} + e^{-x}} \]
    5. associate-+r+97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\left(2 \cdot x + 0.3333333333333333 \cdot {x}^{3}\right) + 0.0003968253968253968 \cdot {x}^{7}}\right)}{e^{x} + e^{-x}} \]
    6. +-commutative97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)} + 0.0003968253968253968 \cdot {x}^{7}\right)}{e^{x} + e^{-x}} \]
    7. associate-+l+97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{0.3333333333333333 \cdot {x}^{3} + \left(2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{e^{x} + e^{-x}} \]
    8. fma-def97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \color{blue}{\mathsf{fma}\left(0.3333333333333333, {x}^{3}, 2 \cdot x + 0.0003968253968253968 \cdot {x}^{7}\right)}\right)}{e^{x} + e^{-x}} \]
    9. +-commutative97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{0.0003968253968253968 \cdot {x}^{7} + 2 \cdot x}\right)\right)}{e^{x} + e^{-x}} \]
    10. fma-def97.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \color{blue}{\mathsf{fma}\left(0.0003968253968253968, {x}^{7}, 2 \cdot x\right)}\right)\right)}{e^{x} + e^{-x}} \]
    11. count-297.1%

      \[\leadsto \frac{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, \color{blue}{x + x}\right)\right)\right)}{e^{x} + e^{-x}} \]
  4. Simplified97.1%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)}}{e^{x} + e^{-x}} \]
  5. Step-by-step derivation
    1. div-inv97.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right) \cdot \frac{1}{e^{x} + e^{-x}}} \]
    2. cosh-undef97.1%

      \[\leadsto \mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right) \cdot \frac{1}{\color{blue}{2 \cdot \cosh x}} \]
  6. Applied egg-rr97.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left(0.016666666666666666, {x}^{5}, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right) \cdot \frac{1}{2 \cdot \cosh x}} \]
  7. Step-by-step derivation
    1. fma-def97.1%

      \[\leadsto \color{blue}{\left(0.016666666666666666 \cdot {x}^{5} + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)} \cdot \frac{1}{2 \cdot \cosh x} \]
    2. *-commutative97.1%

      \[\leadsto \left(\color{blue}{{x}^{5} \cdot 0.016666666666666666} + \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right) \cdot \frac{1}{2 \cdot \cosh x} \]
    3. fma-def97.1%

      \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{5}, 0.016666666666666666, \mathsf{fma}\left(0.3333333333333333, {x}^{3}, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)\right)} \cdot \frac{1}{2 \cdot \cosh x} \]
    4. fma-def97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \color{blue}{0.3333333333333333 \cdot {x}^{3} + \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)}\right) \cdot \frac{1}{2 \cdot \cosh x} \]
    5. *-commutative97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \color{blue}{{x}^{3} \cdot 0.3333333333333333} + \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right) \cdot \frac{1}{2 \cdot \cosh x} \]
    6. fma-def97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \color{blue}{\mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left(0.0003968253968253968, {x}^{7}, x + x\right)\right)}\right) \cdot \frac{1}{2 \cdot \cosh x} \]
    7. fma-udef97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \color{blue}{0.0003968253968253968 \cdot {x}^{7} + \left(x + x\right)}\right)\right) \cdot \frac{1}{2 \cdot \cosh x} \]
    8. *-commutative97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \color{blue}{{x}^{7} \cdot 0.0003968253968253968} + \left(x + x\right)\right)\right) \cdot \frac{1}{2 \cdot \cosh x} \]
    9. fma-def97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \color{blue}{\mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)}\right)\right) \cdot \frac{1}{2 \cdot \cosh x} \]
    10. associate-/r*97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right) \cdot \color{blue}{\frac{\frac{1}{2}}{\cosh x}} \]
    11. metadata-eval97.1%

      \[\leadsto \mathsf{fma}\left({x}^{5}, 0.016666666666666666, \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right) \cdot \frac{\color{blue}{0.5}}{\cosh x} \]
  8. Simplified97.1%

    \[\leadsto \color{blue}{\mathsf{fma}\left({x}^{5}, 0.016666666666666666, \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right) \cdot \frac{0.5}{\cosh x}} \]
  9. Step-by-step derivation
    1. fma-udef97.1%

      \[\leadsto \color{blue}{\left({x}^{5} \cdot 0.016666666666666666 + \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right)} \cdot \frac{0.5}{\cosh x} \]
  10. Applied egg-rr97.1%

    \[\leadsto \color{blue}{\left({x}^{5} \cdot 0.016666666666666666 + \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right)} \cdot \frac{0.5}{\cosh x} \]
  11. Final simplification97.1%

    \[\leadsto \left(0.016666666666666666 \cdot {x}^{5} + \mathsf{fma}\left({x}^{3}, 0.3333333333333333, \mathsf{fma}\left({x}^{7}, 0.0003968253968253968, x + x\right)\right)\right) \cdot \frac{0.5}{\cosh x} \]

Alternative 4: 96.9% accurate, 1.9× speedup?

\[\begin{array}{l} \\ {x}^{3} \cdot -0.3333333333333333 + \left(x + {x}^{5} \cdot 0.13333333333333333\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (+
  (* (pow x 3.0) -0.3333333333333333)
  (+ x (* (pow x 5.0) 0.13333333333333333))))
double code(double x) {
	return (pow(x, 3.0) * -0.3333333333333333) + (x + (pow(x, 5.0) * 0.13333333333333333));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = ((x ** 3.0d0) * (-0.3333333333333333d0)) + (x + ((x ** 5.0d0) * 0.13333333333333333d0))
end function
public static double code(double x) {
	return (Math.pow(x, 3.0) * -0.3333333333333333) + (x + (Math.pow(x, 5.0) * 0.13333333333333333));
}
def code(x):
	return (math.pow(x, 3.0) * -0.3333333333333333) + (x + (math.pow(x, 5.0) * 0.13333333333333333))
function code(x)
	return Float64(Float64((x ^ 3.0) * -0.3333333333333333) + Float64(x + Float64((x ^ 5.0) * 0.13333333333333333)))
end
function tmp = code(x)
	tmp = ((x ^ 3.0) * -0.3333333333333333) + (x + ((x ^ 5.0) * 0.13333333333333333));
end
code[x_] := N[(N[(N[Power[x, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + N[(x + N[(N[Power[x, 5.0], $MachinePrecision] * 0.13333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
{x}^{3} \cdot -0.3333333333333333 + \left(x + {x}^{5} \cdot 0.13333333333333333\right)
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 97.0%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot {x}^{3} + \left(0.13333333333333333 \cdot {x}^{5} + x\right)} \]
  3. Final simplification97.0%

    \[\leadsto {x}^{3} \cdot -0.3333333333333333 + \left(x + {x}^{5} \cdot 0.13333333333333333\right) \]

Alternative 5: 96.9% accurate, 3.6× speedup?

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

\\
\frac{x \cdot 2 + 0.3333333333333333 \cdot {x}^{3}}{2 + x \cdot x}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 96.8%

    \[\leadsto \frac{\color{blue}{2 \cdot x + 0.3333333333333333 \cdot {x}^{3}}}{e^{x} + e^{-x}} \]
  3. Taylor expanded in x around 0 97.0%

    \[\leadsto \frac{2 \cdot x + 0.3333333333333333 \cdot {x}^{3}}{\color{blue}{2 + {x}^{2}}} \]
  4. Step-by-step derivation
    1. unpow28.9%

      \[\leadsto \frac{e^{x} - e^{-x}}{2 + \color{blue}{x \cdot x}} \]
  5. Simplified97.0%

    \[\leadsto \frac{2 \cdot x + 0.3333333333333333 \cdot {x}^{3}}{\color{blue}{2 + x \cdot x}} \]
  6. Final simplification97.0%

    \[\leadsto \frac{x \cdot 2 + 0.3333333333333333 \cdot {x}^{3}}{2 + x \cdot x} \]

Alternative 6: 96.7% accurate, 3.8× speedup?

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

\\
\frac{2 \cdot \sinh x}{2 + x \cdot x}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 9.1%

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

      \[\leadsto \frac{e^{x} - e^{-x}}{2 + \left(\color{blue}{x \cdot x} + 0.08333333333333333 \cdot {x}^{4}\right)} \]
  4. Simplified9.1%

    \[\leadsto \frac{e^{x} - e^{-x}}{\color{blue}{2 + \left(x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)}} \]
  5. Step-by-step derivation
    1. *-un-lft-identity9.1%

      \[\leadsto \color{blue}{1 \cdot \frac{e^{x} - e^{-x}}{2 + \left(x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)}} \]
    2. sinh-undef97.0%

      \[\leadsto 1 \cdot \frac{\color{blue}{2 \cdot \sinh x}}{2 + \left(x \cdot x + 0.08333333333333333 \cdot {x}^{4}\right)} \]
    3. fma-def97.0%

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

    \[\leadsto \color{blue}{1 \cdot \frac{2 \cdot \sinh x}{2 + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)}} \]
  7. Step-by-step derivation
    1. *-lft-identity97.0%

      \[\leadsto \color{blue}{\frac{2 \cdot \sinh x}{2 + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)}} \]
  8. Simplified97.0%

    \[\leadsto \color{blue}{\frac{2 \cdot \sinh x}{2 + \mathsf{fma}\left(x, x, 0.08333333333333333 \cdot {x}^{4}\right)}} \]
  9. Taylor expanded in x around 0 96.8%

    \[\leadsto \frac{2 \cdot \sinh x}{2 + \color{blue}{{x}^{2}}} \]
  10. Step-by-step derivation
    1. unpow296.8%

      \[\leadsto \frac{2 \cdot \sinh x}{2 + \color{blue}{x \cdot x}} \]
  11. Simplified96.8%

    \[\leadsto \frac{2 \cdot \sinh x}{2 + \color{blue}{x \cdot x}} \]
  12. Final simplification96.8%

    \[\leadsto \frac{2 \cdot \sinh x}{2 + x \cdot x} \]

Alternative 7: 96.5% accurate, 3.9× speedup?

\[\begin{array}{l} \\ x + {x}^{3} \cdot -0.3333333333333333 \end{array} \]
(FPCore (x) :precision binary64 (+ x (* (pow x 3.0) -0.3333333333333333)))
double code(double x) {
	return x + (pow(x, 3.0) * -0.3333333333333333);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = x + ((x ** 3.0d0) * (-0.3333333333333333d0))
end function
public static double code(double x) {
	return x + (Math.pow(x, 3.0) * -0.3333333333333333);
}
def code(x):
	return x + (math.pow(x, 3.0) * -0.3333333333333333)
function code(x)
	return Float64(x + Float64((x ^ 3.0) * -0.3333333333333333))
end
function tmp = code(x)
	tmp = x + ((x ^ 3.0) * -0.3333333333333333);
end
code[x_] := N[(x + N[(N[Power[x, 3.0], $MachinePrecision] * -0.3333333333333333), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
x + {x}^{3} \cdot -0.3333333333333333
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 96.6%

    \[\leadsto \color{blue}{-0.3333333333333333 \cdot {x}^{3} + x} \]
  3. Final simplification96.6%

    \[\leadsto x + {x}^{3} \cdot -0.3333333333333333 \]

Alternative 8: 96.4% accurate, 37.2× speedup?

\[\begin{array}{l} \\ \left(x + x\right) \cdot \frac{1}{2 + x \cdot x} \end{array} \]
(FPCore (x) :precision binary64 (* (+ x x) (/ 1.0 (+ 2.0 (* x x)))))
double code(double x) {
	return (x + x) * (1.0 / (2.0 + (x * x)));
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = (x + x) * (1.0d0 / (2.0d0 + (x * x)))
end function
public static double code(double x) {
	return (x + x) * (1.0 / (2.0 + (x * x)));
}
def code(x):
	return (x + x) * (1.0 / (2.0 + (x * x)))
function code(x)
	return Float64(Float64(x + x) * Float64(1.0 / Float64(2.0 + Float64(x * x))))
end
function tmp = code(x)
	tmp = (x + x) * (1.0 / (2.0 + (x * x)));
end
code[x_] := N[(N[(x + x), $MachinePrecision] * N[(1.0 / N[(2.0 + N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\left(x + x\right) \cdot \frac{1}{2 + x \cdot x}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 8.9%

    \[\leadsto \frac{e^{x} - e^{-x}}{\color{blue}{2 + {x}^{2}}} \]
  3. Step-by-step derivation
    1. unpow28.9%

      \[\leadsto \frac{e^{x} - e^{-x}}{2 + \color{blue}{x \cdot x}} \]
  4. Simplified8.9%

    \[\leadsto \frac{e^{x} - e^{-x}}{\color{blue}{2 + x \cdot x}} \]
  5. Taylor expanded in x around 0 96.1%

    \[\leadsto \frac{\color{blue}{2 \cdot x}}{2 + x \cdot x} \]
  6. Step-by-step derivation
    1. count-296.1%

      \[\leadsto \frac{\color{blue}{x + x}}{2 + x \cdot x} \]
  7. Simplified96.1%

    \[\leadsto \frac{\color{blue}{x + x}}{2 + x \cdot x} \]
  8. Step-by-step derivation
    1. div-inv96.1%

      \[\leadsto \color{blue}{\left(x + x\right) \cdot \frac{1}{2 + x \cdot x}} \]
  9. Applied egg-rr96.1%

    \[\leadsto \color{blue}{\left(x + x\right) \cdot \frac{1}{2 + x \cdot x}} \]
  10. Final simplification96.1%

    \[\leadsto \left(x + x\right) \cdot \frac{1}{2 + x \cdot x} \]

Alternative 9: 96.4% accurate, 45.4× speedup?

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

\\
\frac{x + x}{2 + x \cdot x}
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 8.9%

    \[\leadsto \frac{e^{x} - e^{-x}}{\color{blue}{2 + {x}^{2}}} \]
  3. Step-by-step derivation
    1. unpow28.9%

      \[\leadsto \frac{e^{x} - e^{-x}}{2 + \color{blue}{x \cdot x}} \]
  4. Simplified8.9%

    \[\leadsto \frac{e^{x} - e^{-x}}{\color{blue}{2 + x \cdot x}} \]
  5. Taylor expanded in x around 0 96.1%

    \[\leadsto \frac{\color{blue}{2 \cdot x}}{2 + x \cdot x} \]
  6. Step-by-step derivation
    1. count-296.1%

      \[\leadsto \frac{\color{blue}{x + x}}{2 + x \cdot x} \]
  7. Simplified96.1%

    \[\leadsto \frac{\color{blue}{x + x}}{2 + x \cdot x} \]
  8. Final simplification96.1%

    \[\leadsto \frac{x + x}{2 + x \cdot x} \]

Alternative 10: 3.9% accurate, 409.0× speedup?

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

\\
2.5
\end{array}
Derivation
  1. Initial program 10.1%

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 8.9%

    \[\leadsto \frac{e^{x} - e^{-x}}{\color{blue}{2 + {x}^{2}}} \]
  3. Step-by-step derivation
    1. unpow28.9%

      \[\leadsto \frac{e^{x} - e^{-x}}{2 + \color{blue}{x \cdot x}} \]
  4. Simplified8.9%

    \[\leadsto \frac{e^{x} - e^{-x}}{\color{blue}{2 + x \cdot x}} \]
  5. Applied egg-rr4.0%

    \[\leadsto \frac{\color{blue}{5}}{2 + x \cdot x} \]
  6. Taylor expanded in x around 0 4.1%

    \[\leadsto \color{blue}{2.5} \]
  7. Final simplification4.1%

    \[\leadsto 2.5 \]

Alternative 11: 96.3% accurate, 409.0× speedup?

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

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

    \[\frac{e^{x} - e^{-x}}{e^{x} + e^{-x}} \]
  2. Taylor expanded in x around 0 96.0%

    \[\leadsto \color{blue}{x} \]
  3. Final simplification96.0%

    \[\leadsto x \]

Reproduce

?
herbie shell --seed 2023185 
(FPCore (x)
  :name "Hyperbolic tangent"
  :precision binary64
  (/ (- (exp x) (exp (- x))) (+ (exp x) (exp (- x)))))