Average Error: 19.5 → 13.0
Time: 35.7s
Precision: 64
\[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
\[\begin{array}{l} \mathbf{if}\;b \le 2.475379926589225 \cdot 10^{+136}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(a \cdot c\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{4}} \cdot {\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{4}} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{2}} - b}{2 \cdot a}\\ \end{array}\]
\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\

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

\end{array}
\begin{array}{l}
\mathbf{if}\;b \le 2.475379926589225 \cdot 10^{+136}:\\
\;\;\;\;\begin{array}{l}
\mathbf{if}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(a \cdot c\right), \left(b \cdot b\right)\right)}}\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{4}} \cdot {\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{4}} - b}{2 \cdot a}\\

\end{array}\\

\mathbf{elif}\;b \ge 0:\\
\;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\

\mathbf{else}:\\
\;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{2}} - b}{2 \cdot a}\\

\end{array}
double f(double a, double b, double c) {
        double r920781 = b;
        double r920782 = 0.0;
        bool r920783 = r920781 >= r920782;
        double r920784 = 2.0;
        double r920785 = c;
        double r920786 = r920784 * r920785;
        double r920787 = -r920781;
        double r920788 = r920781 * r920781;
        double r920789 = 4.0;
        double r920790 = a;
        double r920791 = r920789 * r920790;
        double r920792 = r920791 * r920785;
        double r920793 = r920788 - r920792;
        double r920794 = sqrt(r920793);
        double r920795 = r920787 - r920794;
        double r920796 = r920786 / r920795;
        double r920797 = r920787 + r920794;
        double r920798 = r920784 * r920790;
        double r920799 = r920797 / r920798;
        double r920800 = r920783 ? r920796 : r920799;
        return r920800;
}

double f(double a, double b, double c) {
        double r920801 = b;
        double r920802 = 2.475379926589225e+136;
        bool r920803 = r920801 <= r920802;
        double r920804 = 0.0;
        bool r920805 = r920801 >= r920804;
        double r920806 = 2.0;
        double r920807 = c;
        double r920808 = r920806 * r920807;
        double r920809 = -r920801;
        double r920810 = -4.0;
        double r920811 = a;
        double r920812 = r920811 * r920807;
        double r920813 = r920801 * r920801;
        double r920814 = fma(r920810, r920812, r920813);
        double r920815 = sqrt(r920814);
        double r920816 = r920809 - r920815;
        double r920817 = r920808 / r920816;
        double r920818 = r920810 * r920811;
        double r920819 = fma(r920818, r920807, r920813);
        double r920820 = 0.25;
        double r920821 = pow(r920819, r920820);
        double r920822 = r920821 * r920821;
        double r920823 = r920822 - r920801;
        double r920824 = r920806 * r920811;
        double r920825 = r920823 / r920824;
        double r920826 = r920805 ? r920817 : r920825;
        double r920827 = r920809 - r920801;
        double r920828 = r920808 / r920827;
        double r920829 = 0.5;
        double r920830 = pow(r920819, r920829);
        double r920831 = r920830 - r920801;
        double r920832 = r920831 / r920824;
        double r920833 = r920805 ? r920828 : r920832;
        double r920834 = r920803 ? r920826 : r920833;
        return r920834;
}

Error

Bits error versus a

Bits error versus b

Bits error versus c

Derivation

  1. Split input into 2 regimes
  2. if b < 2.475379926589225e+136

    1. Initial program 15.6

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified15.6

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} - b}{2 \cdot a}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt15.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}} - b}{2 \cdot a}\\ \end{array}\]
    5. Using strategy rm
    6. Applied pow115.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1}} - b}{2 \cdot a}\\ \end{array}\]
    7. Applied pow115.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{{\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1} \cdot {\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1}} - b}{2 \cdot a}\\ \end{array}\]
    8. Applied pow-prod-down15.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{{\left(\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1}} - b}{2 \cdot a}\\ \end{array}\]
    9. Applied sqrt-pow115.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{\left(\frac{1}{2}\right)} - b}{2 \cdot a}\\ \end{array}\]
    10. Simplified15.6

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\left(\frac{1}{2}\right)} - b}{2 \cdot a}\\ \end{array}\]
    11. Using strategy rm
    12. Applied sqr-pow15.7

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} \cdot {\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\left(\frac{\frac{1}{2}}{2}\right)} - b}{2 \cdot a}\\ \end{array}\]

    if 2.475379926589225e+136 < b

    1. Initial program 34.9

      \[\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\\ \end{array}\]
    2. Simplified34.8

      \[\leadsto \color{blue}{\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} - b}{2 \cdot a}\\ \end{array}}\]
    3. Using strategy rm
    4. Applied add-cube-cbrt34.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}} - b}{2 \cdot a}\\ \end{array}\]
    5. Using strategy rm
    6. Applied pow134.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot {\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1}} - b}{2 \cdot a}\\ \end{array}\]
    7. Applied pow134.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{{\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1} \cdot {\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1}} - b}{2 \cdot a}\\ \end{array}\]
    8. Applied pow-prod-down34.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{\sqrt{{\left(\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{1}} - b}{2 \cdot a}\\ \end{array}\]
    9. Applied sqrt-pow134.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\left(\sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)} \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right) \cdot \sqrt[3]{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}\right)}^{\left(\frac{1}{2}\right)} - b}{2 \cdot a}\\ \end{array}\]
    10. Simplified34.8

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(c \cdot a\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\left(\frac{1}{2}\right)} - b}{2 \cdot a}\\ \end{array}\]
    11. Taylor expanded around 0 2.3

      \[\leadsto \begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \color{blue}{b}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\left(\frac{1}{2}\right)} - b}{2 \cdot a}\\ \end{array}\]
  3. Recombined 2 regimes into one program.
  4. Final simplification13.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \le 2.475379926589225 \cdot 10^{+136}:\\ \;\;\;\;\begin{array}{l} \mathbf{if}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-4, \left(a \cdot c\right), \left(b \cdot b\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{4}} \cdot {\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{4}} - b}{2 \cdot a}\\ \end{array}\\ \mathbf{elif}\;b \ge 0:\\ \;\;\;\;\frac{2 \cdot c}{\left(-b\right) - b}\\ \mathbf{else}:\\ \;\;\;\;\frac{{\left(\mathsf{fma}\left(\left(-4 \cdot a\right), c, \left(b \cdot b\right)\right)\right)}^{\frac{1}{2}} - b}{2 \cdot a}\\ \end{array}\]

Reproduce

herbie shell --seed 2019121 +o rules:numerics
(FPCore (a b c)
  :name "jeff quadratic root 2"
  (if (>= b 0) (/ (* 2 c) (- (- b) (sqrt (- (* b b) (* (* 4 a) c))))) (/ (+ (- b) (sqrt (- (* b b) (* (* 4 a) c)))) (* 2 a))))