Average Error: 34.1 → 6.4
Time: 19.7s
Precision: 64
\[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
\[\begin{array}{l} \mathbf{if}\;b_2 \le -1.406599291770866912849299146668339118937 \cdot 10^{122}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -3.517798769679198567266373905152163688501 \cdot 10^{-300}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\\ \mathbf{elif}\;b_2 \le 5.732888581164670930257747643857376081135 \cdot 10^{134}:\\ \;\;\;\;-\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]
\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}
\begin{array}{l}
\mathbf{if}\;b_2 \le -1.406599291770866912849299146668339118937 \cdot 10^{122}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le -3.517798769679198567266373905152163688501 \cdot 10^{-300}:\\
\;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\\

\mathbf{elif}\;b_2 \le 5.732888581164670930257747643857376081135 \cdot 10^{134}:\\
\;\;\;\;-\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\

\mathbf{else}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

\end{array}
double f(double a, double b_2, double c) {
        double r27581 = b_2;
        double r27582 = -r27581;
        double r27583 = r27581 * r27581;
        double r27584 = a;
        double r27585 = c;
        double r27586 = r27584 * r27585;
        double r27587 = r27583 - r27586;
        double r27588 = sqrt(r27587);
        double r27589 = r27582 + r27588;
        double r27590 = r27589 / r27584;
        return r27590;
}

double f(double a, double b_2, double c) {
        double r27591 = b_2;
        double r27592 = -1.406599291770867e+122;
        bool r27593 = r27591 <= r27592;
        double r27594 = 0.5;
        double r27595 = c;
        double r27596 = r27595 / r27591;
        double r27597 = r27594 * r27596;
        double r27598 = 2.0;
        double r27599 = a;
        double r27600 = r27591 / r27599;
        double r27601 = r27598 * r27600;
        double r27602 = r27597 - r27601;
        double r27603 = -3.5177987696791986e-300;
        bool r27604 = r27591 <= r27603;
        double r27605 = 1.0;
        double r27606 = r27591 * r27591;
        double r27607 = r27599 * r27595;
        double r27608 = r27606 - r27607;
        double r27609 = sqrt(r27608);
        double r27610 = r27609 - r27591;
        double r27611 = r27599 / r27610;
        double r27612 = r27605 / r27611;
        double r27613 = 5.732888581164671e+134;
        bool r27614 = r27591 <= r27613;
        double r27615 = r27609 + r27591;
        double r27616 = r27595 / r27615;
        double r27617 = -r27616;
        double r27618 = -0.5;
        double r27619 = r27618 * r27596;
        double r27620 = r27614 ? r27617 : r27619;
        double r27621 = r27604 ? r27612 : r27620;
        double r27622 = r27593 ? r27602 : r27621;
        return r27622;
}

Error

Bits error versus a

Bits error versus b_2

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 4 regimes
  2. if b_2 < -1.406599291770867e+122

    1. Initial program 51.8

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified51.8

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around -inf 2.8

      \[\leadsto \color{blue}{\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}}\]

    if -1.406599291770867e+122 < b_2 < -3.5177987696791986e-300

    1. Initial program 8.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified8.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied clear-num8.4

      \[\leadsto \color{blue}{\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}\]

    if -3.5177987696791986e-300 < b_2 < 5.732888581164671e+134

    1. Initial program 33.9

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified33.9

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Using strategy rm
    4. Applied flip--33.9

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c} - b_2 \cdot b_2}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    5. Simplified16.6

      \[\leadsto \frac{\frac{\color{blue}{0 - c \cdot a}}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}{a}\]
    6. Using strategy rm
    7. Applied div-sub16.6

      \[\leadsto \frac{\color{blue}{\frac{0}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2} - \frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}}{a}\]
    8. Simplified16.6

      \[\leadsto \frac{\color{blue}{0} - \frac{c \cdot a}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}}{a}\]
    9. Simplified15.8

      \[\leadsto \frac{0 - \color{blue}{\frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}}}{a}\]
    10. Using strategy rm
    11. Applied *-un-lft-identity15.8

      \[\leadsto \frac{0 - \frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}}{\color{blue}{1 \cdot a}}\]
    12. Applied *-un-lft-identity15.8

      \[\leadsto \frac{\color{blue}{1 \cdot \left(0 - \frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}\right)}}{1 \cdot a}\]
    13. Applied times-frac15.8

      \[\leadsto \color{blue}{\frac{1}{1} \cdot \frac{0 - \frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}}{a}}\]
    14. Simplified15.8

      \[\leadsto \color{blue}{1} \cdot \frac{0 - \frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}}{a}\]
    15. Simplified8.6

      \[\leadsto 1 \cdot \color{blue}{\left(-\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\right)}\]

    if 5.732888581164671e+134 < b_2

    1. Initial program 62.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Simplified62.2

      \[\leadsto \color{blue}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}}\]
    3. Taylor expanded around inf 1.8

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b_2}}\]
  3. Recombined 4 regimes into one program.
  4. Final simplification6.4

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -1.406599291770866912849299146668339118937 \cdot 10^{122}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -3.517798769679198567266373905152163688501 \cdot 10^{-300}:\\ \;\;\;\;\frac{1}{\frac{a}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}\\ \mathbf{elif}\;b_2 \le 5.732888581164670930257747643857376081135 \cdot 10^{134}:\\ \;\;\;\;-\frac{c}{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}\\ \mathbf{else}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \end{array}\]

Reproduce

herbie shell --seed 2019326 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))