| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 14016 |
\[\frac{\frac{-3 \cdot \left(c \cdot a\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{a \cdot 3}
\]
(FPCore (a b c) :precision binary64 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c) :precision binary64 (let* ((t_0 (* c (* a -3.0)))) (/ (/ t_0 (+ b (sqrt (fma b b t_0)))) (* a 3.0))))
double code(double a, double b, double c) {
return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
double t_0 = c * (a * -3.0);
return (t_0 / (b + sqrt(fma(b, b, t_0)))) / (a * 3.0);
}
function code(a, b, c) return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) end
function code(a, b, c) t_0 = Float64(c * Float64(a * -3.0)) return Float64(Float64(t_0 / Float64(b + sqrt(fma(b, b, t_0)))) / Float64(a * 3.0)) end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := Block[{t$95$0 = N[(c * N[(a * -3.0), $MachinePrecision]), $MachinePrecision]}, N[(N[(t$95$0 / N[(b + N[Sqrt[N[(b * b + t$95$0), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
t_0 := c \cdot \left(a \cdot -3\right)\\
\frac{\frac{t_0}{b + \sqrt{\mathsf{fma}\left(b, b, t_0\right)}}}{a \cdot 3}
\end{array}
Initial program 52.6
Applied egg-rr52.4
Simplified52.4
[Start]52.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, 3 \cdot \left(a \cdot c\right)\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
|---|---|
*-commutative [=>]52.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \color{blue}{\left(a \cdot c\right) \cdot 3}\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
*-commutative [<=]52.4 | \[ \frac{\frac{b \cdot b - \mathsf{fma}\left(b, b, \color{blue}{\left(c \cdot a\right)} \cdot 3\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
Taylor expanded in b around 0 0.5
Simplified0.4
[Start]0.5 | \[ \frac{\frac{-3 \cdot \left(c \cdot a\right)}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
|---|---|
*-commutative [=>]0.5 | \[ \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot -3}}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
associate-*l* [=>]0.4 | \[ \frac{\frac{\color{blue}{c \cdot \left(a \cdot -3\right)}}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{3 \cdot a}
\] |
Final simplification0.4
| Alternative 1 | |
|---|---|
| Error | 0.5 |
| Cost | 14016 |
| Alternative 2 | |
|---|---|
| Error | 3.1 |
| Cost | 7488 |
| Alternative 3 | |
|---|---|
| Error | 3.1 |
| Cost | 7424 |
| Alternative 4 | |
|---|---|
| Error | 3.3 |
| Cost | 1344 |
| Alternative 5 | |
|---|---|
| Error | 3.3 |
| Cost | 1216 |
| Alternative 6 | |
|---|---|
| Error | 6.4 |
| Cost | 320 |
| Alternative 7 | |
|---|---|
| Error | 6.2 |
| Cost | 320 |
| Alternative 8 | |
|---|---|
| Error | 52.0 |
| Cost | 256 |
herbie shell --seed 2023016
(FPCore (a b c)
:name "Cubic critical, wide range"
:precision binary64
:pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
(/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))