Hyperbolic sine

Percentage Accurate: 54.3% → 99.7%
Time: 8.6s
Alternatives: 11
Speedup: 18.7×

Specification

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

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

Sampling outcomes in binary64 precision:

Local Percentage Accuracy vs ?

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

Accuracy vs Speed?

Herbie found 11 alternatives:

AlternativeAccuracySpeedup
The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Initial Program: 54.3% accurate, 1.0× speedup?

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

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

Alternative 1: 99.7% accurate, 0.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := e^{x} - e^{-x}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 0.001\right):\\ \;\;\;\;\frac{t_0}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (- (exp x) (exp (- x)))))
   (if (or (<= t_0 (- INFINITY)) (not (<= t_0 0.001)))
     (/ t_0 2.0)
     (/
      (+
       (* 0.016666666666666666 (pow x 5.0))
       (* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
      2.0))))
double code(double x) {
	double t_0 = exp(x) - exp(-x);
	double tmp;
	if ((t_0 <= -((double) INFINITY)) || !(t_0 <= 0.001)) {
		tmp = t_0 / 2.0;
	} else {
		tmp = ((0.016666666666666666 * pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
	}
	return tmp;
}
public static double code(double x) {
	double t_0 = Math.exp(x) - Math.exp(-x);
	double tmp;
	if ((t_0 <= -Double.POSITIVE_INFINITY) || !(t_0 <= 0.001)) {
		tmp = t_0 / 2.0;
	} else {
		tmp = ((0.016666666666666666 * Math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
	}
	return tmp;
}
def code(x):
	t_0 = math.exp(x) - math.exp(-x)
	tmp = 0
	if (t_0 <= -math.inf) or not (t_0 <= 0.001):
		tmp = t_0 / 2.0
	else:
		tmp = ((0.016666666666666666 * math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0
	return tmp
function code(x)
	t_0 = Float64(exp(x) - exp(Float64(-x)))
	tmp = 0.0
	if ((t_0 <= Float64(-Inf)) || !(t_0 <= 0.001))
		tmp = Float64(t_0 / 2.0);
	else
		tmp = Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x))))) / 2.0);
	end
	return tmp
