Average Error: 34.6 → 10.0
Time: 6.2s
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 -4.706781135059311758856471716413486308072 \cdot 10^{-92}:\\ \;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \le 6.385814412780331293336851171468331234192 \cdot 10^{98}:\\ \;\;\;\;1 \cdot \left(\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot c\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)\\ \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 -4.706781135059311758856471716413486308072 \cdot 10^{-92}:\\
\;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\

\mathbf{elif}\;b_2 \le 6.385814412780331293336851171468331234192 \cdot 10^{98}:\\
\;\;\;\;1 \cdot \left(\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot c\right)\\

\mathbf{else}:\\
\;\;\;\;1 \cdot \left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)\\

\end{array}
double f(double a, double b_2, double c) {
        double r20646 = b_2;
        double r20647 = -r20646;
        double r20648 = r20646 * r20646;
        double r20649 = a;
        double r20650 = c;
        double r20651 = r20649 * r20650;
        double r20652 = r20648 - r20651;
        double r20653 = sqrt(r20652);
        double r20654 = r20647 + r20653;
        double r20655 = r20654 / r20649;
        return r20655;
}

double f(double a, double b_2, double c) {
        double r20656 = b_2;
        double r20657 = -4.706781135059312e-92;
        bool r20658 = r20656 <= r20657;
        double r20659 = 1.0;
        double r20660 = 0.5;
        double r20661 = c;
        double r20662 = r20661 / r20656;
        double r20663 = r20660 * r20662;
        double r20664 = 2.0;
        double r20665 = a;
        double r20666 = r20656 / r20665;
        double r20667 = r20664 * r20666;
        double r20668 = r20663 - r20667;
        double r20669 = r20659 * r20668;
        double r20670 = 6.385814412780331e+98;
        bool r20671 = r20656 <= r20670;
        double r20672 = -r20656;
        double r20673 = r20656 * r20656;
        double r20674 = r20665 * r20661;
        double r20675 = r20673 - r20674;
        double r20676 = sqrt(r20675);
        double r20677 = r20672 - r20676;
        double r20678 = r20659 / r20677;
        double r20679 = r20678 * r20661;
        double r20680 = r20659 * r20679;
        double r20681 = -0.5;
        double r20682 = r20681 * r20662;
        double r20683 = r20659 * r20682;
        double r20684 = r20671 ? r20680 : r20683;
        double r20685 = r20658 ? r20669 : r20684;
        return r20685;
}

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 3 regimes
  2. if b_2 < -4.706781135059312e-92

    1. Initial program 26.6

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+55.2

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Simplified54.8

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity54.8

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

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

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

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

      \[\leadsto \frac{1 \cdot \color{blue}{\frac{a}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}}{a}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity54.6

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{1}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}\]
    16. Taylor expanded around -inf 12.8

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

    if -4.706781135059312e-92 < b_2 < 6.385814412780331e+98

    1. Initial program 26.4

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+28.7

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Simplified17.8

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity17.8

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

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

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

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

      \[\leadsto \frac{1 \cdot \color{blue}{\frac{a}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}}{a}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity16.3

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{1}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}\]
    16. Using strategy rm
    17. Applied div-inv12.6

      \[\leadsto 1 \cdot \frac{1}{\color{blue}{\left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right) \cdot \frac{1}{c}}}\]
    18. Applied add-cube-cbrt12.6

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

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{\sqrt[3]{1} \cdot \sqrt[3]{1}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot \frac{\sqrt[3]{1}}{\frac{1}{c}}\right)}\]
    20. Simplified12.4

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

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

    if 6.385814412780331e+98 < b_2

    1. Initial program 59.2

      \[\frac{\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied flip-+59.2

      \[\leadsto \frac{\color{blue}{\frac{\left(-b_2\right) \cdot \left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c} \cdot \sqrt{b_2 \cdot b_2 - a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}}{a}\]
    4. Simplified32.6

      \[\leadsto \frac{\frac{\color{blue}{0 + a \cdot c}}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}{a}\]
    5. Using strategy rm
    6. Applied *-un-lft-identity32.6

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{1 \cdot \left(\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}\right)}}}{a}\]
    7. Applied *-un-lft-identity32.6

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

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

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

      \[\leadsto \frac{1 \cdot \color{blue}{\frac{a}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}}{a}\]
    11. Using strategy rm
    12. Applied *-un-lft-identity32.5

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

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

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

      \[\leadsto 1 \cdot \color{blue}{\frac{1}{\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{c}}}\]
    16. Taylor expanded around inf 2.5

      \[\leadsto 1 \cdot \color{blue}{\left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -4.706781135059311758856471716413486308072 \cdot 10^{-92}:\\ \;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \le 6.385814412780331293336851171468331234192 \cdot 10^{98}:\\ \;\;\;\;1 \cdot \left(\frac{1}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}} \cdot c\right)\\ \mathbf{else}:\\ \;\;\;\;1 \cdot \left(\frac{-1}{2} \cdot \frac{c}{b_2}\right)\\ \end{array}\]

Reproduce

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