Hyperbolic secant

Percentage Accurate: 100.0% → 100.0%
Time: 9.4s
Alternatives: 19
Speedup: 1.9×

Specification

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

\\
\frac{2}{e^{x} + e^{-x}}
\end{array}

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

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

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

\\
\frac{2}{e^{x} + e^{-x}}
\end{array}

Alternative 1: 100.0% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \frac{1}{\cosh x} \end{array} \]
(FPCore (x) :precision binary64 (/ 1.0 (cosh x)))
double code(double x) {
	return 1.0 / cosh(x);
}
real(8) function code(x)
    real(8), intent (in) :: x
    code = 1.0d0 / cosh(x)
end function
public static double code(double x) {
	return 1.0 / Math.cosh(x);
}
def code(x):
	return 1.0 / math.cosh(x)
function code(x)
	return Float64(1.0 / cosh(x))
end
function tmp = code(x)
	tmp = 1.0 / cosh(x);
end
code[x_] := N[(1.0 / N[Cosh[x], $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\cosh x}
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \frac{2}{\color{blue}{2 \cdot \cosh x}} \]
    2. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{2}{2}}{\cosh x}} \]
    3. metadata-evalN/A

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

      \[\leadsto \color{blue}{\frac{1}{\cosh x}} \]
    5. lower-cosh.f64100.0

      \[\leadsto \frac{1}{\color{blue}{\cosh x}} \]
  4. Applied egg-rr100.0%

    \[\leadsto \color{blue}{\frac{1}{\cosh x}} \]
  5. Add Preprocessing

Alternative 2: 88.0% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{x} + e^{-x} \leq 4:\\
\;\;\;\;\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.20833333333333334, -0.5\right), 1\right)\\

