Average Error: 34.6 → 14.7
Time: 14.2s
Precision: 64
\[K \cdot \left(A - B \cdot \left(1 - e^{\frac{-A}{B}}\right)\right)\]
\[\begin{array}{l} \mathbf{if}\;B \le -522188506239426.625 \lor \neg \left(B \le 3694682121209042041934729602830172160\right):\\ \;\;\;\;K \cdot \left(\frac{1}{2} \cdot \frac{{A}^{2}}{B}\right)\\ \mathbf{else}:\\ \;\;\;\;K \cdot \left(\left(A - 1 \cdot B\right) - \left(-\sqrt[3]{{\left(e^{\frac{-A}{B}}\right)}^{3}}\right) \cdot B\right)\\ \end{array}\]
K \cdot \left(A - B \cdot \left(1 - e^{\frac{-A}{B}}\right)\right)
\begin{array}{l}
\mathbf{if}\;B \le -522188506239426.625 \lor \neg \left(B \le 3694682121209042041934729602830172160\right):\\
\;\;\;\;K \cdot \left(\frac{1}{2} \cdot \frac{{A}^{2}}{B}\right)\\

\mathbf{else}:\\
\;\;\;\;K \cdot \left(\left(A - 1 \cdot B\right) - \left(-\sqrt[3]{{\left(e^{\frac{-A}{B}}\right)}^{3}}\right) \cdot B\right)\\

\end{array}
double f(double K, double A, double B) {
        double r19933 = K;
        double r19934 = A;
        double r19935 = B;
        double r19936 = 1.0;
        double r19937 = -r19934;
        double r19938 = r19937 / r19935;
        double r19939 = exp(r19938);
        double r19940 = r19936 - r19939;
        double r19941 = r19935 * r19940;
        double r19942 = r19934 - r19941;
        double r19943 = r19933 * r19942;
        return r19943;
}

double f(double K, double A, double B) {
        double r19944 = B;
        double r19945 = -522188506239426.6;
        bool r19946 = r19944 <= r19945;
        double r19947 = 3.694682121209042e+36;
        bool r19948 = r19944 <= r19947;
        double r19949 = !r19948;
        bool r19950 = r19946 || r19949;
        double r19951 = K;
        double r19952 = 0.5;
        double r19953 = A;
        double r19954 = 2.0;
        double r19955 = pow(r19953, r19954);
        double r19956 = r19955 / r19944;
        double r19957 = r19952 * r19956;
        double r19958 = r19951 * r19957;
        double r19959 = 1.0;
        double r19960 = r19959 * r19944;
        double r19961 = r19953 - r19960;
        double r19962 = -r19953;
        double r19963 = r19962 / r19944;
        double r19964 = exp(r19963);
        double r19965 = 3.0;
        double r19966 = pow(r19964, r19965);
        double r19967 = cbrt(r19966);
        double r19968 = -r19967;
        double r19969 = r19968 * r19944;
        double r19970 = r19961 - r19969;
        double r19971 = r19951 * r19970;
        double r19972 = r19950 ? r19958 : r19971;
        return r19972;
}

Error

Bits error versus K

Bits error versus A

Bits error versus B

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if B < -522188506239426.6 or 3.694682121209042e+36 < B

    1. Initial program 46.6

      \[K \cdot \left(A - B \cdot \left(1 - e^{\frac{-A}{B}}\right)\right)\]
    2. Taylor expanded around inf 14.6

      \[\leadsto K \cdot \color{blue}{\left(\frac{1}{2} \cdot \frac{{A}^{2}}{B}\right)}\]

    if -522188506239426.6 < B < 3.694682121209042e+36

    1. Initial program 19.9

      \[K \cdot \left(A - B \cdot \left(1 - e^{\frac{-A}{B}}\right)\right)\]
    2. Using strategy rm
    3. Applied sub-neg19.9

      \[\leadsto K \cdot \left(A - B \cdot \color{blue}{\left(1 + \left(-e^{\frac{-A}{B}}\right)\right)}\right)\]
    4. Applied distribute-rgt-in19.9

      \[\leadsto K \cdot \left(A - \color{blue}{\left(1 \cdot B + \left(-e^{\frac{-A}{B}}\right) \cdot B\right)}\right)\]
    5. Applied associate--r+14.8

      \[\leadsto K \cdot \color{blue}{\left(\left(A - 1 \cdot B\right) - \left(-e^{\frac{-A}{B}}\right) \cdot B\right)}\]
    6. Using strategy rm
    7. Applied add-cbrt-cube14.9

      \[\leadsto K \cdot \left(\left(A - 1 \cdot B\right) - \left(-\color{blue}{\sqrt[3]{\left(e^{\frac{-A}{B}} \cdot e^{\frac{-A}{B}}\right) \cdot e^{\frac{-A}{B}}}}\right) \cdot B\right)\]
    8. Simplified14.9

      \[\leadsto K \cdot \left(\left(A - 1 \cdot B\right) - \left(-\sqrt[3]{\color{blue}{{\left(e^{\frac{-A}{B}}\right)}^{3}}}\right) \cdot B\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification14.7

    \[\leadsto \begin{array}{l} \mathbf{if}\;B \le -522188506239426.625 \lor \neg \left(B \le 3694682121209042041934729602830172160\right):\\ \;\;\;\;K \cdot \left(\frac{1}{2} \cdot \frac{{A}^{2}}{B}\right)\\ \mathbf{else}:\\ \;\;\;\;K \cdot \left(\left(A - 1 \cdot B\right) - \left(-\sqrt[3]{{\left(e^{\frac{-A}{B}}\right)}^{3}}\right) \cdot B\right)\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (K A B)
  :name "K*(A-B*(1-exp(-A/B)))"
  :precision binary64
  (* K (- A (* B (- 1 (exp (/ (- A) B)))))))