Cubic critical

?

Percentage Accurate: 52.2% → 86.8%
Time: 20.3s
Precision: binary64
Cost: 14412

?

\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} \mathbf{if}\;b \leq -1.15 \cdot 10^{+126}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 7.6 \cdot 10^{-156}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 14000000000000:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{\frac{3 \cdot \left(a \cdot c\right)}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (if (<= b -1.15e+126)
   (/ (* b -0.6666666666666666) a)
   (if (<= b 7.6e-156)
     (/ (- (sqrt (- (* b b) (* (* a 3.0) c))) b) (* a 3.0))
     (if (<= b 14000000000000.0)
       (*
        -0.3333333333333333
        (/ (/ (* 3.0 (* a c)) (+ b (sqrt (fma a (* c -3.0) (* b b))))) a))
       (/ (* c -0.5) b)))))
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 tmp;
	if (b <= -1.15e+126) {
		tmp = (b * -0.6666666666666666) / a;
	} else if (b <= 7.6e-156) {
		tmp = (sqrt(((b * b) - ((a * 3.0) * c))) - b) / (a * 3.0);
	} else if (b <= 14000000000000.0) {
		tmp = -0.3333333333333333 * (((3.0 * (a * c)) / (b + sqrt(fma(a, (c * -3.0), (b * b))))) / a);
	} else {
		tmp = (c * -0.5) / b;
	}
	return tmp;
}
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)
	tmp = 0.0
	if (b <= -1.15e+126)
		tmp = Float64(Float64(b * -0.6666666666666666) / a);
	elseif (b <= 7.6e-156)
		tmp = Float64(Float64(sqrt(Float64(Float64(b * b) - Float64(Float64(a * 3.0) * c))) - b) / Float64(a * 3.0));
	elseif (b <= 14000000000000.0)
		tmp = Float64(-0.3333333333333333 * Float64(Float64(Float64(3.0 * Float64(a * c)) / Float64(b + sqrt(fma(a, Float64(c * -3.0), Float64(b * b))))) / a));
	else
		tmp = Float64(Float64(c * -0.5) / b);
	end
	return tmp
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_] := If[LessEqual[b, -1.15e+126], N[(N[(b * -0.6666666666666666), $MachinePrecision] / a), $MachinePrecision], If[LessEqual[b, 7.6e-156], N[(N[(N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(a * 3.0), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[b, 14000000000000.0], N[(-0.3333333333333333 * N[(N[(N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision] / N[(b + N[Sqrt[N[(a * N[(c * -3.0), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(N[(c * -0.5), $MachinePrecision] / b), $MachinePrecision]]]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
\mathbf{if}\;b \leq -1.15 \cdot 10^{+126}:\\
\;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\

\mathbf{elif}\;b \leq 7.6 \cdot 10^{-156}:\\
\;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\

\mathbf{elif}\;b \leq 14000000000000:\\
\;\;\;\;-0.3333333333333333 \cdot \frac{\frac{3 \cdot \left(a \cdot c\right)}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}{a}\\

\mathbf{else}:\\
\;\;\;\;\frac{c \cdot -0.5}{b}\\


\end{array}

Local Percentage Accuracy vs ?

The average percentage accuracy by input value. Horizontal axis shows value of an input variable; the variable is choosen in the title. Vertical axis is accuracy; higher is better. Red represent the original program, while blue represents Herbie's suggestion. These can be toggled with buttons below the plot. The line is an average while dots represent individual samples.

Herbie found 15 alternatives:

AlternativeAccuracySpeedup

Accuracy vs Speed

The accuracy (vertical axis) and speed (horizontal axis) of each alternatives. Up and to the right is better. The red square shows the initial program, and each blue circle shows an alternative.The line shows the best available speed-accuracy tradeoffs.

Bogosity?

Bogosity

Derivation?

  1. Split input into 4 regimes
  2. if b < -1.15e126

    1. Initial program 55.9%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Simplified55.9%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}} \]
      Step-by-step derivation

      [Start]55.9%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      /-rgt-identity [<=]55.9%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{\frac{3 \cdot a}{1}}} \]

      metadata-eval [<=]55.9%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\frac{3 \cdot a}{\color{blue}{--1}}} \]

      associate-/l* [<=]55.9%

      \[ \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(--1\right)}{3 \cdot a}} \]

      associate-*r/ [<=]55.9%

      \[ \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{--1}{3 \cdot a}} \]

      *-commutative [=>]55.9%

      \[ \color{blue}{\frac{--1}{3 \cdot a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)} \]

      associate-*l/ [=>]55.9%

      \[ \color{blue}{\frac{\left(--1\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}} \]

      associate-*r/ [<=]55.9%

      \[ \color{blue}{\left(--1\right) \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}} \]

      metadata-eval [=>]55.9%

      \[ \color{blue}{1} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      metadata-eval [<=]55.9%

      \[ \color{blue}{\frac{-1}{-1}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      times-frac [<=]55.9%

      \[ \color{blue}{\frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{-1 \cdot \left(3 \cdot a\right)}} \]

      neg-mul-1 [<=]55.9%

      \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{-3 \cdot a}} \]

      distribute-rgt-neg-in [=>]55.9%

      \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{3 \cdot \left(-a\right)}} \]

      times-frac [=>]55.9%

      \[ \color{blue}{\frac{-1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a}} \]

      metadata-eval [=>]55.9%

      \[ \color{blue}{-0.3333333333333333} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a} \]

      neg-mul-1 [=>]55.9%

      \[ -0.3333333333333333 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{-1 \cdot a}} \]
    3. Applied egg-rr55.9%

      \[\leadsto -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]
      Step-by-step derivation

      [Start]55.9%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a} \]

      fma-udef [=>]55.9%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b + a \cdot \left(c \cdot -3\right)}}}{a} \]

      associate-*r* [=>]55.9%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{\left(a \cdot c\right) \cdot -3}}}{a} \]

      *-commutative [=>]55.9%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{-3 \cdot \left(a \cdot c\right)}}}{a} \]

      metadata-eval [<=]55.9%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{\left(-3\right)} \cdot \left(a \cdot c\right)}}{a} \]

      cancel-sign-sub-inv [<=]55.9%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]
    4. Taylor expanded in b around -inf 97.7%

      \[\leadsto \color{blue}{-0.6666666666666666 \cdot \frac{b}{a}} \]
    5. Simplified97.9%

      \[\leadsto \color{blue}{\frac{b \cdot -0.6666666666666666}{a}} \]
      Step-by-step derivation

      [Start]97.7%

      \[ -0.6666666666666666 \cdot \frac{b}{a} \]

      *-commutative [=>]97.7%

      \[ \color{blue}{\frac{b}{a} \cdot -0.6666666666666666} \]

      associate-*l/ [=>]97.9%

      \[ \color{blue}{\frac{b \cdot -0.6666666666666666}{a}} \]

    if -1.15e126 < b < 7.60000000000000015e-156

    1. Initial program 83.1%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

    if 7.60000000000000015e-156 < b < 1.4e13

    1. Initial program 56.7%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Simplified56.4%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}} \]
      Step-by-step derivation

      [Start]56.7%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      /-rgt-identity [<=]56.7%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{\frac{3 \cdot a}{1}}} \]

      metadata-eval [<=]56.7%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\frac{3 \cdot a}{\color{blue}{--1}}} \]

      associate-/l* [<=]56.7%

      \[ \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(--1\right)}{3 \cdot a}} \]

      associate-*r/ [<=]56.6%

      \[ \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{--1}{3 \cdot a}} \]

      *-commutative [=>]56.6%

      \[ \color{blue}{\frac{--1}{3 \cdot a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)} \]

      associate-*l/ [=>]56.7%

      \[ \color{blue}{\frac{\left(--1\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}} \]

      associate-*r/ [<=]56.7%

      \[ \color{blue}{\left(--1\right) \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}} \]

      metadata-eval [=>]56.7%

      \[ \color{blue}{1} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      metadata-eval [<=]56.7%

      \[ \color{blue}{\frac{-1}{-1}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      times-frac [<=]56.7%

      \[ \color{blue}{\frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{-1 \cdot \left(3 \cdot a\right)}} \]

      neg-mul-1 [<=]56.7%

      \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{-3 \cdot a}} \]

      distribute-rgt-neg-in [=>]56.7%

      \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{3 \cdot \left(-a\right)}} \]

      times-frac [=>]56.5%

      \[ \color{blue}{\frac{-1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a}} \]

      metadata-eval [=>]56.5%

      \[ \color{blue}{-0.3333333333333333} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a} \]

      neg-mul-1 [=>]56.5%

      \[ -0.3333333333333333 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{-1 \cdot a}} \]
    3. Applied egg-rr56.3%

      \[\leadsto -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]
      Step-by-step derivation

      [Start]56.4%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a} \]

      fma-udef [=>]56.4%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b + a \cdot \left(c \cdot -3\right)}}}{a} \]

      associate-*r* [=>]56.3%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{\left(a \cdot c\right) \cdot -3}}}{a} \]

      *-commutative [=>]56.3%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{-3 \cdot \left(a \cdot c\right)}}}{a} \]

      metadata-eval [<=]56.3%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{\left(-3\right)} \cdot \left(a \cdot c\right)}}{a} \]

      cancel-sign-sub-inv [<=]56.3%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]
    4. Applied egg-rr56.5%

      \[\leadsto -0.3333333333333333 \cdot \frac{\color{blue}{\frac{b \cdot b - \left(b \cdot b + -3 \cdot \left(a \cdot c\right)\right)}{b + \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}}{a} \]
      Step-by-step derivation

      [Start]56.3%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a} \]

      flip-- [=>]56.3%

      \[ -0.3333333333333333 \cdot \frac{\color{blue}{\frac{b \cdot b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} \cdot \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}}{a} \]

      add-sqr-sqrt [<=]56.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{b \cdot b - \color{blue}{\left(b \cdot b - 3 \cdot \left(a \cdot c\right)\right)}}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]

      cancel-sign-sub-inv [=>]56.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{b \cdot b - \color{blue}{\left(b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)\right)}}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]

      metadata-eval [=>]56.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{b \cdot b - \left(b \cdot b + \color{blue}{-3} \cdot \left(a \cdot c\right)\right)}{b + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]

      cancel-sign-sub-inv [=>]56.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{b \cdot b - \left(b \cdot b + -3 \cdot \left(a \cdot c\right)\right)}{b + \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}}}{a} \]

      metadata-eval [=>]56.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{b \cdot b - \left(b \cdot b + -3 \cdot \left(a \cdot c\right)\right)}{b + \sqrt{b \cdot b + \color{blue}{-3} \cdot \left(a \cdot c\right)}}}{a} \]
    5. Simplified85.4%

      \[\leadsto -0.3333333333333333 \cdot \frac{\color{blue}{\frac{0 + 3 \cdot \left(c \cdot a\right)}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}}{a} \]
      Step-by-step derivation

      [Start]56.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{b \cdot b - \left(b \cdot b + -3 \cdot \left(a \cdot c\right)\right)}{b + \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}{a} \]

      associate--r+ [=>]85.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{\color{blue}{\left(b \cdot b - b \cdot b\right) - -3 \cdot \left(a \cdot c\right)}}{b + \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}{a} \]

      +-inverses [=>]85.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{\color{blue}{0} - -3 \cdot \left(a \cdot c\right)}{b + \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}{a} \]

      cancel-sign-sub-inv [=>]85.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{\color{blue}{0 + \left(--3\right) \cdot \left(a \cdot c\right)}}{b + \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}{a} \]

      metadata-eval [=>]85.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{0 + \color{blue}{3} \cdot \left(a \cdot c\right)}{b + \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}{a} \]

      *-commutative [=>]85.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{0 + 3 \cdot \color{blue}{\left(c \cdot a\right)}}{b + \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}}}{a} \]

      +-commutative [=>]85.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{0 + 3 \cdot \left(c \cdot a\right)}{b + \sqrt{\color{blue}{-3 \cdot \left(a \cdot c\right) + b \cdot b}}}}{a} \]

      *-commutative [=>]85.5%

      \[ -0.3333333333333333 \cdot \frac{\frac{0 + 3 \cdot \left(c \cdot a\right)}{b + \sqrt{\color{blue}{\left(a \cdot c\right) \cdot -3} + b \cdot b}}}{a} \]

      associate-*r* [<=]85.4%

      \[ -0.3333333333333333 \cdot \frac{\frac{0 + 3 \cdot \left(c \cdot a\right)}{b + \sqrt{\color{blue}{a \cdot \left(c \cdot -3\right)} + b \cdot b}}}{a} \]

      fma-def [=>]85.4%

      \[ -0.3333333333333333 \cdot \frac{\frac{0 + 3 \cdot \left(c \cdot a\right)}{b + \sqrt{\color{blue}{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}}{a} \]

    if 1.4e13 < b

    1. Initial program 14.8%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Simplified14.8%

      \[\leadsto \color{blue}{-0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a}} \]
      Step-by-step derivation

      [Start]14.8%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      /-rgt-identity [<=]14.8%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{\frac{3 \cdot a}{1}}} \]

      metadata-eval [<=]14.8%

      \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\frac{3 \cdot a}{\color{blue}{--1}}} \]

      associate-/l* [<=]14.8%

      \[ \color{blue}{\frac{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \left(--1\right)}{3 \cdot a}} \]

      associate-*r/ [<=]14.8%

      \[ \color{blue}{\left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right) \cdot \frac{--1}{3 \cdot a}} \]

      *-commutative [=>]14.8%

      \[ \color{blue}{\frac{--1}{3 \cdot a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)} \]

      associate-*l/ [=>]14.8%

      \[ \color{blue}{\frac{\left(--1\right) \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{3 \cdot a}} \]

      associate-*r/ [<=]14.8%

      \[ \color{blue}{\left(--1\right) \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}} \]

      metadata-eval [=>]14.8%

      \[ \color{blue}{1} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      metadata-eval [<=]14.8%

      \[ \color{blue}{\frac{-1}{-1}} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]

      times-frac [<=]14.8%

      \[ \color{blue}{\frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{-1 \cdot \left(3 \cdot a\right)}} \]

      neg-mul-1 [<=]14.8%

      \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{-3 \cdot a}} \]

      distribute-rgt-neg-in [=>]14.8%

      \[ \frac{-1 \cdot \left(\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}\right)}{\color{blue}{3 \cdot \left(-a\right)}} \]

      times-frac [=>]14.8%

      \[ \color{blue}{\frac{-1}{3} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a}} \]

      metadata-eval [=>]14.8%

      \[ \color{blue}{-0.3333333333333333} \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{-a} \]

      neg-mul-1 [=>]14.8%

      \[ -0.3333333333333333 \cdot \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{\color{blue}{-1 \cdot a}} \]
    3. Applied egg-rr14.8%

      \[\leadsto -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]
      Step-by-step derivation

      [Start]14.8%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\mathsf{fma}\left(b, b, a \cdot \left(c \cdot -3\right)\right)}}{a} \]

      fma-udef [=>]14.8%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b + a \cdot \left(c \cdot -3\right)}}}{a} \]

      associate-*r* [=>]14.8%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{\left(a \cdot c\right) \cdot -3}}}{a} \]

      *-commutative [=>]14.8%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{-3 \cdot \left(a \cdot c\right)}}}{a} \]

      metadata-eval [<=]14.8%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b + \color{blue}{\left(-3\right)} \cdot \left(a \cdot c\right)}}{a} \]

      cancel-sign-sub-inv [<=]14.8%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{\color{blue}{b \cdot b - 3 \cdot \left(a \cdot c\right)}}}{a} \]
    4. Applied egg-rr14.8%

      \[\leadsto -0.3333333333333333 \cdot \color{blue}{\left(\left(b - \sqrt{b \cdot b + -3 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{a}\right)} \]
      Step-by-step derivation

      [Start]14.8%

      \[ -0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a} \]

      div-inv [=>]14.8%

      \[ -0.3333333333333333 \cdot \color{blue}{\left(\left(b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{a}\right)} \]

      cancel-sign-sub-inv [=>]14.8%

      \[ -0.3333333333333333 \cdot \left(\left(b - \sqrt{\color{blue}{b \cdot b + \left(-3\right) \cdot \left(a \cdot c\right)}}\right) \cdot \frac{1}{a}\right) \]

      metadata-eval [=>]14.8%

      \[ -0.3333333333333333 \cdot \left(\left(b - \sqrt{b \cdot b + \color{blue}{-3} \cdot \left(a \cdot c\right)}\right) \cdot \frac{1}{a}\right) \]
    5. Taylor expanded in b around inf 96.7%

      \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
    6. Simplified96.7%

      \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
      Step-by-step derivation

      [Start]96.7%

      \[ -0.5 \cdot \frac{c}{b} \]

      *-commutative [=>]96.7%

      \[ \color{blue}{\frac{c}{b} \cdot -0.5} \]

      associate-*l/ [=>]96.7%

      \[ \color{blue}{\frac{c \cdot -0.5}{b}} \]
  3. Recombined 4 regimes into one program.
  4. Final simplification89.9%

    \[\leadsto \begin{array}{l} \mathbf{if}\;b \leq -1.15 \cdot 10^{+126}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 7.6 \cdot 10^{-156}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 14000000000000:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{\frac{3 \cdot \left(a \cdot c\right)}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]

Alternatives

Alternative 1
Accuracy86.8%
Cost14412
\[\begin{array}{l} \mathbf{if}\;b \leq -1.15 \cdot 10^{+126}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 7.6 \cdot 10^{-156}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{elif}\;b \leq 14000000000000:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{\frac{3 \cdot \left(a \cdot c\right)}{b + \sqrt{\mathsf{fma}\left(a, c \cdot -3, b \cdot b\right)}}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 2
Accuracy85.2%
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -1.95 \cdot 10^{+126}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 6.5 \cdot 10^{-92}:\\ \;\;\;\;-0.3333333333333333 \cdot \frac{b - \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 3
Accuracy85.2%
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -1.05 \cdot 10^{+126}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 2.2 \cdot 10^{-92}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 4
Accuracy85.3%
Cost7624
\[\begin{array}{l} \mathbf{if}\;b \leq -2 \cdot 10^{+128}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-92}:\\ \;\;\;\;\frac{\sqrt{b \cdot b - \left(a \cdot 3\right) \cdot c} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 5
Accuracy79.7%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -5.8 \cdot 10^{-8}:\\ \;\;\;\;\frac{1.5 \cdot \left(a \cdot \frac{c}{b}\right) + b \cdot -2}{a \cdot 3}\\ \mathbf{elif}\;b \leq 7.5 \cdot 10^{-92}:\\ \;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\sqrt{\left(a \cdot c\right) \cdot -3} - b\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 6
Accuracy79.6%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -0.00035:\\ \;\;\;\;\frac{1.5 \cdot \left(a \cdot \frac{c}{b}\right) + b \cdot -2}{a \cdot 3}\\ \mathbf{elif}\;b \leq 4.2 \cdot 10^{-92}:\\ \;\;\;\;\left(\sqrt{c \cdot \left(a \cdot -3\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 7
Accuracy79.7%
Cost7368
\[\begin{array}{l} \mathbf{if}\;b \leq -2.6 \cdot 10^{-6}:\\ \;\;\;\;\frac{1.5 \cdot \left(a \cdot \frac{c}{b}\right) + b \cdot -2}{a \cdot 3}\\ \mathbf{elif}\;b \leq 8 \cdot 10^{-92}:\\ \;\;\;\;\frac{\sqrt{c \cdot \left(a \cdot -3\right)} - b}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 8
Accuracy67.1%
Cost1092
\[\begin{array}{l} \mathbf{if}\;b \leq -2.6 \cdot 10^{-308}:\\ \;\;\;\;\frac{1.5 \cdot \left(a \cdot \frac{c}{b}\right) + b \cdot -2}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 9
Accuracy67.1%
Cost964
\[\begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;-0.3333333333333333 \cdot \left(\frac{c}{b} \cdot -1.5 + 2 \cdot \frac{b}{a}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 10
Accuracy67.1%
Cost836
\[\begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a} + \frac{c}{b} \cdot 0.5\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 11
Accuracy67.0%
Cost580
\[\begin{array}{l} \mathbf{if}\;b \leq -1 \cdot 10^{-309}:\\ \;\;\;\;\frac{b \cdot -2}{a \cdot 3}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 12
Accuracy66.9%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 2.1 \cdot 10^{-308}:\\ \;\;\;\;-0.6666666666666666 \cdot \frac{b}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 13
Accuracy67.0%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 6.8 \cdot 10^{-308}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 14
Accuracy67.0%
Cost452
\[\begin{array}{l} \mathbf{if}\;b \leq 6 \cdot 10^{-309}:\\ \;\;\;\;\frac{b \cdot -0.6666666666666666}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{c \cdot -0.5}{b}\\ \end{array} \]
Alternative 15
Accuracy34.9%
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Reproduce?

herbie shell --seed 2023271 
(FPCore (a b c)
  :name "Cubic critical"
  :precision binary64
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))