\[\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
Test:
jeff quadratic root 1
Bits:
128 bits
Bits error versus a
Bits error versus b
Bits error versus c
Time: 24.0 s
Input Error: 10.0
Output Error: 2.7
Log:
Profile: 🕒
\(\begin{cases} \begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - a \cdot \left(c \cdot 4\right)}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\frac{c \cdot 2}{\frac{b}{a}} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases} & \text{when } b \le -7.0905583f+15 \\ \begin{cases} \frac{\left(-b\right) - {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases} & \text{when } b \le 4.0821213f+08 \\ \frac{\frac{c}{b}}{1} - \frac{\frac{b}{2}}{\frac{a}{2}} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4} + \left(-b\right)} & \text{otherwise} \end{cases}\)

    if b < -7.0905583f+15

    1. Started with
      \[\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      17.5
    2. Using strategy rm
      17.5
    3. Applied add-sqr-sqrt to get
      \[\begin{cases} \frac{\left(-b\right) - \color{red}{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - \color{blue}{{\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      17.5
    4. Applied taylor to get
      \[\begin{cases} \frac{\left(-b\right) - {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} - b\right)} & \text{otherwise} \end{cases}\]
      4.3
    5. Taylor expanded around -inf to get
      \[\begin{cases} \frac{\left(-b\right) - {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\color{red}{\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} - b\right)}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\color{blue}{\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} - b\right)}} & \text{otherwise} \end{cases}\]
      4.3
    6. Applied simplify to get
      \[\begin{cases} \frac{\left(-b\right) - {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \left(2 \cdot \frac{c \cdot a}{b} - b\right)} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - a \cdot \left(c \cdot 4\right)}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\frac{c \cdot 2}{\frac{b}{a}} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases}\]
      0.7

    7. Applied final simplification

    if -7.0905583f+15 < b < 4.0821213f+08

    1. Started with
      \[\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      4.1
    2. Using strategy rm
      4.1
    3. Applied add-sqr-sqrt to get
      \[\begin{cases} \frac{\left(-b\right) - \color{red}{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - \color{blue}{{\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      4.2

    if 4.0821213f+08 < b

    1. Started with
      \[\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      20.3
    2. Using strategy rm
      20.3
    3. Applied add-exp-log to get
      \[\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\color{red}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\color{blue}{\left(-b\right) + e^{\log \left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}}} & \text{otherwise} \end{cases}\]
      20.3
    4. Applied taylor to get
      \[\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + e^{\log \left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + e^{\log \left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}} & \text{otherwise} \end{cases}\]
      5.5
    5. Taylor expanded around inf to get
      \[\begin{cases} \frac{\color{red}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + e^{\log \left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + e^{\log \left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}} & \text{otherwise} \end{cases}\]
      5.5
    6. Applied simplify to get
      \[\begin{cases} \frac{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + e^{\log \left(\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}\right)}} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{2}{a} \cdot \left(\frac{\frac{c}{b}}{\frac{2}{a}} - \frac{b}{2}\right) & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      1.3

    7. Applied final simplification
    8. Applied simplify to get
      \[\color{red}{\begin{cases} \frac{2}{a} \cdot \left(\frac{\frac{c}{b}}{\frac{2}{a}} - \frac{b}{2}\right) & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}} \leadsto \color{blue}{\begin{cases} \frac{\frac{c}{b}}{1} - \frac{\frac{b}{2}}{\frac{a}{2}} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4} + \left(-b\right)} & \text{otherwise} \end{cases}}\]
      0.0

  1. Removed slow pow expressions

Original test:


(lambda ((a default) (b default) (c default))
  #:name "jeff quadratic root 1"
  (if (>= b 0) (/ (- (- b) (sqrt (- (sqr b) (* (* 4 a) c)))) (* 2 a)) (/ (* 2 c) (+ (- b) (sqrt (- (sqr b) (* (* 4 a) c)))))))