\mathbf{else}:\\
\;\;\;\;\frac{360}{x \cdot \left(x \cdot \left(x \cdot x\right)\right)}\\


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

    1. Initial program 100.0%

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

        \[\leadsto \frac{2}{\color{blue}{2 \cdot \cosh x}} \]
      2. associate-/r*N/A

        \[\leadsto \color{blue}{\frac{\frac{2}{2}}{\cosh x}} \]
      3. metadata-evalN/A

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

        \[\leadsto \color{blue}{\frac{1}{\cosh x}} \]
      5. lower-cosh.f64100.0

        \[\leadsto \frac{1}{\color{blue}{\cosh x}} \]
    4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, \color{blue}{x \cdot 0.20833333333333334}, -0.5\right), 1\right) \]
    7. Simplified99.7%

      \[\leadsto \color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot 0.20833333333333334, -0.5\right), 1\right)} \]

    if 4 < (+.f64 (exp.f64 x) (exp.f64 (neg.f64 x)))

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
      7. associate-*l*N/A

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
      11. unpow2N/A

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
      16. lower-*.f6482.7

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
    5. Simplified82.7%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}} + \frac{1}{12}, 1\right), 2\right)} \]
      7. lower-fma.f6462.4

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
    8. Simplified62.4%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
    9. Taylor expanded in x around inf

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{\frac{1}{360} \cdot {x}^{3}}, 2\right)} \]
    10. Step-by-step derivation
      1. *-commutativeN/A

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

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

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

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

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{360}\right), 2\right)} \]
      10. lower-*.f6471.2

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot 0.002777777777777778\right), 2\right)} \]
    11. Simplified71.2%

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.002777777777777778\right)}, 2\right)} \]
    12. Taylor expanded in x around inf

      \[\leadsto \color{blue}{\frac{360}{{x}^{4}}} \]
    13. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{360}{{x}^{4}}} \]
      2. metadata-evalN/A

        \[\leadsto \frac{360}{{x}^{\color{blue}{\left(2 \cdot 2\right)}}} \]
      3. pow-sqrN/A

        \[\leadsto \frac{360}{\color{blue}{{x}^{2} \cdot {x}^{2}}} \]
      4. unpow2N/A

        \[\leadsto \frac{360}{\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}} \]
      5. associate-*l*N/A

        \[\leadsto \frac{360}{\color{blue}{x \cdot \left(x \cdot {x}^{2}\right)}} \]
      6. unpow2N/A

        \[\leadsto \frac{360}{x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
      7. cube-multN/A

        \[\leadsto \frac{360}{x \cdot \color{blue}{{x}^{3}}} \]
      8. lower-*.f64N/A

        \[\leadsto \frac{360}{\color{blue}{x \cdot {x}^{3}}} \]
      9. cube-multN/A

        \[\leadsto \frac{360}{x \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}} \]
      10. unpow2N/A

        \[\leadsto \frac{360}{x \cdot \left(x \cdot \color{blue}{{x}^{2}}\right)} \]
      11. lower-*.f64N/A

        \[\leadsto \frac{360}{x \cdot \color{blue}{\left(x \cdot {x}^{2}\right)}} \]
      12. unpow2N/A

        \[\leadsto \frac{360}{x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
      13. lower-*.f6471.2

        \[\leadsto \frac{360}{x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)} \]
    14. Simplified71.2%

      \[\leadsto \color{blue}{\frac{360}{x \cdot \left(x \cdot \left(x \cdot x\right)\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 3: 83.9% accurate, 0.9× speedup?

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

\\
\begin{array}{l}
\mathbf{if}\;e^{x} + e^{-x} \leq 2 \cdot 10^{+50}:\\
\;\;\;\;\frac{2}{\mathsf{fma}\left(x, x, 2\right)}\\

\mathbf{else}:\\
\;\;\;\;\frac{360}{x \cdot \left(x \cdot x\right)}\\


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

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{2}{\color{blue}{{x}^{2} + 2}} \]
      2. unpow2N/A

        \[\leadsto \frac{2}{\color{blue}{x \cdot x} + 2} \]
      3. lower-fma.f6498.2

        \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, x, 2\right)}} \]
    5. Simplified98.2%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, x, 2\right)}} \]

    if 2.0000000000000002e50 < (+.f64 (exp.f64 x) (exp.f64 (neg.f64 x)))

    1. Initial program 100.0%

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

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

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

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
      7. associate-*l*N/A

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
      11. unpow2N/A

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
      16. lower-*.f6483.8

        \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
    5. Simplified83.8%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
    6. Taylor expanded in x around 0

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

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

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

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

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

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

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}} + \frac{1}{12}, 1\right), 2\right)} \]
      7. lower-fma.f6463.3

        \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
    8. Simplified63.3%

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
    9. Taylor expanded in x around -inf

      \[\leadsto \color{blue}{\frac{360}{{x}^{3}}} \]
    10. Step-by-step derivation
      1. lower-/.f64N/A

        \[\leadsto \color{blue}{\frac{360}{{x}^{3}}} \]
      2. cube-multN/A

        \[\leadsto \frac{360}{\color{blue}{x \cdot \left(x \cdot x\right)}} \]
      3. unpow2N/A

        \[\leadsto \frac{360}{x \cdot \color{blue}{{x}^{2}}} \]
      4. lower-*.f64N/A

        \[\leadsto \frac{360}{\color{blue}{x \cdot {x}^{2}}} \]
      5. unpow2N/A

        \[\leadsto \frac{360}{x \cdot \color{blue}{\left(x \cdot x\right)}} \]
      6. lower-*.f6463.3

        \[\leadsto \frac{360}{x \cdot \color{blue}{\left(x \cdot x\right)}} \]
    11. Simplified63.3%

      \[\leadsto \color{blue}{\frac{360}{x \cdot \left(x \cdot x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Add Preprocessing

Alternative 4: 95.4% accurate, 3.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(x \cdot x\right)\\ \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.002777777777777778, t\_0 \cdot t\_0, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* x (* x x))))
   (/
    2.0
    (fma
     (fma
      (* x x)
      (fma 0.002777777777777778 (* t_0 t_0) 0.08333333333333333)
      1.0)
     (* x x)
     2.0))))
double code(double x) {
	double t_0 = x * (x * x);
	return 2.0 / fma(fma((x * x), fma(0.002777777777777778, (t_0 * t_0), 0.08333333333333333), 1.0), (x * x), 2.0);
}
function code(x)
	t_0 = Float64(x * Float64(x * x))
	return Float64(2.0 / fma(fma(Float64(x * x), fma(0.002777777777777778, Float64(t_0 * t_0), 0.08333333333333333), 1.0), Float64(x * x), 2.0))
