Average Error: 9.1 → 9.1
Time: 16.9s
Precision: 64
\[\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)\]
\[\begin{array}{l} \mathbf{if}\;b \le +\infty:\\ \;\;\;\;\left(\sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{1}{2 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\left(-2 \cdot \frac{a \cdot c}{b}\right) \cdot \frac{1}{2 \cdot a}\\ \end{array}\]
\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)
\begin{array}{l}
\mathbf{if}\;b \le +\infty:\\
\;\;\;\;\left(\sqrt{{b}^{2} - 4 \cdot \left(a \cdot c\right)} - b\right) \cdot \frac{1}{2 \cdot a}\\

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

\end{array}
double f(double a, double b, double c) {
        double r604777 = 1.0;
        double r604778 = 2.0;
        double r604779 = a;
        double r604780 = r604778 * r604779;
        double r604781 = r604777 / r604780;
        double r604782 = b;
        double r604783 = -r604782;
        double r604784 = pow(r604782, r604778);
        double r604785 = 4.0;
        double r604786 = r604785 * r604779;
        double r604787 = c;
        double r604788 = r604786 * r604787;
        double r604789 = r604784 - r604788;
        double r604790 = sqrt(r604789);
        double r604791 = r604783 + r604790;
        double r604792 = r604781 * r604791;
        return r604792;
}

double f(double a, double b, double c) {
        double r604793 = b;
        double r604794 = +inf.0;
        bool r604795 = r604793 <= r604794;
        double r604796 = 2.0;
        double r604797 = pow(r604793, r604796);
        double r604798 = 4.0;
        double r604799 = a;
        double r604800 = c;
        double r604801 = r604799 * r604800;
        double r604802 = r604798 * r604801;
        double r604803 = r604797 - r604802;
        double r604804 = sqrt(r604803);
        double r604805 = r604804 - r604793;
        double r604806 = 1.0;
        double r604807 = r604796 * r604799;
        double r604808 = r604806 / r604807;
        double r604809 = r604805 * r604808;
        double r604810 = -2.0;
        double r604811 = r604801 / r604793;
        double r604812 = r604810 * r604811;
        double r604813 = r604812 * r604808;
        double r604814 = r604795 ? r604809 : r604813;
        return r604814;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Split input into 2 regimes
  2. if b < +inf.0

    1. Initial program 9.1

      \[\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)\]
    2. Simplified9.1

      \[\leadsto \color{blue}{\left(\sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c} - b\right) \cdot \frac{1}{2 \cdot a}}\]
    3. Using strategy rm
    4. Applied associate-*l*9.1

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

    if +inf.0 < b

    1. Initial program 9.1

      \[\frac{1}{2 \cdot a} \cdot \left(\left(-b\right) + \sqrt{{b}^{2} - \left(4 \cdot a\right) \cdot c}\right)\]
    2. Simplified9.1

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

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

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

Reproduce

herbie shell --seed 1 
(FPCore (a b c)
  :name "1/(2*a)*(-b+sqrt(b^2-4*a*c))"
  :precision binary32
  (* (/ 1 (* 2 a)) (+ (- b) (sqrt (- (pow b 2) (* (* 4 a) c))))))