?

Average Error: 43.7 → 3.0
Time: 14.4s
Precision: binary64
Cost: 53568

?

\[\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)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a} \]
\[\left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + -1.0546875 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 3.0 a) c)))) (* 3.0 a)))
(FPCore (a b c)
 :precision binary64
 (+
  (+
   (* -0.5 (/ c b))
   (+
    (* a (* (/ (pow c 2.0) (pow b 3.0)) -0.375))
    (* (pow a 2.0) (* -0.5625 (/ (pow c 3.0) (pow b 5.0))))))
  (* -1.0546875 (/ (* (pow c 4.0) (pow a 3.0)) (pow b 7.0)))))
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) {
	return ((-0.5 * (c / b)) + ((a * ((pow(c, 2.0) / pow(b, 3.0)) * -0.375)) + (pow(a, 2.0) * (-0.5625 * (pow(c, 3.0) / pow(b, 5.0)))))) + (-1.0546875 * ((pow(c, 4.0) * pow(a, 3.0)) / pow(b, 7.0)));
}
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
    code = (((-0.5d0) * (c / b)) + ((a * (((c ** 2.0d0) / (b ** 3.0d0)) * (-0.375d0))) + ((a ** 2.0d0) * ((-0.5625d0) * ((c ** 3.0d0) / (b ** 5.0d0)))))) + ((-1.0546875d0) * (((c ** 4.0d0) * (a ** 3.0d0)) / (b ** 7.0d0)))
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) {
	return ((-0.5 * (c / b)) + ((a * ((Math.pow(c, 2.0) / Math.pow(b, 3.0)) * -0.375)) + (Math.pow(a, 2.0) * (-0.5625 * (Math.pow(c, 3.0) / Math.pow(b, 5.0)))))) + (-1.0546875 * ((Math.pow(c, 4.0) * Math.pow(a, 3.0)) / Math.pow(b, 7.0)));
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((3.0 * a) * c)))) / (3.0 * a)
def code(a, b, c):
	return ((-0.5 * (c / b)) + ((a * ((math.pow(c, 2.0) / math.pow(b, 3.0)) * -0.375)) + (math.pow(a, 2.0) * (-0.5625 * (math.pow(c, 3.0) / math.pow(b, 5.0)))))) + (-1.0546875 * ((math.pow(c, 4.0) * math.pow(a, 3.0)) / math.pow(b, 7.0)))
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)
	return Float64(Float64(Float64(-0.5 * Float64(c / b)) + Float64(Float64(a * Float64(Float64((c ^ 2.0) / (b ^ 3.0)) * -0.375)) + Float64((a ^ 2.0) * Float64(-0.5625 * Float64((c ^ 3.0) / (b ^ 5.0)))))) + Float64(-1.0546875 * Float64(Float64((c ^ 4.0) * (a ^ 3.0)) / (b ^ 7.0))))
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)
	tmp = ((-0.5 * (c / b)) + ((a * (((c ^ 2.0) / (b ^ 3.0)) * -0.375)) + ((a ^ 2.0) * (-0.5625 * ((c ^ 3.0) / (b ^ 5.0)))))) + (-1.0546875 * (((c ^ 4.0) * (a ^ 3.0)) / (b ^ 7.0)));
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_] := N[(N[(N[(-0.5 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(a * N[(N[(N[Power[c, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision] * -0.375), $MachinePrecision]), $MachinePrecision] + N[(N[Power[a, 2.0], $MachinePrecision] * N[(-0.5625 * N[(N[Power[c, 3.0], $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-1.0546875 * N[(N[(N[Power[c, 4.0], $MachinePrecision] * N[Power[a, 3.0], $MachinePrecision]), $MachinePrecision] / N[Power[b, 7.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}
\left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + -1.0546875 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 43.7

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

    \[\leadsto \color{blue}{\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{3 \cdot a}} \]
    Proof

    [Start]43.7

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

    rational.json-simplify-2 [=>]43.7

    \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \color{blue}{c \cdot \left(3 \cdot a\right)}}}{3 \cdot a} \]

    rational.json-simplify-43 [=>]43.7

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

    \[\leadsto \color{blue}{-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]
  4. Simplified3.0

    \[\leadsto \color{blue}{\left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}} \]
    Proof

    [Start]3.1

    \[ -0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) \]

    rational.json-simplify-41 [=>]3.1

    \[ \color{blue}{-0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \left(\left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right) + -0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}}\right)} \]

    rational.json-simplify-1 [<=]3.1

    \[ -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}} + \color{blue}{\left(-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right)} \]

    rational.json-simplify-1 [=>]3.1

    \[ \color{blue}{\left(-0.5625 \cdot \frac{{c}^{3} \cdot {a}^{2}}{{b}^{5}} + \left(-0.5 \cdot \frac{c}{b} + -0.375 \cdot \frac{{c}^{2} \cdot a}{{b}^{3}}\right)\right) + -0.16666666666666666 \cdot \frac{{\left(-1.125 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 5.0625 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{a \cdot {b}^{7}}} \]
  5. Taylor expanded in c around 0 3.0

    \[\leadsto \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \color{blue}{-0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}}} \]
  6. Simplified3.0

    \[\leadsto \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \color{blue}{\frac{{c}^{4}}{a \cdot {b}^{7}} \cdot \left({a}^{4} \cdot -1.0546875\right)} \]
    Proof

    [Start]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + -0.16666666666666666 \cdot \frac{{c}^{4} \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)}{a \cdot {b}^{7}} \]

    rational.json-simplify-49 [=>]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + -0.16666666666666666 \cdot \color{blue}{\left(\left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right) \cdot \frac{{c}^{4}}{a \cdot {b}^{7}}\right)} \]

    rational.json-simplify-43 [<=]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \color{blue}{\frac{{c}^{4}}{a \cdot {b}^{7}} \cdot \left(-0.16666666666666666 \cdot \left(1.265625 \cdot {a}^{4} + 5.0625 \cdot {a}^{4}\right)\right)} \]

    rational.json-simplify-2 [=>]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \frac{{c}^{4}}{a \cdot {b}^{7}} \cdot \left(-0.16666666666666666 \cdot \left(\color{blue}{{a}^{4} \cdot 1.265625} + 5.0625 \cdot {a}^{4}\right)\right) \]

    rational.json-simplify-51 [=>]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \frac{{c}^{4}}{a \cdot {b}^{7}} \cdot \left(-0.16666666666666666 \cdot \color{blue}{\left({a}^{4} \cdot \left(5.0625 + 1.265625\right)\right)}\right) \]

    rational.json-simplify-43 [=>]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \frac{{c}^{4}}{a \cdot {b}^{7}} \cdot \color{blue}{\left({a}^{4} \cdot \left(\left(5.0625 + 1.265625\right) \cdot -0.16666666666666666\right)\right)} \]

    metadata-eval [=>]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \frac{{c}^{4}}{a \cdot {b}^{7}} \cdot \left({a}^{4} \cdot \left(\color{blue}{6.328125} \cdot -0.16666666666666666\right)\right) \]

    metadata-eval [=>]3.0

    \[ \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \frac{{c}^{4}}{a \cdot {b}^{7}} \cdot \left({a}^{4} \cdot \color{blue}{-1.0546875}\right) \]
  7. Taylor expanded in c around 0 3.0

    \[\leadsto \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + \color{blue}{-1.0546875 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}}} \]
  8. Final simplification3.0

    \[\leadsto \left(-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right)\right) + -1.0546875 \cdot \frac{{c}^{4} \cdot {a}^{3}}{{b}^{7}} \]