end
code[x_] := Block[{t$95$0 = N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]}, N[(2.0 / N[(N[(N[(x * x), $MachinePrecision] * N[(0.002777777777777778 * N[(t$95$0 * t$95$0), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] + 1.0), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot x\right)\\
\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.002777777777777778, t\_0 \cdot t\_0, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left({x}^{4} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right)}, 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left({x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right), 1\right), 2\right)} \]
    2. pow-sqrN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\left(\frac{1}{12} \cdot \frac{1}{{x}^{4}}\right) \cdot \left({x}^{2} \cdot {x}^{2}\right)}\right), 1\right), 2\right)} \]
    5. associate-*r*N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot \left({x}^{2} \cdot {x}^{2}\right)\right)}\right), 1\right), 2\right)} \]
    6. pow-sqrN/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot {x}^{\color{blue}{4}}\right)\right), 1\right), 2\right)} \]
    8. lft-mult-inverseN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    11. associate-*l*N/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    13. cube-multN/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \frac{1}{360} \cdot {x}^{3}, \frac{1}{12}\right)}, 1\right), 2\right)} \]
  8. Simplified92.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  9. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{2}{\color{blue}{\left(x \cdot x\right)} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}\right)} + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    5. lift-fma.f64N/A

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

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}, \frac{1}{12}\right)\right)} + 1\right) + 2} \]
    7. lift-fma.f64N/A

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

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}, \frac{1}{12}\right), 1\right) \cdot \left(x \cdot x\right)} + 2} \]
    9. lower-fma.f6492.1

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}} \]
  10. Applied egg-rr92.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot x\right) \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}} \]
  11. Taylor expanded in x around 0

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{360}, {x}^{\color{blue}{\left(2 \cdot 3\right)}}, \frac{1}{12}\right), 1\right), x \cdot x, 2\right)} \]
    8. pow-sqrN/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{360}, \color{blue}{{x}^{3} \cdot {x}^{3}}, \frac{1}{12}\right), 1\right), x \cdot x, 2\right)} \]
    10. cube-multN/A

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{360}, \left(x \cdot \left(x \cdot x\right)\right) \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}, \frac{1}{12}\right), 1\right), x \cdot x, 2\right)} \]
    16. unpow2N/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\frac{1}{360}, \left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right), \frac{1}{12}\right), 1\right), x \cdot x, 2\right)} \]
    19. lower-*.f6493.2

      \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.002777777777777778, \left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right), 0.08333333333333333\right), 1\right), x \cdot x, 2\right)} \]
  13. Simplified93.2%

    \[\leadsto \frac{2}{\mathsf{fma}\left(\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(0.002777777777777778, \left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right), 0.08333333333333333\right), 1\right)}, x \cdot x, 2\right)} \]
  14. Add Preprocessing

Alternative 5: 95.0% accurate, 3.6× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(-x\right)\right)\right)\right), 2\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/ 2.0 (fma (* x x) (* (* x (* x (* x x))) (* x (* x (* x (- x))))) 2.0)))
double code(double x) {
	return 2.0 / fma((x * x), ((x * (x * (x * x))) * (x * (x * (x * -x)))), 2.0);
}
function code(x)
	return Float64(2.0 / fma(Float64(x * x), Float64(Float64(x * Float64(x * Float64(x * x))) * Float64(x * Float64(x * Float64(x * Float64(-x))))), 2.0))
end
code[x_] := N[(2.0 / N[(N[(x * x), $MachinePrecision] * N[(N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * N[(x * N[(x * (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(-x\right)\right)\right)\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

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

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-1 \cdot x}, \frac{1}{12}\right), 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{\mathsf{neg}\left(x\right)}, \frac{1}{12}\right), 1\right), 2\right)} \]
    2. lower-neg.f6490.9

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  8. Simplified90.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  9. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{-1 \cdot {x}^{8}}, 2\right)} \]
  10. Step-by-step derivation
    1. mul-1-negN/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{neg}\left({x}^{\color{blue}{\left(2 \cdot 4\right)}}\right), 2\right)} \]
    3. pow-sqrN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{neg}\left(\color{blue}{{x}^{4} \cdot {x}^{4}}\right), 2\right)} \]
    4. distribute-rgt-neg-inN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \left(\mathsf{neg}\left({x}^{4}\right)\right)}, 2\right)} \]
    5. metadata-evalN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, {x}^{4} \cdot \left(\mathsf{neg}\left({x}^{\color{blue}{\left(2 \cdot 2\right)}}\right)\right), 2\right)} \]
    6. pow-sqrN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, {x}^{4} \cdot \left(\mathsf{neg}\left(\color{blue}{{x}^{2} \cdot {x}^{2}}\right)\right), 2\right)} \]
    7. distribute-rgt-neg-outN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{4} \cdot \left({x}^{2} \cdot \left(-1 \cdot {x}^{2}\right)\right)}, 2\right)} \]
    10. metadata-evalN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \left(x \cdot \color{blue}{\left(-1 \cdot \left({x}^{2} \cdot x\right)\right)}\right), 2\right)} \]
  11. Simplified92.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(-x\right)\right)\right)\right)}, 2\right)} \]
  12. Add Preprocessing

Alternative 6: 94.4% accurate, 3.7× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(x \cdot x\right)\\ \frac{2}{\mathsf{fma}\left(0.08333333333333333 \cdot \left(x \cdot \left(t\_0 \cdot t\_0\right)\right), x \cdot x, 2\right)} \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* x (* x x))))
   (/ 2.0 (fma (* 0.08333333333333333 (* x (* t_0 t_0))) (* x x) 2.0))))
