Average Error: 52.4 → 1.5
Time: 29.9s
Precision: binary64
Cost: 35968
\[\left(\left(4.930380657631324 \cdot 10^{-32} < a \land a < 2.028240960365167 \cdot 10^{+31}\right) \land \left(4.930380657631324 \cdot 10^{-32} < b \land b < 2.028240960365167 \cdot 10^{+31}\right)\right) \land \left(4.930380657631324 \cdot 10^{-32} < c \land c < 2.028240960365167 \cdot 10^{+31}\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\begin{array}{l} t_0 := {\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2}\\ -0.16666666666666666 \cdot \frac{{\left(\frac{1}{b}\right)}^{7} \cdot \left({\left(\left(\left(2.25 \cdot \left(c \cdot c\right)\right) \cdot a\right) \cdot a\right)}^{2} \cdot 1.25\right)}{a} + \left(-0.25 \cdot \left(c \cdot \left(t_0 \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{t_0 \cdot \frac{\frac{1}{b \cdot b}}{b}}{a} + -0.5 \cdot \frac{c}{b}\right)\right) \end{array} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (let* ((t_0 (pow (* -1.5 (* c a)) 2.0)))
   (+
    (*
     -0.16666666666666666
     (/
      (* (pow (/ 1.0 b) 7.0) (* (pow (* (* (* 2.25 (* c c)) a) a) 2.0) 1.25))
      a))
    (+
     (* -0.25 (* c (* t_0 (pow (/ 1.0 b) 5.0))))
     (+
      (* -0.16666666666666666 (/ (* t_0 (/ (/ 1.0 (* b b)) b)) a))
      (* -0.5 (/ c b)))))))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
}
double code(double a, double b, double c) {
	double t_0 = pow((-1.5 * (c * a)), 2.0);
	return (-0.16666666666666666 * ((pow((1.0 / b), 7.0) * (pow((((2.25 * (c * c)) * a) * a), 2.0) * 1.25)) / a)) + ((-0.25 * (c * (t_0 * pow((1.0 / b), 5.0)))) + ((-0.16666666666666666 * ((t_0 * ((1.0 / (b * b)) / b)) / a)) + (-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 = (-b + sqrt(((b * b) - ((3.0d0 * a) * c)))) / (3.0d0 * a)
end function
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 = ((-1.5d0) * (c * a)) ** 2.0d0
    code = ((-0.16666666666666666d0) * ((((1.0d0 / b) ** 7.0d0) * (((((2.25d0 * (c * c)) * a) * a) ** 2.0d0) * 1.25d0)) / a)) + (((-0.25d0) * (c * (t_0 * ((1.0d0 / b) ** 5.0d0)))) + (((-0.16666666666666666d0) * ((t_0 * ((1.0d0 / (b * b)) / b)) / a)) + ((-0.5d0) * (c / b))))
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);
}
public static double code(double a, double b, double c) {
	double t_0 = Math.pow((-1.5 * (c * a)), 2.0);
	return (-0.16666666666666666 * ((Math.pow((1.0 / b), 7.0) * (Math.pow((((2.25 * (c * c)) * a) * a), 2.0) * 1.25)) / a)) + ((-0.25 * (c * (t_0 * Math.pow((1.0 / b), 5.0)))) + ((-0.16666666666666666 * ((t_0 * ((1.0 / (b * b)) / b)) / a)) + (-0.5 * (c / b))));
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
def code(a, b, c):
	t_0 = math.pow((-1.5 * (c * a)), 2.0)
	return (-0.16666666666666666 * ((math.pow((1.0 / b), 7.0) * (math.pow((((2.25 * (c * c)) * a) * a), 2.0) * 1.25)) / a)) + ((-0.25 * (c * (t_0 * math.pow((1.0 / b), 5.0)))) + ((-0.16666666666666666 * ((t_0 * ((1.0 / (b * b)) / b)) / a)) + (-0.5 * (c / b))))
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(3.0 * a) * c)))) / Float64(3.0 * a))
end
function code(a, b, c)
	t_0 = Float64(-1.5 * Float64(c * a)) ^ 2.0
	return Float64(Float64(-0.16666666666666666 * Float64(Float64((Float64(1.0 / b) ^ 7.0) * Float64((Float64(Float64(Float64(2.25 * Float64(c * c)) * a) * a) ^ 2.0) * 1.25)) / a)) + Float64(Float64(-0.25 * Float64(c * Float64(t_0 * (Float64(1.0 / b) ^ 5.0)))) + Float64(Float64(-0.16666666666666666 * Float64(Float64(t_0 * Float64(Float64(1.0 / Float64(b * b)) / b)) / a)) + Float64(-0.5 * Float64(c / b)))))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a);
