\[\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: 20.2 s
Input Error: 20.4
Output Error: 6.2
Log:
Profile: 🕒
\(\begin{cases} \begin{cases} \frac{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)}{a \cdot 2} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases} & \text{when } b \le -4.191830935951668 \cdot 10^{+150} \\ \begin{cases} \frac{b}{a} \cdot \frac{-2}{2} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}} & \text{otherwise} \end{cases} & \text{when } b \le 4.2941756400879677 \cdot 10^{-302} \\ \begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - c \cdot \left(4 \cdot a\right)}}{a \cdot 2} & \text{when } b \ge 0 \\ \frac{\frac{-2}{a} \cdot \frac{c}{4}}{\frac{b}{a \cdot 2}} & \text{otherwise} \end{cases} & \text{when } b \le 3.4791896352684183 \cdot 10^{+99} \\ \frac{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)}{a \cdot 2} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases}\)

    if b < -4.191830935951668e+150 or 3.4791896352684183e+99 < 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}\]
      41.8
    2. Using strategy rm
      41.8
    3. Applied add-sqr-sqrt 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) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}} & \text{otherwise} \end{cases}\]
      41.8
    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) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - \left(b - 2 \cdot \frac{c \cdot a}{b}\right)}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2} & \text{otherwise} \end{cases}\]
      25.8
    5. Taylor expanded around inf to get
      \[\begin{cases} \frac{\left(-b\right) - \color{red}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right)}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - \color{blue}{\left(b - 2 \cdot \frac{c \cdot a}{b}\right)}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2} & \text{otherwise} \end{cases}\]
      25.8
    6. Applied simplify to get
      \[\color{red}{\begin{cases} \frac{\left(-b\right) - \left(b - 2 \cdot \frac{c \cdot a}{b}\right)}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2} & \text{otherwise} \end{cases}} \leadsto \color{blue}{\begin{cases} \frac{\left(\left(-b\right) - b\right) + \left(2 \cdot a\right) \cdot \frac{c}{b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)} + \left(-b\right)} & \text{otherwise} \end{cases}}\]
      21.5
    7. Applied taylor to get
      \[\begin{cases} \frac{\left(\left(-b\right) - b\right) + \left(2 \cdot a\right) \cdot \frac{c}{b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)} + \left(-b\right)} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(\left(-b\right) - b\right) + \left(2 \cdot a\right) \cdot \frac{c}{b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)} & \text{otherwise} \end{cases}\]
      4.8
    8. Taylor expanded around -inf to get
      \[\begin{cases} \frac{\left(\left(-b\right) - b\right) + \left(2 \cdot a\right) \cdot \frac{c}{b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{\color{red}{2 \cdot c}}{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(\left(-b\right) - b\right) + \left(2 \cdot a\right) \cdot \frac{c}{b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{\color{blue}{2 \cdot c}}{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)} & \text{otherwise} \end{cases}\]
      4.8
    9. Applied simplify to get
      \[\begin{cases} \frac{\left(\left(-b\right) - b\right) + \left(2 \cdot a\right) \cdot \frac{c}{b}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(2 \cdot \frac{c \cdot a}{b} - b\right) + \left(-b\right)} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)}{a \cdot 2} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\left(a \cdot 2\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases}\]
      1.5

    10. Applied final simplification

    if -4.191830935951668e+150 < b < 4.2941756400879677e-302

    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}\]
      9.7
    2. Using strategy rm
      9.7
    3. Applied flip-- to get
      \[\begin{cases} \frac{\color{red}{\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} \leadsto \begin{cases} \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} & \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}\]
      9.7
    4. Applied simplify to get
      \[\begin{cases} \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} & \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{\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} & \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}\]
      9.7
    5. Applied taylor to get
      \[\begin{cases} \frac{\frac{\left(4 \cdot a\right) \cdot c}{\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} \leadsto \begin{cases} \frac{-2 \cdot b}{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}\]
      8.7
    6. Taylor expanded around 0 to get
      \[\begin{cases} \frac{\color{red}{-2 \cdot b}}{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{\color{blue}{-2 \cdot b}}{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}\]
      8.7
    7. Applied simplify to get
      \[\begin{cases} \frac{-2 \cdot b}{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{b}{a} \cdot \frac{-2}{2} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\left(-b\right) + \sqrt{{b}^2 - 4 \cdot \left(a \cdot c\right)}} & \text{otherwise} \end{cases}\]
      8.6

    8. Applied final simplification

    if 4.2941756400879677e-302 < b < 3.4791896352684183e+99

    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}\]
      8.8
    2. Using strategy rm
      8.8
    3. Applied flip-+ 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 \\ \color{red}{\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) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \color{blue}{\frac{2 \cdot c}{\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}}}} & \text{otherwise} \end{cases}\]
      8.8
    4. Applied simplify 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{\color{red}{2 \cdot c}}{\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}}} & \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{\color{blue}{2 \cdot c}}{\frac{\left(4 \cdot a\right) \cdot c}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}} & \text{otherwise} \end{cases}\]
      8.8
    5. 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}{\frac{\left(4 \cdot a\right) \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) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{\frac{\left(4 \cdot a\right) \cdot c}{-2 \cdot \frac{c \cdot a}{b}}} & \text{otherwise} \end{cases}\]
      8.8
    6. Taylor expanded around -inf 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}{\frac{\left(4 \cdot a\right) \cdot c}{-2 \cdot \frac{c \cdot a}{b}}}} & \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}{\frac{\left(4 \cdot a\right) \cdot c}{-2 \cdot \frac{c \cdot a}{b}}}} & \text{otherwise} \end{cases}\]
      8.8
    7. Applied simplify 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}{\frac{\left(4 \cdot a\right) \cdot c}{-2 \cdot \frac{c \cdot a}{b}}} & \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 \\ \left(\frac{c}{4} \cdot \frac{-2}{a}\right) \cdot \frac{\frac{2}{1}}{\frac{b}{a}} & \text{otherwise} \end{cases}\]
      8.7

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

  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)))))))