Average Error: 32.9 → 10.3
Time: 19.2s
Precision: 64
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
\[\begin{array}{l} \mathbf{if}\;b \le -9.088000531423294 \cdot 10^{+152}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 9.354082991670835 \cdot 10^{-125}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}{a}}{2} - \frac{\frac{b}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \le -9.088000531423294 \cdot 10^{+152}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

\mathbf{else}:\\
\;\;\;\;-\frac{c}{b}\\

\end{array}
double f(double a, double b, double c) {
        double r721128 = b;
        double r721129 = -r721128;
        double r721130 = r721128 * r721128;
        double r721131 = 4.0;
        double r721132 = a;
        double r721133 = r721131 * r721132;
        double r721134 = c;
        double r721135 = r721133 * r721134;
        double r721136 = r721130 - r721135;
        double r721137 = sqrt(r721136);
        double r721138 = r721129 + r721137;
        double r721139 = 2.0;
        double r721140 = r721139 * r721132;
        double r721141 = r721138 / r721140;
        return r721141;
}

double f(double a, double b, double c) {
        double r721142 = b;
        double r721143 = -9.088000531423294e+152;
        bool r721144 = r721142 <= r721143;
        double r721145 = c;
        double r721146 = r721145 / r721142;
        double r721147 = a;
        double r721148 = r721142 / r721147;
        double r721149 = r721146 - r721148;
        double r721150 = 9.354082991670835e-125;
        bool r721151 = r721142 <= r721150;
        double r721152 = r721142 * r721142;
        double r721153 = r721145 * r721147;
        double r721154 = 4.0;
        double r721155 = r721153 * r721154;
        double r721156 = r721152 - r721155;
        double r721157 = sqrt(r721156);
        double r721158 = r721157 / r721147;
        double r721159 = 2.0;
        double r721160 = r721158 / r721159;
        double r721161 = r721148 / r721159;
        double r721162 = r721160 - r721161;
        double r721163 = -r721146;
        double r721164 = r721151 ? r721162 : r721163;
        double r721165 = r721144 ? r721149 : r721164;
        return r721165;
}

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 3 regimes
  2. if b < -9.088000531423294e+152

    1. Initial program 60.4

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Using strategy rm
    4. Applied *-un-lft-identity60.4

      \[\leadsto \frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{\color{blue}{1 \cdot 2}}\]
    5. Applied div-inv60.4

      \[\leadsto \frac{\color{blue}{\left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right) \cdot \frac{1}{a}}}{1 \cdot 2}\]
    6. Applied times-frac60.4

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

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

      \[\leadsto \color{blue}{\frac{c}{b} - \frac{b}{a}}\]

    if -9.088000531423294e+152 < b < 9.354082991670835e-125

    1. Initial program 10.9

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

      \[\leadsto \color{blue}{\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a}}{2}}\]
    3. Using strategy rm
    4. Applied div-sub10.9

      \[\leadsto \frac{\color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}{a} - \frac{b}{a}}}{2}\]
    5. Applied div-sub10.9

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

    if 9.354082991670835e-125 < b

    1. Initial program 49.8

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

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

      \[\leadsto \color{blue}{-1 \cdot \frac{c}{b}}\]
    4. Simplified11.9

      \[\leadsto \color{blue}{-\frac{c}{b}}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification10.3

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -9.088000531423294 \cdot 10^{+152}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 9.354082991670835 \cdot 10^{-125}:\\ \;\;\;\;\frac{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}{a}}{2} - \frac{\frac{b}{a}}{2}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

herbie shell --seed 2019153 
(FPCore (a b c)
  :name "Quadratic roots, full range"
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a)))