Alternatives

Alternative 1
Error4.0
Cost33664
\[-0.5 \cdot \frac{c}{b} + \left(a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) + {a}^{2} \cdot \left(-0.5625 \cdot \frac{{c}^{3}}{{b}^{5}}\right)\right) \]
Alternative 2
Error11.0
Cost30156
\[\begin{array}{l} t_0 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ t_1 := \left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\\ \mathbf{if}\;t_0 \leq -0.01:\\ \;\;\;\;\frac{t_1 \cdot 0.6666666666666666}{a} \cdot 0.5\\ \mathbf{elif}\;t_0 \leq -0.0002:\\ \;\;\;\;\frac{-1.5 \cdot \left(a \cdot \frac{c}{b}\right)}{3 \cdot a}\\ \mathbf{elif}\;t_0 \leq -2 \cdot 10^{-13}:\\ \;\;\;\;\frac{1}{a \cdot 12} \cdot \left(t_1 \cdot 4\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 3
Error11.0
Cost30028
\[\begin{array}{l} t_0 := \frac{\left(\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right) \cdot 0.6666666666666666}{a} \cdot 0.5\\ t_1 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{if}\;t_1 \leq -0.01:\\ \;\;\;\;t_0\\ \mathbf{elif}\;t_1 \leq -0.0002:\\ \;\;\;\;\frac{-1.5 \cdot \left(a \cdot \frac{c}{b}\right)}{3 \cdot a}\\ \mathbf{elif}\;t_1 \leq -2 \cdot 10^{-13}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 4
Error11.0
Cost29900
\[\begin{array}{l} t_0 := \left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\\ t_1 := \frac{\left(-b\right) + \sqrt{b \cdot b - \left(3 \cdot a\right) \cdot c}}{3 \cdot a}\\ \mathbf{if}\;t_1 \leq -0.01:\\ \;\;\;\;\frac{t_0}{a} \cdot 0.3333333333333333\\ \mathbf{elif}\;t_1 \leq -0.0002:\\ \;\;\;\;\frac{-1.5 \cdot \left(a \cdot \frac{c}{b}\right)}{3 \cdot a}\\ \mathbf{elif}\;t_1 \leq -2 \cdot 10^{-13}:\\ \;\;\;\;\frac{t_0}{3 \cdot a}\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 5
Error6.0
Cost13760
\[-0.5 \cdot \frac{c}{b} + a \cdot \left(\frac{{c}^{2}}{{b}^{3}} \cdot -0.375\right) \]
Alternative 6
Error11.2
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \leq 0.0027:\\ \;\;\;\;\frac{0.3333333333333333}{a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 7
Error11.2
Cost7556
\[\begin{array}{l} \mathbf{if}\;b \leq 0.0027:\\ \;\;\;\;\frac{\left(-b\right) + \sqrt{b \cdot b - 3 \cdot \left(a \cdot c\right)}}{a} \cdot 0.3333333333333333\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot \frac{c}{b}\\ \end{array} \]
Alternative 8
Error12.1
Cost320
\[-0.5 \cdot \frac{c}{b} \]

Error

Reproduce?

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