Average Error: 34.8 → 10.6
Time: 4.8s
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.6114837319571935 \cdot 10^{38}:\\ \;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\ \mathbf{elif}\;b_2 \le 2.8340580980410285 \cdot 10^{-68}:\\ \;\;\;\;1 \cdot \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\ \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 -6.6114837319571935 \cdot 10^{38}:\\
\;\;\;\;1 \cdot \left(\frac{1}{2} \cdot \frac{c}{b_2} - 2 \cdot \frac{b_2}{a}\right)\\

\mathbf{elif}\;b_2 \le 2.8340580980410285 \cdot 10^{-68}:\\
\;\;\;\;1 \cdot \frac{\sqrt{b_2 \cdot b_2 - a \cdot c} - b_2}{a}\\

\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 r15506 = b_2;
        double r15507 = -r15506;
        double r15508 = r15506 * r15506;
        double r15509 = a;
        double r15510 = c;
        double r15511 = r15509 * r15510;
        double r15512 = r15508 - r15511;
        double r15513 = sqrt(r15512);
        double r15514 = r15507 + r15513;
        double r15515 = r15514 / r15509;
        return r15515;
}

double f(double a, double b_2, double c) {
        double r15516 = b_2;
        double r15517 = -6.6114837319571935e+38;
        bool r15518 = r15516 <= r15517;
        double r15519 = 1.0;
        double r15520 = 0.5;
        double r15521 = c;
        double r15522 = r15521 / r15516;
        double r15523 = r15520 * r15522;
        double r15524 = 2.0;
        double r15525 = a;
        double r15526 = r15516 / r15525;
        double r15527 = r15524 * r15526;
        double r15528 = r15523 - r15527;
        double r15529 = r15519 * r15528;
        double r15530 = 2.8340580980410285e-68;
        bool r15531 = r15516 <= r15530;
        double r15532 = r15516 * r15516;
        double r15533 = r15525 * r15521;
        double r15534 = r15532 - r15533;
        double r15535 = sqrt(r15534);
        double r15536 = r15535 - r15516;
        double r15537 = r15536 / r15525;
        double r15538 = r15519 * r15537;
        double r15539 = -0.5;
        double r15540 = r15539 * r15522;
        double r15541 = r15519 * r15540;
        double r15542 = r15531 ? r15538 : r15541;
        double r15543 = r15518 ? r15529 : r15542;
        return r15543;
}

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.6114837319571935e+38

    1. Initial program 36.8

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\right)} \cdot \frac{1}{a}\]
    6. Applied associate-*l*36.9

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

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

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

    if -6.6114837319571935e+38 < b_2 < 2.8340580980410285e-68

    1. Initial program 15.0

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\right)} \cdot \frac{1}{a}\]
    6. Applied associate-*l*15.1

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

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

    if 2.8340580980410285e-68 < b_2

    1. Initial program 53.9

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

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

      \[\leadsto \color{blue}{\left(1 \cdot \left(\left(-b_2\right) + \sqrt{b_2 \cdot b_2 - a \cdot c}\right)\right)} \cdot \frac{1}{a}\]
    6. Applied associate-*l*54.0

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

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

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

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

Reproduce

herbie shell --seed 2020039 +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))