end
function tmp_2 = code(x)
	t_0 = exp(x) - exp(-x);
	tmp = 0.0;
	if ((t_0 <= -Inf) || ~((t_0 <= 0.001)))
		tmp = t_0 / 2.0;
	else
		tmp = ((0.016666666666666666 * (x ^ 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
	end
	tmp_2 = tmp;
end
code[x_] := Block[{t$95$0 = N[(N[Exp[x], $MachinePrecision] - N[Exp[(-x)], $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$0, (-Infinity)], N[Not[LessEqual[t$95$0, 0.001]], $MachinePrecision]], N[(t$95$0 / 2.0), $MachinePrecision], N[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := e^{x} - e^{-x}\\
\mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 0.001\right):\\
\;\;\;\;\frac{t_0}{2}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < -inf.0 or 1e-3 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x)))

    1. Initial program 100.0%

      \[\frac{e^{x} - e^{-x}}{2} \]

    if -inf.0 < (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < 1e-3

    1. Initial program 7.8%

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

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)}}{2} \]
    3. Step-by-step derivation
      1. unpow3100.0%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} + 2 \cdot x\right)}{2} \]
      2. associate-*r*100.0%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(\color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot x} + 2 \cdot x\right)}{2} \]
      3. distribute-rgt-in100.0%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
      4. fma-udef100.0%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
      5. *-commutative100.0%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right) \cdot x}}{2} \]
    4. Applied egg-rr100.0%

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

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
    6. Applied egg-rr100.0%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification100.0%

    \[\leadsto \begin{array}{l} \mathbf{if}\;e^{x} - e^{-x} \leq -\infty \lor \neg \left(e^{x} - e^{-x} \leq 0.001\right):\\ \;\;\;\;\frac{e^{x} - e^{-x}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \]

Alternative 2: 98.8% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -34000 \lor \neg \left(x \leq 13200\right):\\ \;\;\;\;\langle \left( 0.008333333333333333 \cdot {x}^{5} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (or (<= x -34000.0) (not (<= x 13200.0)))
   (cast (! :precision binary32 (* 0.008333333333333333 (pow x 5.0))))
   (/
    (+
     (* 0.016666666666666666 (pow x 5.0))
     (* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
    2.0)))
double code(double x) {
	float tmp_1;
	if ((x <= -34000.0) || !(x <= 13200.0)) {
		float tmp_2 = 0.008333333333333333f * powf(x, 5.0f);
		tmp_1 = (double) tmp_2;
	} else {
		tmp_1 = ((0.016666666666666666f * powf(x, 5.0f)) + (x * (2.0f + (0.3333333333333333f * (x * x))))) / 2.0f;
	}
	return tmp_1;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(4) :: tmp
    real(4) :: tmp_1
    real(4) :: tmp_2
    if ((x <= (-34000.0d0)) .or. (.not. (x <= 13200.0d0))) then
        tmp_2 = 0.008333333333333333e0 * (x ** 5.0e0)
        tmp_1 = real(tmp_2, 8)
    else
        tmp_1 = ((0.016666666666666666e0 * (x ** 5.0e0)) + (x * (2.0e0 + (0.3333333333333333e0 * (x * x))))) / 2.0e0
    end if
    code = tmp_1
end function
function code(x)
	tmp_1 = Float32(0.0)
	if ((x <= -34000.0) || !(x <= 13200.0))
		tmp_2 = Float32(Float32(0.008333333333333333) * (x ^ Float32(5.0)))
		tmp_1 = Float64(tmp_2);
	else
		tmp_1 = Float32(Float32(Float32(Float32(0.016666666666666666) * (x ^ Float32(5.0))) + Float32(x * Float32(Float32(2.0) + Float32(Float32(0.3333333333333333) * Float32(x * x))))) / Float32(2.0));
	end
	return tmp_1
end
function tmp_4 = code(x)
	tmp_2 = single(0.0);
	if ((x <= -34000.0) || ~((x <= 13200.0)))
		tmp_3 = single(0.008333333333333333) * single((x ^ double(single(5.0))));
		tmp_2 = double(tmp_3);
	else
		tmp_2 = ((single(0.016666666666666666) * single((x ^ double(single(5.0))))) + single((x * double((single(2.0) + (single(0.3333333333333333) * single((x * x)))))))) / single(2.0);
	end
	tmp_4 = tmp_2;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -34000 \lor \neg \left(x \leq 13200\right):\\
\;\;\;\;\langle \left( 0.008333333333333333 \cdot {x}^{5} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -34000 or 13200 < x

    1. Initial program 100.0%

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

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)}}{2} \]
    3. Taylor expanded in x around inf 77.6%

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5}}}{2} \]
    4. Step-by-step derivation
      1. rewrite-binary64/binary3299.3%

        \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\frac{0.016666666666666666 \cdot {x}^{5}}{2}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]
    5. Applied rewrite-once99.3%

      \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\frac{0.016666666666666666 \cdot {x}^{5}}{2}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]
    6. Step-by-step derivation
      1. associate-/l*99.3%

        \[\leadsto \langle \left( \frac{\color{blue}{0.016666666666666666}}{\frac{2}{{x}^{5}}} \right)_{\text{binary32}} \rangle_{\text{binary64}} \]
      2. associate-/r/99.3%

        \[\leadsto \langle \left( \color{blue}{\frac{0.016666666666666666}{2}} \cdot {x}^{5} \right)_{\text{binary32}} \rangle_{\text{binary64}} \]
      3. metadata-eval99.3%

        \[\leadsto \langle \left( 0.008333333333333333 \cdot {x}^{5} \right)_{\text{binary32}} \rangle_{\text{binary64}} \]
    7. Simplified99.3%

      \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{0.008333333333333333 \cdot {x}^{5}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]

    if -34000 < x < 13200

    1. Initial program 9.3%

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

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)}}{2} \]
    3. Step-by-step derivation
      1. unpow398.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} + 2 \cdot x\right)}{2} \]
      2. associate-*r*98.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(\color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot x} + 2 \cdot x\right)}{2} \]
      3. distribute-rgt-in98.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
      4. fma-udef98.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
      5. *-commutative98.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right) \cdot x}}{2} \]
    4. Applied egg-rr98.6%

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

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
    6. Applied egg-rr98.6%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification98.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -34000 \lor \neg \left(x \leq 13200\right):\\ \;\;\;\;\langle \left( 0.008333333333333333 \cdot {x}^{5} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \]

Alternative 3: 97.9% accurate, 1.3× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -12600000000000 \lor \neg \left(x \leq 12500000000000\right):\\ \;\;\;\;\langle \left( \langle \left( x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (or (<= x -12600000000000.0) (not (<= x 12500000000000.0)))
   (cast
    (!
     :precision
     binary32
     (cast (! :precision binary64 (* x (* x (* x 0.16666666666666666)))))))
   (/
    (+
     (* 0.016666666666666666 (pow x 5.0))
     (* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
    2.0)))
double code(double x) {
	double tmp_3;
	if ((x <= -12600000000000.0) || !(x <= 12500000000000.0)) {
		double tmp_6 = x * (x * (x * 0.16666666666666666));
		double tmp_5 = (float) tmp_6;
		tmp_3 = (double) tmp_5;
	} else {
		tmp_3 = ((0.016666666666666666 * pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
	}
	return tmp_3;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    real(8) :: tmp_1
    real(8) :: tmp_2
    real(8) :: tmp_3
    real(8) :: tmp_4
    real(8) :: tmp_5
    real(8) :: tmp_6
    if ((x <= (-12600000000000.0d0)) .or. (.not. (x <= 12500000000000.0d0))) then
        tmp_6 = x * (x * (x * 0.16666666666666666d0))
        tmp_5 = real(tmp_6, 4)
        tmp_3 = real(tmp_5, 8)
    else
        tmp_3 = ((0.016666666666666666d0 * (x ** 5.0d0)) + (x * (2.0d0 + (0.3333333333333333d0 * (x * x))))) / 2.0d0
    end if
    code = tmp_3
end function
function code(x)
	tmp_3 = 0.0
	if ((x <= -12600000000000.0) || !(x <= 12500000000000.0))
		tmp_6 = Float64(x * Float64(x * Float64(x * 0.16666666666666666)))
		tmp_5 = Float32(tmp_6)
		tmp_3 = Float64(tmp_5);
	else
		tmp_3 = Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x))))) / 2.0);
	end
	return tmp_3
