Cubic critical, medium range

Percentage Accurate: 31.8% → 95.4%
Time: 17.5s
Alternatives: 7
Speedup: 23.2×

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 7 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.8% 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: 95.4% accurate, 0.2× speedup?

\[\begin{array}{l} \\ \frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, a \cdot \mathsf{fma}\left(a, -3 \cdot \left(a \cdot \left(-0.5625 \cdot \frac{{c}^{2}}{{b}^{5}}\right) + \frac{c}{{b}^{3}} \cdot -0.375\right), \frac{1.5}{b}\right)\right)} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/
  1.0
  (fma
   -2.0
   (/ b c)
   (*
    a
    (fma
     a
     (*
      -3.0
      (+
       (* a (* -0.5625 (/ (pow c 2.0) (pow b 5.0))))
       (* (/ c (pow b 3.0)) -0.375)))
     (/ 1.5 b))))))
double code(double a, double b, double c) {
	return 1.0 / fma(-2.0, (b / c), (a * fma(a, (-3.0 * ((a * (-0.5625 * (pow(c, 2.0) / pow(b, 5.0)))) + ((c / pow(b, 3.0)) * -0.375))), (1.5 / b))));
}
function code(a, b, c)
	return Float64(1.0 / fma(-2.0, Float64(b / c), Float64(a * fma(a, Float64(-3.0 * Float64(Float64(a * Float64(-0.5625 * Float64((c ^ 2.0) / (b ^ 5.0)))) + Float64(Float64(c / (b ^ 3.0)) * -0.375))), Float64(1.5 / b)))))
