\[\frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
Test:
The quadratic formula (r1)
Bits:
128 bits
Bits error versus a
Bits error versus b
Bits error versus c
Time: 23.8 s
Input Error: 16.3
Output Error: 2.7
Log:
Profile: 🕒
\(\begin{cases} \frac{\frac{2 \cdot c}{\frac{b}{a}} - \left(b - \left(-b\right)\right)}{a \cdot 2} & \text{when } b \le -1.0189882f+17 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(c \cdot a\right)}}{2 \cdot a} & \text{when } b \le 4.7617268f-36 \\ \frac{1}{2} \cdot \frac{4 \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot a\right) \cdot 4}} & \text{when } b \le 6.8314427f+10 \\ \frac{c}{b} \cdot \frac{-2}{2} & \text{otherwise} \end{cases}\)

    if b < -1.0189882f+17

    1. Started with
      \[\frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
      25.5
    2. Using strategy rm
      25.5
    3. Applied add-exp-log to get
      \[\frac{\color{red}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \leadsto \frac{\color{blue}{e^{\log \left(\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}}}{2 \cdot a}\]
      25.9
    4. Applied taylor to get
      \[\frac{e^{\log \left(\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}}{2 \cdot a} \leadsto \frac{e^{\log \left(\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} - b\right)\right)}}{2 \cdot a}\]
      8.9
    5. Taylor expanded around -inf to get
      \[\frac{e^{\log \left(\left(-b\right) + \color{red}{\left(2 \cdot \frac{c \cdot a}{b} - b\right)}\right)}}{2 \cdot a} \leadsto \frac{e^{\log \left(\left(-b\right) + \color{blue}{\left(2 \cdot \frac{c \cdot a}{b} - b\right)}\right)}}{2 \cdot a}\]
      8.9
    6. Applied simplify to get
      \[\frac{e^{\log \left(\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} - b\right)\right)}}{2 \cdot a} \leadsto \frac{\frac{2 \cdot c}{\frac{b}{a}} - \left(b - \left(-b\right)\right)}{a \cdot 2}\]
      1.0

    7. Applied final simplification

    if -1.0189882f+17 < b < 4.7617268f-36

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

    if 4.7617268f-36 < b < 6.8314427f+10

    1. Started with
      \[\frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
      14.7
    2. Using strategy rm
      14.7
    3. Applied flip-+ to get
      \[\frac{\color{red}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \leadsto \frac{\color{blue}{\frac{{\left(-b\right)}^2 - {\left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}^2}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
      15.3
    4. Applied simplify to get
      \[\frac{\frac{\color{red}{{\left(-b\right)}^2 - {\left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}^2}}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} \leadsto \frac{\frac{\color{blue}{\left(4 \cdot a\right) \cdot c}}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}\]
      7.1
    5. Using strategy rm
      7.1
    6. Applied *-un-lft-identity to get
      \[\frac{\color{red}{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a} \leadsto \frac{\color{blue}{1 \cdot \frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}}{2 \cdot a}\]
      7.1
    7. Applied times-frac to get
      \[\color{red}{\frac{1 \cdot \frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a}} \leadsto \color{blue}{\frac{1}{2} \cdot \frac{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{a}}\]
      7.1
    8. Applied simplify to get
      \[\frac{1}{2} \cdot \color{red}{\frac{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{a}} \leadsto \frac{1}{2} \cdot \color{blue}{\frac{4 \cdot c}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}}\]
      4.2
    9. Applied simplify to get
      \[\frac{1}{2} \cdot \frac{4 \cdot c}{\color{red}{\left(-b\right) - \sqrt{b \cdot b - \left(4 \cdot c\right) \cdot a}}} \leadsto \frac{1}{2} \cdot \frac{4 \cdot c}{\color{blue}{\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot a\right) \cdot 4}}}\]
      4.3

    if 6.8314427f+10 < b

    1. Started with
      \[\frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}\]
      28.6
    2. Applied taylor to get
      \[\frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leadsto \frac{-2 \cdot \frac{c \cdot a}{b}}{2 \cdot a}\]
      6.9
    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}\]
      6.9
    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

  1. Removed slow pow expressions

Original test:


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