end
function tmp_8 = code(x)
	tmp_4 = 0.0;
	if ((x <= -12600000000000.0) || ~((x <= 12500000000000.0)))
		tmp_7 = x * (x * (x * 0.16666666666666666));
		tmp_6 = single(tmp_7);
		tmp_4 = double(tmp_6);
	else
		tmp_4 = ((0.016666666666666666 * (x ^ 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
	end
	tmp_8 = tmp_4;
end
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -12600000000000 \lor \neg \left(x \leq 12500000000000\right):\\
\;\;\;\;\langle \left( \langle \left( x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\

\mathbf{else}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if x < -1.26e13 or 1.25e13 < x

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult72.4%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*72.4%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative72.4%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out72.4%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative72.4%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def72.4%

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot {x}^{2}\right)}}{2} \]
    6. Step-by-step derivation
      1. unpow272.4%

        \[\leadsto \frac{x \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right)}{2} \]
      2. associate-*r*72.4%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(0.3333333333333333 \cdot x\right) \cdot x\right)}}{2} \]
      3. *-commutative72.4%

        \[\leadsto \frac{x \cdot \left(\color{blue}{\left(x \cdot 0.3333333333333333\right)} \cdot x\right)}{2} \]
    7. Simplified72.4%

      \[\leadsto \frac{x \cdot \color{blue}{\left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)}}{2} \]
    8. Step-by-step derivation
      1. div-inv72.4%

        \[\leadsto \color{blue}{\left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right) \cdot \frac{1}{2}} \]
      2. *-commutative72.4%

        \[\leadsto \left(x \cdot \left(\color{blue}{\left(0.3333333333333333 \cdot x\right)} \cdot x\right)\right) \cdot \frac{1}{2} \]
      3. associate-*r*72.4%

        \[\leadsto \left(x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}\right) \cdot \frac{1}{2} \]
      4. associate-*l*71.8%

        \[\leadsto \color{blue}{x \cdot \left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right)} \]
      5. *-commutative71.8%

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right) \cdot x} \]
      6. *-commutative71.8%

        \[\leadsto \left(\color{blue}{\left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} \cdot \frac{1}{2}\right) \cdot x \]
      7. associate-*l*71.8%

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \frac{1}{2}\right)\right)} \cdot x \]
      8. metadata-eval71.8%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \color{blue}{0.5}\right)\right) \cdot x \]
      9. metadata-eval71.8%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \color{blue}{0.16666666666666666}\right) \cdot x \]
      10. associate-*l*71.8%

        \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)} \cdot x \]
    9. Applied egg-rr71.8%

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x} \]
    10. Step-by-step derivation
      1. rewrite-binary64/binary32-simplify100.0%

        \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x} \right)_{\text{binary64}}} \rangle_{\text{binary32}}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]
    11. Applied rewrite-once100.0%

      \[\leadsto \color{blue}{\langle \color{blue}{\left( \color{blue}{\langle \color{blue}{\left( \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x} \right)_{\text{binary64}}} \rangle_{\text{binary32}}} \right)_{\text{binary32}}} \rangle_{\text{binary64}}} \]

    if -1.26e13 < x < 1.25e13

    1. Initial program 15.6%

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

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)}}{2} \]
    3. Step-by-step derivation
      1. unpow391.9%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} + 2 \cdot x\right)}{2} \]
      2. associate-*r*91.9%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(\color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot x} + 2 \cdot x\right)}{2} \]
      3. distribute-rgt-in91.9%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
      4. fma-udef91.9%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
      5. *-commutative91.9%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right) \cdot x}}{2} \]
    4. Applied egg-rr91.9%

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

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
    6. Applied egg-rr91.9%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification95.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -12600000000000 \lor \neg \left(x \leq 12500000000000\right):\\ \;\;\;\;\langle \left( \langle \left( x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \right)_{\text{binary64}} \rangle_{\text{binary32}} \right)_{\text{binary32}} \rangle_{\text{binary64}}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \]

Alternative 4: 92.4% accurate, 1.6× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\ \mathbf{if}\;x \leq 3.2 \cdot 10^{+34}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* x (* x (* x 0.16666666666666666)))))
   (if (<= x 3.2e+34)
     (/
      (+
       (* 0.016666666666666666 (pow x 5.0))
       (* x (+ 2.0 (* 0.3333333333333333 (* x x)))))
      2.0)
     (cbrt (* t_0 (* t_0 t_0))))))
