Cubic critical, medium range

Percentage Accurate: 31.1% → 99.1%
Time: 11.7s
Alternatives: 6
Speedup: N/A×

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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    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 6 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.1% 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);
}
module fmin_fmax_functions
    implicit none
    private
    public fmax
    public fmin

    interface fmax
        module procedure fmax88
        module procedure fmax44
        module procedure fmax84
        module procedure fmax48
    end interface
    interface fmin
        module procedure fmin88
        module procedure fmin44
        module procedure fmin84
        module procedure fmin48
    end interface
contains
    real(8) function fmax88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(4) function fmax44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, max(x, y), y /= y), x /= x)
    end function
    real(8) function fmax84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, max(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmax48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), max(dble(x), y), y /= y), x /= x)
    end function
    real(8) function fmin88(x, y) result (res)
        real(8), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(4) function fmin44(x, y) result (res)
        real(4), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(y, merge(x, min(x, y), y /= y), x /= x)
    end function
    real(8) function fmin84(x, y) result(res)
        real(8), intent (in) :: x
        real(4), intent (in) :: y
        res = merge(dble(y), merge(x, min(x, dble(y)), y /= y), x /= x)
    end function
    real(8) function fmin48(x, y) result(res)
        real(4), intent (in) :: x
        real(8), intent (in) :: y
        res = merge(y, merge(dble(x), min(dble(x), y), y /= y), x /= x)
    end function
end module

real(8) function code(a, b, c)
use fmin_fmax_functions
    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.1% accurate, N/A× speedup?

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

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

    \[\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{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
    3. 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} \]
    4. 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} \]
    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-*.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} \]
    7. 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} \]
    8. flip-+N/A

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

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

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

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

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

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

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

    \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - {\color{blue}{\left(a \cdot \left(-3 \cdot c + \frac{{b}^{2}}{a}\right)\right)}}^{\frac{1}{2}}}}{3 \cdot a} \]
  9. Step-by-step derivation
    1. lower-*.f64N/A

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

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

      \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - {\left(a \cdot \mathsf{fma}\left(-3, c, \frac{{b}^{2}}{a}\right)\right)}^{\frac{1}{2}}}}{3 \cdot a} \]
    4. pow2N/A

      \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - {\left(a \cdot \mathsf{fma}\left(-3, c, \frac{b \cdot b}{a}\right)\right)}^{\frac{1}{2}}}}{3 \cdot a} \]
    5. lift-*.f6499.3

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

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

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

Alternative 2: 99.1% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} \mathbf{if}\;\frac{-1 \cdot b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \leq -2 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{-3 \cdot \left(a \cdot c\right)}{b + e^{\log \left(\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) \cdot 0.5}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot \frac{\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125}{b}, -0.16666666666666666, \frac{-0.5625 \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{5}}\right), a, \frac{-0.375 \cdot \left(c \cdot c\right)}{{b}^{3}}\right), a, \frac{c}{b} \cdot -0.5\right)\\ \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (if (<=
      (/ (+ (* -1.0 b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a))
      -2e-16)
   (/
    (/
     (- (* 3.0 (* a c)))
     (+ b (exp (* (log (fma b b (* -3.0 (* c a)))) 0.5))))
    (* 3.0 a))
   (fma
    (fma
     (fma
      (* a (/ (* (/ (pow c 4.0) (pow b 6.0)) 6.328125) b))
      -0.16666666666666666
      (/ (* -0.5625 (* (* c c) c)) (pow b 5.0)))
     a
     (/ (* -0.375 (* c c)) (pow b 3.0)))
    a
    (* (/ c b) -0.5))))
