\[\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: 26.6 s
Input Error: 9.8
Output Error: 2.7
Log:
Profile: 🕒
\(\begin{cases} \begin{cases} \frac{2 \cdot c}{\left(-b\right) - \frac{\sqrt{{b}^3 \cdot {b}^3 - {\left(c \cdot \left(4 \cdot a\right)\right)}^3}}{\sqrt{(\left(c \cdot \left(4 \cdot a\right)\right) * \left((c * \left(4 \cdot a\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\right))_*}}} & \text{when } b \ge 0 \\ 1 \cdot \frac{c}{b} - \frac{b - \left(-b\right)}{a \cdot 2} & \text{otherwise} \end{cases} & \text{when } b \le -1.3462214f+10 \\ \begin{cases} \frac{2 \cdot c}{\left(-b\right) - {\left(\sqrt{\sqrt{{b}^2 - \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} & \text{when } b \le 1.6720318f+16 \\ \frac{c}{{\left(\sqrt[3]{\frac{c}{b} \cdot a}\right)}^3 - 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}\)

    if b < -1.3462214f+10

    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}\]
      20.7
    2. Using strategy rm
      20.7
    3. Applied flip3-- to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \sqrt{\color{red}{{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{\color{blue}{\frac{{\left({b}^2\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}{{\left({b}^2\right)}^2 + \left({\left(\left(4 \cdot a\right) \cdot c\right)}^2 + {b}^2 \cdot \left(\left(4 \cdot a\right) \cdot c\right)\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}\]
      20.7
    4. Applied sqrt-div to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \color{red}{\sqrt{\frac{{\left({b}^2\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}{{\left({b}^2\right)}^2 + \left({\left(\left(4 \cdot a\right) \cdot c\right)}^2 + {b}^2 \cdot \left(\left(4 \cdot a\right) \cdot c\right)\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}{\frac{\sqrt{{\left({b}^2\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}{\sqrt{{\left({b}^2\right)}^2 + \left({\left(\left(4 \cdot a\right) \cdot c\right)}^2 + {b}^2 \cdot \left(\left(4 \cdot a\right) \cdot c\right)\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}\]
      20.7
    5. Applied simplify to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \frac{\color{red}{\sqrt{{\left({b}^2\right)}^{3} - {\left(\left(4 \cdot a\right) \cdot c\right)}^{3}}}}{\sqrt{{\left({b}^2\right)}^2 + \left({\left(\left(4 \cdot a\right) \cdot c\right)}^2 + {b}^2 \cdot \left(\left(4 \cdot a\right) \cdot c\right)\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) - \frac{\color{blue}{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}}{\sqrt{{\left({b}^2\right)}^2 + \left({\left(\left(4 \cdot a\right) \cdot c\right)}^2 + {b}^2 \cdot \left(\left(4 \cdot a\right) \cdot c\right)\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}\]
      20.7
    6. Applied simplify to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \frac{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}{\color{red}{\sqrt{{\left({b}^2\right)}^2 + \left({\left(\left(4 \cdot a\right) \cdot c\right)}^2 + {b}^2 \cdot \left(\left(4 \cdot a\right) \cdot c\right)\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) - \frac{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}{\color{blue}{\sqrt{(\left(a \cdot \left(c \cdot 4\right)\right) * \left((c * \left(a \cdot 4\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\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}\]
      20.7
    7. Applied taylor to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \frac{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}{\sqrt{(\left(a \cdot \left(c \cdot 4\right)\right) * \left((c * \left(a \cdot 4\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\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) - \frac{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}{\sqrt{(\left(a \cdot \left(c \cdot 4\right)\right) * \left((c * \left(a \cdot 4\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\right))_*}}} & \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}\]
      5.8
    8. Taylor expanded around -inf to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \frac{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}{\sqrt{(\left(a \cdot \left(c \cdot 4\right)\right) * \left((c * \left(a \cdot 4\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\right))_*}}} & \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) - \frac{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}{\sqrt{(\left(a \cdot \left(c \cdot 4\right)\right) * \left((c * \left(a \cdot 4\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\right))_*}}} & \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}\]
      5.8
    9. Applied simplify to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \frac{\sqrt{{\left({b}^3\right)}^2 - {\left(a \cdot \left(c \cdot 4\right)\right)}^3}}{\sqrt{(\left(a \cdot \left(c \cdot 4\right)\right) * \left((c * \left(a \cdot 4\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\right))_*}}} & \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) - \frac{\sqrt{{b}^3 \cdot {b}^3 - {\left(\left(a \cdot c\right) \cdot 4\right)}^3}}{\sqrt{(\left(\left(a \cdot c\right) \cdot 4\right) * \left((c * \left(a \cdot 4\right) + \left({b}^2\right))_*\right) + \left({b}^2 \cdot {b}^2\right))_*}}} & \text{when } b \ge 0 \\ \frac{\frac{c \cdot 2}{\frac{b}{a}} - \left(b - \left(-b\right)\right)}{a \cdot 2} & \text{otherwise} \end{cases}\]
      1.6

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

    if -1.3462214f+10 < b < 1.6720318f+16

    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}\]
      4.0
    2. Using strategy rm
      4.0
    3. Applied add-sqr-sqrt to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \color{red}{\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) - \color{blue}{{\left(\sqrt{\sqrt{{b}^2 - \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}\]
      4.1

    if 1.6720318f+16 < b

    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}\]
      17.0
    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}\]
      4.0
    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}\]
      4.0
    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}}\]
      0.4
    5. Using strategy rm
      0.4
    6. Applied add-cube-cbrt to get
      \[\begin{cases} \frac{c}{\color{red}{\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}{\color{blue}{{\left(\sqrt[3]{\frac{c}{b} \cdot a}\right)}^3} - 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}\]
      0.4

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