double code(double x) {
	double t_0 = x * (x * (x * 0.16666666666666666));
	double tmp;
	if (x <= 3.2e+34) {
		tmp = ((0.016666666666666666 * pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
	} else {
		tmp = cbrt((t_0 * (t_0 * t_0)));
	}
	return tmp;
}
public static double code(double x) {
	double t_0 = x * (x * (x * 0.16666666666666666));
	double tmp;
	if (x <= 3.2e+34) {
		tmp = ((0.016666666666666666 * Math.pow(x, 5.0)) + (x * (2.0 + (0.3333333333333333 * (x * x))))) / 2.0;
	} else {
		tmp = Math.cbrt((t_0 * (t_0 * t_0)));
	}
	return tmp;
}
function code(x)
	t_0 = Float64(x * Float64(x * Float64(x * 0.16666666666666666)))
	tmp = 0.0
	if (x <= 3.2e+34)
		tmp = Float64(Float64(Float64(0.016666666666666666 * (x ^ 5.0)) + Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x))))) / 2.0);
	else
		tmp = cbrt(Float64(t_0 * Float64(t_0 * t_0)));
	end
	return tmp
end
code[x_] := Block[{t$95$0 = N[(x * N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, 3.2e+34], N[(N[(N[(0.016666666666666666 * N[Power[x, 5.0], $MachinePrecision]), $MachinePrecision] + N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision], N[Power[N[(t$95$0 * N[(t$95$0 * t$95$0), $MachinePrecision]), $MachinePrecision], 1/3], $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\
\mathbf{if}\;x \leq 3.2 \cdot 10^{+34}:\\
\;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\

\mathbf{else}:\\
\;\;\;\;\sqrt[3]{t_0 \cdot \left(t_0 \cdot t_0\right)}\\


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

    1. Initial program 45.0%

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

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)}}{2} \]
    3. Step-by-step derivation
      1. unpow386.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} + 2 \cdot x\right)}{2} \]
      2. associate-*r*86.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(\color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot x} + 2 \cdot x\right)}{2} \]
      3. distribute-rgt-in86.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
      4. fma-udef86.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
      5. *-commutative86.6%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right) \cdot x}}{2} \]
    4. Applied egg-rr86.6%

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

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
    6. Applied egg-rr86.6%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]

    if 3.1999999999999998e34 < x

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult75.7%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*75.7%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative75.7%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out75.7%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative75.7%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def75.7%

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot {x}^{2}\right)}}{2} \]
    6. Step-by-step derivation
      1. unpow275.7%

        \[\leadsto \frac{x \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right)}{2} \]
      2. associate-*r*75.7%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(0.3333333333333333 \cdot x\right) \cdot x\right)}}{2} \]
      3. *-commutative75.7%

        \[\leadsto \frac{x \cdot \left(\color{blue}{\left(x \cdot 0.3333333333333333\right)} \cdot x\right)}{2} \]
    7. Simplified75.7%

      \[\leadsto \frac{x \cdot \color{blue}{\left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)}}{2} \]
    8. Step-by-step derivation
      1. div-inv75.7%

        \[\leadsto \color{blue}{\left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right) \cdot \frac{1}{2}} \]
      2. *-commutative75.7%

        \[\leadsto \left(x \cdot \left(\color{blue}{\left(0.3333333333333333 \cdot x\right)} \cdot x\right)\right) \cdot \frac{1}{2} \]
      3. associate-*r*75.7%

        \[\leadsto \left(x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}\right) \cdot \frac{1}{2} \]
      4. associate-*l*75.7%

        \[\leadsto \color{blue}{x \cdot \left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right)} \]
      5. *-commutative75.7%

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right) \cdot x} \]
      6. *-commutative75.7%

        \[\leadsto \left(\color{blue}{\left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} \cdot \frac{1}{2}\right) \cdot x \]
      7. associate-*l*75.7%

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \frac{1}{2}\right)\right)} \cdot x \]
      8. metadata-eval75.7%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \color{blue}{0.5}\right)\right) \cdot x \]
      9. metadata-eval75.7%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \color{blue}{0.16666666666666666}\right) \cdot x \]
      10. associate-*l*75.7%

        \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)} \cdot x \]
    9. Applied egg-rr75.7%

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x} \]
    10. Step-by-step derivation
      1. add-cbrt-cube_binary64100.0%

        \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x\right) \cdot \left(\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x\right)\right) \cdot \left(\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x\right)}} \]
    11. Applied rewrite-once100.0%

      \[\leadsto \color{blue}{\sqrt[3]{\left(\left(\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x\right) \cdot \left(\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x\right)\right) \cdot \left(\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x\right)}} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification89.6%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq 3.2 \cdot 10^{+34}:\\ \;\;\;\;\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\sqrt[3]{\left(x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\right) \cdot \left(\left(x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\right) \cdot \left(x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\right)\right)}\\ \end{array} \]

Alternative 5: 90.3% accurate, 1.8× speedup?

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

\\
\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}
\end{array}
Derivation
  1. Initial program 57.5%

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

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

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} + 2 \cdot x\right)}{2} \]
    2. associate-*r*87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(\color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot x} + 2 \cdot x\right)}{2} \]
    3. distribute-rgt-in87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
    4. fma-udef87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
    5. *-commutative87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right) \cdot x}}{2} \]
  4. Applied egg-rr87.4%

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

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
  6. Applied egg-rr87.4%

    \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
  7. Final simplification87.4%

    \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2} \]

