Hyperbolic sine

Percentage Accurate: 54.1% → 99.7%
Time: 4.6s
Alternatives: 9
Speedup: TODO×

Specification

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

Your Program's Arguments

Results

Enter valid numbers for all inputs

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 9 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.

Alternative 1?

\[\begin{array}{l} t_0 := e^{x} - e^{-x}\\ \mathbf{if}\;t_0 \leq -\infty \lor \neg \left(t_0 \leq 5 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{t_0}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2 + x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if (-.f64 (exp.f64 x) (exp.f64 (neg.f64 x))) < -inf.0 or 5.00000000000000024e-5 < (-.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))) < 5.00000000000000024e-5

    1. Initial program 8.9%

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

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

        \[\leadsto \frac{2 \cdot x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)\right)}}{2} \]
      2. expm1-udef99.4%

        \[\leadsto \frac{2 \cdot x + \color{blue}{\left(e^{\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)} - 1\right)}}{2} \]
      3. log1p-udef99.4%

        \[\leadsto \frac{2 \cdot x + \left(e^{\color{blue}{\log \left(1 + 0.3333333333333333 \cdot {x}^{3}\right)}} - 1\right)}{2} \]
      4. rem-exp-log99.4%

        \[\leadsto \frac{2 \cdot x + \left(\color{blue}{\left(1 + 0.3333333333333333 \cdot {x}^{3}\right)} - 1\right)}{2} \]
    4. Applied egg-rr99.4%

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

        \[\leadsto \frac{2 \cdot x + \left(\color{blue}{e^{\log \left(1 + 0.3333333333333333 \cdot {x}^{3}\right)}} - 1\right)}{2} \]
      2. log1p-udef99.4%

        \[\leadsto \frac{2 \cdot x + \left(e^{\color{blue}{\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)}} - 1\right)}{2} \]
      3. expm1-udef100.0%

        \[\leadsto \frac{2 \cdot x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)\right)}}{2} \]
      4. expm1-log1p-u100.0%

        \[\leadsto \frac{2 \cdot x + \color{blue}{0.3333333333333333 \cdot {x}^{3}}}{2} \]
      5. unpow3100.0%

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

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

      \[\leadsto \frac{2 \cdot x + \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right)\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 5 \cdot 10^{-5}\right):\\ \;\;\;\;\frac{e^{x} - e^{-x}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2 + x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2}\\ \end{array} \]

Alternative 2?

\[\begin{array}{l} t_0 := x \cdot \left(x \cdot 0.3333333333333333\right)\\ \mathbf{if}\;x \leq -1 \cdot 10^{+160}:\\ \;\;\;\;\frac{x \cdot t_0}{2}\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\frac{x \cdot \frac{4 - {x}^{4} \cdot 0.1111111111111111}{2 - t_0}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333 \cdot {x}^{3}}{2}\\ \end{array} \]
Derivation
  1. Split input into 3 regimes
  2. if x < -1.00000000000000001e160

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
    7. Taylor expanded in x around inf 100.0%

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

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

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

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

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

    if -1.00000000000000001e160 < x < 5.60000000000000037e102

    1. Initial program 41.6%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{x \cdot \frac{4 - \left(\left(x \cdot x\right) \cdot 0.3333333333333333\right) \cdot \color{blue}{\left(\left(x \cdot x\right) \cdot 0.3333333333333333\right)}}{2 - 0.3333333333333333 \cdot \left(x \cdot x\right)}}{2} \]
      6. swap-sqr78.0%

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

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

        \[\leadsto \frac{x \cdot \frac{4 - \left({x}^{2} \cdot \color{blue}{{x}^{2}}\right) \cdot \left(0.3333333333333333 \cdot 0.3333333333333333\right)}{2 - 0.3333333333333333 \cdot \left(x \cdot x\right)}}{2} \]
      9. pow-prod-up78.0%

        \[\leadsto \frac{x \cdot \frac{4 - \color{blue}{{x}^{\left(2 + 2\right)}} \cdot \left(0.3333333333333333 \cdot 0.3333333333333333\right)}{2 - 0.3333333333333333 \cdot \left(x \cdot x\right)}}{2} \]
      10. metadata-eval78.0%

        \[\leadsto \frac{x \cdot \frac{4 - {x}^{\color{blue}{4}} \cdot \left(0.3333333333333333 \cdot 0.3333333333333333\right)}{2 - 0.3333333333333333 \cdot \left(x \cdot x\right)}}{2} \]
      11. metadata-eval78.0%

        \[\leadsto \frac{x \cdot \frac{4 - {x}^{4} \cdot \color{blue}{0.1111111111111111}}{2 - 0.3333333333333333 \cdot \left(x \cdot x\right)}}{2} \]
      12. *-commutative78.0%

        \[\leadsto \frac{x \cdot \frac{4 - {x}^{4} \cdot 0.1111111111111111}{2 - \color{blue}{\left(x \cdot x\right) \cdot 0.3333333333333333}}}{2} \]
      13. associate-*r*78.0%

        \[\leadsto \frac{x \cdot \frac{4 - {x}^{4} \cdot 0.1111111111111111}{2 - \color{blue}{x \cdot \left(x \cdot 0.3333333333333333\right)}}}{2} \]
    8. Applied egg-rr78.0%

      \[\leadsto \frac{x \cdot \color{blue}{\frac{4 - {x}^{4} \cdot 0.1111111111111111}{2 - x \cdot \left(x \cdot 0.3333333333333333\right)}}}{2} \]

    if 5.60000000000000037e102 < x

    1. Initial program 100.0%

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

      \[\leadsto \frac{\color{blue}{2 \cdot x + 0.3333333333333333 \cdot {x}^{3}}}{2} \]
    3. Taylor expanded in x around inf 100.0%

      \[\leadsto \frac{\color{blue}{0.3333333333333333 \cdot {x}^{3}}}{2} \]
  3. Recombined 3 regimes into one program.
  4. Final simplification84.4%

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1 \cdot 10^{+160}:\\ \;\;\;\;\frac{x \cdot \left(x \cdot \left(x \cdot 0.3333333333333333\right)\right)}{2}\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{+102}:\\ \;\;\;\;\frac{x \cdot \frac{4 - {x}^{4} \cdot 0.1111111111111111}{2 - x \cdot \left(x \cdot 0.3333333333333333\right)}}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{0.3333333333333333 \cdot {x}^{3}}{2}\\ \end{array} \]

