\[\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: 21.6 s
Input Error: 10.5
Output Error: 3.1
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{c \cdot 2}{\frac{2 \cdot a}{\frac{b}{c}} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases} & \text{when } b \le -776.7439f0 \\ \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(\left(-b\right) + {\left(\sqrt[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3\right)}^{1}} & \text{otherwise} \end{cases} & \text{when } b \le 1.7973414f+17 \\ \frac{(\left(\frac{c}{\frac{b}{2}}\right) * a + \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 < -776.7439f0

    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}\]
      14.1
    2. Using strategy rm
      14.1
    3. Applied add-cube-cbrt 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[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3}} & \text{otherwise} \end{cases}\]
      14.2
    4. Using strategy rm
      14.2
    5. Applied pow1 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 \\ \color{red}{\frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3}} & \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 \\ \color{blue}{\frac{2 \cdot c}{{\left(\left(-b\right) + {\left(\sqrt[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3\right)}^{1}}} & \text{otherwise} \end{cases}\]
      14.2
    6. 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(\left(-b\right) + {\left(\sqrt[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3\right)}^{1}} & \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(\left(-b\right) + {\left(\sqrt[3]{2 \cdot \frac{c \cdot a}{b} - b}\right)}^3\right)}^{1}} & \text{otherwise} \end{cases}\]
      3.8
    7. 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(\left(-b\right) + {\left(\sqrt[3]{2 \cdot \frac{c \cdot a}{b} - b}\right)}^3\right)}^{1}} & \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(\left(-b\right) + {\left(\sqrt[3]{2 \cdot \frac{c \cdot a}{b} - b}\right)}^3\right)}^{1}} & \text{otherwise} \end{cases}\]
      3.8
    8. 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(\left(-b\right) + {\left(\sqrt[3]{2 \cdot \frac{c \cdot a}{b} - b}\right)}^3\right)}^{1}} & \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}{\frac{2 \cdot a}{\frac{b}{c}} - \left(b - \left(-b\right)\right)} & \text{otherwise} \end{cases}}\]
      1.4

    if -776.7439f0 < b < 1.7973414f+17

    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}\]
      4.4
    2. Using strategy rm
      4.4
    3. Applied add-cube-cbrt 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[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3}} & \text{otherwise} \end{cases}\]
      4.5
    4. Using strategy rm
      4.5
    5. Applied pow1 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 \\ \color{red}{\frac{2 \cdot c}{\left(-b\right) + {\left(\sqrt[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3}} & \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 \\ \color{blue}{\frac{2 \cdot c}{{\left(\left(-b\right) + {\left(\sqrt[3]{\sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}}\right)}^3\right)}^{1}}} & \text{otherwise} \end{cases}\]
      4.6

    if 1.7973414f+17 < 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}\]
      26.2
    2. 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) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \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) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      6.5
    3. 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) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \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) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}\]
      6.5
    4. 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) + \sqrt{{b}^2 - \left(4 \cdot a\right) \cdot c}} & \text{otherwise} \end{cases}} \leadsto \color{blue}{\begin{cases} \frac{(\left(\frac{c}{\frac{b}{2}}\right) * a + \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}}\]
      1.2

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