double code(double x) {
	double t_0 = x * (x * x);
	return 2.0 / fma((0.08333333333333333 * (x * (t_0 * t_0))), (x * x), 2.0);
}
function code(x)
	t_0 = Float64(x * Float64(x * x))
	return Float64(2.0 / fma(Float64(0.08333333333333333 * Float64(x * Float64(t_0 * t_0))), Float64(x * x), 2.0))
end
code[x_] := Block[{t$95$0 = N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]}, N[(2.0 / N[(N[(0.08333333333333333 * N[(x * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot x\right)\\
\frac{2}{\mathsf{fma}\left(0.08333333333333333 \cdot \left(x \cdot \left(t\_0 \cdot t\_0\right)\right), x \cdot x, 2\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left({x}^{4} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right)}, 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left({x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right), 1\right), 2\right)} \]
    2. pow-sqrN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\left(\frac{1}{12} \cdot \frac{1}{{x}^{4}}\right) \cdot \left({x}^{2} \cdot {x}^{2}\right)}\right), 1\right), 2\right)} \]
    5. associate-*r*N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot \left({x}^{2} \cdot {x}^{2}\right)\right)}\right), 1\right), 2\right)} \]
    6. pow-sqrN/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot {x}^{\color{blue}{4}}\right)\right), 1\right), 2\right)} \]
    8. lft-mult-inverseN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    11. associate-*l*N/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    13. cube-multN/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \frac{1}{360} \cdot {x}^{3}, \frac{1}{12}\right)}, 1\right), 2\right)} \]
  8. Simplified92.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  9. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{2}{\color{blue}{\left(x \cdot x\right)} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}\right)} + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    5. lift-fma.f64N/A

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

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}, \frac{1}{12}\right)\right)} + 1\right) + 2} \]
    7. lift-fma.f64N/A

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

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}, \frac{1}{12}\right), 1\right) \cdot \left(x \cdot x\right)} + 2} \]
    9. lower-fma.f6492.1

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}} \]
  10. Applied egg-rr92.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot x\right) \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}} \]
  11. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(\color{blue}{\frac{1}{12} \cdot {x}^{7}}, x \cdot x, 2\right)} \]
  12. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(\left(x \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \cdot \frac{1}{12}, x \cdot x, 2\right)} \]
    19. lower-*.f6492.2

      \[\leadsto \frac{2}{\mathsf{fma}\left(\left(x \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right)\right) \cdot 0.08333333333333333, x \cdot x, 2\right)} \]
  13. Simplified92.2%

    \[\leadsto \frac{2}{\mathsf{fma}\left(\color{blue}{\left(x \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right) \cdot 0.08333333333333333}, x \cdot x, 2\right)} \]
  14. Final simplification92.2%

    \[\leadsto \frac{2}{\mathsf{fma}\left(0.08333333333333333 \cdot \left(x \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \left(x \cdot \left(x \cdot x\right)\right)\right)\right), x \cdot x, 2\right)} \]
  15. Add Preprocessing

Alternative 7: 94.0% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 9.259259259259259 \cdot 10^{-5}, 0.002777777777777778\right), 0.08333333333333333\right), 1\right), 2\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/
  2.0
  (fma
   (* x x)
   (fma
    (* x x)
    (fma
     (* x x)
     (fma (* x x) 9.259259259259259e-5 0.002777777777777778)
     0.08333333333333333)
    1.0)
   2.0)))
double code(double x) {
	return 2.0 / fma((x * x), fma((x * x), fma((x * x), fma((x * x), 9.259259259259259e-5, 0.002777777777777778), 0.08333333333333333), 1.0), 2.0);
}
function code(x)
	return Float64(2.0 / fma(Float64(x * x), fma(Float64(x * x), fma(Float64(x * x), fma(Float64(x * x), 9.259259259259259e-5, 0.002777777777777778), 0.08333333333333333), 1.0), 2.0))
end
code[x_] := N[(2.0 / N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * N[(N[(x * x), $MachinePrecision] * 9.259259259259259e-5 + 0.002777777777777778), $MachinePrecision] + 0.08333333333333333), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 9.259259259259259 \cdot 10^{-5}, 0.002777777777777778\right), 0.08333333333333333\right), 1\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \color{blue}{\left(x \cdot \frac{1}{360}\right)} + \frac{1}{12}\right), 1\right), 2\right)} \]
    2. flip-+N/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\frac{\left(x \cdot \left(x \cdot \frac{1}{360}\right)\right) \cdot \left(x \cdot \left(x \cdot \frac{1}{360}\right)\right) - \frac{1}{12} \cdot \frac{1}{12}}{x \cdot \left(x \cdot \frac{1}{360}\right) - \frac{1}{12}}}, 1\right), 2\right)} \]
  7. Applied egg-rr66.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\frac{\mathsf{fma}\left(x \cdot \left(x \cdot \left(x \cdot x\right)\right), 7.71604938271605 \cdot 10^{-6}, -0.006944444444444444\right)}{\mathsf{fma}\left(x, x \cdot 0.002777777777777778, -0.08333333333333333\right)}}, 1\right), 2\right)} \]
  8. Taylor expanded in x around 0

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{10800}, \frac{1}{360}\right), \frac{1}{12}\right), 1\right), 2\right)} \]
    13. lower-*.f6492.2

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, 9.259259259259259 \cdot 10^{-5}, 0.002777777777777778\right), 0.08333333333333333\right), 1\right), 2\right)} \]
  10. Simplified92.2%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 9.259259259259259 \cdot 10^{-5}, 0.002777777777777778\right), 0.08333333333333333\right), 1\right)}, 2\right)} \]
  11. Add Preprocessing

