\[\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: 22.5 s
Input Error: 21.2
Output Error: 6.2
Log:
Profile: 🕒
\(\begin{cases} \begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot 4\right) \cdot a}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{(\left(a \cdot 2\right) * \left(\frac{c}{b}\right) + \left(-b\right))_* - b} & \text{otherwise} \end{cases} & \text{when } b \le -4.2041338255256416 \cdot 10^{+111} \\ \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} & \text{when } b \le 4.449432714488087 \cdot 10^{+57} \\ \frac{(\left(c \cdot \frac{a}{b}\right) * 2 + \left(\left(-b\right) - b\right))_*}{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}\)

    if b < -4.2041338255256416e+111

    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}\]
      32.2
    2. Using strategy rm
      32.2
    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}\]
      32.2
    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) - \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{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2} & \text{otherwise} \end{cases}\]
      8.3
    5. 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}{\left(-\color{red}{b}\right) + {\left(\sqrt{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2} & \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}{\left(-\color{blue}{b}\right) + {\left(\sqrt{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2} & \text{otherwise} \end{cases}\]
      8.3
    6. Applied simplify to get
      \[\color{red}{\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{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2} & \text{otherwise} \end{cases}} \leadsto \color{blue}{\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot 4\right) \cdot a}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\left(2 \cdot a\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases}}\]
      0.9
    7. Applied simplify to get
      \[\begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot 4\right) \cdot a}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{c \cdot 2}{\left(2 \cdot a\right) \cdot \frac{c}{b} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot 4\right) \cdot a}}{2 \cdot a} & \text{when } b \ge 0 \\ \frac{2 \cdot c}{(\left(a \cdot 2\right) * \left(\frac{c}{b}\right) + \left(-b\right))_* - b} & \text{otherwise} \end{cases}\]
      0.9

    if -4.2041338255256416e+111 < b < 4.449432714488087e+57

    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.5
    2. Using strategy rm
      9.5
    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}\]
      9.6

    if 4.449432714488087e+57 < 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.5
    2. Using strategy rm
      41.5
    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.5
    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}\]
      10.9
    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}\]
      10.9
    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(c \cdot \frac{a}{b}\right) * 2 + \left(\left(-b\right) - b\right))_*}{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}}\]
      2.3

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