Alternative 6: 89.9% accurate, 1.9× speedup?

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

\\
\frac{0.016666666666666666 \cdot {x}^{5} + x \cdot 2}{2}
\end{array}
Derivation
  1. Initial program 57.5%

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

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

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot x\right)} + 2 \cdot x\right)}{2} \]
    2. associate-*r*87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \left(\color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot x} + 2 \cdot x\right)}{2} \]
    3. distribute-rgt-in87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
    4. fma-udef87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
    5. *-commutative87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right) \cdot x}}{2} \]
  4. Applied egg-rr87.4%

    \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right) \cdot x}}{2} \]
  5. Taylor expanded in x around 0 87.2%

    \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{2 \cdot x}}{2} \]
  6. Final simplification87.2%

    \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + x \cdot 2}{2} \]

Alternative 7: 90.2% accurate, 1.9× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -5 \lor \neg \left(x \leq 5\right):\\ \;\;\;\;{x}^{5} \cdot 0.008333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (or (<= x -5.0) (not (<= x 5.0)))
   (* (pow x 5.0) 0.008333333333333333)
   (/ (* x (+ 2.0 (* 0.3333333333333333 (* x x)))) 2.0)))
double code(double x) {
	double tmp;
	if ((x <= -5.0) || !(x <= 5.0)) {
		tmp = pow(x, 5.0) * 0.008333333333333333;
	} else {
		tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-5.0d0)) .or. (.not. (x <= 5.0d0))) then
        tmp = (x ** 5.0d0) * 0.008333333333333333d0
    else
        tmp = (x * (2.0d0 + (0.3333333333333333d0 * (x * x)))) / 2.0d0
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if ((x <= -5.0) || !(x <= 5.0)) {
		tmp = Math.pow(x, 5.0) * 0.008333333333333333;
	} else {
		tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if (x <= -5.0) or not (x <= 5.0):
		tmp = math.pow(x, 5.0) * 0.008333333333333333
	else:
		tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0
	return tmp
function code(x)
	tmp = 0.0
	if ((x <= -5.0) || !(x <= 5.0))
		tmp = Float64((x ^ 5.0) * 0.008333333333333333);
	else
		tmp = Float64(Float64(x * Float64(2.0 + Float64(0.3333333333333333 * Float64(x * x)))) / 2.0);
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if ((x <= -5.0) || ~((x <= 5.0)))
		tmp = (x ^ 5.0) * 0.008333333333333333;
	else
		tmp = (x * (2.0 + (0.3333333333333333 * (x * x)))) / 2.0;
	end
	tmp_2 = tmp;
end
code[x_] := If[Or[LessEqual[x, -5.0], N[Not[LessEqual[x, 5.0]], $MachinePrecision]], N[(N[Power[x, 5.0], $MachinePrecision] * 0.008333333333333333), $MachinePrecision], N[(N[(x * N[(2.0 + N[(0.3333333333333333 * N[(x * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 2.0), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \lor \neg \left(x \leq 5\right):\\
\;\;\;\;{x}^{5} \cdot 0.008333333333333333\\

\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\


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

    1. Initial program 100.0%

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

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5} + \left(0.3333333333333333 \cdot {x}^{3} + 2 \cdot x\right)}}{2} \]
    3. Taylor expanded in x around inf 76.6%

      \[\leadsto \frac{\color{blue}{0.016666666666666666 \cdot {x}^{5}}}{2} \]
    4. Taylor expanded in x around 0 76.6%

      \[\leadsto \color{blue}{0.008333333333333333 \cdot {x}^{5}} \]
    5. Step-by-step derivation
      1. *-commutative76.6%

        \[\leadsto \color{blue}{{x}^{5} \cdot 0.008333333333333333} \]
    6. Simplified76.6%

      \[\leadsto \color{blue}{{x}^{5} \cdot 0.008333333333333333} \]

    if -5 < x < 5

    1. Initial program 7.8%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult100.0%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*100.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative100.0%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out100.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative100.0%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def100.0%

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

      \[\leadsto \frac{\color{blue}{x \cdot \mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
    5. Step-by-step derivation
      1. fma-udef100.0%

        \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
    6. Applied egg-rr100.0%

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification87.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -5 \lor \neg \left(x \leq 5\right):\\ \;\;\;\;{x}^{5} \cdot 0.008333333333333333\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \]

Alternative 8: 83.3% accurate, 18.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.4 \lor \neg \left(x \leq 2.4\right):\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (or (<= x -2.4) (not (<= x 2.4)))
   (* x (* x (* x 0.16666666666666666)))
   x))
double code(double x) {
	double tmp;
	if ((x <= -2.4) || !(x <= 2.4)) {
		tmp = x * (x * (x * 0.16666666666666666));
	} else {
		tmp = x;
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if ((x <= (-2.4d0)) .or. (.not. (x <= 2.4d0))) then
        tmp = x * (x * (x * 0.16666666666666666d0))
    else
        tmp = x
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if ((x <= -2.4) || !(x <= 2.4)) {
		tmp = x * (x * (x * 0.16666666666666666));
	} else {
		tmp = x;
	}
	return tmp;
}
def code(x):
	tmp = 0
	if (x <= -2.4) or not (x <= 2.4):
		tmp = x * (x * (x * 0.16666666666666666))
	else:
		tmp = x
	return tmp
function code(x)
	tmp = 0.0
	if ((x <= -2.4) || !(x <= 2.4))
		tmp = Float64(x * Float64(x * Float64(x * 0.16666666666666666)));
	else
		tmp = x;
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if ((x <= -2.4) || ~((x <= 2.4)))
		tmp = x * (x * (x * 0.16666666666666666));
	else
		tmp = x;
	end
	tmp_2 = tmp;
end
code[x_] := If[Or[LessEqual[x, -2.4], N[Not[LessEqual[x, 2.4]], $MachinePrecision]], N[(x * N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], x]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4 \lor \neg \left(x \leq 2.4\right):\\
\;\;\;\;x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult67.0%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*67.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative67.0%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out67.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative67.0%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def67.0%

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot {x}^{2}\right)}}{2} \]
    6. Step-by-step derivation
      1. unpow267.0%

        \[\leadsto \frac{x \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right)}{2} \]
      2. associate-*r*67.0%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(0.3333333333333333 \cdot x\right) \cdot x\right)}}{2} \]
      3. *-commutative67.0%

        \[\leadsto \frac{x \cdot \left(\color{blue}{\left(x \cdot 0.3333333333333333\right)} \cdot x\right)}{2} \]
    7. Simplified67.0%

      \[\leadsto \frac{x \cdot \color{blue}{\left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)}}{2} \]
    8. Step-by-step derivation
      1. div-inv67.0%

        \[\leadsto \color{blue}{\left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right) \cdot \frac{1}{2}} \]
      2. *-commutative67.0%

        \[\leadsto \left(x \cdot \left(\color{blue}{\left(0.3333333333333333 \cdot x\right)} \cdot x\right)\right) \cdot \frac{1}{2} \]
      3. associate-*r*67.0%

        \[\leadsto \left(x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}\right) \cdot \frac{1}{2} \]
      4. associate-*l*66.4%

        \[\leadsto \color{blue}{x \cdot \left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right)} \]
      5. *-commutative66.4%

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right) \cdot x} \]
      6. *-commutative66.4%

        \[\leadsto \left(\color{blue}{\left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} \cdot \frac{1}{2}\right) \cdot x \]
      7. associate-*l*66.4%

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \frac{1}{2}\right)\right)} \cdot x \]
      8. metadata-eval66.4%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \color{blue}{0.5}\right)\right) \cdot x \]
      9. metadata-eval66.4%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \color{blue}{0.16666666666666666}\right) \cdot x \]
      10. associate-*l*66.4%

        \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)} \cdot x \]
    9. Applied egg-rr66.4%

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x} \]

    if -2.39999999999999991 < x < 2.39999999999999991

    1. Initial program 7.8%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult100.0%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*100.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative100.0%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out100.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative100.0%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def100.0%

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

      \[\leadsto \frac{\color{blue}{x \cdot \mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
    5. Taylor expanded in x around 0 99.6%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.4 \lor \neg \left(x \leq 2.4\right):\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]

Alternative 9: 83.3% accurate, 18.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;x \leq -2.4:\\ \;\;\;\;-0.16666666666666666 \cdot \frac{x \cdot x}{\frac{-1}{x}}\\ \mathbf{elif}\;x \leq 2.4:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\ \end{array} \end{array} \]
(FPCore (x)
 :precision binary64
 (if (<= x -2.4)
   (* -0.16666666666666666 (/ (* x x) (/ -1.0 x)))
   (if (<= x 2.4) x (* x (* x (* x 0.16666666666666666))))))
double code(double x) {
	double tmp;
	if (x <= -2.4) {
		tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x));
	} else if (x <= 2.4) {
		tmp = x;
	} else {
		tmp = x * (x * (x * 0.16666666666666666));
	}
	return tmp;
}
real(8) function code(x)
    real(8), intent (in) :: x
    real(8) :: tmp
    if (x <= (-2.4d0)) then
        tmp = (-0.16666666666666666d0) * ((x * x) / ((-1.0d0) / x))
    else if (x <= 2.4d0) then
        tmp = x
    else
        tmp = x * (x * (x * 0.16666666666666666d0))
    end if
    code = tmp
