\[\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.2 s
Input Error: 31.0
Output Error: 9.0
Log:
Profile: 🕒
\(\begin{cases} \frac{c}{b} \cdot \frac{2}{-2} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - c \cdot \left(4 \cdot a\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}\]
    31.0
  2. Using strategy rm
    31.0
  3. Applied flip-- to get
    \[\begin{cases} \frac{2 \cdot c}{\color{red}{\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}{\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}}}} & \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}\]
    44.6
  4. Applied simplify to get
    \[\begin{cases} \frac{2 \cdot c}{\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}}} & \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}{\frac{\color{blue}{\left(4 \cdot a\right) \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}\]
    43.9
  5. Applied taylor to get
    \[\begin{cases} \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{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 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}\]
    9.0
  6. Taylor expanded around 0 to get
    \[\begin{cases} \frac{2 \cdot c}{\color{red}{-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 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}\]
    9.0
  7. Applied simplify to get
    \[\begin{cases} \frac{2 \cdot c}{-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{c}{b} \cdot \frac{2}{-2} & \text{when } b \ge 0 \\ \frac{\left(-b\right) + \sqrt{{b}^2 - c \cdot \left(4 \cdot a\right)}}{a \cdot 2} & \text{otherwise} \end{cases}\]
    9.0

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