Average Error: 33.8 → 6.8
Time: 21.0s
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 -8.301687926884188663878043402578250574713 \cdot 10^{98}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -7.89283599384243582562951448457087501988 \cdot 10^{-230}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.523104187564355660465456399839335705723 \cdot 10^{61}:\\ \;\;\;\;-\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 -8.301687926884188663878043402578250574713 \cdot 10^{98}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le -7.89283599384243582562951448457087501988 \cdot 10^{-230}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\

\mathbf{elif}\;b_2 \le 2.523104187564355660465456399839335705723 \cdot 10^{61}:\\
\;\;\;\;-\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 r33629 = b_2;
        double r33630 = -r33629;
        double r33631 = r33629 * r33629;
        double r33632 = a;
        double r33633 = c;
        double r33634 = r33632 * r33633;
        double r33635 = r33631 - r33634;
        double r33636 = sqrt(r33635);
        double r33637 = r33630 + r33636;
        double r33638 = r33637 / r33632;
        return r33638;
}

double f(double a, double b_2, double c) {
        double r33639 = b_2;
        double r33640 = -8.301687926884189e+98;
        bool r33641 = r33639 <= r33640;
        double r33642 = 0.5;
        double r33643 = c;
        double r33644 = r33643 / r33639;
        double r33645 = r33642 * r33644;
        double r33646 = 2.0;
        double r33647 = a;
        double r33648 = r33639 / r33647;
        double r33649 = r33646 * r33648;
        double r33650 = r33645 - r33649;
        double r33651 = -7.892835993842436e-230;
        bool r33652 = r33639 <= r33651;
        double r33653 = r33639 * r33639;
        double r33654 = r33647 * r33643;
        double r33655 = r33653 - r33654;
        double r33656 = sqrt(r33655);
        double r33657 = r33656 / r33647;
        double r33658 = r33657 - r33648;
        double r33659 = 2.5231041875643557e+61;
        bool r33660 = r33639 <= r33659;
        double r33661 = r33656 + r33639;
        double r33662 = r33643 / r33661;
        double r33663 = -r33662;
        double r33664 = -0.5;
        double r33665 = r33664 * r33644;
        double r33666 = r33660 ? r33663 : r33665;
        double r33667 = r33652 ? r33658 : r33666;
        double r33668 = r33641 ? r33650 : r33667;
        return r33668;
}

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 < -8.301687926884189e+98

    1. Initial program 46.2

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

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

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

    if -8.301687926884189e+98 < b_2 < -7.892835993842436e-230

    1. Initial program 8.0

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

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

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

    if -7.892835993842436e-230 < b_2 < 2.5231041875643557e+61

    1. Initial program 27.6

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

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

      \[\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.1

      \[\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 frac-2neg16.1

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

      \[\leadsto \frac{\color{blue}{\frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}}}{-a}\]
    9. Using strategy rm
    10. Applied add-sqr-sqrt39.9

      \[\leadsto \frac{\frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}}{-\color{blue}{\sqrt{a} \cdot \sqrt{a}}}\]
    11. Applied distribute-lft-neg-in39.9

      \[\leadsto \frac{\frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{a}}}{\color{blue}{\left(-\sqrt{a}\right) \cdot \sqrt{a}}}\]
    12. Applied add-sqr-sqrt39.8

      \[\leadsto \frac{\frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{\color{blue}{\sqrt{a} \cdot \sqrt{a}}}}}{\left(-\sqrt{a}\right) \cdot \sqrt{a}}\]
    13. Applied *-un-lft-identity39.8

      \[\leadsto \frac{\frac{c}{\frac{\color{blue}{1 \cdot \left(\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2\right)}}{\sqrt{a} \cdot \sqrt{a}}}}{\left(-\sqrt{a}\right) \cdot \sqrt{a}}\]
    14. Applied times-frac39.9

      \[\leadsto \frac{\frac{c}{\color{blue}{\frac{1}{\sqrt{a}} \cdot \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{\sqrt{a}}}}}{\left(-\sqrt{a}\right) \cdot \sqrt{a}}\]
    15. Applied *-un-lft-identity39.9

      \[\leadsto \frac{\frac{\color{blue}{1 \cdot c}}{\frac{1}{\sqrt{a}} \cdot \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{\sqrt{a}}}}{\left(-\sqrt{a}\right) \cdot \sqrt{a}}\]
    16. Applied times-frac39.6

      \[\leadsto \frac{\color{blue}{\frac{1}{\frac{1}{\sqrt{a}}} \cdot \frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{\sqrt{a}}}}}{\left(-\sqrt{a}\right) \cdot \sqrt{a}}\]
    17. Applied times-frac38.4

      \[\leadsto \color{blue}{\frac{\frac{1}{\frac{1}{\sqrt{a}}}}{-\sqrt{a}} \cdot \frac{\frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{\sqrt{a}}}}{\sqrt{a}}}\]
    18. Simplified38.4

      \[\leadsto \color{blue}{-1} \cdot \frac{\frac{c}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} + b_2}{\sqrt{a}}}}{\sqrt{a}}\]
    19. Simplified10.0

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

    if 2.5231041875643557e+61 < b_2

    1. Initial program 57.4

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -8.301687926884188663878043402578250574713 \cdot 10^{98}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le -7.89283599384243582562951448457087501988 \cdot 10^{-230}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - a \cdot c}}{a} - \frac{b_2}{a}\\ \mathbf{elif}\;b_2 \le 2.523104187564355660465456399839335705723 \cdot 10^{61}:\\ \;\;\;\;-\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 2019304 
(FPCore (a b_2 c)
  :name "quad2p (problem 3.2.1, positive)"
  :precision binary64
  (/ (+ (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))