end function
public static double code(double x) {
	double tmp;
	if (x <= -2.4) {
		tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x));
	} else if (x <= 2.4) {
		tmp = x;
	} else {
		tmp = x * (x * (x * 0.16666666666666666));
	}
	return tmp;
}
def code(x):
	tmp = 0
	if x <= -2.4:
		tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x))
	elif x <= 2.4:
		tmp = x
	else:
		tmp = x * (x * (x * 0.16666666666666666))
	return tmp
function code(x)
	tmp = 0.0
	if (x <= -2.4)
		tmp = Float64(-0.16666666666666666 * Float64(Float64(x * x) / Float64(-1.0 / x)));
	elseif (x <= 2.4)
		tmp = x;
	else
		tmp = Float64(x * Float64(x * Float64(x * 0.16666666666666666)));
	end
	return tmp
end
function tmp_2 = code(x)
	tmp = 0.0;
	if (x <= -2.4)
		tmp = -0.16666666666666666 * ((x * x) / (-1.0 / x));
	elseif (x <= 2.4)
		tmp = x;
	else
		tmp = x * (x * (x * 0.16666666666666666));
	end
	tmp_2 = tmp;
end
code[x_] := If[LessEqual[x, -2.4], N[(-0.16666666666666666 * N[(N[(x * x), $MachinePrecision] / N[(-1.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4], x, N[(x * N[(x * N[(x * 0.16666666666666666), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.4:\\
\;\;\;\;-0.16666666666666666 \cdot \frac{x \cdot x}{\frac{-1}{x}}\\

\mathbf{elif}\;x \leq 2.4:\\
\;\;\;\;x\\

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


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

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult73.7%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*73.7%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative73.7%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out73.7%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative73.7%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def73.7%

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot {x}^{2}\right)}}{2} \]
    6. Step-by-step derivation
      1. unpow273.7%

        \[\leadsto \frac{x \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right)}{2} \]
      2. associate-*r*73.7%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(0.3333333333333333 \cdot x\right) \cdot x\right)}}{2} \]
      3. *-commutative73.7%

        \[\leadsto \frac{x \cdot \left(\color{blue}{\left(x \cdot 0.3333333333333333\right)} \cdot x\right)}{2} \]
    7. Simplified73.7%

      \[\leadsto \frac{x \cdot \color{blue}{\left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)}}{2} \]
    8. Step-by-step derivation
      1. add-cbrt-cube_binary6485.2%

        \[\leadsto \color{blue}{\frac{\sqrt[3]{\left(\left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right) \cdot \left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right)\right) \cdot \left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right)}}{2}} \]
    9. Applied rewrite-once85.2%

      \[\leadsto \frac{\color{blue}{\sqrt[3]{\left(\left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right) \cdot \left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right)\right) \cdot \left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right)}}}{2} \]
    10. Step-by-step derivation
      1. pow385.2%

        \[\leadsto \frac{\sqrt[3]{\color{blue}{{\left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right)}^{3}}}}{2} \]
      2. rem-cbrt-cube73.7%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)}}{2} \]
      3. *-commutative73.7%

        \[\leadsto \frac{\color{blue}{\left(\left(x \cdot 0.3333333333333333\right) \cdot x\right) \cdot x}}{2} \]
      4. *-commutative73.7%

        \[\leadsto \frac{\left(\color{blue}{\left(0.3333333333333333 \cdot x\right)} \cdot x\right) \cdot x}{2} \]
      5. associate-*r*73.7%

        \[\leadsto \frac{\color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)} \cdot x}{2} \]
      6. associate-/l*72.4%

        \[\leadsto \color{blue}{\frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{\frac{2}{x}}} \]
      7. frac-2neg72.4%

        \[\leadsto \frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{\color{blue}{\frac{-2}{-x}}} \]
      8. metadata-eval72.4%

        \[\leadsto \frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{\frac{\color{blue}{-2}}{-x}} \]
      9. div-inv72.4%

        \[\leadsto \frac{0.3333333333333333 \cdot \left(x \cdot x\right)}{\color{blue}{-2 \cdot \frac{1}{-x}}} \]
      10. times-frac73.7%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{-2} \cdot \frac{x \cdot x}{\frac{1}{-x}}} \]
      11. metadata-eval73.7%

        \[\leadsto \color{blue}{-0.16666666666666666} \cdot \frac{x \cdot x}{\frac{1}{-x}} \]
      12. neg-mul-173.7%

        \[\leadsto -0.16666666666666666 \cdot \frac{x \cdot x}{\frac{1}{\color{blue}{-1 \cdot x}}} \]
      13. associate-/r*73.7%

        \[\leadsto -0.16666666666666666 \cdot \frac{x \cdot x}{\color{blue}{\frac{\frac{1}{-1}}{x}}} \]
    11. Applied egg-rr73.7%

      \[\leadsto \color{blue}{-0.16666666666666666 \cdot \frac{x \cdot x}{\frac{-1}{x}}} \]

    if -2.39999999999999991 < x < 2.39999999999999991

    1. Initial program 7.8%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult100.0%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*100.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative100.0%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out100.0%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative100.0%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def100.0%

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

      \[\leadsto \frac{\color{blue}{x \cdot \mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
    5. Taylor expanded in x around 0 99.6%

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

    if 2.39999999999999991 < x

    1. Initial program 100.0%

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

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

        \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
      2. cube-mult61.1%

        \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
      3. associate-*l*61.1%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
      4. *-commutative61.1%

        \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
      5. distribute-lft-out61.1%

        \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
      6. *-commutative61.1%

        \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
      7. fma-def61.1%

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot {x}^{2}\right)}}{2} \]
    6. Step-by-step derivation
      1. unpow261.1%

        \[\leadsto \frac{x \cdot \left(0.3333333333333333 \cdot \color{blue}{\left(x \cdot x\right)}\right)}{2} \]
      2. associate-*r*61.1%

        \[\leadsto \frac{x \cdot \color{blue}{\left(\left(0.3333333333333333 \cdot x\right) \cdot x\right)}}{2} \]
      3. *-commutative61.1%

        \[\leadsto \frac{x \cdot \left(\color{blue}{\left(x \cdot 0.3333333333333333\right)} \cdot x\right)}{2} \]
    7. Simplified61.1%

      \[\leadsto \frac{x \cdot \color{blue}{\left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)}}{2} \]
    8. Step-by-step derivation
      1. div-inv61.1%

        \[\leadsto \color{blue}{\left(x \cdot \left(\left(x \cdot 0.3333333333333333\right) \cdot x\right)\right) \cdot \frac{1}{2}} \]
      2. *-commutative61.1%

        \[\leadsto \left(x \cdot \left(\color{blue}{\left(0.3333333333333333 \cdot x\right)} \cdot x\right)\right) \cdot \frac{1}{2} \]
      3. associate-*r*61.1%

        \[\leadsto \left(x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}\right) \cdot \frac{1}{2} \]
      4. associate-*l*61.1%

        \[\leadsto \color{blue}{x \cdot \left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right)} \]
      5. *-commutative61.1%

        \[\leadsto \color{blue}{\left(\left(0.3333333333333333 \cdot \left(x \cdot x\right)\right) \cdot \frac{1}{2}\right) \cdot x} \]
      6. *-commutative61.1%

        \[\leadsto \left(\color{blue}{\left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} \cdot \frac{1}{2}\right) \cdot x \]
      7. associate-*l*61.1%

        \[\leadsto \color{blue}{\left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \frac{1}{2}\right)\right)} \cdot x \]
      8. metadata-eval61.1%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \left(0.3333333333333333 \cdot \color{blue}{0.5}\right)\right) \cdot x \]
      9. metadata-eval61.1%

        \[\leadsto \left(\left(x \cdot x\right) \cdot \color{blue}{0.16666666666666666}\right) \cdot x \]
      10. associate-*l*61.1%

        \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)} \cdot x \]
    9. Applied egg-rr61.1%

      \[\leadsto \color{blue}{\left(x \cdot \left(x \cdot 0.16666666666666666\right)\right) \cdot x} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification82.1%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -2.4:\\ \;\;\;\;-0.16666666666666666 \cdot \frac{x \cdot x}{\frac{-1}{x}}\\ \mathbf{elif}\;x \leq 2.4:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(x \cdot \left(x \cdot 0.16666666666666666\right)\right)\\ \end{array} \]

