Average Error: 34.0 → 10.2
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.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;\frac{\frac{c}{b_2}}{2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 6.407662420749314643846659194387390530859 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{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.035809894237901445931970544225072398237 \cdot 10^{152}:\\
\;\;\;\;\frac{\frac{c}{b_2}}{2} - \frac{b_2}{a} \cdot 2\\

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

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

\end{array}
double f(double a, double b_2, double c) {
        double r928639 = b_2;
        double r928640 = -r928639;
        double r928641 = r928639 * r928639;
        double r928642 = a;
        double r928643 = c;
        double r928644 = r928642 * r928643;
        double r928645 = r928641 - r928644;
        double r928646 = sqrt(r928645);
        double r928647 = r928640 + r928646;
        double r928648 = r928647 / r928642;
        return r928648;
}

double f(double a, double b_2, double c) {
        double r928649 = b_2;
        double r928650 = -8.035809894237901e+152;
        bool r928651 = r928649 <= r928650;
        double r928652 = c;
        double r928653 = r928652 / r928649;
        double r928654 = 2.0;
        double r928655 = r928653 / r928654;
        double r928656 = a;
        double r928657 = r928649 / r928656;
        double r928658 = r928657 * r928654;
        double r928659 = r928655 - r928658;
        double r928660 = 6.407662420749315e-35;
        bool r928661 = r928649 <= r928660;
        double r928662 = r928649 * r928649;
        double r928663 = r928652 * r928656;
        double r928664 = r928662 - r928663;
        double r928665 = sqrt(r928664);
        double r928666 = r928665 / r928656;
        double r928667 = r928666 - r928657;
        double r928668 = -0.5;
        double r928669 = r928653 * r928668;
        double r928670 = r928661 ? r928667 : r928669;
        double r928671 = r928651 ? r928659 : r928670;
        return r928671;
}

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 < -8.035809894237901e+152

    1. Initial program 63.6

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

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

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

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

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

    if -8.035809894237901e+152 < b_2 < 6.407662420749315e-35

    1. Initial program 13.9

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

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

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

    if 6.407662420749315e-35 < b_2

    1. Initial program 54.6

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -8.035809894237901445931970544225072398237 \cdot 10^{152}:\\ \;\;\;\;\frac{\frac{c}{b_2}}{2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 6.407662420749314643846659194387390530859 \cdot 10^{-35}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a}}{a} - \frac{b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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