\[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
Test:
The quadratic formula (r2)
Bits:
128 bits
Bits error versus a
Bits error versus b
Bits error versus c
Time: 49.2 s
Input Error: 35.9
Output Error: 6.3
Log:
Profile: 🕒
\(\begin{cases} \frac{c}{b} \cdot \frac{-2}{2} & \text{when } b \le -1.6322467053286328 \cdot 10^{+86} \\ \frac{\left(c \cdot 4\right) \cdot a}{(\left(\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}\right) * \left(2 \cdot a\right) + \left(\left(-b\right) \cdot \left(2 \cdot a\right)\right))_*} & \text{when } b \le -0.004845025334922612 \\ \frac{c}{b} \cdot \frac{-2}{2} & \text{when } b \le -1.0745984396746834 \cdot 10^{-89} \\ \frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} & \text{when } b \le 3.741572576046744 \cdot 10^{+123} \\ \left(\frac{c}{b} + \frac{-b}{2 \cdot a}\right) - \frac{\frac{b}{2}}{a} & \text{otherwise} \end{cases}\)

    if b < -1.6322467053286328e+86 or -0.004845025334922612 < b < -1.0745984396746834e-89

    1. Started with
      \[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
      58.9
    2. Applied taylor to get
      \[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \leadsto \frac{-2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}\]
      15.7
    3. Taylor expanded around -inf to get
      \[\frac{\color{red}{-2 \cdot \frac{c \cdot a}{b}}}{2 \cdot a} \leadsto \frac{\color{blue}{-2 \cdot \frac{c \cdot a}{b}}}{2 \cdot a}\]
      15.7
    4. Applied simplify to get
      \[\color{red}{\frac{-2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}} \leadsto \color{blue}{\frac{c}{b} \cdot \frac{-2}{2}}\]
      0

    if -1.6322467053286328e+86 < b < -0.004845025334922612

    1. Started with
      \[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
      47.6
    2. Using strategy rm
      47.6
    3. Applied flip-- to get
      \[\frac{\color{red}{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a} \leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^2 - {\left(\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)}^2}{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}}}{2 \cdot a}\]
      47.7
    4. Applied associate-/l/ to get
      \[\color{red}{\frac{\frac{{\left(-b\right)}^2 - {\left(\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)}^2}{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}}{2 \cdot a}} \leadsto \color{blue}{\frac{{\left(-b\right)}^2 - {\left(\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)}^2}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)}}\]
      49.7
    5. Applied taylor to get
      \[\frac{{\left(-b\right)}^2 - {\left(\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)}^2}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)} \leadsto \frac{4 \cdot \left(c \cdot a\right)}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)}\]
      13.5
    6. Taylor expanded around inf to get
      \[\frac{\color{red}{4 \cdot \left(c \cdot a\right)}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)} \leadsto \frac{\color{blue}{4 \cdot \left(c \cdot a\right)}}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)}\]
      13.5
    7. Applied simplify to get
      \[\frac{4 \cdot \left(c \cdot a\right)}{\left(2 \cdot a\right) \cdot \left(\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}\right)} \leadsto \frac{\left(c \cdot 4\right) \cdot a}{(\left(\sqrt{b \cdot b - \left(c \cdot 4\right) \cdot a}\right) * \left(2 \cdot a\right) + \left(\left(-b\right) \cdot \left(2 \cdot a\right)\right))_*}\]
      13.6

    8. Applied final simplification

    if -1.0745984396746834e-89 < b < 3.741572576046744e+123

    1. Started with
      \[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
      11.7
    2. Using strategy rm
      11.7
    3. Applied div-sub to get
      \[\color{red}{\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \leadsto \color{blue}{\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\]
      11.7

    if 3.741572576046744e+123 < b

    1. Started with
      \[\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}\]
      51.0
    2. Using strategy rm
      51.0
    3. Applied div-sub to get
      \[\color{red}{\frac{\left(-b\right) - \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}} \leadsto \color{blue}{\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a}}\]
      51.0
    4. Applied taylor to get
      \[\frac{-b}{2 \cdot a} - \frac{\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}}{2 \cdot a} \leadsto \frac{-b}{2 \cdot a} - \frac{b - 2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}\]
      12.7
    5. Taylor expanded around inf to get
      \[\frac{-b}{2 \cdot a} - \frac{\color{red}{b - 2 \cdot \frac{c \cdot a}{b}}}{2 \cdot a} \leadsto \frac{-b}{2 \cdot a} - \frac{\color{blue}{b - 2 \cdot \frac{c \cdot a}{b}}}{2 \cdot a}\]
      12.7
    6. Applied simplify to get
      \[\color{red}{\frac{-b}{2 \cdot a} - \frac{b - 2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}} \leadsto \color{blue}{\left(\frac{\frac{c}{b}}{1} + \frac{-b}{2 \cdot a}\right) - \frac{\frac{b}{2}}{a}}\]
      0.0
    7. Applied simplify to get
      \[\color{red}{\left(\frac{\frac{c}{b}}{1} + \frac{-b}{2 \cdot a}\right)} - \frac{\frac{b}{2}}{a} \leadsto \color{blue}{\left(\frac{c}{b} + \frac{-b}{2 \cdot a}\right)} - \frac{\frac{b}{2}}{a}\]
      0.0

  1. Removed slow pow expressions

Original test:


(lambda ((a default) (b default) (c default))
  #:name "The quadratic formula (r2)"
  (/ (- (- b) (sqrt (- (sqr b) (* 4 (* a c))))) (* 2 a))
  #:target
  (if (< b 0) (/ c (* a (/ (+ (- b) (sqrt (- (sqr b) (* 4 (* a c))))) (* 2 a)))) (/ (- (- b) (sqrt (- (sqr b) (* 4 (* a c))))) (* 2 a))))