end
function tmp = code(a, b, c)
	t_0 = (-1.5 * (c * a)) ^ 2.0;
	tmp = (-0.16666666666666666 * ((((1.0 / b) ^ 7.0) * (((((2.25 * (c * c)) * a) * a) ^ 2.0) * 1.25)) / a)) + ((-0.25 * (c * (t_0 * ((1.0 / b) ^ 5.0)))) + ((-0.16666666666666666 * ((t_0 * ((1.0 / (b * b)) / b)) / a)) + (-0.5 * (c / b))));
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(3.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(3.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := Block[{t$95$0 = N[Power[N[(-1.5 * N[(c * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]}, N[(N[(-0.16666666666666666 * N[(N[(N[Power[N[(1.0 / b), $MachinePrecision], 7.0], $MachinePrecision] * N[(N[Power[N[(N[(N[(2.25 * N[(c * c), $MachinePrecision]), $MachinePrecision] * a), $MachinePrecision] * a), $MachinePrecision], 2.0], $MachinePrecision] * 1.25), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.25 * N[(c * N[(t$95$0 * N[Power[N[(1.0 / b), $MachinePrecision], 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.16666666666666666 * N[(N[(t$95$0 * N[(N[(1.0 / N[(b * b), $MachinePrecision]), $MachinePrecision] / b), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] + N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\begin{array}{l}
t_0 := {\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2}\\
-0.16666666666666666 \cdot \frac{{\left(\frac{1}{b}\right)}^{7} \cdot \left({\left(\left(\left(2.25 \cdot \left(c \cdot c\right)\right) \cdot a\right) \cdot a\right)}^{2} \cdot 1.25\right)}{a} + \left(-0.25 \cdot \left(c \cdot \left(t_0 \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{t_0 \cdot \frac{\frac{1}{b \cdot b}}{b}}{a} + -0.5 \cdot \frac{c}{b}\right)\right)
\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 52.4

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

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

    \[\leadsto \color{blue}{-0.16666666666666666 \cdot \frac{{\left(\frac{1}{b}\right)}^{7} \cdot \left(2.25 \cdot \left({\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot \left({a}^{2} \cdot {c}^{2}\right)\right) + {\left(-0.5 \cdot {\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2}\right)}^{2}\right)}{a} + \left(-0.25 \cdot \left(c \cdot \left({\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{{\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{3}}{a} + -0.5 \cdot \frac{c}{b}\right)\right)} \]
  4. Applied egg-rr1.5

    \[\leadsto -0.16666666666666666 \cdot \color{blue}{\left(\frac{1}{a} \cdot \left({\left(\frac{1}{b}\right)}^{7} \cdot {\left({\left(\left(-1.5 \cdot c\right) \cdot a\right)}^{2}\right)}^{2}\right) + \frac{1}{a} \cdot \left({\left(\frac{1}{b}\right)}^{7} \cdot \left(0.25 \cdot {\left({\left(\left(-1.5 \cdot c\right) \cdot a\right)}^{2}\right)}^{2}\right)\right)\right)} + \left(-0.25 \cdot \left(c \cdot \left({\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{{\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{3}}{a} + -0.5 \cdot \frac{c}{b}\right)\right) \]
  5. Simplified1.5

    \[\leadsto -0.16666666666666666 \cdot \color{blue}{\frac{{\left(\frac{1}{b}\right)}^{7} \cdot \left({\left({\left(\left(-1.5 \cdot c\right) \cdot a\right)}^{2}\right)}^{2} \cdot 1.25\right)}{a}} + \left(-0.25 \cdot \left(c \cdot \left({\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{{\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{3}}{a} + -0.5 \cdot \frac{c}{b}\right)\right) \]
    Proof
  6. Applied egg-rr1.5

    \[\leadsto -0.16666666666666666 \cdot \frac{{\left(\frac{1}{b}\right)}^{7} \cdot \left({\left({\left(\left(-1.5 \cdot c\right) \cdot a\right)}^{2}\right)}^{2} \cdot 1.25\right)}{a} + \left(-0.25 \cdot \left(c \cdot \left({\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{{\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot \color{blue}{\frac{\frac{1}{b \cdot b}}{b}}}{a} + -0.5 \cdot \frac{c}{b}\right)\right) \]
  7. Applied egg-rr1.5

    \[\leadsto -0.16666666666666666 \cdot \frac{{\left(\frac{1}{b}\right)}^{7} \cdot \left({\color{blue}{\left(\left(\left(2.25 \cdot \left(c \cdot c\right)\right) \cdot a\right) \cdot a\right)}}^{2} \cdot 1.25\right)}{a} + \left(-0.25 \cdot \left(c \cdot \left({\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{{\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot \frac{\frac{1}{b \cdot b}}{b}}{a} + -0.5 \cdot \frac{c}{b}\right)\right) \]

Alternatives

Alternative 1
Error2.1
Cost27968
\[\begin{array}{l} t_0 := {\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2}\\ -0.25 \cdot \left(c \cdot \left(t_0 \cdot {\left(\frac{1}{b}\right)}^{5}\right)\right) + \left(-0.16666666666666666 \cdot \frac{t_0 \cdot {\left(\frac{1}{b}\right)}^{3}}{a} + -0.5 \cdot \frac{c}{b}\right) \end{array} \]
Alternative 2
Error5.8
Cost21316
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \leq -1 \cdot 10^{-17}:\\ \;\;\;\;\left(\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)} - b\right) \cdot \frac{-1}{\frac{-a}{0.3333333333333333}}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 3
Error5.8
Cost21124
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \leq -1 \cdot 10^{-17}:\\ \;\;\;\;\left(\sqrt{\mathsf{fma}\left(b, b, -3 \cdot \left(a \cdot c\right)\right)} - b\right) \cdot \frac{0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 4
Error5.8
Cost21124
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \leq -1 \cdot 10^{-17}:\\ \;\;\;\;\frac{\left(\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} - b\right) \cdot 0.3333333333333333}{a}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 5
Error5.8
Cost21124
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \leq -1 \cdot 10^{-17}:\\ \;\;\;\;\frac{\frac{\sqrt{\mathsf{fma}\left(b, b, \left(-3 \cdot c\right) \cdot a\right)} - b}{a}}{3}\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 6
Error5.8
Cost14916
\[\begin{array}{l} t_0 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{if}\;t_0 \leq -1 \cdot 10^{-17}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\frac{-0.5 \cdot c}{b}\\ \end{array} \]
Alternative 7
Error3.1
Cost14144
\[-0.16666666666666666 \cdot \frac{{\left(-1.5 \cdot \left(c \cdot a\right)\right)}^{2} \cdot {\left(\frac{1}{b}\right)}^{3}}{a} + -0.5 \cdot \frac{c}{b} \]
Alternative 8
Error6.3
Cost320
\[\frac{-0.5 \cdot c}{b} \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (a b c)
  :name "Cubic critical, wide range"
  :precision binary64
  :pre (and (and (and (< 4.930380657631324e-32 a) (< a 2.028240960365167e+31)) (and (< 4.930380657631324e-32 b) (< b 2.028240960365167e+31))) (and (< 4.930380657631324e-32 c) (< c 2.028240960365167e+31)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))