Hyperbolic tangent

Percentage Accurate: 9.2% → 100.0%
Time: 12.1s
Alternatives: 7
Speedup: 24.8×

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 7 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.2% 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: 100.0% accurate, 4.2× speedup?

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

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

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

      \[\leadsto \color{blue}{\frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\mathsf{neg}\left(x\right)}}} \]
    2. lift--.f64N/A

      \[\leadsto \frac{\color{blue}{e^{x} - e^{\mathsf{neg}\left(x\right)}}}{e^{x} + e^{\mathsf{neg}\left(x\right)}} \]
    3. lift-exp.f64N/A

      \[\leadsto \frac{\color{blue}{e^{x}} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\mathsf{neg}\left(x\right)}} \]
    4. lift-exp.f64N/A

      \[\leadsto \frac{e^{x} - \color{blue}{e^{\mathsf{neg}\left(x\right)}}}{e^{x} + e^{\mathsf{neg}\left(x\right)}} \]
    5. lift-neg.f64N/A

      \[\leadsto \frac{e^{x} - e^{\color{blue}{\mathsf{neg}\left(x\right)}}}{e^{x} + e^{\mathsf{neg}\left(x\right)}} \]
    6. lift-+.f64N/A

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

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{e^{x}} + e^{\mathsf{neg}\left(x\right)}} \]
    8. lift-exp.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + \color{blue}{e^{\mathsf{neg}\left(x\right)}}} \]
    9. lift-neg.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\color{blue}{\mathsf{neg}\left(x\right)}}} \]
    10. tanh-undefN/A

      \[\leadsto \color{blue}{\tanh x} \]
    11. lower-tanh.f64100.0

      \[\leadsto \color{blue}{\tanh x} \]
  4. Applied rewrites100.0%

    \[\leadsto \color{blue}{\tanh x} \]
  5. Add Preprocessing

Alternative 2: 97.4% accurate, 4.8× speedup?

\[\begin{array}{l} \\ \frac{1}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right) \end{array} \]
(FPCore (x)
 :precision binary64
 (*
  (/
   1.0
   (fma
    (* x x)
    (fma (* x x) (fma (* x x) 0.001388888888888889 0.041666666666666664) 0.5)
    1.0))
  (fma
   (fma
    (* x x)
    (fma x (* x 0.0001984126984126984) 0.008333333333333333)
    0.16666666666666666)
   (* x (* x x))
   x)))
double code(double x) {
	return (1.0 / fma((x * x), fma((x * x), fma((x * x), 0.001388888888888889, 0.041666666666666664), 0.5), 1.0)) * fma(fma((x * x), fma(x, (x * 0.0001984126984126984), 0.008333333333333333), 0.16666666666666666), (x * (x * x)), x);
}
function code(x)
	return Float64(Float64(1.0 / fma(Float64(x * x), fma(Float64(x * x), fma(Float64(x * x), 0.001388888888888889, 0.041666666666666664), 0.5), 1.0)) * fma(fma(Float64(x * x), fma(x, Float64(x * 0.0001984126984126984), 0.008333333333333333), 0.16666666666666666), Float64(x * Float64(x * x)), x))