double code(double a, double b, double c) {
	double tmp;
	if ((((-1.0 * b) + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)) <= -2e-16) {
		tmp = (-(3.0 * (a * c)) / (b + exp((log(fma(b, b, (-3.0 * (c * a)))) * 0.5)))) / (3.0 * a);
	} else {
		tmp = fma(fma(fma((a * (((pow(c, 4.0) / pow(b, 6.0)) * 6.328125) / b)), -0.16666666666666666, ((-0.5625 * ((c * c) * c)) / pow(b, 5.0))), a, ((-0.375 * (c * c)) / pow(b, 3.0))), a, ((c / b) * -0.5));
	}
	return tmp;
}
function code(a, b, c)
	tmp = 0.0
	if (Float64(Float64(Float64(-1.0 * b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a)) <= -2e-16)
		tmp = Float64(Float64(Float64(-Float64(3.0 * Float64(a * c))) / Float64(b + exp(Float64(log(fma(b, b, Float64(-3.0 * Float64(c * a)))) * 0.5)))) / Float64(3.0 * a));
	else
		tmp = fma(fma(fma(Float64(a * Float64(Float64(Float64((c ^ 4.0) / (b ^ 6.0)) * 6.328125) / b)), -0.16666666666666666, Float64(Float64(-0.5625 * Float64(Float64(c * c) * c)) / (b ^ 5.0))), a, Float64(Float64(-0.375 * Float64(c * c)) / (b ^ 3.0))), a, Float64(Float64(c / b) * -0.5));
	end
	return tmp
end
code[a_, b_, c_] := If[LessEqual[N[(N[(N[(-1.0 * b), $MachinePrecision] + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], -2e-16], N[(N[((-N[(3.0 * N[(a * c), $MachinePrecision]), $MachinePrecision]) / N[(b + N[Exp[N[(N[Log[N[(b * b + N[(-3.0 * N[(c * a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]], $MachinePrecision] * 0.5), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision], N[(N[(N[(N[(a * N[(N[(N[(N[Power[c, 4.0], $MachinePrecision] / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] * 6.328125), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] * -0.16666666666666666 + N[(N[(-0.5625 * N[(N[(c * c), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + N[(N[(-0.375 * N[(c * c), $MachinePrecision]), $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * a + N[(N[(c / b), $MachinePrecision] * -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
\mathbf{if}\;\frac{-1 \cdot b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \leq -2 \cdot 10^{-16}:\\
\;\;\;\;\frac{\frac{-3 \cdot \left(a \cdot c\right)}{b + e^{\log \left(\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) \cdot 0.5}}}{3 \cdot a}\\

\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot \frac{\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125}{b}, -0.16666666666666666, \frac{-0.5625 \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{5}}\right), a, \frac{-0.375 \cdot \left(c \cdot c\right)}{{b}^{3}}\right), a, \frac{c}{b} \cdot -0.5\right)\\


\end{array}
\end{array}
Derivation
  1. Split input into 2 regimes
  2. if (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a)) < -2e-16

    1. Initial program 63.6%

      \[\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{\color{blue}{\left(\mathsf{neg}\left(b\right)\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}}{3 \cdot a} \]
      3. 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} \]
      4. 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} \]
      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-*.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} \]
      7. 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} \]
      8. flip-+N/A

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

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

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

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

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

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

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

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

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

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

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

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

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - {\left({b}^{1} \cdot {b}^{1} + \color{blue}{-3 \cdot \left(c \cdot a\right)}\right)}^{\frac{1}{2}}}}{3 \cdot a} \]
      7. pow-to-expN/A

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - \color{blue}{e^{\log \left({b}^{1} \cdot {b}^{1} + -3 \cdot \left(c \cdot a\right)\right) \cdot \frac{1}{2}}}}}{3 \cdot a} \]
      8. lower-exp.f64N/A

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - \color{blue}{e^{\log \left({b}^{1} \cdot {b}^{1} + -3 \cdot \left(c \cdot a\right)\right) \cdot \frac{1}{2}}}}}{3 \cdot a} \]
      9. lower-*.f64N/A

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - e^{\color{blue}{\log \left({b}^{1} \cdot {b}^{1} + -3 \cdot \left(c \cdot a\right)\right) \cdot \frac{1}{2}}}}}{3 \cdot a} \]
      10. lower-log.f64N/A

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - e^{\color{blue}{\log \left({b}^{1} \cdot {b}^{1} + -3 \cdot \left(c \cdot a\right)\right)} \cdot \frac{1}{2}}}}{3 \cdot a} \]
      11. unpow1N/A

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - e^{\log \left(\color{blue}{b} \cdot {b}^{1} + -3 \cdot \left(c \cdot a\right)\right) \cdot \frac{1}{2}}}}{3 \cdot a} \]
      12. unpow1N/A

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - e^{\log \left(b \cdot \color{blue}{b} + -3 \cdot \left(c \cdot a\right)\right) \cdot \frac{1}{2}}}}{3 \cdot a} \]
      13. lower-fma.f64N/A

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

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - e^{\log \left(\mathsf{fma}\left(b, b, \color{blue}{-3 \cdot \left(c \cdot a\right)}\right)\right) \cdot \frac{1}{2}}}}{3 \cdot a} \]
      15. lift-*.f6498.2

        \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - e^{\log \left(\mathsf{fma}\left(b, b, -3 \cdot \color{blue}{\left(c \cdot a\right)}\right)\right) \cdot 0.5}}}{3 \cdot a} \]
    9. Applied rewrites98.2%

      \[\leadsto \frac{\frac{3 \cdot \left(a \cdot c\right)}{-1 \cdot b - \color{blue}{e^{\log \left(\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) \cdot 0.5}}}}{3 \cdot a} \]

    if -2e-16 < (/.f64 (+.f64 (neg.f64 b) (sqrt.f64 (-.f64 (*.f64 b b) (*.f64 (*.f64 #s(literal 3 binary64) a) c)))) (*.f64 #s(literal 3 binary64) a))

    1. Initial program 4.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 a around 0

      \[\leadsto \color{blue}{\frac{-1}{2} \cdot \frac{c}{b} + a \cdot \left(\frac{-3}{8} \cdot \frac{{c}^{2}}{{b}^{3}} + a \cdot \left(\frac{-9}{16} \cdot \frac{{c}^{3}}{{b}^{5}} + \frac{-1}{6} \cdot \frac{a \cdot \left(\frac{81}{64} \cdot \frac{{c}^{4}}{{b}^{6}} + \frac{81}{16} \cdot \frac{{c}^{4}}{{b}^{6}}\right)}{b}\right)\right)} \]
    4. Applied rewrites100.0%

      \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot \frac{\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125}{b}, -0.16666666666666666, \frac{-0.5625 \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{5}}\right), a, \frac{-0.375 \cdot \left(c \cdot c\right)}{{b}^{3}}\right), a, \frac{c}{b} \cdot -0.5\right)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification99.2%

    \[\leadsto \begin{array}{l} \mathbf{if}\;\frac{-1 \cdot b + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \leq -2 \cdot 10^{-16}:\\ \;\;\;\;\frac{\frac{-3 \cdot \left(a \cdot c\right)}{b + e^{\log \left(\mathsf{fma}\left(b, b, -3 \cdot \left(c \cdot a\right)\right)\right) \cdot 0.5}}}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(a \cdot \frac{\frac{{c}^{4}}{{b}^{6}} \cdot 6.328125}{b}, -0.16666666666666666, \frac{-0.5625 \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{5}}\right), a, \frac{-0.375 \cdot \left(c \cdot c\right)}{{b}^{3}}\right), a, \frac{c}{b} \cdot -0.5\right)\\ \end{array} \]
  5. Add Preprocessing

Alternative 3: 95.8% accurate, N/A× speedup?

\[\begin{array}{l} \\ \frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot -0.5625}{b} + \frac{\mathsf{fma}\left(\frac{c \cdot c}{b} \cdot \frac{a}{b}, -0.375, -0.5 \cdot c\right) + \frac{-0.16666666666666666}{{b}^{6}} \cdot \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{a}}{b} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (+
  (/ (* (/ (* (* a a) (* (* c c) c)) (pow b 4.0)) -0.5625) b)
  (/
   (+
    (fma (* (/ (* c c) b) (/ a b)) -0.375 (* -0.5 c))
    (*
     (/ -0.16666666666666666 (pow b 6.0))
     (/ (* (pow (* c a) 4.0) 6.328125) a)))
   b)))
double code(double a, double b, double c) {
	return (((((a * a) * ((c * c) * c)) / pow(b, 4.0)) * -0.5625) / b) + ((fma((((c * c) / b) * (a / b)), -0.375, (-0.5 * c)) + ((-0.16666666666666666 / pow(b, 6.0)) * ((pow((c * a), 4.0) * 6.328125) / a))) / b);
}
function code(a, b, c)
	return Float64(Float64(Float64(Float64(Float64(Float64(a * a) * Float64(Float64(c * c) * c)) / (b ^ 4.0)) * -0.5625) / b) + Float64(Float64(fma(Float64(Float64(Float64(c * c) / b) * Float64(a / b)), -0.375, Float64(-0.5 * c)) + Float64(Float64(-0.16666666666666666 / (b ^ 6.0)) * Float64(Float64((Float64(c * a) ^ 4.0) * 6.328125) / a))) / b))
end
code[a_, b_, c_] := N[(N[(N[(N[(N[(N[(a * a), $MachinePrecision] * N[(N[(c * c), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision] / N[Power[b, 4.0], $MachinePrecision]), $MachinePrecision] * -0.5625), $MachinePrecision] / b), $MachinePrecision] + N[(N[(N[(N[(N[(N[(c * c), $MachinePrecision] / b), $MachinePrecision] * N[(a / b), $MachinePrecision]), $MachinePrecision] * -0.375 + N[(-0.5 * c), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.16666666666666666 / N[Power[b, 6.0], $MachinePrecision]), $MachinePrecision] * N[(N[(N[Power[N[(c * a), $MachinePrecision], 4.0], $MachinePrecision] * 6.328125), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}

\\
\frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot -0.5625}{b} + \frac{\mathsf{fma}\left(\frac{c \cdot c}{b} \cdot \frac{a}{b}, -0.375, -0.5 \cdot c\right) + \frac{-0.16666666666666666}{{b}^{6}} \cdot \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{a}}{b}
\end{array}
Derivation
  1. Initial program 30.6%

    \[\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 \color{blue}{\frac{\frac{-9}{16} \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(\frac{-1}{2} \cdot c + \left(\frac{-3}{8} \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{6} \cdot \frac{\frac{81}{64} \cdot \left({a}^{4} \cdot {c}^{4}\right) + \frac{81}{16} \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{b}} \]
  4. Applied rewrites95.5%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}}, -0.5625, \mathsf{fma}\left(\frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -0.375, -0.5 \cdot c\right) + \frac{-0.16666666666666666 \cdot \left({\left(c \cdot a\right)}^{4} \cdot 6.328125\right)}{{b}^{6} \cdot a}\right)}{b}} \]
  5. Applied rewrites95.5%

    \[\leadsto \frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot -0.5625}{b} + \color{blue}{\frac{\mathsf{fma}\left(\frac{c \cdot c}{b} \cdot \frac{a}{b}, -0.375, -0.5 \cdot c\right) + \frac{-0.16666666666666666}{{b}^{6}} \cdot \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{a}}{b}} \]
  6. Add Preprocessing

Alternative 4: 95.5% accurate, N/A× speedup?

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

\\
\frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot -0.5625}{b} + c \cdot \left(c \cdot \mathsf{fma}\left(-1.0546875, \frac{\left(\left(a \cdot a\right) \cdot a\right) \cdot \left(c \cdot c\right)}{{b}^{7}}, -0.375 \cdot \frac{a}{{b}^{3}}\right) - 0.5 \cdot {b}^{-1}\right)
\end{array}
Derivation
  1. Initial program 30.6%

    \[\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 \color{blue}{\frac{\frac{-9}{16} \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(\frac{-1}{2} \cdot c + \left(\frac{-3}{8} \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{6} \cdot \frac{\frac{81}{64} \cdot \left({a}^{4} \cdot {c}^{4}\right) + \frac{81}{16} \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{b}} \]
  4. Applied rewrites95.5%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}}, -0.5625, \mathsf{fma}\left(\frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -0.375, -0.5 \cdot c\right) + \frac{-0.16666666666666666 \cdot \left({\left(c \cdot a\right)}^{4} \cdot 6.328125\right)}{{b}^{6} \cdot a}\right)}{b}} \]
  5. Applied rewrites95.5%

    \[\leadsto \frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot -0.5625}{b} + \color{blue}{\frac{\mathsf{fma}\left(\frac{c \cdot c}{b} \cdot \frac{a}{b}, -0.375, -0.5 \cdot c\right) + \frac{-0.16666666666666666}{{b}^{6}} \cdot \frac{{\left(c \cdot a\right)}^{4} \cdot 6.328125}{a}}{b}} \]
  6. Taylor expanded in c around 0

    \[\leadsto \frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot \frac{-9}{16}}{b} + c \cdot \color{blue}{\left(c \cdot \left(\frac{-135}{128} \cdot \frac{{a}^{3} \cdot {c}^{2}}{{b}^{7}} + \frac{-3}{8} \cdot \frac{a}{{b}^{3}}\right) - \frac{1}{2} \cdot \frac{1}{b}\right)} \]
  7. Step-by-step derivation
    1. lower-*.f64N/A

      \[\leadsto \frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot \frac{-9}{16}}{b} + c \cdot \left(c \cdot \left(\frac{-135}{128} \cdot \frac{{a}^{3} \cdot {c}^{2}}{{b}^{7}} + \frac{-3}{8} \cdot \frac{a}{{b}^{3}}\right) - \color{blue}{\frac{1}{2} \cdot \frac{1}{b}}\right) \]
    2. lower--.f64N/A

      \[\leadsto \frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot \frac{-9}{16}}{b} + c \cdot \left(c \cdot \left(\frac{-135}{128} \cdot \frac{{a}^{3} \cdot {c}^{2}}{{b}^{7}} + \frac{-3}{8} \cdot \frac{a}{{b}^{3}}\right) - \frac{1}{2} \cdot \color{blue}{\frac{1}{b}}\right) \]
  8. Applied rewrites95.2%

    \[\leadsto \frac{\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}} \cdot -0.5625}{b} + c \cdot \color{blue}{\left(c \cdot \mathsf{fma}\left(-1.0546875, \frac{\left(\left(a \cdot a\right) \cdot a\right) \cdot \left(c \cdot c\right)}{{b}^{7}}, -0.375 \cdot \frac{a}{{b}^{3}}\right) - 0.5 \cdot {b}^{-1}\right)} \]
  9. Add Preprocessing

Alternative 5: 95.5% accurate, N/A× speedup?

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

\\
\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{c}{a} \cdot \frac{\frac{{a}^{4}}{{b}^{6}} \cdot 6.328125}{b}, -0.16666666666666666, \frac{-0.5625 \cdot \left(a \cdot a\right)}{{b}^{5}}\right), c, \frac{a}{{b}^{3}} \cdot -0.375\right), c, -0.5 \cdot {b}^{-1}\right) \cdot c
\end{array}
Derivation
  1. Initial program 30.6%

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

    \[\leadsto \color{blue}{c \cdot \left(c \cdot \left(\frac{-3}{8} \cdot \frac{a}{{b}^{3}} + c \cdot \left(\frac{-9}{16} \cdot \frac{{a}^{2}}{{b}^{5}} + \frac{-1}{6} \cdot \frac{c \cdot \left(\frac{81}{64} \cdot \frac{{a}^{4}}{{b}^{6}} + \frac{81}{16} \cdot \frac{{a}^{4}}{{b}^{6}}\right)}{a \cdot b}\right)\right) - \frac{1}{2} \cdot \frac{1}{b}\right)} \]
  4. Applied rewrites95.2%

    \[\leadsto \color{blue}{\mathsf{fma}\left(\mathsf{fma}\left(\mathsf{fma}\left(\frac{c}{a} \cdot \frac{\frac{{a}^{4}}{{b}^{6}} \cdot 6.328125}{b}, -0.16666666666666666, \frac{-0.5625 \cdot \left(a \cdot a\right)}{{b}^{5}}\right), c, \frac{a}{{b}^{3}} \cdot -0.375\right), c, -0.5 \cdot {b}^{-1}\right) \cdot c} \]
  5. Add Preprocessing

Alternative 6: 95.4% accurate, N/A× speedup?

\[\begin{array}{l} \\ \begin{array}{l} t_0 := \left(a \cdot a\right) \cdot a\\ t\_0 \cdot \left(-1.0546875 \cdot \frac{{c}^{4}}{{b}^{7}} + \left(-0.5625 \cdot \frac{\left(c \cdot c\right) \cdot c}{a \cdot {b}^{5}} + \mathsf{fma}\left(-0.5, \frac{c}{t\_0 \cdot b}, -0.375 \cdot \frac{c \cdot c}{\left(a \cdot a\right) \cdot {b}^{3}}\right)\right)\right) \end{array} \end{array} \]
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (* (* a a) a)))
   (*
    t_0
    (+
     (* -1.0546875 (/ (pow c 4.0) (pow b 7.0)))
     (+
      (* -0.5625 (/ (* (* c c) c) (* a (pow b 5.0))))
      (fma
       -0.5
       (/ c (* t_0 b))
       (* -0.375 (/ (* c c) (* (* a a) (pow b 3.0))))))))))
