Average Error: 38.5 → 0.4
Time: 9.7s
Precision: 64
\[e^{x} - e^{2 \cdot x}\]
\[\begin{array}{l} \mathbf{if}\;x \le -6.364142259443218143863396640824703354156 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{e^{x} - e^{2 \cdot x}} \cdot \sqrt{e^{x} - e^{2 \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;-\left(\left(x \cdot \left(1.166666666666666518636930049979127943516 \cdot x + 1.5\right)\right) \cdot x + 1 \cdot x\right)\\ \end{array}\]
e^{x} - e^{2 \cdot x}
\begin{array}{l}
\mathbf{if}\;x \le -6.364142259443218143863396640824703354156 \cdot 10^{-5}:\\
\;\;\;\;\sqrt{e^{x} - e^{2 \cdot x}} \cdot \sqrt{e^{x} - e^{2 \cdot x}}\\

\mathbf{else}:\\
\;\;\;\;-\left(\left(x \cdot \left(1.166666666666666518636930049979127943516 \cdot x + 1.5\right)\right) \cdot x + 1 \cdot x\right)\\

\end{array}
double f(double x) {
        double r1629654 = x;
        double r1629655 = exp(r1629654);
        double r1629656 = 2.0;
        double r1629657 = r1629656 * r1629654;
        double r1629658 = exp(r1629657);
        double r1629659 = r1629655 - r1629658;
        return r1629659;
}

double f(double x) {
        double r1629660 = x;
        double r1629661 = -6.364142259443218e-05;
        bool r1629662 = r1629660 <= r1629661;
        double r1629663 = exp(r1629660);
        double r1629664 = 2.0;
        double r1629665 = r1629664 * r1629660;
        double r1629666 = exp(r1629665);
        double r1629667 = r1629663 - r1629666;
        double r1629668 = sqrt(r1629667);
        double r1629669 = r1629668 * r1629668;
        double r1629670 = 1.1666666666666665;
        double r1629671 = r1629670 * r1629660;
        double r1629672 = 1.5;
        double r1629673 = r1629671 + r1629672;
        double r1629674 = r1629660 * r1629673;
        double r1629675 = r1629674 * r1629660;
        double r1629676 = 1.0;
        double r1629677 = r1629676 * r1629660;
        double r1629678 = r1629675 + r1629677;
        double r1629679 = -r1629678;
        double r1629680 = r1629662 ? r1629669 : r1629679;
        return r1629680;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if x < -6.364142259443218e-05

    1. Initial program 0.1

      \[e^{x} - e^{2 \cdot x}\]
    2. Using strategy rm
    3. Applied add-sqr-sqrt0.1

      \[\leadsto \color{blue}{\sqrt{e^{x} - e^{2 \cdot x}} \cdot \sqrt{e^{x} - e^{2 \cdot x}}}\]

    if -6.364142259443218e-05 < x

    1. Initial program 58.5

      \[e^{x} - e^{2 \cdot x}\]
    2. Taylor expanded around 0 0.6

      \[\leadsto \color{blue}{-\left(1.5 \cdot {x}^{2} + \left(1 \cdot x + 1.166666666666666518636930049979127943516 \cdot {x}^{3}\right)\right)}\]
    3. Simplified0.6

      \[\leadsto \color{blue}{-x \cdot \left(x \cdot \left(1.166666666666666518636930049979127943516 \cdot x + 1.5\right) + 1\right)}\]
    4. Using strategy rm
    5. Applied distribute-rgt-in0.6

      \[\leadsto -\color{blue}{\left(\left(x \cdot \left(1.166666666666666518636930049979127943516 \cdot x + 1.5\right)\right) \cdot x + 1 \cdot x\right)}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -6.364142259443218143863396640824703354156 \cdot 10^{-5}:\\ \;\;\;\;\sqrt{e^{x} - e^{2 \cdot x}} \cdot \sqrt{e^{x} - e^{2 \cdot x}}\\ \mathbf{else}:\\ \;\;\;\;-\left(\left(x \cdot \left(1.166666666666666518636930049979127943516 \cdot x + 1.5\right)\right) \cdot x + 1 \cdot x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (x)
  :name "exp(x)-exp(2*x)"
  :precision binary64
  (- (exp x) (exp (* 2 x))))