end
code[x_] := N[(N[(1.0 / N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 0.001388888888888889 + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision] * N[(N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.0001984126984126984), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] + 0.16666666666666666), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right)
\end{array}
Derivation
  1. Initial program 10.5%

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

      \[\leadsto \color{blue}{\frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\mathsf{neg}\left(x\right)}}} \]
    2. lift-+.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{e^{x} + e^{\mathsf{neg}\left(x\right)}}} \]
    3. lift-exp.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{e^{x}} + e^{\mathsf{neg}\left(x\right)}} \]
    4. lift-exp.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + \color{blue}{e^{\mathsf{neg}\left(x\right)}}} \]
    5. lift-neg.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\color{blue}{\mathsf{neg}\left(x\right)}}} \]
    6. cosh-undefN/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{2 \cdot \cosh x}} \]
    7. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{2}}{\cosh x}} \]
    8. lift--.f64N/A

      \[\leadsto \frac{\frac{\color{blue}{e^{x} - e^{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
    9. lift-exp.f64N/A

      \[\leadsto \frac{\frac{\color{blue}{e^{x}} - e^{\mathsf{neg}\left(x\right)}}{2}}{\cosh x} \]
    10. lift-exp.f64N/A

      \[\leadsto \frac{\frac{e^{x} - \color{blue}{e^{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
    11. lift-neg.f64N/A

      \[\leadsto \frac{\frac{e^{x} - e^{\color{blue}{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
    12. sinh-defN/A

      \[\leadsto \frac{\color{blue}{\sinh x}}{\cosh x} \]
    13. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sinh x}{\cosh x}} \]
    14. lower-sinh.f64N/A

      \[\leadsto \frac{\color{blue}{\sinh x}}{\cosh x} \]
    15. lower-cosh.f6498.0

      \[\leadsto \frac{\sinh x}{\color{blue}{\cosh x}} \]
  4. Applied rewrites98.0%

    \[\leadsto \color{blue}{\frac{\sinh x}{\cosh x}} \]
  5. Taylor expanded in x around 0

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

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

      \[\leadsto \frac{\sinh x}{\color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)}} \]
    3. unpow2N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)} \]
    5. +-commutativeN/A

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

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right)}, 1\right)} \]
    7. unpow2N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right), 1\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right), 1\right)} \]
    9. +-commutativeN/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{720} \cdot {x}^{2} + \frac{1}{24}}, \frac{1}{2}\right), 1\right)} \]
    10. unpow2N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{720} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{24}, \frac{1}{2}\right), 1\right)} \]
    11. associate-*r*N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{1}{720} \cdot x\right) \cdot x} + \frac{1}{24}, \frac{1}{2}\right), 1\right)} \]
    12. *-commutativeN/A

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

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{1}{720} \cdot x, \frac{1}{24}\right)}, \frac{1}{2}\right), 1\right)} \]
    14. *-commutativeN/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{720}}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    15. lower-*.f6497.0

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right), 1\right)} \]
  7. Applied rewrites97.0%

    \[\leadsto \frac{\sinh x}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)}} \]
  8. Taylor expanded in x around 0

    \[\leadsto \frac{\color{blue}{x \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right)\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
  9. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) + 1\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    2. distribute-rgt-inN/A

      \[\leadsto \frac{\color{blue}{\left({x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right)\right) \cdot x + 1 \cdot x}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\left(\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot {x}^{2}\right)} \cdot x + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    4. associate-*l*N/A

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot \left({x}^{2} \cdot x\right)} + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    5. unpow2N/A

      \[\leadsto \frac{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    6. unpow3N/A

      \[\leadsto \frac{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot \color{blue}{{x}^{3}} + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    7. *-lft-identityN/A

      \[\leadsto \frac{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot {x}^{3} + \color{blue}{x}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    8. lower-fma.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right), {x}^{3}, x\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
  10. Applied rewrites97.3%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \]
  11. Step-by-step derivation
    1. lift-/.f64N/A

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{5040}, \frac{1}{120}\right), \frac{1}{6}\right), x \cdot \left(x \cdot x\right), x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)}} \]
    2. clear-numN/A

      \[\leadsto \color{blue}{\frac{1}{\frac{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{5040}, \frac{1}{120}\right), \frac{1}{6}\right), x \cdot \left(x \cdot x\right), x\right)}}} \]
    3. associate-/r/N/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{5040}, \frac{1}{120}\right), \frac{1}{6}\right), x \cdot \left(x \cdot x\right), x\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{5040}, \frac{1}{120}\right), \frac{1}{6}\right), x \cdot \left(x \cdot x\right), x\right)} \]
  12. Applied rewrites97.3%

    \[\leadsto \color{blue}{\frac{1}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \cdot \mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right)} \]
  13. Add Preprocessing

Alternative 3: 97.4% accurate, 5.1× speedup?

\[\begin{array}{l} \\ \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/
  (fma
   (*
    (* x x)
    (fma
     (* x x)
     (fma x (* x 0.0001984126984126984) 0.008333333333333333)
     0.16666666666666666))
   x
   x)
  (fma
   (* x x)
   (fma (* x x) (fma x (* x 0.001388888888888889) 0.041666666666666664) 0.5)
   1.0)))
double code(double x) {
	return fma(((x * x) * fma((x * x), fma(x, (x * 0.0001984126984126984), 0.008333333333333333), 0.16666666666666666)), x, x) / fma((x * x), fma((x * x), fma(x, (x * 0.001388888888888889), 0.041666666666666664), 0.5), 1.0);
}
function code(x)
	return Float64(fma(Float64(Float64(x * x) * fma(Float64(x * x), fma(x, Float64(x * 0.0001984126984126984), 0.008333333333333333), 0.16666666666666666)), x, x) / fma(Float64(x * x), fma(Float64(x * x), fma(x, Float64(x * 0.001388888888888889), 0.041666666666666664), 0.5), 1.0))
