Average Error: 44.0 → 42.2
Time: 27.8s
Precision: 64
Internal Precision: 2624
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
↓
\[\begin{array}{l}
\mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \le -3.146842250165989 \cdot 10^{-21}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 3} - b}{3 \cdot a}\\
\mathbf{else}:\\
\;\;\;\;\frac{-\left(b + b\right)}{a \cdot 3}\\
\end{array}\]
Derivation
- Split input into 2 regimes
if (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)) < -3.146842250165989e-21
Initial program 24.2
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
Applied simplify24.2
\[\leadsto \color{blue}{\frac{\sqrt{b \cdot b - \left(a \cdot c\right) \cdot 3} - b}{3 \cdot a}}\]
if -3.146842250165989e-21 < (/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a))
Initial program 61.9
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\]
- Using strategy
rm Applied add-cube-cbrt61.9
\[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\left(\sqrt[3]{\left(3 \cdot a\right) \cdot c} \cdot \sqrt[3]{\left(3 \cdot a\right) \cdot c}\right) \cdot \sqrt[3]{\left(3 \cdot a\right) \cdot c}}}}{3 \cdot a}\]
- Using strategy
rm Applied add-log-exp62.1
\[\leadsto \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{\log \left(e^{\sqrt[3]{\left(3 \cdot a\right) \cdot c} \cdot \sqrt[3]{\left(3 \cdot a\right) \cdot c}}\right)} \cdot \sqrt[3]{\left(3 \cdot a\right) \cdot c}}}{3 \cdot a}\]
Taylor expanded around -inf 58.5
\[\leadsto \frac{\left(-b\right) + \color{blue}{-1 \cdot b}}{3 \cdot a}\]
Applied simplify58.5
\[\leadsto \color{blue}{\frac{-\left(b + b\right)}{a \cdot 3}}\]
- Recombined 2 regimes into one program.
Runtime
herbie shell --seed '#(1071821486 549052472 3784827256 1559736200 3548510075 881134285)'
(FPCore (a b c d)
:name "Cubic critical, medium range"
:pre (and (< 1.1102230246251565e-16 a 9007199254740992.0) (< 1.1102230246251565e-16 b 9007199254740992.0) (< 1.1102230246251565e-16 c 9007199254740992.0))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3 a) c)))) (* 3 a)))