Average Error: 32.9 → 10.5
Time: 17.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 -6.1701110130378705 \cdot 10^{+68}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 7.055294936690956 \cdot 10^{-115}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - 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 -6.1701110130378705 \cdot 10^{+68}:\\
\;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\

\mathbf{elif}\;b_2 \le 7.055294936690956 \cdot 10^{-115}:\\
\;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - 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 r563632 = b_2;
        double r563633 = -r563632;
        double r563634 = r563632 * r563632;
        double r563635 = a;
        double r563636 = c;
        double r563637 = r563635 * r563636;
        double r563638 = r563634 - r563637;
        double r563639 = sqrt(r563638);
        double r563640 = r563633 + r563639;
        double r563641 = r563640 / r563635;
        return r563641;
}

double f(double a, double b_2, double c) {
        double r563642 = b_2;
        double r563643 = -6.1701110130378705e+68;
        bool r563644 = r563642 <= r563643;
        double r563645 = 0.5;
        double r563646 = c;
        double r563647 = r563646 / r563642;
        double r563648 = r563645 * r563647;
        double r563649 = a;
        double r563650 = r563642 / r563649;
        double r563651 = 2.0;
        double r563652 = r563650 * r563651;
        double r563653 = r563648 - r563652;
        double r563654 = 7.055294936690956e-115;
        bool r563655 = r563642 <= r563654;
        double r563656 = r563642 * r563642;
        double r563657 = r563646 * r563649;
        double r563658 = r563656 - r563657;
        double r563659 = sqrt(r563658);
        double r563660 = r563659 - r563642;
        double r563661 = r563660 / r563649;
        double r563662 = -0.5;
        double r563663 = r563647 * r563662;
        double r563664 = r563655 ? r563661 : r563663;
        double r563665 = r563644 ? r563653 : r563664;
        return r563665;
}

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 < -6.1701110130378705e+68

    1. Initial program 38.0

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

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

      \[\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 4.7

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

    if -6.1701110130378705e+68 < b_2 < 7.055294936690956e-115

    1. Initial program 12.0

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

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

      \[\leadsto \color{blue}{\left(\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2\right) \cdot \frac{1}{a}}\]
    5. Using strategy rm
    6. Applied associate-*r/12.0

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

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

    if 7.055294936690956e-115 < b_2

    1. Initial program 50.8

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

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

      \[\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 11.5

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b_2 \le -6.1701110130378705 \cdot 10^{+68}:\\ \;\;\;\;\frac{1}{2} \cdot \frac{c}{b_2} - \frac{b_2}{a} \cdot 2\\ \mathbf{elif}\;b_2 \le 7.055294936690956 \cdot 10^{-115}:\\ \;\;\;\;\frac{\sqrt{b_2 \cdot b_2 - c \cdot a} - b_2}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c}{b_2} \cdot \frac{-1}{2}\\ \end{array}\]

Reproduce

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