end
code[x_] := N[(N[(N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.0001984126984126984), $MachinePrecision] + 0.008333333333333333), $MachinePrecision] + 0.16666666666666666), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)}
\end{array}
Derivation
  1. Initial program 10.5%

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

      \[\leadsto \color{blue}{\frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\mathsf{neg}\left(x\right)}}} \]
    2. lift-+.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{e^{x} + e^{\mathsf{neg}\left(x\right)}}} \]
    3. lift-exp.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{e^{x}} + e^{\mathsf{neg}\left(x\right)}} \]
    4. lift-exp.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + \color{blue}{e^{\mathsf{neg}\left(x\right)}}} \]
    5. lift-neg.f64N/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\color{blue}{\mathsf{neg}\left(x\right)}}} \]
    6. cosh-undefN/A

      \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{2 \cdot \cosh x}} \]
    7. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{2}}{\cosh x}} \]
    8. lift--.f64N/A

      \[\leadsto \frac{\frac{\color{blue}{e^{x} - e^{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
    9. lift-exp.f64N/A

      \[\leadsto \frac{\frac{\color{blue}{e^{x}} - e^{\mathsf{neg}\left(x\right)}}{2}}{\cosh x} \]
    10. lift-exp.f64N/A

      \[\leadsto \frac{\frac{e^{x} - \color{blue}{e^{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
    11. lift-neg.f64N/A

      \[\leadsto \frac{\frac{e^{x} - e^{\color{blue}{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
    12. sinh-defN/A

      \[\leadsto \frac{\color{blue}{\sinh x}}{\cosh x} \]
    13. lower-/.f64N/A

      \[\leadsto \color{blue}{\frac{\sinh x}{\cosh x}} \]
    14. lower-sinh.f64N/A

      \[\leadsto \frac{\color{blue}{\sinh x}}{\cosh x} \]
    15. lower-cosh.f6498.0

      \[\leadsto \frac{\sinh x}{\color{blue}{\cosh x}} \]
  4. Applied rewrites98.0%

    \[\leadsto \color{blue}{\frac{\sinh x}{\cosh x}} \]
  5. Taylor expanded in x around 0

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

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

      \[\leadsto \frac{\sinh x}{\color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)}} \]
    3. unpow2N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)} \]
    4. lower-*.f64N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)} \]
    5. +-commutativeN/A

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

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right)}, 1\right)} \]
    7. unpow2N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right), 1\right)} \]
    8. lower-*.f64N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right), 1\right)} \]
    9. +-commutativeN/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{720} \cdot {x}^{2} + \frac{1}{24}}, \frac{1}{2}\right), 1\right)} \]
    10. unpow2N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{720} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{24}, \frac{1}{2}\right), 1\right)} \]
    11. associate-*r*N/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{1}{720} \cdot x\right) \cdot x} + \frac{1}{24}, \frac{1}{2}\right), 1\right)} \]
    12. *-commutativeN/A

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

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{1}{720} \cdot x, \frac{1}{24}\right)}, \frac{1}{2}\right), 1\right)} \]
    14. *-commutativeN/A

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{720}}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    15. lower-*.f6497.0

      \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right), 1\right)} \]
  7. Applied rewrites97.0%

    \[\leadsto \frac{\sinh x}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)}} \]
  8. Taylor expanded in x around 0

    \[\leadsto \frac{\color{blue}{x \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right)\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
  9. Step-by-step derivation
    1. +-commutativeN/A

      \[\leadsto \frac{x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) + 1\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    2. distribute-rgt-inN/A

      \[\leadsto \frac{\color{blue}{\left({x}^{2} \cdot \left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right)\right) \cdot x + 1 \cdot x}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    3. *-commutativeN/A

      \[\leadsto \frac{\color{blue}{\left(\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot {x}^{2}\right)} \cdot x + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    4. associate-*l*N/A

      \[\leadsto \frac{\color{blue}{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot \left({x}^{2} \cdot x\right)} + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    5. unpow2N/A

      \[\leadsto \frac{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    6. unpow3N/A

      \[\leadsto \frac{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot \color{blue}{{x}^{3}} + 1 \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    7. *-lft-identityN/A

      \[\leadsto \frac{\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right)\right) \cdot {x}^{3} + \color{blue}{x}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    8. lower-fma.f64N/A

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{1}{6} + {x}^{2} \cdot \left(\frac{1}{120} + \frac{1}{5040} \cdot {x}^{2}\right), {x}^{3}, x\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
  10. Applied rewrites97.3%

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \]
  11. Step-by-step derivation
    1. Applied rewrites97.3%

      \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right) \cdot \left(x \cdot x\right), \color{blue}{x}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \]
    2. Final simplification97.3%

      \[\leadsto \frac{\mathsf{fma}\left(\left(x \cdot x\right) \cdot \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.0001984126984126984, 0.008333333333333333\right), 0.16666666666666666\right), x, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \]
    3. Add Preprocessing

    Alternative 4: 97.3% accurate, 5.9× speedup?

    \[\begin{array}{l} \\ \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.008333333333333333, 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \end{array} \]
    (FPCore (x)
     :precision binary64
     (/
      (fma (fma (* x x) 0.008333333333333333 0.16666666666666666) (* x (* x x)) x)
      (fma
       (* x x)
       (fma (* x x) (fma x (* x 0.001388888888888889) 0.041666666666666664) 0.5)
       1.0)))
    double code(double x) {
    	return fma(fma((x * x), 0.008333333333333333, 0.16666666666666666), (x * (x * x)), x) / fma((x * x), fma((x * x), fma(x, (x * 0.001388888888888889), 0.041666666666666664), 0.5), 1.0);
    }
    
    function code(x)
    	return Float64(fma(fma(Float64(x * x), 0.008333333333333333, 0.16666666666666666), Float64(x * Float64(x * x)), x) / fma(Float64(x * x), fma(Float64(x * x), fma(x, Float64(x * 0.001388888888888889), 0.041666666666666664), 0.5), 1.0))
    end
    
    code[x_] := N[(N[(N[(N[(x * x), $MachinePrecision] * 0.008333333333333333 + 0.16666666666666666), $MachinePrecision] * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision] / N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * 0.001388888888888889), $MachinePrecision] + 0.041666666666666664), $MachinePrecision] + 0.5), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.008333333333333333, 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)}
    \end{array}
    
    Derivation
    1. Initial program 10.5%

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

        \[\leadsto \color{blue}{\frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\mathsf{neg}\left(x\right)}}} \]
      2. lift-+.f64N/A

        \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{e^{x} + e^{\mathsf{neg}\left(x\right)}}} \]
      3. lift-exp.f64N/A

        \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{e^{x}} + e^{\mathsf{neg}\left(x\right)}} \]
      4. lift-exp.f64N/A

        \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + \color{blue}{e^{\mathsf{neg}\left(x\right)}}} \]
      5. lift-neg.f64N/A

        \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{e^{x} + e^{\color{blue}{\mathsf{neg}\left(x\right)}}} \]
      6. cosh-undefN/A

        \[\leadsto \frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{\color{blue}{2 \cdot \cosh x}} \]
      7. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{e^{x} - e^{\mathsf{neg}\left(x\right)}}{2}}{\cosh x}} \]
      8. lift--.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{e^{x} - e^{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
      9. lift-exp.f64N/A

        \[\leadsto \frac{\frac{\color{blue}{e^{x}} - e^{\mathsf{neg}\left(x\right)}}{2}}{\cosh x} \]
      10. lift-exp.f64N/A

        \[\leadsto \frac{\frac{e^{x} - \color{blue}{e^{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
      11. lift-neg.f64N/A

        \[\leadsto \frac{\frac{e^{x} - e^{\color{blue}{\mathsf{neg}\left(x\right)}}}{2}}{\cosh x} \]
      12. sinh-defN/A

        \[\leadsto \frac{\color{blue}{\sinh x}}{\cosh x} \]
      13. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{\sinh x}{\cosh x}} \]
      14. lower-sinh.f64N/A

        \[\leadsto \frac{\color{blue}{\sinh x}}{\cosh x} \]
      15. lower-cosh.f6498.0

        \[\leadsto \frac{\sinh x}{\color{blue}{\cosh x}} \]
    4. Applied rewrites98.0%

      \[\leadsto \color{blue}{\frac{\sinh x}{\cosh x}} \]
    5. Taylor expanded in x around 0

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

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

        \[\leadsto \frac{\sinh x}{\color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)}} \]
      3. unpow2N/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{2} + {x}^{2} \cdot \left(\frac{1}{24} + \frac{1}{720} \cdot {x}^{2}\right), 1\right)} \]
      5. +-commutativeN/A

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

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right)}, 1\right)} \]
      7. unpow2N/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right), 1\right)} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24} + \frac{1}{720} \cdot {x}^{2}, \frac{1}{2}\right), 1\right)} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\frac{1}{720} \cdot {x}^{2} + \frac{1}{24}}, \frac{1}{2}\right), 1\right)} \]
      10. unpow2N/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \frac{1}{720} \cdot \color{blue}{\left(x \cdot x\right)} + \frac{1}{24}, \frac{1}{2}\right), 1\right)} \]
      11. associate-*r*N/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\left(\frac{1}{720} \cdot x\right) \cdot x} + \frac{1}{24}, \frac{1}{2}\right), 1\right)} \]
      12. *-commutativeN/A

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

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x, \frac{1}{720} \cdot x, \frac{1}{24}\right)}, \frac{1}{2}\right), 1\right)} \]
      14. *-commutativeN/A

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{720}}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      15. lower-*.f6497.0

        \[\leadsto \frac{\sinh x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.001388888888888889}, 0.041666666666666664\right), 0.5\right), 1\right)} \]
    7. Applied rewrites97.0%

      \[\leadsto \frac{\sinh x}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)}} \]
    8. Taylor expanded in x around 0

      \[\leadsto \frac{\color{blue}{x \cdot \left(1 + {x}^{2} \cdot \left(\frac{1}{6} + \frac{1}{120} \cdot {x}^{2}\right)\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
    9. Step-by-step derivation
      1. distribute-rgt-inN/A

        \[\leadsto \frac{\color{blue}{1 \cdot x + \left({x}^{2} \cdot \left(\frac{1}{6} + \frac{1}{120} \cdot {x}^{2}\right)\right) \cdot x}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      2. *-lft-identityN/A

        \[\leadsto \frac{\color{blue}{x} + \left({x}^{2} \cdot \left(\frac{1}{6} + \frac{1}{120} \cdot {x}^{2}\right)\right) \cdot x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      3. +-commutativeN/A

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

        \[\leadsto \frac{\color{blue}{\left(\left(\frac{1}{6} + \frac{1}{120} \cdot {x}^{2}\right) \cdot {x}^{2}\right)} \cdot x + x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      5. associate-*l*N/A

        \[\leadsto \frac{\color{blue}{\left(\frac{1}{6} + \frac{1}{120} \cdot {x}^{2}\right) \cdot \left({x}^{2} \cdot x\right)} + x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      6. unpow2N/A

        \[\leadsto \frac{\left(\frac{1}{6} + \frac{1}{120} \cdot {x}^{2}\right) \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot x\right) + x}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      7. unpow3N/A

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

        \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\frac{1}{6} + \frac{1}{120} \cdot {x}^{2}, {x}^{3}, x\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      9. +-commutativeN/A

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\frac{1}{120} \cdot {x}^{2} + \frac{1}{6}}, {x}^{3}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      10. *-commutativeN/A

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

        \[\leadsto \frac{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left({x}^{2}, \frac{1}{120}, \frac{1}{6}\right)}, {x}^{3}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      12. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{120}, \frac{1}{6}\right), {x}^{3}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      13. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{120}, \frac{1}{6}\right), {x}^{3}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      14. cube-multN/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{120}, \frac{1}{6}\right), \color{blue}{x \cdot \left(x \cdot x\right)}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      15. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{120}, \frac{1}{6}\right), x \cdot \color{blue}{{x}^{2}}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      16. lower-*.f64N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{120}, \frac{1}{6}\right), \color{blue}{x \cdot {x}^{2}}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      17. unpow2N/A

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \frac{1}{120}, \frac{1}{6}\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \frac{1}{720}, \frac{1}{24}\right), \frac{1}{2}\right), 1\right)} \]
      18. lower-*.f6497.2

        \[\leadsto \frac{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.008333333333333333, 0.16666666666666666\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right)}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \]
    10. Applied rewrites97.2%

      \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, 0.008333333333333333, 0.16666666666666666\right), x \cdot \left(x \cdot x\right), x\right)}}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.001388888888888889, 0.041666666666666664\right), 0.5\right), 1\right)} \]
    11. Add Preprocessing

    Alternative 5: 97.1% accurate, 15.1× speedup?

    \[\begin{array}{l} \\ \mathsf{fma}\left(x \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot 0.13333333333333333, -0.3333333333333333\right)\right), x, x\right) \end{array} \]
    (FPCore (x)
     :precision binary64
     (fma (* x (* x (fma x (* x 0.13333333333333333) -0.3333333333333333))) x x))
    double code(double x) {
    	return fma((x * (x * fma(x, (x * 0.13333333333333333), -0.3333333333333333))), x, x);
    }
    
    function code(x)
    	return fma(Float64(x * Float64(x * fma(x, Float64(x * 0.13333333333333333), -0.3333333333333333))), x, x)
    end
    
    code[x_] := N[(N[(x * N[(x * N[(x * N[(x * 0.13333333333333333), $MachinePrecision] + -0.3333333333333333), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * x + x), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \mathsf{fma}\left(x \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot 0.13333333333333333, -0.3333333333333333\right)\right), x, x\right)
    \end{array}
    
    Derivation
    1. Initial program 10.5%

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

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

        \[\leadsto x \cdot \color{blue}{\left({x}^{2} \cdot \left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}\right) + 1\right)} \]
      2. distribute-rgt-inN/A

        \[\leadsto \color{blue}{\left({x}^{2} \cdot \left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}\right)\right) \cdot x + 1 \cdot x} \]
      3. *-lft-identityN/A

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

        \[\leadsto \color{blue}{x \cdot \left({x}^{2} \cdot \left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}\right)\right)} + x \]
      5. associate-*r*N/A

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

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

        \[\leadsto \color{blue}{\mathsf{fma}\left(\frac{2}{15} \cdot {x}^{2} - \frac{1}{3}, x \cdot {x}^{2}, x\right)} \]
      8. sub-negN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\frac{2}{15} \cdot {x}^{2} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right)}, x \cdot {x}^{2}, x\right) \]
      9. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\frac{2}{15} \cdot \color{blue}{\left(x \cdot x\right)} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
      10. associate-*r*N/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{\left(\frac{2}{15} \cdot x\right) \cdot x} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
      11. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\color{blue}{x \cdot \left(\frac{2}{15} \cdot x\right)} + \left(\mathsf{neg}\left(\frac{1}{3}\right)\right), x \cdot {x}^{2}, x\right) \]
      12. metadata-evalN/A

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

        \[\leadsto \mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x, \frac{2}{15} \cdot x, \frac{-1}{3}\right)}, x \cdot {x}^{2}, x\right) \]
      14. *-commutativeN/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \color{blue}{x \cdot \frac{2}{15}}, \frac{-1}{3}\right), x \cdot {x}^{2}, x\right) \]
      15. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, \color{blue}{x \cdot \frac{2}{15}}, \frac{-1}{3}\right), x \cdot {x}^{2}, x\right) \]
      16. lower-*.f64N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot \frac{2}{15}, \frac{-1}{3}\right), \color{blue}{x \cdot {x}^{2}}, x\right) \]
      17. unpow2N/A

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot \frac{2}{15}, \frac{-1}{3}\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
      18. lower-*.f6497.0

        \[\leadsto \mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot 0.13333333333333333, -0.3333333333333333\right), x \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
    5. Applied rewrites97.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot 0.13333333333333333, -0.3333333333333333\right), x \cdot \left(x \cdot x\right), x\right)} \]
    6. Step-by-step derivation
      1. Applied rewrites97.0%

        \[\leadsto \mathsf{fma}\left(\left(x \cdot \mathsf{fma}\left(x, x \cdot 0.13333333333333333, -0.3333333333333333\right)\right) \cdot x, \color{blue}{x}, x\right) \]
      2. Final simplification97.0%

        \[\leadsto \mathsf{fma}\left(x \cdot \left(x \cdot \mathsf{fma}\left(x, x \cdot 0.13333333333333333, -0.3333333333333333\right)\right), x, x\right) \]
      3. Add Preprocessing

      Alternative 6: 96.7% accurate, 24.8× speedup?

      \[\begin{array}{l} \\ \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot -0.3333333333333333, x\right) \end{array} \]
      (FPCore (x) :precision binary64 (fma x (* (* x x) -0.3333333333333333) x))
      double code(double x) {
      	return fma(x, ((x * x) * -0.3333333333333333), x);
      }
      
      function code(x)
      	return fma(x, Float64(Float64(x * x) * -0.3333333333333333), x)
      end
      
      code[x_] := N[(x * N[(N[(x * x), $MachinePrecision] * -0.3333333333333333), $MachinePrecision] + x), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot -0.3333333333333333, x\right)
      \end{array}
      
      Derivation
      1. Initial program 10.5%

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

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

          \[\leadsto x \cdot \color{blue}{\left(\frac{-1}{3} \cdot {x}^{2} + 1\right)} \]
        2. distribute-lft-inN/A

          \[\leadsto \color{blue}{x \cdot \left(\frac{-1}{3} \cdot {x}^{2}\right) + x \cdot 1} \]
        3. *-rgt-identityN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{-1}{3} \cdot {x}^{2}, x\right)} \]
        5. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{\frac{-1}{3} \cdot {x}^{2}}, x\right) \]
        6. unpow2N/A

          \[\leadsto \mathsf{fma}\left(x, \frac{-1}{3} \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
        7. lower-*.f6496.5

          \[\leadsto \mathsf{fma}\left(x, -0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
      5. Applied rewrites96.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -0.3333333333333333 \cdot \left(x \cdot x\right), x\right)} \]
      6. Final simplification96.5%

        \[\leadsto \mathsf{fma}\left(x, \left(x \cdot x\right) \cdot -0.3333333333333333, x\right) \]
      7. Add Preprocessing

      Alternative 7: 4.9% accurate, 26.4× speedup?

      \[\begin{array}{l} \\ \left(x \cdot \left(x \cdot x\right)\right) \cdot -0.3333333333333333 \end{array} \]
      (FPCore (x) :precision binary64 (* (* x (* x x)) -0.3333333333333333))
      double code(double x) {
      	return (x * (x * x)) * -0.3333333333333333;
      }
      
      real(8) function code(x)
          real(8), intent (in) :: x
          code = (x * (x * x)) * (-0.3333333333333333d0)
      end function
      
      public static double code(double x) {
      	return (x * (x * x)) * -0.3333333333333333;
      }
      
      def code(x):
      	return (x * (x * x)) * -0.3333333333333333
      
      function code(x)
      	return Float64(Float64(x * Float64(x * x)) * -0.3333333333333333)
      end
      
      function tmp = code(x)
      	tmp = (x * (x * x)) * -0.3333333333333333;
      end
      
      code[x_] := N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \left(x \cdot \left(x \cdot x\right)\right) \cdot -0.3333333333333333
      \end{array}
      
      Derivation
      1. Initial program 10.5%

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

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

          \[\leadsto x \cdot \color{blue}{\left(\frac{-1}{3} \cdot {x}^{2} + 1\right)} \]
        2. distribute-lft-inN/A

          \[\leadsto \color{blue}{x \cdot \left(\frac{-1}{3} \cdot {x}^{2}\right) + x \cdot 1} \]
        3. *-rgt-identityN/A

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

          \[\leadsto \color{blue}{\mathsf{fma}\left(x, \frac{-1}{3} \cdot {x}^{2}, x\right)} \]
        5. lower-*.f64N/A

          \[\leadsto \mathsf{fma}\left(x, \color{blue}{\frac{-1}{3} \cdot {x}^{2}}, x\right) \]
        6. unpow2N/A

          \[\leadsto \mathsf{fma}\left(x, \frac{-1}{3} \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
        7. lower-*.f6496.5

          \[\leadsto \mathsf{fma}\left(x, -0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}, x\right) \]
      5. Applied rewrites96.5%

        \[\leadsto \color{blue}{\mathsf{fma}\left(x, -0.3333333333333333 \cdot \left(x \cdot x\right), x\right)} \]
      6. Taylor expanded in x around inf

        \[\leadsto \frac{-1}{3} \cdot \color{blue}{{x}^{3}} \]
      7. Step-by-step derivation
        1. Applied rewrites4.9%

          \[\leadsto -0.3333333333333333 \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \]
        2. Final simplification4.9%

          \[\leadsto \left(x \cdot \left(x \cdot x\right)\right) \cdot -0.3333333333333333 \]
        3. Add Preprocessing

        Reproduce

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