\[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{otherwise} \end{cases}\]
Test:
jeff quadratic root 2
Bits:
128 bits
Bits error versus a
Bits error versus b
Bits error versus c
Time: 22.7 s
Input Error: 22.6
Output Error: 3.5
Log:
Profile: 🕒
\(\begin{cases} \begin{cases} \frac{c \cdot 2}{\left(-b\right) - \sqrt{b - \sqrt{\left(4 \cdot a\right) \cdot c}} \cdot \sqrt{b + \sqrt{\left(4 \cdot a\right) \cdot c}}} & \text{when } b \ge 0 \\ \frac{\frac{c \cdot 2}{\frac{b}{a}} - \left(b - \left(-b\right)\right)}{2 \cdot a} & \text{otherwise} \end{cases} & \text{when } {b}^2 - \left(4 \cdot a\right) \cdot c \le 2.5634812188193 \cdot 10^{-315} \\ \begin{cases} \frac{2 \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{2 \cdot a} & \text{otherwise} \end{cases} & \text{when } {b}^2 - \left(4 \cdot a\right) \cdot c \le 5.685096271129504 \cdot 10^{+306} \\ \frac{c}{\frac{a}{b} \cdot c - b} & \text{when } b \ge 0 \\ \frac{c}{b} - \frac{b - \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases}\)

    if (- (sqr b) (* (* 4 a) c)) < 2.5634812188193e-315

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

    9. Applied final simplification

    if 2.5634812188193e-315 < (- (sqr b) (* (* 4 a) c)) < 5.685096271129504e+306

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

    if 5.685096271129504e+306 < (- (sqr b) (* (* 4 a) c))

    1. Started with
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{otherwise} \end{cases}\]
      46.1
    2. Applied taylor to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{otherwise} \end{cases}\]
      29.4
    3. Taylor expanded around inf to get
      \[\begin{cases} \frac{2 \cdot c}{\color{red}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{2 \cdot c}{\color{blue}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{otherwise} \end{cases}\]
      29.4
    4. Applied simplify to get
      \[\color{red}{\begin{cases} \frac{2 \cdot c}{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{otherwise} \end{cases}} \leadsto \color{blue}{\begin{cases} \frac{c}{\frac{c}{b} \cdot a - b} & \text{when } b \ge 0 \\ \frac{\sqrt{{b}^2 - \left(c \cdot a\right) \cdot 4} + \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases}}\]
      26.1
    5. Applied taylor to get
      \[\begin{cases} \frac{c}{\frac{c}{b} \cdot a - b} & \text{when } b \ge 0 \\ \frac{\sqrt{{b}^2 - \left(c \cdot a\right) \cdot 4} + \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{c}{\frac{c}{b} \cdot a - b} & \text{when } b \ge 0 \\ \frac{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases}\]
      10.1
    6. Taylor expanded around -inf to get
      \[\begin{cases} \frac{c}{\frac{c}{b} \cdot a - b} & \text{when } b \ge 0 \\ \frac{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{c}{\frac{c}{b} \cdot a - b} & \text{when } b \ge 0 \\ \frac{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases}\]
      10.1
    7. Applied simplify to get
      \[\color{red}{\begin{cases} \frac{c}{\frac{c}{b} \cdot a - b} & \text{when } b \ge 0 \\ \frac{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases}} \leadsto \color{blue}{\begin{cases} \frac{c}{\frac{a}{b} \cdot c - b} & \text{when } b \ge 0 \\ \frac{c}{b} - \frac{b - \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases}}\]
      2.9

  1. Removed slow pow expressions

Original test:


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