Average Error: 33.5 → 8.7
Time: 49.4s
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 -1.4645165627901968 \cdot 10^{+147}:\\ \;\;\;\;\frac{c}{b} - \frac{b}{a}\\ \mathbf{elif}\;b \le 3.2059736638617364 \cdot 10^{-150}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} - b}{a} \cdot \frac{1}{2}\\ \mathbf{elif}\;b \le 8.834167001137509 \cdot 10^{-10}:\\ \;\;\;\;\frac{\left(c \cdot a\right) \cdot 4}{\frac{a}{\frac{1}{2}}} \cdot \frac{-1}{b + \sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4}}\\ \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 -1.4645165627901968 \cdot 10^{+147}:\\
\;\;\;\;\frac{c}{b} - \frac{b}{a}\\

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

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

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

\end{array}
double f(double a, double b, double c) {
        double r3663776 = b;
        double r3663777 = -r3663776;
        double r3663778 = r3663776 * r3663776;
        double r3663779 = 4.0;
        double r3663780 = a;
        double r3663781 = r3663779 * r3663780;
        double r3663782 = c;
        double r3663783 = r3663781 * r3663782;
        double r3663784 = r3663778 - r3663783;
        double r3663785 = sqrt(r3663784);
        double r3663786 = r3663777 + r3663785;
        double r3663787 = 2.0;
        double r3663788 = r3663787 * r3663780;
        double r3663789 = r3663786 / r3663788;
        return r3663789;
}

double f(double a, double b, double c) {
        double r3663790 = b;
        double r3663791 = -1.4645165627901968e+147;
        bool r3663792 = r3663790 <= r3663791;
        double r3663793 = c;
        double r3663794 = r3663793 / r3663790;
        double r3663795 = a;
        double r3663796 = r3663790 / r3663795;
        double r3663797 = r3663794 - r3663796;
        double r3663798 = 3.2059736638617364e-150;
        bool r3663799 = r3663790 <= r3663798;
        double r3663800 = r3663790 * r3663790;
        double r3663801 = r3663793 * r3663795;
        double r3663802 = 4.0;
        double r3663803 = r3663801 * r3663802;
        double r3663804 = r3663800 - r3663803;
        double r3663805 = sqrt(r3663804);
        double r3663806 = r3663805 - r3663790;
        double r3663807 = r3663806 / r3663795;
        double r3663808 = 0.5;
        double r3663809 = r3663807 * r3663808;
        double r3663810 = 8.834167001137509e-10;
        bool r3663811 = r3663790 <= r3663810;
        double r3663812 = r3663795 / r3663808;
        double r3663813 = r3663803 / r3663812;
        double r3663814 = -1.0;
        double r3663815 = r3663790 + r3663805;
        double r3663816 = r3663814 / r3663815;
        double r3663817 = r3663813 * r3663816;
        double r3663818 = -r3663793;
        double r3663819 = r3663818 / r3663790;
        double r3663820 = r3663811 ? r3663817 : r3663819;
        double r3663821 = r3663799 ? r3663809 : r3663820;
        double r3663822 = r3663792 ? r3663797 : r3663821;
        return r3663822;
}

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 < -1.4645165627901968e+147

    1. Initial program 58.2

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

      \[\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.1

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

    if -1.4645165627901968e+147 < b < 3.2059736638617364e-150

    1. Initial program 10.5

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

      \[\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-identity10.5

      \[\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*10.6

      \[\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-identity10.6

      \[\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-frac10.6

      \[\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 add-sqr-sqrt10.6

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

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

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

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

    if 3.2059736638617364e-150 < b < 8.834167001137509e-10

    1. Initial program 32.0

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

      \[\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-identity32.0

      \[\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*32.1

      \[\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--32.2

      \[\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/32.2

      \[\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 *-un-lft-identity32.2

      \[\leadsto \frac{\color{blue}{1 \cdot 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} \cdot \left(\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b\right)}\]
    10. Applied times-frac32.3

      \[\leadsto \color{blue}{\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}} \cdot \frac{1}{\sqrt{b \cdot b - \left(c \cdot a\right) \cdot 4} + b}}\]
    11. Simplified16.5

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

    if 8.834167001137509e-10 < b

    1. Initial program 54.0

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

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

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

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

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

Reproduce

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