\[\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: 20.8 s
Input Error: 20.0
Output Error: 6.1
Log:
Profile: 🕒
\(\begin{cases} \begin{cases} \frac{c \cdot 2}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot c\right) \cdot a}} & \text{when } b \ge 0 \\ \frac{c}{b} - \frac{b}{a} & \text{otherwise} \end{cases} & \text{when } b \le -1.9477068539312885 \cdot 10^{+142} \\ \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 2.2736054037680634 \cdot 10^{+124} \\ \frac{c \cdot 2}{(\left(\frac{c}{\frac{b}{a}}\right) * 2 + \left(\left(-b\right) - b\right))_*} & \text{when } b \ge 0 \\ \frac{\frac{{\left(\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4}\right)}^{3} - {\left(-b\right)}^{3}}{(\left(-b\right) * \left(\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot 4\right) \cdot a}\right) + \left({b}^2 - \left(c \cdot 4\right) \cdot a\right))_*}}{2 \cdot a} & \text{otherwise} \end{cases}\)

    if b < -1.9477068539312885e+142

    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}\]
      57.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}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{when } b \ge 0 \\ \frac{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{2 \cdot a} & \text{otherwise} \end{cases}\]
      12.6
    3. Taylor expanded around -inf 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{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{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{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{2 \cdot a} & \text{otherwise} \end{cases}\]
      12.6
    4. Applied simplify to get
      \[\color{red}{\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{2 \cdot \frac{c \cdot a}{b} - 2 \cdot b}{2 \cdot a} & \text{otherwise} \end{cases}} \leadsto \color{blue}{\begin{cases} \frac{c \cdot 2}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot c\right) \cdot a}} & \text{when } b \ge 0 \\ \frac{\frac{c}{b}}{1} - \frac{b}{a} & \text{otherwise} \end{cases}}\]
      0.0
    5. Applied simplify to get
      \[\begin{cases} \frac{c \cdot 2}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot c\right) \cdot a}} & \text{when } b \ge 0 \\ \frac{\frac{c}{b}}{1} - \frac{b}{a} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{c \cdot 2}{\left(-b\right) - \sqrt{{b}^2 - \left(4 \cdot c\right) \cdot a}} & \text{when } b \ge 0 \\ \frac{c}{b} - \frac{b}{a} & \text{otherwise} \end{cases}\]
      0.0

    if -1.9477068539312885e+142 < b < 2.2736054037680634e+124

    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}\]
      8.7
    2. Using strategy rm
      8.7
    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}\]
      8.8

    if 2.2736054037680634e+124 < 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}\]
      34.6
    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}{\left(-b\right) - \left(b - 2 \cdot \frac{c \cdot a}{b}\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}\]
      7.2
    3. Taylor expanded around inf to get
      \[\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \color{red}{\left(b - 2 \cdot \frac{c \cdot a}{b}\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}{\left(b - 2 \cdot \frac{c \cdot a}{b}\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}\]
      7.2
    4. Applied simplify to get
      \[\color{red}{\begin{cases} \frac{2 \cdot c}{\left(-b\right) - \left(b - 2 \cdot \frac{c \cdot a}{b}\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 \color{blue}{\begin{cases} \frac{c \cdot 2}{(\left(\frac{c}{\frac{b}{a}}\right) * 2 + \left(\left(-b\right) - b\right))_*} & \text{when } b \ge 0 \\ \frac{\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}{2 \cdot a} & \text{otherwise} \end{cases}}\]
      1.2
    5. Using strategy rm
      1.2
    6. Applied flip3-+ to get
      \[\begin{cases} \frac{c \cdot 2}{(\left(\frac{c}{\frac{b}{a}}\right) * 2 + \left(\left(-b\right) - b\right))_*} & \text{when } b \ge 0 \\ \frac{\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4} + \left(-b\right)}{2 \cdot a} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{c \cdot 2}{(\left(\frac{c}{\frac{b}{a}}\right) * 2 + \left(\left(-b\right) - b\right))_*} & \text{when } b \ge 0 \\ \frac{\frac{{\left(\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4}\right)}^{3} - {\left(-b\right)}^{3}}{{\left(\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4}\right)}^2 + \left({\left(-b\right)}^2 - \sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4} \cdot \left(-b\right)\right)}}{2 \cdot a} & \text{otherwise} \end{cases}\]
      1.2
    7. Applied simplify to get
      \[\begin{cases} \frac{c \cdot 2}{(\left(\frac{c}{\frac{b}{a}}\right) * 2 + \left(\left(-b\right) - b\right))_*} & \text{when } b \ge 0 \\ \frac{\frac{{\left(\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4}\right)}^{3} - {\left(-b\right)}^{3}}{{\left(\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4}\right)}^2 + \left({\left(-b\right)}^2 - \sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4} \cdot \left(-b\right)\right)}}{2 \cdot a} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{c \cdot 2}{(\left(\frac{c}{\frac{b}{a}}\right) * 2 + \left(\left(-b\right) - b\right))_*} & \text{when } b \ge 0 \\ \frac{\frac{{\left(\sqrt{{b}^2 - \left(a \cdot c\right) \cdot 4}\right)}^{3} - {\left(-b\right)}^{3}}{(\left(-b\right) * \left(\left(-b\right) - \sqrt{{b}^2 - \left(c \cdot 4\right) \cdot a}\right) + \left({b}^2 - \left(c \cdot 4\right) \cdot a\right))_*}}{2 \cdot a} & \text{otherwise} \end{cases}\]
      1.2

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