Alternative 3?

\[\frac{x \cdot 2 + 0.3333333333333333 \cdot {x}^{3}}{2} \]
Derivation
  1. Initial program 58.7%

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

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

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

Alternative 4?

\[\begin{array}{l} \mathbf{if}\;x \leq -2.5 \lor \neg \left(x \leq 2.5\right):\\ \;\;\;\;\frac{x \cdot \left(x \cdot \left(x \cdot 0.3333333333333333\right)\right)}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot 2}{2}\\ \end{array} \]
Derivation
  1. Split input into 2 regimes
  2. if x < -2.5 or 2.5 < x

    1. Initial program 100.0%

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{x \cdot \color{blue}{\left(0.3333333333333333 \cdot \left(x \cdot x\right) + 2\right)}}{2} \]
    7. Taylor expanded in x around inf 65.2%

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

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

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

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

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

    if -2.5 < x < 2.5

    1. Initial program 9.7%

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

      \[\leadsto \frac{\color{blue}{2 \cdot x}}{2} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification80.5%

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

Alternative 5?

\[\frac{x \cdot 2 + x \cdot \left(0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2} \]
Derivation
  1. Initial program 58.7%

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

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

      \[\leadsto \frac{2 \cdot x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)\right)}}{2} \]
    2. expm1-udef63.4%

      \[\leadsto \frac{2 \cdot x + \color{blue}{\left(e^{\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)} - 1\right)}}{2} \]
    3. log1p-udef63.4%

      \[\leadsto \frac{2 \cdot x + \left(e^{\color{blue}{\log \left(1 + 0.3333333333333333 \cdot {x}^{3}\right)}} - 1\right)}{2} \]
    4. rem-exp-log81.0%

      \[\leadsto \frac{2 \cdot x + \left(\color{blue}{\left(1 + 0.3333333333333333 \cdot {x}^{3}\right)} - 1\right)}{2} \]
  4. Applied egg-rr81.0%

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

      \[\leadsto \frac{2 \cdot x + \left(\color{blue}{e^{\log \left(1 + 0.3333333333333333 \cdot {x}^{3}\right)}} - 1\right)}{2} \]
    2. log1p-udef63.4%

      \[\leadsto \frac{2 \cdot x + \left(e^{\color{blue}{\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)}} - 1\right)}{2} \]
    3. expm1-udef63.6%

      \[\leadsto \frac{2 \cdot x + \color{blue}{\mathsf{expm1}\left(\mathsf{log1p}\left(0.3333333333333333 \cdot {x}^{3}\right)\right)}}{2} \]
    4. expm1-log1p-u81.3%

      \[\leadsto \frac{2 \cdot x + \color{blue}{0.3333333333333333 \cdot {x}^{3}}}{2} \]
    5. unpow381.3%

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

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

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

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

Alternative 6?

\[\frac{x \cdot \left(2 + 0.3333333333333333 \cdot \left(x \cdot x\right)\right)}{2} \]
Derivation
  1. Initial program 58.7%

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7?

\[\frac{x \cdot 2}{2} \]
Derivation
  1. Initial program 58.7%

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

    \[\leadsto \frac{\color{blue}{2 \cdot x}}{2} \]
  3. Final simplification47.9%

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

Alternative 8?

\[-1 \]
Derivation
  1. Initial program 58.7%

    \[\frac{e^{x} - e^{-x}}{2} \]
  2. Applied egg-rr2.9%

    \[\leadsto \frac{\color{blue}{-2}}{2} \]
  3. Final simplification2.9%

    \[\leadsto -1 \]

Alternative 9?

\[0 \]
Derivation
  1. Initial program 58.7%

    \[\frac{e^{x} - e^{-x}}{2} \]
  2. Applied egg-rr3.3%

    \[\leadsto \frac{\color{blue}{0}}{2} \]
  3. Final simplification3.3%

    \[\leadsto 0 \]

Reproduce

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