end
code[a_, b_, c_] := N[(1.0 / N[(-2.0 * N[(b / c), $MachinePrecision] + N[(a * N[(a * N[(-3.0 * N[(N[(a * N[(-0.5625 * N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.5 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, a \cdot \mathsf{fma}\left(a, -3 \cdot \left(a \cdot \left(-0.5625 \cdot \frac{{c}^{2}}{{b}^{5}}\right) + \frac{c}{{b}^{3}} \cdot -0.375\right), \frac{1.5}{b}\right)\right)}
\end{array}
Derivation
  1. Initial program 33.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity33.8%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{1}}}{3 \cdot a} \]
    2. metadata-eval33.8%

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

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

    \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)}} - b}{3 \cdot a} \]
  6. Step-by-step derivation
    1. clear-num33.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}}} \]
    2. inv-pow33.7%

      \[\leadsto \color{blue}{{\left(\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
    3. *-commutative33.7%

      \[\leadsto {\left(\frac{\color{blue}{a \cdot 3}}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    4. *-commutative33.7%

      \[\leadsto {\left(\frac{a \cdot 3}{\sqrt{a \cdot \left(\color{blue}{c \cdot -3} + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    5. fma-define33.7%

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

    \[\leadsto \color{blue}{{\left(\frac{a \cdot 3}{\sqrt{a \cdot \mathsf{fma}\left(c, -3, \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
  8. Step-by-step derivation
    1. unpow-133.7%

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

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

    \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{b}{c} + a \cdot \left(a \cdot \left(-3 \cdot \left(a \cdot \left(-0.75 \cdot \frac{c \cdot \left(-0.75 \cdot \frac{c}{{b}^{3}} + 0.375 \cdot \frac{c}{{b}^{3}}\right)}{{b}^{2}} + \left(-0.2222222222222222 \cdot \frac{b \cdot \left(1.265625 \cdot \frac{{c}^{4}}{{b}^{6}} + 5.0625 \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{{c}^{2}} + 0.5625 \cdot \frac{{c}^{2}}{{b}^{5}}\right)\right)\right) + -3 \cdot \left(-0.75 \cdot \frac{c}{{b}^{3}} + 0.375 \cdot \frac{c}{{b}^{3}}\right)\right) + 1.5 \cdot \frac{1}{b}\right)}} \]
  11. Simplified94.4%

    \[\leadsto \frac{1}{\color{blue}{\mathsf{fma}\left(-2, \frac{b}{c}, a \cdot \mathsf{fma}\left(a, -3 \cdot \left(a \cdot \mathsf{fma}\left(-0.75, c \cdot \frac{\frac{c}{{b}^{3}} \cdot -0.375}{{b}^{2}}, \mathsf{fma}\left(-0.2222222222222222, b \cdot \frac{\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125}{{c}^{2}}, 0.5625 \cdot \frac{{c}^{2}}{{b}^{5}}\right)\right) + \frac{c}{{b}^{3}} \cdot -0.375\right), \frac{1.5}{b}\right)\right)}} \]
  12. Taylor expanded in c around 0 94.4%

    \[\leadsto \frac{1}{\mathsf{fma}\left(-2, \frac{b}{c}, a \cdot \mathsf{fma}\left(a, -3 \cdot \left(a \cdot \color{blue}{\left(-0.5625 \cdot \frac{{c}^{2}}{{b}^{5}}\right)} + \frac{c}{{b}^{3}} \cdot -0.375\right), \frac{1.5}{b}\right)\right)} \]
  13. Add Preprocessing

Alternative 2: 93.9% accurate, 0.3× speedup?

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

\\
\frac{1}{\frac{\mathsf{fma}\left(-2, b, c \cdot \mathsf{fma}\left(-3, c \cdot \left(-0.375 \cdot \frac{{a}^{2}}{{b}^{3}}\right), \frac{a \cdot 1.5}{b}\right)\right)}{c}}
\end{array}
Derivation
  1. Initial program 33.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity33.8%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{1}}}{3 \cdot a} \]
    2. metadata-eval33.8%

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

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

    \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)}} - b}{3 \cdot a} \]
  6. Step-by-step derivation
    1. clear-num33.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}}} \]
    2. inv-pow33.7%

      \[\leadsto \color{blue}{{\left(\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
    3. *-commutative33.7%

      \[\leadsto {\left(\frac{\color{blue}{a \cdot 3}}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    4. *-commutative33.7%

      \[\leadsto {\left(\frac{a \cdot 3}{\sqrt{a \cdot \left(\color{blue}{c \cdot -3} + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    5. fma-define33.7%

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

    \[\leadsto \color{blue}{{\left(\frac{a \cdot 3}{\sqrt{a \cdot \mathsf{fma}\left(c, -3, \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
  8. Step-by-step derivation
    1. unpow-133.7%

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{-2 \cdot b + c \cdot \left(-3 \cdot \left(c \cdot \left(-0.75 \cdot \frac{{a}^{2}}{{b}^{3}} + 0.375 \cdot \frac{{a}^{2}}{{b}^{3}}\right)\right) + 1.5 \cdot \frac{a}{b}\right)}{c}}} \]
  11. Step-by-step derivation
    1. fma-define92.6%

      \[\leadsto \frac{1}{\frac{\color{blue}{\mathsf{fma}\left(-2, b, c \cdot \left(-3 \cdot \left(c \cdot \left(-0.75 \cdot \frac{{a}^{2}}{{b}^{3}} + 0.375 \cdot \frac{{a}^{2}}{{b}^{3}}\right)\right) + 1.5 \cdot \frac{a}{b}\right)\right)}}{c}} \]
    2. fma-define92.6%

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-2, b, c \cdot \color{blue}{\mathsf{fma}\left(-3, c \cdot \left(-0.75 \cdot \frac{{a}^{2}}{{b}^{3}} + 0.375 \cdot \frac{{a}^{2}}{{b}^{3}}\right), 1.5 \cdot \frac{a}{b}\right)}\right)}{c}} \]
    3. distribute-rgt-out92.6%

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-2, b, c \cdot \mathsf{fma}\left(-3, c \cdot \color{blue}{\left(\frac{{a}^{2}}{{b}^{3}} \cdot \left(-0.75 + 0.375\right)\right)}, 1.5 \cdot \frac{a}{b}\right)\right)}{c}} \]
    4. metadata-eval92.6%

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-2, b, c \cdot \mathsf{fma}\left(-3, c \cdot \left(\frac{{a}^{2}}{{b}^{3}} \cdot \color{blue}{-0.375}\right), 1.5 \cdot \frac{a}{b}\right)\right)}{c}} \]
    5. associate-*r/92.6%

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-2, b, c \cdot \mathsf{fma}\left(-3, c \cdot \left(\frac{{a}^{2}}{{b}^{3}} \cdot -0.375\right), \color{blue}{\frac{1.5 \cdot a}{b}}\right)\right)}{c}} \]
    6. *-commutative92.6%

      \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-2, b, c \cdot \mathsf{fma}\left(-3, c \cdot \left(\frac{{a}^{2}}{{b}^{3}} \cdot -0.375\right), \frac{\color{blue}{a \cdot 1.5}}{b}\right)\right)}{c}} \]
  12. Simplified92.6%

    \[\leadsto \frac{1}{\color{blue}{\frac{\mathsf{fma}\left(-2, b, c \cdot \mathsf{fma}\left(-3, c \cdot \left(\frac{{a}^{2}}{{b}^{3}} \cdot -0.375\right), \frac{a \cdot 1.5}{b}\right)\right)}{c}}} \]
  13. Final simplification92.6%

    \[\leadsto \frac{1}{\frac{\mathsf{fma}\left(-2, b, c \cdot \mathsf{fma}\left(-3, c \cdot \left(-0.375 \cdot \frac{{a}^{2}}{{b}^{3}}\right), \frac{a \cdot 1.5}{b}\right)\right)}{c}} \]
  14. Add Preprocessing

Alternative 3: 93.9% accurate, 0.5× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \frac{c}{{b}^{3}}\\ \frac{1}{-2 \cdot \frac{b}{c} + a \cdot \left(-3 \cdot \left(a \cdot \left(t\_0 \cdot -0.75 + t\_0 \cdot 0.375\right)\right) + 1.5 \cdot \frac{1}{b}\right)} \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (/ c (pow b 3.0))))
   (/
    1.0
    (+
     (* -2.0 (/ b c))
     (*
      a
      (+ (* -3.0 (* a (+ (* t_0 -0.75) (* t_0 0.375)))) (* 1.5 (/ 1.0 b))))))))
double code(double a, double b, double c) {
	double t_0 = c / pow(b, 3.0);
	return 1.0 / ((-2.0 * (b / c)) + (a * ((-3.0 * (a * ((t_0 * -0.75) + (t_0 * 0.375)))) + (1.5 * (1.0 / b)))));
}
real(8) function code(a, b, c)
    real(8), intent (in) :: a
    real(8), intent (in) :: b
    real(8), intent (in) :: c
    real(8) :: t_0
    t_0 = c / (b ** 3.0d0)
    code = 1.0d0 / (((-2.0d0) * (b / c)) + (a * (((-3.0d0) * (a * ((t_0 * (-0.75d0)) + (t_0 * 0.375d0)))) + (1.5d0 * (1.0d0 / b)))))
end function
public static double code(double a, double b, double c) {
	double t_0 = c / Math.pow(b, 3.0);
	return 1.0 / ((-2.0 * (b / c)) + (a * ((-3.0 * (a * ((t_0 * -0.75) + (t_0 * 0.375)))) + (1.5 * (1.0 / b)))));
}
def code(a, b, c):
	t_0 = c / math.pow(b, 3.0)
	return 1.0 / ((-2.0 * (b / c)) + (a * ((-3.0 * (a * ((t_0 * -0.75) + (t_0 * 0.375)))) + (1.5 * (1.0 / b)))))
function code(a, b, c)
	t_0 = Float64(c / (b ^ 3.0))
	return Float64(1.0 / Float64(Float64(-2.0 * Float64(b / c)) + Float64(a * Float64(Float64(-3.0 * Float64(a * Float64(Float64(t_0 * -0.75) + Float64(t_0 * 0.375)))) + Float64(1.5 * Float64(1.0 / b))))))
end
function tmp = code(a, b, c)
	t_0 = c / (b ^ 3.0);
	tmp = 1.0 / ((-2.0 * (b / c)) + (a * ((-3.0 * (a * ((t_0 * -0.75) + (t_0 * 0.375)))) + (1.5 * (1.0 / b)))));
end
code[a_, b_, c_] := Block[{t$95$0 = N[(c / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]}, N[(1.0 / N[(N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(a * N[(N[(-3.0 * N[(a * N[(N[(t$95$0 * -0.75), $MachinePrecision] + N[(t$95$0 * 0.375), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(1.5 * N[(1.0 / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \frac{c}{{b}^{3}}\\
\frac{1}{-2 \cdot \frac{b}{c} + a \cdot \left(-3 \cdot \left(a \cdot \left(t\_0 \cdot -0.75 + t\_0 \cdot 0.375\right)\right) + 1.5 \cdot \frac{1}{b}\right)}
\end{array}
\end{array}
Derivation
  1. Initial program 33.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity33.8%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{1}}}{3 \cdot a} \]
    2. metadata-eval33.8%

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

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

    \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)}} - b}{3 \cdot a} \]
  6. Step-by-step derivation
    1. clear-num33.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}}} \]
    2. inv-pow33.7%

      \[\leadsto \color{blue}{{\left(\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
    3. *-commutative33.7%

      \[\leadsto {\left(\frac{\color{blue}{a \cdot 3}}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    4. *-commutative33.7%

      \[\leadsto {\left(\frac{a \cdot 3}{\sqrt{a \cdot \left(\color{blue}{c \cdot -3} + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    5. fma-define33.7%

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

    \[\leadsto \color{blue}{{\left(\frac{a \cdot 3}{\sqrt{a \cdot \mathsf{fma}\left(c, -3, \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
  8. Step-by-step derivation
    1. unpow-133.7%

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

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

    \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{b}{c} + a \cdot \left(-3 \cdot \left(a \cdot \left(-0.75 \cdot \frac{c}{{b}^{3}} + 0.375 \cdot \frac{c}{{b}^{3}}\right)\right) + 1.5 \cdot \frac{1}{b}\right)}} \]
  11. Final simplification92.6%

    \[\leadsto \frac{1}{-2 \cdot \frac{b}{c} + a \cdot \left(-3 \cdot \left(a \cdot \left(\frac{c}{{b}^{3}} \cdot -0.75 + \frac{c}{{b}^{3}} \cdot 0.375\right)\right) + 1.5 \cdot \frac{1}{b}\right)} \]
  12. Add Preprocessing

Alternative 4: 90.7% accurate, 7.7× speedup?

\[\begin{array}{l} \\ \frac{1}{\frac{-2 \cdot b + 1.5 \cdot \frac{c \cdot a}{b}}{c}} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ 1.0 (/ (+ (* -2.0 b) (* 1.5 (/ (* c a) b))) c)))
double code(double a, double b, double c) {
	return 1.0 / (((-2.0 * b) + (1.5 * ((c * a) / b))) / c);
}
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 / ((((-2.0d0) * b) + (1.5d0 * ((c * a) / b))) / c)
end function
public static double code(double a, double b, double c) {
	return 1.0 / (((-2.0 * b) + (1.5 * ((c * a) / b))) / c);
}
def code(a, b, c):
	return 1.0 / (((-2.0 * b) + (1.5 * ((c * a) / b))) / c)
function code(a, b, c)
	return Float64(1.0 / Float64(Float64(Float64(-2.0 * b) + Float64(1.5 * Float64(Float64(c * a) / b))) / c))
end
function tmp = code(a, b, c)
	tmp = 1.0 / (((-2.0 * b) + (1.5 * ((c * a) / b))) / c);
end
code[a_, b_, c_] := N[(1.0 / N[(N[(N[(-2.0 * b), $MachinePrecision] + N[(1.5 * N[(N[(c * a), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / c), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{\frac{-2 \cdot b + 1.5 \cdot \frac{c \cdot a}{b}}{c}}
\end{array}
Derivation
  1. Initial program 33.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity33.8%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{1}}}{3 \cdot a} \]
    2. metadata-eval33.8%

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

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

    \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)}} - b}{3 \cdot a} \]
  6. Step-by-step derivation
    1. clear-num33.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}}} \]
    2. inv-pow33.7%

      \[\leadsto \color{blue}{{\left(\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
    3. *-commutative33.7%

      \[\leadsto {\left(\frac{\color{blue}{a \cdot 3}}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    4. *-commutative33.7%

      \[\leadsto {\left(\frac{a \cdot 3}{\sqrt{a \cdot \left(\color{blue}{c \cdot -3} + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    5. fma-define33.7%

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

    \[\leadsto \color{blue}{{\left(\frac{a \cdot 3}{\sqrt{a \cdot \mathsf{fma}\left(c, -3, \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
  8. Step-by-step derivation
    1. unpow-133.7%

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

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

    \[\leadsto \frac{1}{\color{blue}{\frac{-2 \cdot b + 1.5 \cdot \frac{a \cdot c}{b}}{c}}} \]
  11. Final simplification89.5%

    \[\leadsto \frac{1}{\frac{-2 \cdot b + 1.5 \cdot \frac{c \cdot a}{b}}{c}} \]
  12. Add Preprocessing

Alternative 5: 90.7% accurate, 8.9× speedup?

\[\begin{array}{l} \\ \frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ 1.0 (+ (* -2.0 (/ b c)) (* 1.5 (/ a b)))))
double code(double a, double b, double c) {
	return 1.0 / ((-2.0 * (b / c)) + (1.5 * (a / 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 / (((-2.0d0) * (b / c)) + (1.5d0 * (a / b)))
end function
public static double code(double a, double b, double c) {
	return 1.0 / ((-2.0 * (b / c)) + (1.5 * (a / b)));
}
def code(a, b, c):
	return 1.0 / ((-2.0 * (b / c)) + (1.5 * (a / b)))
function code(a, b, c)
	return Float64(1.0 / Float64(Float64(-2.0 * Float64(b / c)) + Float64(1.5 * Float64(a / b))))
end
function tmp = code(a, b, c)
	tmp = 1.0 / ((-2.0 * (b / c)) + (1.5 * (a / b)));
end
code[a_, b_, c_] := N[(1.0 / N[(N[(-2.0 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(1.5 * N[(a / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{1}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}}
\end{array}
Derivation
  1. Initial program 33.8%

    \[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
  2. Step-by-step derivation
    1. /-rgt-identity33.8%

      \[\leadsto \frac{\color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{1}}}{3 \cdot a} \]
    2. metadata-eval33.8%

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

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

    \[\leadsto \frac{\sqrt{\color{blue}{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)}} - b}{3 \cdot a} \]
  6. Step-by-step derivation
    1. clear-num33.7%

      \[\leadsto \color{blue}{\frac{1}{\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}}} \]
    2. inv-pow33.7%

      \[\leadsto \color{blue}{{\left(\frac{3 \cdot a}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
    3. *-commutative33.7%

      \[\leadsto {\left(\frac{\color{blue}{a \cdot 3}}{\sqrt{a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    4. *-commutative33.7%

      \[\leadsto {\left(\frac{a \cdot 3}{\sqrt{a \cdot \left(\color{blue}{c \cdot -3} + \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1} \]
    5. fma-define33.7%

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

    \[\leadsto \color{blue}{{\left(\frac{a \cdot 3}{\sqrt{a \cdot \mathsf{fma}\left(c, -3, \frac{{b}^{2}}{a}\right)} - b}\right)}^{-1}} \]
  8. Step-by-step derivation
    1. unpow-133.7%

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

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

    \[\leadsto \frac{1}{\color{blue}{-2 \cdot \frac{b}{c} + 1.5 \cdot \frac{a}{b}}} \]
  11. Add Preprocessing

Alternative 6: 81.0% accurate, 23.2× speedup?

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

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

    \[\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 79.6%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  4. Step-by-step derivation
    1. associate-*r/79.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    2. *-commutative79.6%

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

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

Alternative 7: 80.8% accurate, 23.2× speedup?

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

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

    \[\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 79.6%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  4. Step-by-step derivation
    1. associate-*r/79.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    2. *-commutative79.6%

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

    \[\leadsto \color{blue}{\frac{c \cdot -0.5}{b}} \]
  6. Taylor expanded in c around 0 79.6%

    \[\leadsto \color{blue}{-0.5 \cdot \frac{c}{b}} \]
  7. Step-by-step derivation
    1. associate-*r/79.6%

      \[\leadsto \color{blue}{\frac{-0.5 \cdot c}{b}} \]
    2. *-commutative79.6%

      \[\leadsto \frac{\color{blue}{c \cdot -0.5}}{b} \]
    3. associate-*r/79.4%

      \[\leadsto \color{blue}{c \cdot \frac{-0.5}{b}} \]
  8. Simplified79.4%

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

Reproduce

?
herbie shell --seed 2024135 
(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)))