Alternative 8: 94.0% accurate, 3.9× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, 0.002777777777777778 \cdot \left(x \cdot \left(x \cdot x\right)\right), 0.08333333333333333\right), 1\right), 2\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/
  2.0
  (fma
   (* x x)
   (fma
    x
    (* x (fma x (* 0.002777777777777778 (* x (* x x))) 0.08333333333333333))
    1.0)
   2.0)))
double code(double x) {
	return 2.0 / fma((x * x), fma(x, (x * fma(x, (0.002777777777777778 * (x * (x * x))), 0.08333333333333333)), 1.0), 2.0);
}
function code(x)
	return Float64(2.0 / fma(Float64(x * x), fma(x, Float64(x * fma(x, Float64(0.002777777777777778 * Float64(x * Float64(x * x))), 0.08333333333333333)), 1.0), 2.0))
end
code[x_] := N[(2.0 / N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * N[(x * N[(0.002777777777777778 * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 0.08333333333333333), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, 0.002777777777777778 \cdot \left(x \cdot \left(x \cdot x\right)\right), 0.08333333333333333\right), 1\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left({x}^{4} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right)}, 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left({x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right), 1\right), 2\right)} \]
    2. pow-sqrN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\left(\frac{1}{12} \cdot \frac{1}{{x}^{4}}\right) \cdot \left({x}^{2} \cdot {x}^{2}\right)}\right), 1\right), 2\right)} \]
    5. associate-*r*N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot \left({x}^{2} \cdot {x}^{2}\right)\right)}\right), 1\right), 2\right)} \]
    6. pow-sqrN/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot {x}^{\color{blue}{4}}\right)\right), 1\right), 2\right)} \]
    8. lft-mult-inverseN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    11. associate-*l*N/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    13. cube-multN/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \frac{1}{360} \cdot {x}^{3}, \frac{1}{12}\right)}, 1\right), 2\right)} \]
  8. Simplified92.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  9. Final simplification92.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, 0.002777777777777778 \cdot \left(x \cdot \left(x \cdot x\right)\right), 0.08333333333333333\right), 1\right), 2\right)} \]
  10. Add Preprocessing

Alternative 9: 94.0% accurate, 4.3× speedup?

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

\\
\frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, x \cdot x, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left({x}^{4} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right)}, 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left({x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right), 1\right), 2\right)} \]
    2. pow-sqrN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\left(\frac{1}{12} \cdot \frac{1}{{x}^{4}}\right) \cdot \left({x}^{2} \cdot {x}^{2}\right)}\right), 1\right), 2\right)} \]
    5. associate-*r*N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot \left({x}^{2} \cdot {x}^{2}\right)\right)}\right), 1\right), 2\right)} \]
    6. pow-sqrN/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot {x}^{\color{blue}{4}}\right)\right), 1\right), 2\right)} \]
    8. lft-mult-inverseN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    11. associate-*l*N/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    13. cube-multN/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \frac{1}{360} \cdot {x}^{3}, \frac{1}{12}\right)}, 1\right), 2\right)} \]
  8. Simplified92.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  9. Step-by-step derivation
    1. lift-*.f64N/A

      \[\leadsto \frac{2}{\color{blue}{\left(x \cdot x\right)} \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    2. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\left(x \cdot \color{blue}{\left(x \cdot x\right)}\right) \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    3. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \left(\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot \frac{1}{360}\right) + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    4. lift-*.f64N/A

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot \color{blue}{\left(\left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}\right)} + \frac{1}{12}\right)\right) + 1\right) + 2} \]
    5. lift-fma.f64N/A

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

      \[\leadsto \frac{2}{\left(x \cdot x\right) \cdot \left(x \cdot \color{blue}{\left(x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}, \frac{1}{12}\right)\right)} + 1\right) + 2} \]
    7. lift-fma.f64N/A

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

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{360}, \frac{1}{12}\right), 1\right) \cdot \left(x \cdot x\right)} + 2} \]
    9. lower-fma.f6492.1

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}} \]
  10. Applied egg-rr92.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \left(x \cdot x\right) \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)}} \]
  11. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{{x}^{2}}, \frac{1}{12}\right), 1\right), x \cdot x, 2\right)} \]
  12. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot x}, \frac{1}{12}\right), 1\right), x \cdot x, 2\right)} \]
    2. lower-*.f6492.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot x}, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)} \]
  13. Simplified92.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, \color{blue}{x \cdot x}, 0.08333333333333333\right), 1\right), x \cdot x, 2\right)} \]
  14. Add Preprocessing