double code(double a, double b, double c) {
	double t_0 = (a * a) * a;
	return t_0 * ((-1.0546875 * (pow(c, 4.0) / pow(b, 7.0))) + ((-0.5625 * (((c * c) * c) / (a * pow(b, 5.0)))) + fma(-0.5, (c / (t_0 * b)), (-0.375 * ((c * c) / ((a * a) * pow(b, 3.0)))))));
}
function code(a, b, c)
	t_0 = Float64(Float64(a * a) * a)
	return Float64(t_0 * Float64(Float64(-1.0546875 * Float64((c ^ 4.0) / (b ^ 7.0))) + Float64(Float64(-0.5625 * Float64(Float64(Float64(c * c) * c) / Float64(a * (b ^ 5.0)))) + fma(-0.5, Float64(c / Float64(t_0 * b)), Float64(-0.375 * Float64(Float64(c * c) / Float64(Float64(a * a) * (b ^ 3.0))))))))
end
code[a_, b_, c_] := Block[{t$95$0 = N[(N[(a * a), $MachinePrecision] * a), $MachinePrecision]}, N[(t$95$0 * N[(N[(-1.0546875 * N[(N[Power[c, 4.0], $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5625 * N[(N[(N[(c * c), $MachinePrecision] * c), $MachinePrecision] / N[(a * N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / N[(t$95$0 * b), $MachinePrecision]), $MachinePrecision] + N[(-0.375 * N[(N[(c * c), $MachinePrecision] / N[(N[(a * a), $MachinePrecision] * N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}

\\
\begin{array}{l}
t_0 := \left(a \cdot a\right) \cdot a\\
t\_0 \cdot \left(-1.0546875 \cdot \frac{{c}^{4}}{{b}^{7}} + \left(-0.5625 \cdot \frac{\left(c \cdot c\right) \cdot c}{a \cdot {b}^{5}} + \mathsf{fma}\left(-0.5, \frac{c}{t\_0 \cdot b}, -0.375 \cdot \frac{c \cdot c}{\left(a \cdot a\right) \cdot {b}^{3}}\right)\right)\right)
\end{array}
\end{array}
Derivation
  1. Initial program 30.6%

    \[\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 \color{blue}{\frac{\frac{-9}{16} \cdot \frac{{a}^{2} \cdot {c}^{3}}{{b}^{4}} + \left(\frac{-1}{2} \cdot c + \left(\frac{-3}{8} \cdot \frac{a \cdot {c}^{2}}{{b}^{2}} + \frac{-1}{6} \cdot \frac{\frac{81}{64} \cdot \left({a}^{4} \cdot {c}^{4}\right) + \frac{81}{16} \cdot \left({a}^{4} \cdot {c}^{4}\right)}{a \cdot {b}^{6}}\right)\right)}{b}} \]
  4. Applied rewrites95.5%

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(\frac{\left(a \cdot a\right) \cdot \left(\left(c \cdot c\right) \cdot c\right)}{{b}^{4}}, -0.5625, \mathsf{fma}\left(\frac{\left(c \cdot c\right) \cdot a}{b \cdot b}, -0.375, -0.5 \cdot c\right) + \frac{-0.16666666666666666 \cdot \left({\left(c \cdot a\right)}^{4} \cdot 6.328125\right)}{{b}^{6} \cdot a}\right)}{b}} \]
  5. Taylor expanded in a around inf

    \[\leadsto {a}^{3} \cdot \color{blue}{\left(\frac{-135}{128} \cdot \frac{{c}^{4}}{{b}^{7}} + \left(\frac{-9}{16} \cdot \frac{{c}^{3}}{a \cdot {b}^{5}} + \left(\frac{-1}{2} \cdot \frac{c}{{a}^{3} \cdot b} + \frac{-3}{8} \cdot \frac{{c}^{2}}{{a}^{2} \cdot {b}^{3}}\right)\right)\right)} \]
  6. Applied rewrites95.1%

    \[\leadsto \left(\left(a \cdot a\right) \cdot a\right) \cdot \color{blue}{\left(-1.0546875 \cdot \frac{{c}^{4}}{{b}^{7}} + \left(-0.5625 \cdot \frac{\left(c \cdot c\right) \cdot c}{a \cdot {b}^{5}} + \mathsf{fma}\left(-0.5, \frac{c}{\left(\left(a \cdot a\right) \cdot a\right) \cdot b}, -0.375 \cdot \frac{c \cdot c}{\left(a \cdot a\right) \cdot {b}^{3}}\right)\right)\right)} \]
  7. Add Preprocessing

Reproduce

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