Alternative 10: 83.6% accurate, 18.7× speedup?

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

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

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

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

      \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
    2. cube-mult82.2%

      \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
    3. associate-*l*82.2%

      \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
    4. *-commutative82.2%

      \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
    5. distribute-lft-out82.2%

      \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
    6. *-commutative82.2%

      \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
    7. fma-def82.2%

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

    \[\leadsto \frac{\color{blue}{x \cdot \mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
  5. Step-by-step derivation
    1. fma-udef87.4%

      \[\leadsto \frac{0.016666666666666666 \cdot {x}^{5} + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)} \cdot x}{2} \]
  6. Applied egg-rr82.2%

    \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
  7. Final simplification82.2%

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

Alternative 11: 52.2% accurate, 206.0× speedup?

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

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

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

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

      \[\leadsto \frac{\color{blue}{{x}^{3} \cdot 0.3333333333333333} + 2 \cdot x}{2} \]
    2. cube-mult82.2%

      \[\leadsto \frac{\color{blue}{\left(x \cdot \left(x \cdot x\right)\right)} \cdot 0.3333333333333333 + 2 \cdot x}{2} \]
    3. associate-*l*82.2%

      \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)} + 2 \cdot x}{2} \]
    4. *-commutative82.2%

      \[\leadsto \frac{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) + \color{blue}{x \cdot 2}}{2} \]
    5. distribute-lft-out82.2%

      \[\leadsto \frac{\color{blue}{x \cdot \left(\left(x \cdot x\right) \cdot 0.3333333333333333 + 2\right)}}{2} \]
    6. *-commutative82.2%

      \[\leadsto \frac{x \cdot \left(\color{blue}{0.3333333333333333 \cdot \left(x \cdot x\right)} + 2\right)}{2} \]
    7. fma-def82.2%

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

    \[\leadsto \frac{\color{blue}{x \cdot \mathsf{fma}\left(0.3333333333333333, x \cdot x, 2\right)}}{2} \]
  5. Taylor expanded in x around 0 48.8%

    \[\leadsto \color{blue}{x} \]
  6. Final simplification48.8%

    \[\leadsto x \]

Reproduce

?
herbie shell --seed 2023297 
(FPCore (x)
  :name "Hyperbolic sine"
  :precision binary64
  (/ (- (exp x) (exp (- x))) 2.0))