Alternative 10: 93.1% accurate, 4.3× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot \left(x \cdot x\right), 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/
  2.0
  (fma
   (* x x)
   (fma
    x
    (* x (fma (* x (* x x)) 0.002777777777777778 0.08333333333333333))
    1.0)
   2.0)))
double code(double x) {
	return 2.0 / fma((x * x), fma(x, (x * fma((x * (x * x)), 0.002777777777777778, 0.08333333333333333)), 1.0), 2.0);
}
function code(x)
	return Float64(2.0 / fma(Float64(x * x), fma(x, Float64(x * fma(Float64(x * Float64(x * x)), 0.002777777777777778, 0.08333333333333333)), 1.0), 2.0))
end
code[x_] := N[(2.0 / N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * N[(N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] * 0.002777777777777778 + 0.08333333333333333), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot \left(x \cdot x\right), 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around 0

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left({x}^{3}, \frac{1}{360}, \frac{1}{12}\right)}, 1\right), 2\right)} \]
    4. cube-multN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(\color{blue}{x \cdot \left(x \cdot x\right)}, \frac{1}{360}, \frac{1}{12}\right), 1\right), 2\right)} \]
    5. unpow2N/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot \color{blue}{\left(x \cdot x\right)}, \frac{1}{360}, \frac{1}{12}\right), 1\right), 2\right)} \]
    8. lower-*.f6492.0

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x \cdot \color{blue}{\left(x \cdot x\right)}, 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)} \]
  8. Simplified92.0%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x \cdot \left(x \cdot x\right), 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  9. Add Preprocessing

Alternative 11: 93.1% accurate, 4.8× speedup?

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

\\
\frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot x, 0.08333333333333333\right), 1\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left({x}^{4} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right)}, 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. metadata-evalN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left({x}^{\color{blue}{\left(2 \cdot 2\right)}} \cdot \left(\frac{1}{360} + \frac{1}{12} \cdot \frac{1}{{x}^{4}}\right)\right), 1\right), 2\right)} \]
    2. pow-sqrN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\left(\frac{1}{12} \cdot \frac{1}{{x}^{4}}\right) \cdot \left({x}^{2} \cdot {x}^{2}\right)}\right), 1\right), 2\right)} \]
    5. associate-*r*N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \color{blue}{\frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot \left({x}^{2} \cdot {x}^{2}\right)\right)}\right), 1\right), 2\right)} \]
    6. pow-sqrN/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left({x}^{2} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12} \cdot \left(\frac{1}{{x}^{4}} \cdot {x}^{\color{blue}{4}}\right)\right), 1\right), 2\right)} \]
    8. lft-mult-inverseN/A

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(\color{blue}{\left(x \cdot x\right)} \cdot {x}^{2}\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    11. associate-*l*N/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(\left(x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right)\right) \cdot \frac{1}{360} + \frac{1}{12}\right), 1\right), 2\right)} \]
    13. cube-multN/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \frac{1}{360} \cdot {x}^{3}, \frac{1}{12}\right)}, 1\right), 2\right)} \]
  8. Simplified92.1%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\mathsf{fma}\left(x, \left(x \cdot \left(x \cdot x\right)\right) \cdot 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  9. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{{x}^{2}}, \frac{1}{12}\right), 1\right), 2\right)} \]
  10. Step-by-step derivation
    1. unpow2N/A

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  11. Simplified92.0%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  12. Add Preprocessing

Alternative 12: 93.0% accurate, 4.9× speedup?

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

\\
\frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \left(x \cdot x\right)\right), 1\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

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

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-1 \cdot x}, \frac{1}{12}\right), 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{\mathsf{neg}\left(x\right)}, \frac{1}{12}\right), 1\right), 2\right)} \]
    2. lower-neg.f6490.9

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  8. Simplified90.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  9. Taylor expanded in x around -inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{{x}^{3}}, 1\right), 2\right)} \]
  10. Step-by-step derivation
    1. cube-multN/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \left(x \cdot \color{blue}{\left(x \cdot x\right)}\right), 1\right), 2\right)} \]
  11. Simplified91.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(x \cdot \left(x \cdot x\right)\right)}, 1\right), 2\right)} \]
  12. Add Preprocessing

