Average Error: 52.4 → 1.6
Time: 29.7s
Precision: binary64
Cost: 35712
\[\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(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[-1 \cdot \frac{c}{b} + \left(-0.25 \cdot \frac{{b}^{-7} \cdot {\left(\left(a \cdot a\right) \cdot \left(c \cdot c\right)\right)}^{2}}{\frac{a}{20}} + \left(-0.5 \cdot \left(c \cdot \left({\left(\frac{1}{b}\right)}^{5} \cdot {\left(-2 \cdot \left(c \cdot a\right)\right)}^{2}\right)\right) + -0.25 \cdot \frac{{\left(\frac{1}{b}\right)}^{3} \cdot \left(\left(a \cdot a\right) \cdot \left(4 \cdot \left(c \cdot c\right)\right)\right)}{a}\right)\right) \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (+
  (* -1.0 (/ c b))
  (+
   (* -0.25 (/ (* (pow b -7.0) (pow (* (* a a) (* c c)) 2.0)) (/ a 20.0)))
   (+
    (* -0.5 (* c (* (pow (/ 1.0 b) 5.0) (pow (* -2.0 (* c a)) 2.0))))
    (* -0.25 (/ (* (pow (/ 1.0 b) 3.0) (* (* a a) (* 4.0 (* c c)))) a))))))
double code(double a, double b, double c) {
	return (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
double code(double a, double b, double c) {
	return (-1.0 * (c / b)) + ((-0.25 * ((pow(b, -7.0) * pow(((a * a) * (c * c)), 2.0)) / (a / 20.0))) + ((-0.5 * (c * (pow((1.0 / b), 5.0) * pow((-2.0 * (c * a)), 2.0)))) + (-0.25 * ((pow((1.0 / b), 3.0) * ((a * a) * (4.0 * (c * c)))) / 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) - ((4.0d0 * a) * c)))) / (2.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 = ((-1.0d0) * (c / b)) + (((-0.25d0) * (((b ** (-7.0d0)) * (((a * a) * (c * c)) ** 2.0d0)) / (a / 20.0d0))) + (((-0.5d0) * (c * (((1.0d0 / b) ** 5.0d0) * (((-2.0d0) * (c * a)) ** 2.0d0)))) + ((-0.25d0) * ((((1.0d0 / b) ** 3.0d0) * ((a * a) * (4.0d0 * (c * c)))) / a))))
end function
public static double code(double a, double b, double c) {
	return (-b + Math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
}
public static double code(double a, double b, double c) {
	return (-1.0 * (c / b)) + ((-0.25 * ((Math.pow(b, -7.0) * Math.pow(((a * a) * (c * c)), 2.0)) / (a / 20.0))) + ((-0.5 * (c * (Math.pow((1.0 / b), 5.0) * Math.pow((-2.0 * (c * a)), 2.0)))) + (-0.25 * ((Math.pow((1.0 / b), 3.0) * ((a * a) * (4.0 * (c * c)))) / a))));
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
def code(a, b, c):
	return (-1.0 * (c / b)) + ((-0.25 * ((math.pow(b, -7.0) * math.pow(((a * a) * (c * c)), 2.0)) / (a / 20.0))) + ((-0.5 * (c * (math.pow((1.0 / b), 5.0) * math.pow((-2.0 * (c * a)), 2.0)))) + (-0.25 * ((math.pow((1.0 / b), 3.0) * ((a * a) * (4.0 * (c * c)))) / a))))
function code(a, b, c)
	return Float64(Float64(Float64(-b) + sqrt(Float64(Float64(b * b) - Float64(Float64(4.0 * a) * c)))) / Float64(2.0 * a))
end
function code(a, b, c)
	return Float64(Float64(-1.0 * Float64(c / b)) + Float64(Float64(-0.25 * Float64(Float64((b ^ -7.0) * (Float64(Float64(a * a) * Float64(c * c)) ^ 2.0)) / Float64(a / 20.0))) + Float64(Float64(-0.5 * Float64(c * Float64((Float64(1.0 / b) ^ 5.0) * (Float64(-2.0 * Float64(c * a)) ^ 2.0)))) + Float64(-0.25 * Float64(Float64((Float64(1.0 / b) ^ 3.0) * Float64(Float64(a * a) * Float64(4.0 * Float64(c * c)))) / a)))))
end
function tmp = code(a, b, c)
	tmp = (-b + sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a);
end
function tmp = code(a, b, c)
	tmp = (-1.0 * (c / b)) + ((-0.25 * (((b ^ -7.0) * (((a * a) * (c * c)) ^ 2.0)) / (a / 20.0))) + ((-0.5 * (c * (((1.0 / b) ^ 5.0) * ((-2.0 * (c * a)) ^ 2.0)))) + (-0.25 * ((((1.0 / b) ^ 3.0) * ((a * a) * (4.0 * (c * c)))) / a))));
end
code[a_, b_, c_] := N[(N[((-b) + N[Sqrt[N[(N[(b * b), $MachinePrecision] - N[(N[(4.0 * a), $MachinePrecision] * c), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] / N[(2.0 * a), $MachinePrecision]), $MachinePrecision]
code[a_, b_, c_] := N[(N[(-1.0 * N[(c / b), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.25 * N[(N[(N[Power[b, -7.0], $MachinePrecision] * N[Power[N[(N[(a * a), $MachinePrecision] * N[(c * c), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision] / N[(a / 20.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(N[(-0.5 * N[(c * N[(N[Power[N[(1.0 / b), $MachinePrecision], 5.0], $MachinePrecision] * N[Power[N[(-2.0 * N[(c * a), $MachinePrecision]), $MachinePrecision], 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(-0.25 * N[(N[(N[Power[N[(1.0 / b), $MachinePrecision], 3.0], $MachinePrecision] * N[(N[(a * a), $MachinePrecision] * N[(4.0 * N[(c * c), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
-1 \cdot \frac{c}{b} + \left(-0.25 \cdot \frac{{b}^{-7} \cdot {\left(\left(a \cdot a\right) \cdot \left(c \cdot c\right)\right)}^{2}}{\frac{a}{20}} + \left(-0.5 \cdot \left(c \cdot \left({\left(\frac{1}{b}\right)}^{5} \cdot {\left(-2 \cdot \left(c \cdot a\right)\right)}^{2}\right)\right) + -0.25 \cdot \frac{{\left(\frac{1}{b}\right)}^{3} \cdot \left(\left(a \cdot a\right) \cdot \left(4 \cdot \left(c \cdot c\right)\right)\right)}{a}\right)\right)

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(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
  2. Simplified52.3

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

    \[\leadsto \color{blue}{-1 \cdot \frac{c}{b} + \left(-0.25 \cdot \frac{{\left(\frac{1}{b}\right)}^{7} \cdot \left(4 \cdot \left({\left(-2 \cdot \left(c \cdot a\right)\right)}^{2} \cdot \left({a}^{2} \cdot {c}^{2}\right)\right) + {\left(-0.5 \cdot {\left(-2 \cdot \left(c \cdot a\right)\right)}^{2}\right)}^{2}\right)}{a} + \left(-0.5 \cdot \left(c \cdot \left({\left(\frac{1}{b}\right)}^{5} \cdot {\left(-2 \cdot \left(c \cdot a\right)\right)}^{2}\right)\right) + -0.25 \cdot \frac{{\left(\frac{1}{b}\right)}^{3} \cdot {\left(-2 \cdot \left(c \cdot a\right)\right)}^{2}}{a}\right)\right)} \]
  4. Taylor expanded in b around 0 1.6

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

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

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

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

Alternatives

Alternative 1
Error2.1
Cost27968
\[\begin{array}{l} t_0 := {\left(-2 \cdot \left(c \cdot a\right)\right)}^{2}\\ -1 \cdot \frac{c}{b} + \left(-0.5 \cdot \left(c \cdot \left({\left(\frac{1}{b}\right)}^{5} \cdot t_0\right)\right) + -0.25 \cdot \frac{{\left(\frac{1}{b}\right)}^{3} \cdot t_0}{a}\right) \end{array} \]
Alternative 2
Error3.2
Cost7296
\[\left(-\frac{c}{b}\right) + \frac{\left(c \cdot c\right) \cdot a}{-{b}^{3}} \]
Alternative 3
Error6.4
Cost256
\[-\frac{c}{b} \]

Error

Reproduce

herbie shell --seed 2023010 
(FPCore (a b c)
  :name "Quadratic roots, 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) (* (* 4.0 a) c)))) (* 2.0 a)))