Average Error: 26.5 → 4.6
Time: 15.2s
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 r29791132 = b;
        double r29791133 = -r29791132;
        double r29791134 = r29791132 * r29791132;
        double r29791135 = 4.0;
        double r29791136 = a;
        double r29791137 = c;
        double r29791138 = r29791136 * r29791137;
        double r29791139 = r29791135 * r29791138;
        double r29791140 = r29791134 - r29791139;
        double r29791141 = sqrt(r29791140);
        double r29791142 = r29791133 + r29791141;
        double r29791143 = 2.0;
        double r29791144 = r29791142 / r29791143;
        double r29791145 = r29791144 * r29791136;
        return r29791145;
}

double f(double b, double a, double c) {
        double r29791146 = b;
        double r29791147 = -1.3484959318131997e+154;
        bool r29791148 = r29791146 <= r29791147;
        double r29791149 = -1.0;
        double r29791150 = a;
        double r29791151 = r29791146 * r29791150;
        double r29791152 = r29791149 * r29791151;
        double r29791153 = 5.7892503899498136e+35;
        bool r29791154 = r29791146 <= r29791153;
        double r29791155 = r29791146 * r29791146;
        double r29791156 = 4.0;
        double r29791157 = r29791150 * r29791156;
        double r29791158 = c;
        double r29791159 = r29791157 * r29791158;
        double r29791160 = r29791155 - r29791159;
        double r29791161 = sqrt(r29791160);
        double r29791162 = r29791161 - r29791146;
        double r29791163 = r29791162 * r29791150;
        double r29791164 = 2.0;
        double r29791165 = r29791163 / r29791164;
        double r29791166 = r29791158 * r29791150;
        double r29791167 = r29791166 / r29791146;
        double r29791168 = -2.0;
        double r29791169 = r29791167 * r29791168;
        double r29791170 = r29791169 * r29791150;
        double r29791171 = r29791170 / r29791164;
        double r29791172 = r29791154 ? r29791165 : r29791171;
        double r29791173 = r29791148 ? r29791152 : r29791172;
        return r29791173;
}

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))