Alternative 13: 92.1% accurate, 5.2× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, -x, 0.08333333333333333\right), 1\right), 2\right)} \end{array} \]
(FPCore (x)
 :precision binary64
 (/ 2.0 (fma (* x x) (fma x (* x (fma x (- x) 0.08333333333333333)) 1.0) 2.0)))
double code(double x) {
	return 2.0 / fma((x * x), fma(x, (x * fma(x, -x, 0.08333333333333333)), 1.0), 2.0);
}
function code(x)
	return Float64(2.0 / fma(Float64(x * x), fma(x, Float64(x * fma(x, Float64(-x), 0.08333333333333333)), 1.0), 2.0))
end
code[x_] := N[(2.0 / N[(N[(x * x), $MachinePrecision] * N[(x * N[(x * N[(x * (-x) + 0.08333333333333333), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, -x, 0.08333333333333333\right), 1\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

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

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-1 \cdot x}, \frac{1}{12}\right), 1\right), 2\right)} \]
  7. Step-by-step derivation
    1. mul-1-negN/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{\mathsf{neg}\left(x\right)}, \frac{1}{12}\right), 1\right), 2\right)} \]
    2. lower-neg.f6490.9

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  8. Simplified90.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{-x}, 0.08333333333333333\right), 1\right), 2\right)} \]
  9. Add Preprocessing

Alternative 14: 87.9% accurate, 6.4× speedup?

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

\\
\frac{1}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x \cdot x, 0.041666666666666664, 0.5\right), 1\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \frac{2}{\color{blue}{2 \cdot \cosh x}} \]
    2. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{2}{2}}{\cosh x}} \]
    3. metadata-evalN/A

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

      \[\leadsto \color{blue}{\frac{1}{\cosh x}} \]
    5. lower-cosh.f64100.0

      \[\leadsto \frac{1}{\color{blue}{\cosh x}} \]
  4. Applied egg-rr100.0%

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{1}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(\color{blue}{x \cdot x}, \frac{1}{24}, \frac{1}{2}\right), 1\right)} \]
    9. lower-*.f6485.1

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

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

Alternative 15: 87.6% accurate, 7.8× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x, x \cdot \left(x \cdot x\right), 2\right)} \end{array} \]
(FPCore (x) :precision binary64 (/ 2.0 (fma x (* x (* x x)) 2.0)))
double code(double x) {
	return 2.0 / fma(x, (x * (x * x)), 2.0);
}
function code(x)
	return Float64(2.0 / fma(x, Float64(x * Float64(x * x)), 2.0))
end
code[x_] := N[(2.0 / N[(x * N[(x * N[(x * x), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x, x \cdot \left(x \cdot x\right), 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around 0

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}} + \frac{1}{12}, 1\right), 2\right)} \]
    7. lower-fma.f6480.0

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  8. Simplified80.0%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  9. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{\frac{1}{360} \cdot {x}^{3}}, 2\right)} \]
  10. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{360}\right), 2\right)} \]
    10. lower-*.f6484.9

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot 0.002777777777777778\right), 2\right)} \]
  11. Simplified84.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.002777777777777778\right)}, 2\right)} \]
  12. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \color{blue}{{x}^{2}}, 2\right)} \]
  13. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \color{blue}{\left(x \cdot x\right)}, 2\right)} \]
    2. lower-*.f6484.9

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \color{blue}{\left(x \cdot x\right)}, 2\right)} \]
  14. Simplified84.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \color{blue}{\left(x \cdot x\right)}, 2\right)} \]
  15. Add Preprocessing

Alternative 16: 83.6% accurate, 9.4× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x, x \cdot x, 2\right)} \end{array} \]
(FPCore (x) :precision binary64 (/ 2.0 (fma x (* x x) 2.0)))
double code(double x) {
	return 2.0 / fma(x, (x * x), 2.0);
}
function code(x)
	return Float64(2.0 / fma(x, Float64(x * x), 2.0))
