Cubic critical, medium range

Percentage Accurate: 31.3% → 99.3%
Time: 10.6s
Alternatives: 8
Speedup: 2.9×

Specification

?
\[\left(\left(1.1102230246251565 \cdot 10^{-16} < a \land a < 9007199254740992\right) \land \left(1.1102230246251565 \cdot 10^{-16} < b \land b < 9007199254740992\right)\right) \land \left(1.1102230246251565 \cdot 10^{-16} < c \land c < 9007199254740992\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 8 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: 31.3% 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.7× speedup?

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

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

    \[\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-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 2: 99.2% accurate, 0.7× speedup?

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

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

    \[\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-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

      \[\leadsto \frac{\left(\left(\mathsf{neg}\left(\color{blue}{-3 \cdot c}\right)\right) \cdot a\right) \cdot \frac{\frac{1}{3}}{a}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)}} \]
    9. distribute-lft-neg-inN/A

      \[\leadsto \frac{\left(\color{blue}{\left(\left(\mathsf{neg}\left(-3\right)\right) \cdot c\right)} \cdot a\right) \cdot \frac{\frac{1}{3}}{a}}{\left(-b\right) - \sqrt{\mathsf{fma}\left(-3 \cdot c, a, b \cdot b\right)}} \]
    10. metadata-evalN/A

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

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

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

Alternative 3: 99.2% accurate, 0.7× speedup?

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

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

    \[\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-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

Alternative 4: 99.2% accurate, 0.8× speedup?

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

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

    \[\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-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 5: 99.1% accurate, 0.8× speedup?

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

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

    \[\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-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 6: 99.2% accurate, 0.8× speedup?

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

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

    \[\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-/.f64N/A

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Alternative 7: 90.9% accurate, 1.1× speedup?

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

\\
\frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, 0.5 \cdot \frac{a}{b}\right)}
\end{array}
Derivation
  1. Initial program 30.5%

    \[\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-/.f64N/A

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

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

      \[\leadsto \frac{1}{\frac{\color{blue}{3 \cdot a}}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}} \]
    4. associate-/l*N/A

      \[\leadsto \frac{1}{\color{blue}{3 \cdot \frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}} \]
    5. associate-/r*N/A

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

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

      \[\leadsto \frac{\color{blue}{\frac{1}{3}}}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}} \]
    8. lower-/.f6430.5

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

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

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

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

      \[\leadsto \frac{\frac{1}{3}}{\frac{a}{\color{blue}{\sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c} - b}}} \]
    13. lower--.f6430.5

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

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

    \[\leadsto \frac{\frac{1}{3}}{\color{blue}{\frac{-2}{3} \cdot \frac{b}{c} + \frac{1}{2} \cdot \frac{a}{b}}} \]
  6. Step-by-step derivation
    1. lower-fma.f64N/A

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

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

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

      \[\leadsto \frac{0.3333333333333333}{\mathsf{fma}\left(-0.6666666666666666, \frac{b}{c}, 0.5 \cdot \color{blue}{\frac{a}{b}}\right)} \]
  7. Applied rewrites90.4%

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

Alternative 8: 81.4% accurate, 2.9× speedup?

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

\\
-0.5 \cdot \frac{c}{b}
\end{array}
Derivation
  1. Initial program 30.5%

    \[\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 a around 0

    \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
  4. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b}} \]
    2. lower-/.f6481.5

      \[\leadsto -0.5 \cdot \color{blue}{\frac{c}{b}} \]
  5. Applied rewrites81.5%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  6. Add Preprocessing

Reproduce

?
herbie shell --seed 2024314 
(FPCore (a b c)
  :name "Cubic critical, medium range"
  :precision binary64
  :pre (and (and (and (< 1.1102230246251565e-16 a) (< a 9007199254740992.0)) (and (< 1.1102230246251565e-16 b) (< b 9007199254740992.0))) (and (< 1.1102230246251565e-16 c) (< c 9007199254740992.0)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))