Cubic critical, narrow range

Percentage Accurate: 55.7% → 99.3%
Time: 18.9s
Alternatives: 9
Speedup: 1.1×

Specification

?
\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
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 tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
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]
\begin{array}{l}

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

Sampling outcomes in binary64 precision:

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.

Accuracy vs Speed?

Herbie found 9 alternatives:

AlternativeAccuracySpeedup
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.

Initial Program: 55.7% accurate, 1.0× speedup?

\[\begin{array}{l} \\ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    code = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
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 tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
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]
\begin{array}{l}

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

Alternative 1: 99.3% accurate, 0.9× speedup?

\[\begin{array}{l} \\ \frac{\frac{-3 \cdot c}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{3} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (/ (* -3.0 c) (+ b (sqrt (fma a (* -3.0 c) (* b b))))) 3.0))
double code(double a, double b, double c) {
	return ((-3.0 * c) / (b + sqrt(fma(a, (-3.0 * c), (b * b))))) / 3.0;
}
function code(a, b, c)
	return Float64(Float64(Float64(-3.0 * c) / Float64(b + sqrt(fma(a, Float64(-3.0 * c), Float64(b * b))))) / 3.0)
end
code[a_, b_, c_] := N[(N[(N[(-3.0 * c), $MachinePrecision] / N[(b + N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / 3.0), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{-3 \cdot c}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{3}
\end{array}
Derivation
  1. Initial program 55.9%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Add Preprocessing
  3. Applied egg-rr56.6%

    \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}} - \frac{b \cdot b}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}}{3 \cdot a} \]
  4. Step-by-step derivation
    1. Applied egg-rr57.5%

      \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) - b \cdot b}{3 \cdot \left(b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right)}}{a}} \]
    2. Applied egg-rr99.2%

      \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, -3 \cdot c, 0\right)}{a} \cdot \frac{\frac{0.3333333333333333}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{1}} \]
    3. Applied egg-rr99.3%

      \[\leadsto \color{blue}{\frac{\frac{1 \cdot \left(-3 \cdot c\right)}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{3}} \]
    4. Final simplification99.3%

      \[\leadsto \frac{\frac{-3 \cdot c}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{3} \]
    5. Add Preprocessing

    Alternative 2: 99.2% accurate, 0.9× speedup?

    \[\begin{array}{l} \\ \frac{0.3333333333333333}{\frac{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{-3 \cdot c}} \end{array} \]
    (FPCore (a b c)
     :precision binary64
     (/ 0.3333333333333333 (/ (+ b (sqrt (fma a (* -3.0 c) (* b b)))) (* -3.0 c))))
    double code(double a, double b, double c) {
    	return 0.3333333333333333 / ((b + sqrt(fma(a, (-3.0 * c), (b * b)))) / (-3.0 * c));
    }
    
    function code(a, b, c)
    	return Float64(0.3333333333333333 / Float64(Float64(b + sqrt(fma(a, Float64(-3.0 * c), Float64(b * b)))) / Float64(-3.0 * c)))
    end
    
    code[a_, b_, c_] := N[(0.3333333333333333 / N[(N[(b + N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(-3.0 * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
    
    \begin{array}{l}
    
    \\
    \frac{0.3333333333333333}{\frac{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{-3 \cdot c}}
    \end{array}
    
    Derivation
    1. Initial program 55.9%

      \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
    2. Add Preprocessing
    3. Applied egg-rr56.6%

      \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}} - \frac{b \cdot b}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}}{3 \cdot a} \]
    4. Step-by-step derivation
      1. Applied egg-rr57.5%

        \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) - b \cdot b}{3 \cdot \left(b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right)}}{a}} \]
      2. Applied egg-rr99.2%

        \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, -3 \cdot c, 0\right)}{a} \cdot \frac{\frac{0.3333333333333333}{b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}}}{1}} \]
      3. Applied egg-rr99.3%

        \[\leadsto \color{blue}{\frac{0.3333333333333333}{\frac{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{1 \cdot \left(-3 \cdot c\right)}}} \]
      4. Final simplification99.3%

        \[\leadsto \frac{0.3333333333333333}{\frac{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{-3 \cdot c}} \]
      5. Add Preprocessing

      Alternative 3: 99.3% accurate, 1.0× speedup?

      \[\begin{array}{l} \\ \frac{-3 \cdot c}{3 \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}\right)} \end{array} \]
      (FPCore (a b c)
       :precision binary64
       (/ (* -3.0 c) (* 3.0 (+ b (sqrt (fma b b (* c (* -3.0 a))))))))
      double code(double a, double b, double c) {
      	return (-3.0 * c) / (3.0 * (b + sqrt(fma(b, b, (c * (-3.0 * a))))));
      }
      
      function code(a, b, c)
      	return Float64(Float64(-3.0 * c) / Float64(3.0 * Float64(b + sqrt(fma(b, b, Float64(c * Float64(-3.0 * a)))))))
      end
      
      code[a_, b_, c_] := N[(N[(-3.0 * c), $MachinePrecision] / N[(3.0 * N[(b + N[Sqrt[N[(b * b + N[(c * N[(-3.0 * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
      
      \begin{array}{l}
      
      \\
      \frac{-3 \cdot c}{3 \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}\right)}
      \end{array}
      
      Derivation
      1. Initial program 55.9%

        \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
      2. Add Preprocessing
      3. Applied egg-rr56.6%

        \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}} - \frac{b \cdot b}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}}{3 \cdot a} \]
      4. Step-by-step derivation
        1. Applied egg-rr57.5%

          \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right) - b \cdot b}{3 \cdot \left(b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right)}}{a}} \]
        2. Applied egg-rr99.1%

          \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(a, -3 \cdot c, 0\right) \cdot \frac{1}{a}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3}} \]
        3. Taylor expanded in a around 0

          \[\leadsto \frac{\color{blue}{-3 \cdot c}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
        4. Step-by-step derivation
          1. *-commutativeN/A

            \[\leadsto \frac{\color{blue}{c \cdot -3}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
          2. rem-square-sqrtN/A

            \[\leadsto \frac{c \cdot \color{blue}{\left(\sqrt{-3} \cdot \sqrt{-3}\right)}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
          3. unpow2N/A

            \[\leadsto \frac{c \cdot \color{blue}{{\left(\sqrt{-3}\right)}^{2}}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
          4. lower-*.f64N/A

            \[\leadsto \frac{\color{blue}{c \cdot {\left(\sqrt{-3}\right)}^{2}}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
          5. unpow2N/A

            \[\leadsto \frac{c \cdot \color{blue}{\left(\sqrt{-3} \cdot \sqrt{-3}\right)}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
          6. rem-square-sqrt99.2

            \[\leadsto \frac{c \cdot \color{blue}{-3}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
        5. Simplified99.2%

          \[\leadsto \frac{\color{blue}{c \cdot -3}}{\left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(a \cdot -3\right)\right)}\right) \cdot 3} \]
        6. Final simplification99.2%

          \[\leadsto \frac{-3 \cdot c}{3 \cdot \left(b + \sqrt{\mathsf{fma}\left(b, b, c \cdot \left(-3 \cdot a\right)\right)}\right)} \]
        7. Add Preprocessing

        Alternative 4: 55.8% accurate, 1.1× speedup?

        \[\begin{array}{l} \\ \frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} - b}{a \cdot 3} \end{array} \]
        (FPCore (a b c)
         :precision binary64
         (/ (- (sqrt (fma b b (* (* -3.0 c) a))) b) (* a 3.0)))
        double code(double a, double b, double c) {
        	return (sqrt(fma(b, b, ((-3.0 * c) * a))) - b) / (a * 3.0);
        }
        
        function code(a, b, c)
        	return Float64(Float64(sqrt(fma(b, b, Float64(Float64(-3.0 * c) * a))) - b) / Float64(a * 3.0))
        end
        
        code[a_, b_, c_] := N[(N[(N[Sqrt[N[(b * b + N[(N[(-3.0 * c), $MachinePrecision] * a), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} - b}{a \cdot 3}
        \end{array}
        
        Derivation
        1. Initial program 55.9%

          \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift-neg.f64N/A

            \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(b\right)\right)} + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{\color{blue}{b \cdot b} - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
          3. lift-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{b \cdot b - \color{blue}{\left(3 \cdot a\right)} \cdot c}}{3 \cdot a} \]
          4. lift-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{b \cdot b - \color{blue}{\left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
          5. lift--.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{\color{blue}{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
          6. lift-sqrt.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
          7. +-commutativeN/A

            \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(\mathsf{neg}\left(b\right)\right)}}{3 \cdot a} \]
          8. lift-neg.f64N/A

            \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \color{blue}{\left(\mathsf{neg}\left(b\right)\right)}}{3 \cdot a} \]
          9. unsub-negN/A

            \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}{3 \cdot a} \]
          10. lower--.f6455.9

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

          \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} - b}}{3 \cdot a} \]
        5. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{\sqrt{a \cdot \color{blue}{\left(-3 \cdot c\right)} + b \cdot b} - b}{3 \cdot a} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{\sqrt{a \cdot \left(-3 \cdot c\right) + \color{blue}{b \cdot b}} - b}{3 \cdot a} \]
          3. +-rgt-identityN/A

            \[\leadsto \frac{\sqrt{\color{blue}{\left(a \cdot \left(-3 \cdot c\right) + 0\right)} + b \cdot b} - b}{3 \cdot a} \]
          4. lift-fma.f64N/A

            \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(a, -3 \cdot c, 0\right)} + b \cdot b} - b}{3 \cdot a} \]
          5. +-commutativeN/A

            \[\leadsto \frac{\sqrt{\color{blue}{b \cdot b + \mathsf{fma}\left(a, -3 \cdot c, 0\right)}} - b}{3 \cdot a} \]
          6. lift-*.f64N/A

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

            \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, \mathsf{fma}\left(a, -3 \cdot c, 0\right)\right)}} - b}{3 \cdot a} \]
          8. lift-fma.f64N/A

            \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{a \cdot \left(-3 \cdot c\right) + 0}\right)} - b}{3 \cdot a} \]
          9. +-rgt-identityN/A

            \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{a \cdot \left(-3 \cdot c\right)}\right)} - b}{3 \cdot a} \]
          10. lower-*.f6456.0

            \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \color{blue}{a \cdot \left(-3 \cdot c\right)}\right)} - b}{3 \cdot a} \]
        6. Applied egg-rr56.0%

          \[\leadsto \frac{\sqrt{\color{blue}{\mathsf{fma}\left(b, b, a \cdot \left(-3 \cdot c\right)\right)}} - b}{3 \cdot a} \]
        7. Final simplification56.0%

          \[\leadsto \frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} - b}{a \cdot 3} \]
        8. Add Preprocessing

        Alternative 5: 55.6% accurate, 1.1× speedup?

        \[\begin{array}{l} \\ \frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a} \cdot -0.3333333333333333 \end{array} \]
        (FPCore (a b c)
         :precision binary64
         (* (/ (- b (sqrt (fma a (* -3.0 c) (* b b)))) a) -0.3333333333333333))
        double code(double a, double b, double c) {
        	return ((b - sqrt(fma(a, (-3.0 * c), (b * b)))) / a) * -0.3333333333333333;
        }
        
        function code(a, b, c)
        	return Float64(Float64(Float64(b - sqrt(fma(a, Float64(-3.0 * c), Float64(b * b)))) / a) * -0.3333333333333333)
        end
        
        code[a_, b_, c_] := N[(N[(N[(b - N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision] * -0.3333333333333333), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a} \cdot -0.3333333333333333
        \end{array}
        
        Derivation
        1. Initial program 55.9%

          \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
        2. Add Preprocessing
        3. Applied egg-rr55.9%

          \[\leadsto \color{blue}{\frac{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a}}{-3}} \]
        4. Step-by-step derivation
          1. lift-*.f64N/A

            \[\leadsto \frac{\frac{b - \sqrt{a \cdot \color{blue}{\left(-3 \cdot c\right)} + b \cdot b}}{a}}{-3} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{\frac{b - \sqrt{a \cdot \left(-3 \cdot c\right) + \color{blue}{b \cdot b}}}{a}}{-3} \]
          3. lift-fma.f64N/A

            \[\leadsto \frac{\frac{b - \sqrt{\color{blue}{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{a}}{-3} \]
          4. lift-sqrt.f64N/A

            \[\leadsto \frac{\frac{b - \color{blue}{\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{a}}{-3} \]
          5. lift--.f64N/A

            \[\leadsto \frac{\frac{\color{blue}{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}{a}}{-3} \]
          6. lift-/.f64N/A

            \[\leadsto \frac{\color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a}}}{-3} \]
          7. div-invN/A

            \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a} \cdot \frac{1}{-3}} \]
          8. lower-*.f64N/A

            \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a} \cdot \frac{1}{-3}} \]
          9. metadata-eval55.9

            \[\leadsto \frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a} \cdot \color{blue}{-0.3333333333333333} \]
        5. Applied egg-rr55.9%

          \[\leadsto \color{blue}{\frac{b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}{a} \cdot -0.3333333333333333} \]
        6. Add Preprocessing

        Alternative 6: 55.6% accurate, 1.1× speedup?

        \[\begin{array}{l} \\ \left(b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right) \cdot \frac{-0.3333333333333333}{a} \end{array} \]
        (FPCore (a b c)
         :precision binary64
         (* (- b (sqrt (fma a (* -3.0 c) (* b b)))) (/ -0.3333333333333333 a)))
        double code(double a, double b, double c) {
        	return (b - sqrt(fma(a, (-3.0 * c), (b * b)))) * (-0.3333333333333333 / a);
        }
        
        function code(a, b, c)
        	return Float64(Float64(b - sqrt(fma(a, Float64(-3.0 * c), Float64(b * b)))) * Float64(-0.3333333333333333 / a))
        end
        
        code[a_, b_, c_] := N[(N[(b - N[Sqrt[N[(a * N[(-3.0 * c), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(-0.3333333333333333 / a), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \left(b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right) \cdot \frac{-0.3333333333333333}{a}
        \end{array}
        
        Derivation
        1. Initial program 55.9%

          \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
        2. Add Preprocessing
        3. Applied egg-rr55.9%

          \[\leadsto \color{blue}{\frac{-0.3333333333333333}{a} \cdot \left(b - \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}\right)} \]
        4. Final simplification55.9%

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

        Alternative 7: 15.2% accurate, 1.2× speedup?

        \[\begin{array}{l} \\ \frac{\sqrt{\mathsf{fma}\left(a, -c, b \cdot b\right)} - b}{a \cdot 3} \end{array} \]
        (FPCore (a b c)
         :precision binary64
         (/ (- (sqrt (fma a (- c) (* b b))) b) (* a 3.0)))
        double code(double a, double b, double c) {
        	return (sqrt(fma(a, -c, (b * b))) - b) / (a * 3.0);
        }
        
        function code(a, b, c)
        	return Float64(Float64(sqrt(fma(a, Float64(-c), Float64(b * b))) - b) / Float64(a * 3.0))
        end
        
        code[a_, b_, c_] := N[(N[(N[Sqrt[N[(a * (-c) + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] - b), $MachinePrecision] / N[(a * 3.0), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{\sqrt{\mathsf{fma}\left(a, -c, b \cdot b\right)} - b}{a \cdot 3}
        \end{array}
        
        Derivation
        1. Initial program 55.9%

          \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
        2. Add Preprocessing
        3. Step-by-step derivation
          1. lift-neg.f64N/A

            \[\leadsto \frac{\color{blue}{\left(\mathsf{neg}\left(b\right)\right)} + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
          2. lift-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{\color{blue}{b \cdot b} - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
          3. lift-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{b \cdot b - \color{blue}{\left(3 \cdot a\right)} \cdot c}}{3 \cdot a} \]
          4. lift-*.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{b \cdot b - \color{blue}{\left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
          5. lift--.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{\color{blue}{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
          6. lift-sqrt.f64N/A

            \[\leadsto \frac{\left(\mathsf{neg}\left(b\right)\right) + \color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
          7. +-commutativeN/A

            \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \left(\mathsf{neg}\left(b\right)\right)}}{3 \cdot a} \]
          8. lift-neg.f64N/A

            \[\leadsto \frac{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} + \color{blue}{\left(\mathsf{neg}\left(b\right)\right)}}{3 \cdot a} \]
          9. unsub-negN/A

            \[\leadsto \frac{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}{3 \cdot a} \]
          10. lower--.f6455.9

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

          \[\leadsto \frac{\color{blue}{\sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)} - b}}{3 \cdot a} \]
        5. Taylor expanded in c around -inf

          \[\leadsto \frac{\sqrt{\mathsf{fma}\left(a, \color{blue}{-1 \cdot c}, b \cdot b\right)} - b}{3 \cdot a} \]
        6. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \frac{\sqrt{\mathsf{fma}\left(a, \color{blue}{\mathsf{neg}\left(c\right)}, b \cdot b\right)} - b}{3 \cdot a} \]
          2. lower-neg.f6415.1

            \[\leadsto \frac{\sqrt{\mathsf{fma}\left(a, \color{blue}{-c}, b \cdot b\right)} - b}{3 \cdot a} \]
        7. Simplified15.1%

          \[\leadsto \frac{\sqrt{\mathsf{fma}\left(a, \color{blue}{-c}, b \cdot b\right)} - b}{3 \cdot a} \]
        8. Final simplification15.1%

          \[\leadsto \frac{\sqrt{\mathsf{fma}\left(a, -c, b \cdot b\right)} - b}{a \cdot 3} \]
        9. Add Preprocessing

        Alternative 8: 11.1% accurate, 1.9× speedup?

        \[\begin{array}{l} \\ \frac{-1}{b \cdot \left(b \cdot \left(b \cdot b\right)\right)} \end{array} \]
        (FPCore (a b c) :precision binary64 (/ -1.0 (* b (* b (* b b)))))
        double code(double a, double b, double c) {
        	return -1.0 / (b * (b * (b * b)));
        }
        
        real(8) function code(a, b, c)
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8), intent (in) :: c
            code = (-1.0d0) / (b * (b * (b * b)))
        end function
        
        public static double code(double a, double b, double c) {
        	return -1.0 / (b * (b * (b * b)));
        }
        
        def code(a, b, c):
        	return -1.0 / (b * (b * (b * b)))
        
        function code(a, b, c)
        	return Float64(-1.0 / Float64(b * Float64(b * Float64(b * b))))
        end
        
        function tmp = code(a, b, c)
        	tmp = -1.0 / (b * (b * (b * b)));
        end
        
        code[a_, b_, c_] := N[(-1.0 / N[(b * N[(b * N[(b * b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        \frac{-1}{b \cdot \left(b \cdot \left(b \cdot b\right)\right)}
        \end{array}
        
        Derivation
        1. Initial program 55.9%

          \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
        2. Add Preprocessing
        3. Applied egg-rr56.6%

          \[\leadsto \frac{\color{blue}{\frac{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}} - \frac{b \cdot b}{b + \sqrt{\mathsf{fma}\left(a, -3 \cdot c, b \cdot b\right)}}}}{3 \cdot a} \]
        4. Taylor expanded in b around inf

          \[\leadsto \color{blue}{\frac{-1}{{b}^{4}}} \]
        5. Step-by-step derivation
          1. lower-/.f64N/A

            \[\leadsto \color{blue}{\frac{-1}{{b}^{4}}} \]
          2. metadata-evalN/A

            \[\leadsto \frac{-1}{{b}^{\color{blue}{\left(3 + 1\right)}}} \]
          3. pow-plusN/A

            \[\leadsto \frac{-1}{\color{blue}{{b}^{3} \cdot b}} \]
          4. lower-*.f64N/A

            \[\leadsto \frac{-1}{\color{blue}{{b}^{3} \cdot b}} \]
          5. cube-multN/A

            \[\leadsto \frac{-1}{\color{blue}{\left(b \cdot \left(b \cdot b\right)\right)} \cdot b} \]
          6. unpow2N/A

            \[\leadsto \frac{-1}{\left(b \cdot \color{blue}{{b}^{2}}\right) \cdot b} \]
          7. lower-*.f64N/A

            \[\leadsto \frac{-1}{\color{blue}{\left(b \cdot {b}^{2}\right)} \cdot b} \]
          8. unpow2N/A

            \[\leadsto \frac{-1}{\left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \cdot b} \]
          9. lower-*.f6410.9

            \[\leadsto \frac{-1}{\left(b \cdot \color{blue}{\left(b \cdot b\right)}\right) \cdot b} \]
        6. Simplified10.9%

          \[\leadsto \color{blue}{\frac{-1}{\left(b \cdot \left(b \cdot b\right)\right) \cdot b}} \]
        7. Final simplification10.9%

          \[\leadsto \frac{-1}{b \cdot \left(b \cdot \left(b \cdot b\right)\right)} \]
        8. Add Preprocessing

        Alternative 9: 10.9% accurate, 2.6× speedup?

        \[\begin{array}{l} \\ b \cdot \frac{b}{-a} \end{array} \]
        (FPCore (a b c) :precision binary64 (* b (/ b (- a))))
        double code(double a, double b, double c) {
        	return b * (b / -a);
        }
        
        real(8) function code(a, b, c)
            real(8), intent (in) :: a
            real(8), intent (in) :: b
            real(8), intent (in) :: c
            code = b * (b / -a)
        end function
        
        public static double code(double a, double b, double c) {
        	return b * (b / -a);
        }
        
        def code(a, b, c):
        	return b * (b / -a)
        
        function code(a, b, c)
        	return Float64(b * Float64(b / Float64(-a)))
        end
        
        function tmp = code(a, b, c)
        	tmp = b * (b / -a);
        end
        
        code[a_, b_, c_] := N[(b * N[(b / (-a)), $MachinePrecision]), $MachinePrecision]
        
        \begin{array}{l}
        
        \\
        b \cdot \frac{b}{-a}
        \end{array}
        
        Derivation
        1. Initial program 55.9%

          \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
        2. Add Preprocessing
        3. Taylor expanded in b around inf

          \[\leadsto \frac{\color{blue}{{b}^{2}}}{3 \cdot a} \]
        4. Step-by-step derivation
          1. unpow2N/A

            \[\leadsto \frac{\color{blue}{b \cdot b}}{3 \cdot a} \]
          2. lower-*.f641.6

            \[\leadsto \frac{\color{blue}{b \cdot b}}{3 \cdot a} \]
        5. Simplified1.6%

          \[\leadsto \frac{\color{blue}{b \cdot b}}{3 \cdot a} \]
        6. Taylor expanded in a around -inf

          \[\leadsto \frac{b \cdot b}{\color{blue}{-1 \cdot a}} \]
        7. Step-by-step derivation
          1. mul-1-negN/A

            \[\leadsto \frac{b \cdot b}{\color{blue}{\mathsf{neg}\left(a\right)}} \]
          2. lower-neg.f6410.9

            \[\leadsto \frac{b \cdot b}{\color{blue}{-a}} \]
        8. Simplified10.9%

          \[\leadsto \frac{b \cdot b}{\color{blue}{-a}} \]
        9. Step-by-step derivation
          1. lift-neg.f64N/A

            \[\leadsto \frac{b \cdot b}{\color{blue}{\mathsf{neg}\left(a\right)}} \]
          2. associate-/l*N/A

            \[\leadsto \color{blue}{b \cdot \frac{b}{\mathsf{neg}\left(a\right)}} \]
          3. *-commutativeN/A

            \[\leadsto \color{blue}{\frac{b}{\mathsf{neg}\left(a\right)} \cdot b} \]
          4. lower-*.f64N/A

            \[\leadsto \color{blue}{\frac{b}{\mathsf{neg}\left(a\right)} \cdot b} \]
          5. lower-/.f6410.9

            \[\leadsto \color{blue}{\frac{b}{-a}} \cdot b \]
        10. Applied egg-rr10.9%

          \[\leadsto \color{blue}{\frac{b}{-a} \cdot b} \]
        11. Final simplification10.9%

          \[\leadsto b \cdot \frac{b}{-a} \]
        12. Add Preprocessing

        Reproduce

        ?
        herbie shell --seed 2024214 
        (FPCore (a b c)
          :name "Cubic critical, narrow range"
          :precision binary64
          :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
          (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))