Average Error: 26.5 → 4.6
Time: 14.8s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot a\]
\[\begin{array}{l} \mathbf{if}\;b \le -1.348495931813199651380956550510723066785 \cdot 10^{154}:\\ \;\;\;\;-1 \cdot \left(b \cdot a\right)\\ \mathbf{elif}\;b \le 578925038994981359076265559618224128:\\ \;\;\;\;\frac{\left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b\right) \cdot a}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{c \cdot a}{b} \cdot -2\right) \cdot a}{2}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot a
\begin{array}{l}
\mathbf{if}\;b \le -1.348495931813199651380956550510723066785 \cdot 10^{154}:\\
\;\;\;\;-1 \cdot \left(b \cdot a\right)\\

\mathbf{elif}\;b \le 578925038994981359076265559618224128:\\
\;\;\;\;\frac{\left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b\right) \cdot a}{2}\\

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

\end{array}
double f(double b, double a, double c) {
        double r58869121 = b;
        double r58869122 = -r58869121;
        double r58869123 = r58869121 * r58869121;
        double r58869124 = 4.0;
        double r58869125 = a;
        double r58869126 = c;
        double r58869127 = r58869125 * r58869126;
        double r58869128 = r58869124 * r58869127;
        double r58869129 = r58869123 - r58869128;
        double r58869130 = sqrt(r58869129);
        double r58869131 = r58869122 + r58869130;
        double r58869132 = 2.0;
        double r58869133 = r58869131 / r58869132;
        double r58869134 = r58869133 * r58869125;
        return r58869134;
}

double f(double b, double a, double c) {
        double r58869135 = b;
        double r58869136 = -1.3484959318131997e+154;
        bool r58869137 = r58869135 <= r58869136;
        double r58869138 = -1.0;
        double r58869139 = a;
        double r58869140 = r58869135 * r58869139;
        double r58869141 = r58869138 * r58869140;
        double r58869142 = 5.7892503899498136e+35;
        bool r58869143 = r58869135 <= r58869142;
        double r58869144 = r58869135 * r58869135;
        double r58869145 = 4.0;
        double r58869146 = r58869139 * r58869145;
        double r58869147 = c;
        double r58869148 = r58869146 * r58869147;
        double r58869149 = r58869144 - r58869148;
        double r58869150 = sqrt(r58869149);
        double r58869151 = r58869150 - r58869135;
        double r58869152 = r58869151 * r58869139;
        double r58869153 = 2.0;
        double r58869154 = r58869152 / r58869153;
        double r58869155 = r58869147 * r58869139;
        double r58869156 = r58869155 / r58869135;
        double r58869157 = -2.0;
        double r58869158 = r58869156 * r58869157;
        double r58869159 = r58869158 * r58869139;
        double r58869160 = r58869159 / r58869153;
        double r58869161 = r58869143 ? r58869154 : r58869160;
        double r58869162 = r58869137 ? r58869141 : r58869161;
        return r58869162;
}

Error

Bits error versus b

Bits error versus a

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 < -1.3484959318131997e+154

    1. Initial program 64.0

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot a\]
    2. Taylor expanded around -inf 0.2

      \[\leadsto \color{blue}{-1 \cdot \left(a \cdot b\right)}\]

    if -1.3484959318131997e+154 < b < 5.7892503899498136e+35

    1. Initial program 5.2

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot a\]
    2. Using strategy rm
    3. Applied associate-*l/5.3

      \[\leadsto \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot a}{2}}\]
    4. Simplified5.3

      \[\leadsto \frac{\color{blue}{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right) \cdot a}}{2}\]

    if 5.7892503899498136e+35 < b

    1. Initial program 51.6

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}{2} \cdot a\]
    2. Using strategy rm
    3. Applied associate-*l/51.6

      \[\leadsto \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right) \cdot a}{2}}\]
    4. Simplified51.6

      \[\leadsto \frac{\color{blue}{\left(\sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c} - b\right) \cdot a}}{2}\]
    5. Taylor expanded around inf 5.3

      \[\leadsto \frac{\color{blue}{\left(-2 \cdot \frac{a \cdot c}{b}\right)} \cdot a}{2}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification4.6

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -1.348495931813199651380956550510723066785 \cdot 10^{154}:\\ \;\;\;\;-1 \cdot \left(b \cdot a\right)\\ \mathbf{elif}\;b \le 578925038994981359076265559618224128:\\ \;\;\;\;\frac{\left(\sqrt{b \cdot b - \left(a \cdot 4\right) \cdot c} - b\right) \cdot a}{2}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(\frac{c \cdot a}{b} \cdot -2\right) \cdot a}{2}\\ \end{array}\]

Reproduce

herbie shell --seed 1 
(FPCore (b a c)
  :name "(-b + sqrt(b*b - 4 a c)) / 2a"
  (* (/ (+ (- b) (sqrt (- (* b b) (* 4.0 (* a c))))) 2.0) a))