Average Error: 34.4 → 6.7
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 -5.5038627888747993 \cdot 10^{151}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.10735029247724072 \cdot 10^{-236}:\\ \;\;\;\;1 \cdot \left(\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2} \cdot c\right)\\ \mathbf{elif}\;b_2 \le 5.43153376685683538 \cdot 10^{106}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \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 -5.5038627888747993 \cdot 10^{151}:\\
\;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\

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

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r22676 = b_2;
        double r22677 = -r22676;
        double r22678 = r22676 * r22676;
        double r22679 = a;
        double r22680 = c;
        double r22681 = r22679 * r22680;
        double r22682 = r22678 - r22681;
        double r22683 = sqrt(r22682);
        double r22684 = r22677 - r22683;
        double r22685 = r22684 / r22679;
        return r22685;
}

double f(double a, double b_2, double c) {
        double r22686 = b_2;
        double r22687 = -5.503862788874799e+151;
        bool r22688 = r22686 <= r22687;
        double r22689 = -0.5;
        double r22690 = c;
        double r22691 = r22690 / r22686;
        double r22692 = r22689 * r22691;
        double r22693 = 1.1073502924772407e-236;
        bool r22694 = r22686 <= r22693;
        double r22695 = 1.0;
        double r22696 = r22686 * r22686;
        double r22697 = a;
        double r22698 = r22697 * r22690;
        double r22699 = r22696 - r22698;
        double r22700 = sqrt(r22699);
        double r22701 = r22700 - r22686;
        double r22702 = r22695 / r22701;
        double r22703 = r22702 * r22690;
        double r22704 = r22695 * r22703;
        double r22705 = 5.431533766856835e+106;
        bool r22706 = r22686 <= r22705;
        double r22707 = -r22686;
        double r22708 = r22707 - r22700;
        double r22709 = r22697 / r22708;
        double r22710 = r22695 / r22709;
        double r22711 = 0.5;
        double r22712 = r22711 * r22691;
        double r22713 = 2.0;
        double r22714 = r22686 / r22697;
        double r22715 = r22713 * r22714;
        double r22716 = r22712 - r22715;
        double r22717 = r22706 ? r22710 : r22716;
        double r22718 = r22694 ? r22704 : r22717;
        double r22719 = r22688 ? r22692 : r22718;
        return r22719;
}

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 < -5.503862788874799e+151

    1. Initial program 63.7

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around -inf 1.5

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

    if -5.503862788874799e+151 < b_2 < 1.1073502924772407e-236

    1. Initial program 32.5

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

      \[\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. Simplified16.2

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

      \[\leadsto \frac{\frac{0 + a \cdot c}{\color{blue}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{a}\]
    6. Using strategy rm
    7. Applied *-un-lft-identity16.2

      \[\leadsto \frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{1 \cdot a}}\]
    8. Applied associate-/r*16.2

      \[\leadsto \color{blue}{\frac{\frac{\frac{0 + a \cdot c}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{1}}{a}}\]
    9. Simplified14.2

      \[\leadsto \frac{\color{blue}{\frac{a}{\frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{c}}}}{a}\]
    10. Using strategy rm
    11. Applied div-inv14.2

      \[\leadsto \frac{\frac{a}{\color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{c}}}}{a}\]
    12. Applied *-un-lft-identity14.2

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

      \[\leadsto \frac{\color{blue}{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2} \cdot \frac{a}{\frac{1}{c}}}}{a}\]
    14. Applied associate-/l*14.9

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

      \[\leadsto \frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{\frac{1}{c}}}\]
    16. Using strategy rm
    17. Applied *-un-lft-identity8.8

      \[\leadsto \frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{1}{\color{blue}{1 \cdot c}}}\]
    18. Applied add-sqr-sqrt8.8

      \[\leadsto \frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\frac{\color{blue}{\sqrt{1} \cdot \sqrt{1}}}{1 \cdot c}}\]
    19. Applied times-frac8.8

      \[\leadsto \frac{\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}{\color{blue}{\frac{\sqrt{1}}{1} \cdot \frac{\sqrt{1}}{c}}}\]
    20. Applied *-un-lft-identity8.8

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

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

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{1}}{1} \cdot \frac{\sqrt{1}}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}}}{\frac{\sqrt{1}}{1} \cdot \frac{\sqrt{1}}{c}}\]
    23. Applied times-frac8.8

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

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

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

    if 1.1073502924772407e-236 < b_2 < 5.431533766856835e+106

    1. Initial program 8.6

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Using strategy rm
    3. Applied clear-num8.7

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

    if 5.431533766856835e+106 < b_2

    1. Initial program 50.0

      \[\frac{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}{a}\]
    2. Taylor expanded around inf 3.8

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -5.5038627888747993 \cdot 10^{151}:\\ \;\;\;\;\frac{-1}{2} \cdot \frac{c}{b_2}\\ \mathbf{elif}\;b_2 \le 1.10735029247724072 \cdot 10^{-236}:\\ \;\;\;\;1 \cdot \left(\frac{1}{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2} \cdot c\right)\\ \mathbf{elif}\;b_2 \le 5.43153376685683538 \cdot 10^{106}:\\ \;\;\;\;\frac{1}{\frac{a}{\left(-b_2\right) - \sqrt{b_2 \cdot b_2 - a \cdot c}}}\\ \mathbf{else}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\\ \end{array}\]

Reproduce

herbie shell --seed 2020062 
(FPCore (a b_2 c)
  :name "quad2m (problem 3.2.1, negative)"
  :precision binary64
  (/ (- (- b_2) (sqrt (- (* b_2 b_2) (* a c)))) a))