end
code[x_] := N[(2.0 / N[(x * N[(x * x), $MachinePrecision] + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x, x \cdot x, 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \color{blue}{\left(x \cdot x\right)} \cdot \left(\frac{1}{12} + \frac{1}{360} \cdot {x}^{2}\right) + 1, 2\right)} \]
    7. associate-*l*N/A

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \color{blue}{\left(\frac{1}{360} \cdot {x}^{2} + \frac{1}{12}\right)}, 1\right), 2\right)} \]
    11. unpow2N/A

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}}, \frac{1}{12}\right), 1\right), 2\right)} \]
    16. lower-*.f6491.1

      \[\leadsto \frac{2}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, \color{blue}{x \cdot 0.002777777777777778}, 0.08333333333333333\right), 1\right), 2\right)} \]
  5. Simplified91.1%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x \cdot x, \mathsf{fma}\left(x, x \cdot \mathsf{fma}\left(x, x \cdot 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  6. Taylor expanded in x around 0

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{x \cdot \frac{1}{360}} + \frac{1}{12}, 1\right), 2\right)} \]
    7. lower-fma.f6480.0

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \color{blue}{\mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right)}, 1\right), 2\right)} \]
  8. Simplified80.0%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, \mathsf{fma}\left(x, \mathsf{fma}\left(x, 0.002777777777777778, 0.08333333333333333\right), 1\right), 2\right)}} \]
  9. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{\frac{1}{360} \cdot {x}^{3}}, 2\right)} \]
  10. Step-by-step derivation
    1. *-commutativeN/A

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

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

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

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

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

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

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

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

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot \frac{1}{360}\right), 2\right)} \]
    10. lower-*.f6484.9

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, x \cdot \left(\color{blue}{\left(x \cdot x\right)} \cdot 0.002777777777777778\right), 2\right)} \]
  11. Simplified84.9%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.002777777777777778\right)}, 2\right)} \]
  12. Taylor expanded in x around inf

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{{x}^{2}}, 2\right)} \]
  13. Step-by-step derivation
    1. unpow2N/A

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{x \cdot x}, 2\right)} \]
    2. lower-*.f6480.4

      \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{x \cdot x}, 2\right)} \]
  14. Simplified80.4%

    \[\leadsto \frac{2}{\mathsf{fma}\left(x, \color{blue}{x \cdot x}, 2\right)} \]
  15. Add Preprocessing

Alternative 17: 76.6% accurate, 12.1× speedup?

\[\begin{array}{l} \\ \frac{2}{\mathsf{fma}\left(x, x, 2\right)} \end{array} \]
(FPCore (x) :precision binary64 (/ 2.0 (fma x x 2.0)))
double code(double x) {
	return 2.0 / fma(x, x, 2.0);
}
function code(x)
	return Float64(2.0 / fma(x, x, 2.0))
end
code[x_] := N[(2.0 / N[(x * x + 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{2}{\mathsf{fma}\left(x, x, 2\right)}
\end{array}
Derivation
  1. Initial program 100.0%

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

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

      \[\leadsto \frac{2}{\color{blue}{{x}^{2} + 2}} \]
    2. unpow2N/A

      \[\leadsto \frac{2}{\color{blue}{x \cdot x} + 2} \]
    3. lower-fma.f6474.9

      \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, x, 2\right)}} \]
  5. Simplified74.9%

    \[\leadsto \frac{2}{\color{blue}{\mathsf{fma}\left(x, x, 2\right)}} \]
  6. Add Preprocessing

Alternative 18: 52.1% accurate, 217.0× speedup?

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

\\
1
\end{array}
Derivation
  1. Initial program 100.0%

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

      \[\leadsto \frac{2}{\color{blue}{2 \cdot \cosh x}} \]
    2. associate-/r*N/A

      \[\leadsto \color{blue}{\frac{\frac{2}{2}}{\cosh x}} \]
    3. metadata-evalN/A

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

      \[\leadsto \color{blue}{\frac{1}{\cosh x}} \]
    5. lower-cosh.f64100.0

      \[\leadsto \frac{1}{\color{blue}{\cosh x}} \]
  4. Applied egg-rr100.0%

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

    \[\leadsto \color{blue}{1} \]
  6. Step-by-step derivation
    1. Simplified50.1%

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

    Alternative 19: 11.1% accurate, 217.0× speedup?

    \[\begin{array}{l} \\ 0.5 \end{array} \]
    (FPCore (x) :precision binary64 0.5)
    double code(double x) {
    	return 0.5;
    }
    
    real(8) function code(x)
        real(8), intent (in) :: x
        code = 0.5d0
    end function
    
    public static double code(double x) {
    	return 0.5;
    }
    
    def code(x):
    	return 0.5
    
    function code(x)
    	return 0.5
    end
    
    function tmp = code(x)
    	tmp = 0.5;
    end
    
    code[x_] := 0.5
    
    \begin{array}{l}
    
    \\
    0.5
    \end{array}
    
    Derivation
    1. Initial program 100.0%

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

      \[\leadsto \color{blue}{\frac{1}{2}} \]
    4. Step-by-step derivation
      1. Simplified10.8%

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

      Reproduce

      ?
      herbie shell --seed 2024214 
      (FPCore (x)
        :name "Hyperbolic secant"
        :precision binary64
        (/ 2.0 (+ (exp x) (exp (- x)))))