\[\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: 10.9 s
Input Error: 30.7
Output Error: 13.9
Log:
Profile: 🕒
\(\begin{cases} \frac{c \cdot 2}{\left(-b\right) - \sqrt{{b}^2 - a \cdot \left(4 \cdot c\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. 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}\]
    30.7
  2. Using strategy rm
    30.7
  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}\]
    30.8
  4. 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) + {\left(\sqrt{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^2}{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{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2}{2 \cdot a} & \text{otherwise} \end{cases}\]
    20.4
  5. 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{\left(-b\right) + {\left(\sqrt{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2}{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{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2}{2 \cdot a} & \text{otherwise} \end{cases}\]
    20.4
  6. Applied simplify 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) + {\left(\sqrt{2 \cdot \frac{c \cdot a}{b} - b}\right)}^2}{2 \cdot a} & \text{otherwise} \end{cases} \leadsto \begin{cases} \frac{c \cdot 2}{\left(-b\right) - \sqrt{{b}^2 - a \cdot \left(4 \cdot c\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}\]
    13.9

  7. Applied final simplification

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