Average Error: 33.3 → 6.4
Time: 1.4m
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 -3.263941314600607 \cdot 10^{+152}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -4.687918346756617 \cdot 10^{-254}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a} \cdot \frac{1}{2}\\ \mathbf{elif}\;b \le 3.463606471108268 \cdot 10^{+121}:\\ \;\;\;\;\frac{c \cdot -2}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + b}\\ \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 -3.263941314600607 \cdot 10^{+152}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r12099712 = b;
        double r12099713 = -r12099712;
        double r12099714 = r12099712 * r12099712;
        double r12099715 = 4.0;
        double r12099716 = a;
        double r12099717 = r12099715 * r12099716;
        double r12099718 = c;
        double r12099719 = r12099717 * r12099718;
        double r12099720 = r12099714 - r12099719;
        double r12099721 = sqrt(r12099720);
        double r12099722 = r12099713 + r12099721;
        double r12099723 = 2.0;
        double r12099724 = r12099723 * r12099716;
        double r12099725 = r12099722 / r12099724;
        return r12099725;
}

double f(double a, double b, double c) {
        double r12099726 = b;
        double r12099727 = -3.263941314600607e+152;
        bool r12099728 = r12099726 <= r12099727;
        double r12099729 = c;
        double r12099730 = r12099729 / r12099726;
        double r12099731 = a;
        double r12099732 = r12099726 / r12099731;
        double r12099733 = r12099730 - r12099732;
        double r12099734 = -4.687918346756617e-254;
        bool r12099735 = r12099726 <= r12099734;
        double r12099736 = r12099726 * r12099726;
        double r12099737 = 4.0;
        double r12099738 = r12099729 * r12099731;
        double r12099739 = r12099737 * r12099738;
        double r12099740 = r12099736 - r12099739;
        double r12099741 = sqrt(r12099740);
        double r12099742 = r12099741 - r12099726;
        double r12099743 = r12099742 / r12099731;
        double r12099744 = 0.5;
        double r12099745 = r12099743 * r12099744;
        double r12099746 = 3.463606471108268e+121;
        bool r12099747 = r12099726 <= r12099746;
        double r12099748 = -2.0;
        double r12099749 = r12099729 * r12099748;
        double r12099750 = r12099741 + r12099726;
        double r12099751 = r12099749 / r12099750;
        double r12099752 = -r12099730;
        double r12099753 = r12099747 ? r12099751 : r12099752;
        double r12099754 = r12099735 ? r12099745 : r12099753;
        double r12099755 = r12099728 ? r12099733 : r12099754;
        return r12099755;
}

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

    1. Initial program 60.1

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

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

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

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

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

    if -3.263941314600607e+152 < b < -4.687918346756617e-254

    1. Initial program 7.8

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right)}}{2 \cdot a}\]
    5. Applied associate-/l*8.0

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

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

      \[\leadsto \frac{1}{\color{blue}{\frac{2}{1} \cdot \frac{a}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}}}\]
    9. Applied *-un-lft-identity8.0

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

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

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

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

    if -4.687918346756617e-254 < b < 3.463606471108268e+121

    1. Initial program 31.6

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

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

      \[\leadsto \frac{\color{blue}{1 \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b\right)}}{2 \cdot a}\]
    5. Applied associate-/l*31.7

      \[\leadsto \color{blue}{\frac{1}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}}}\]
    6. Using strategy rm
    7. Applied flip--31.8

      \[\leadsto \frac{1}{\frac{2 \cdot a}{\color{blue}{\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b \cdot b}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}}}}\]
    8. Applied associate-/r/31.9

      \[\leadsto \frac{1}{\color{blue}{\frac{2 \cdot a}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} \cdot \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b \cdot b} \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b\right)}}\]
    9. Applied associate-/r*31.9

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

      \[\leadsto \frac{\color{blue}{\frac{0 - \left(c \cdot a\right) \cdot 4}{a \cdot 2}}}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}\]
    11. Taylor expanded around 0 8.7

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

    if 3.463606471108268e+121 < b

    1. Initial program 59.8

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

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

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le -3.263941314600607 \cdot 10^{+152}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le -4.687918346756617 \cdot 10^{-254}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} - b}{a} \cdot \frac{1}{2}\\ \mathbf{elif}\;b \le 3.463606471108268 \cdot 10^{+121}:\\ \;\;\;\;\frac{c \cdot -2}{\sqrt{b \cdot b - 4 \cdot \left(c \cdot a\right)} + b}\\ \mathbf{else}:\\ \;\;\;\;-\frac{c}{b}\\ \end{array}\]

Reproduce

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