?

Average Error: 28.3 → 5.7
Time: 11.9s
Precision: binary64
Cost: 47744

?

\[\left(\left(1.0536712127723509 \cdot 10^{-8} < a \land a < 94906265.62425156\right) \land \left(1.0536712127723509 \cdot 10^{-8} < b \land b < 94906265.62425156\right)\right) \land \left(1.0536712127723509 \cdot 10^{-8} < c \land c < 94906265.62425156\right)\]
\[\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\frac{0.5}{-0.5 \cdot \frac{b}{c} + \left(0.5 \cdot \frac{a}{b} + \left(c \cdot \left(0.5 \cdot \frac{{a}^{2}}{{b}^{3}}\right) + \left(-\frac{\left(\left(20 \cdot \frac{{c}^{4}}{{c}^{2}}\right) \cdot 0.125 + {c}^{2} \cdot -1.5\right) \cdot \left(-{a}^{3}\right)}{{b}^{5}}\right)\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
 (/
  0.5
  (+
   (* -0.5 (/ b c))
   (+
    (* 0.5 (/ a b))
    (+
     (* c (* 0.5 (/ (pow a 2.0) (pow b 3.0))))
     (-
      (/
       (*
        (+ (* (* 20.0 (/ (pow c 4.0) (pow c 2.0))) 0.125) (* (pow c 2.0) -1.5))
        (- (pow a 3.0)))
       (pow b 5.0))))))))
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 0.5 / ((-0.5 * (b / c)) + ((0.5 * (a / b)) + ((c * (0.5 * (pow(a, 2.0) / pow(b, 3.0)))) + -(((((20.0 * (pow(c, 4.0) / pow(c, 2.0))) * 0.125) + (pow(c, 2.0) * -1.5)) * -pow(a, 3.0)) / pow(b, 5.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) - ((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 = 0.5d0 / (((-0.5d0) * (b / c)) + ((0.5d0 * (a / b)) + ((c * (0.5d0 * ((a ** 2.0d0) / (b ** 3.0d0)))) + -(((((20.0d0 * ((c ** 4.0d0) / (c ** 2.0d0))) * 0.125d0) + ((c ** 2.0d0) * (-1.5d0))) * -(a ** 3.0d0)) / (b ** 5.0d0)))))
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 0.5 / ((-0.5 * (b / c)) + ((0.5 * (a / b)) + ((c * (0.5 * (Math.pow(a, 2.0) / Math.pow(b, 3.0)))) + -(((((20.0 * (Math.pow(c, 4.0) / Math.pow(c, 2.0))) * 0.125) + (Math.pow(c, 2.0) * -1.5)) * -Math.pow(a, 3.0)) / Math.pow(b, 5.0)))));
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
def code(a, b, c):
	return 0.5 / ((-0.5 * (b / c)) + ((0.5 * (a / b)) + ((c * (0.5 * (math.pow(a, 2.0) / math.pow(b, 3.0)))) + -(((((20.0 * (math.pow(c, 4.0) / math.pow(c, 2.0))) * 0.125) + (math.pow(c, 2.0) * -1.5)) * -math.pow(a, 3.0)) / math.pow(b, 5.0)))))
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(0.5 / Float64(Float64(-0.5 * Float64(b / c)) + Float64(Float64(0.5 * Float64(a / b)) + Float64(Float64(c * Float64(0.5 * Float64((a ^ 2.0) / (b ^ 3.0)))) + Float64(-Float64(Float64(Float64(Float64(Float64(20.0 * Float64((c ^ 4.0) / (c ^ 2.0))) * 0.125) + Float64((c ^ 2.0) * -1.5)) * Float64(-(a ^ 3.0))) / (b ^ 5.0)))))))
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 = 0.5 / ((-0.5 * (b / c)) + ((0.5 * (a / b)) + ((c * (0.5 * ((a ^ 2.0) / (b ^ 3.0)))) + -(((((20.0 * ((c ^ 4.0) / (c ^ 2.0))) * 0.125) + ((c ^ 2.0) * -1.5)) * -(a ^ 3.0)) / (b ^ 5.0)))));
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[(0.5 / N[(N[(-0.5 * N[(b / c), $MachinePrecision]), $MachinePrecision] + N[(N[(0.5 * N[(a / b), $MachinePrecision]), $MachinePrecision] + N[(N[(c * N[(0.5 * N[(N[Power[a, 2.0], $MachinePrecision] / N[Power[b, 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + (-N[(N[(N[(N[(N[(20.0 * N[(N[Power[c, 4.0], $MachinePrecision] / N[Power[c, 2.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * 0.125), $MachinePrecision] + N[(N[Power[c, 2.0], $MachinePrecision] * -1.5), $MachinePrecision]), $MachinePrecision] * (-N[Power[a, 3.0], $MachinePrecision])), $MachinePrecision] / N[Power[b, 5.0], $MachinePrecision]), $MachinePrecision])), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{0.5}{-0.5 \cdot \frac{b}{c} + \left(0.5 \cdot \frac{a}{b} + \left(c \cdot \left(0.5 \cdot \frac{{a}^{2}}{{b}^{3}}\right) + \left(-\frac{\left(\left(20 \cdot \frac{{c}^{4}}{{c}^{2}}\right) \cdot 0.125 + {c}^{2} \cdot -1.5\right) \cdot \left(-{a}^{3}\right)}{{b}^{5}}\right)\right)\right)}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation?

  1. Initial program 28.3

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

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

    [Start]28.3

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

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

    \[ \frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{\color{blue}{a \cdot 2}} \]
  3. Applied egg-rr28.3

    \[\leadsto \color{blue}{\frac{0.5}{a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)} \]
  4. Applied egg-rr28.3

    \[\leadsto \color{blue}{\frac{0.5}{\frac{a}{\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}}}} \]
  5. Taylor expanded in b around inf 5.7

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

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

    [Start]5.7

    \[ \frac{0.5}{0.5 \cdot \frac{a}{b} + \left(-1 \cdot \frac{0.5 \cdot \left(c \cdot {a}^{2}\right) + -1 \cdot \left(c \cdot {a}^{2}\right)}{{b}^{3}} + \left(-0.5 \cdot \frac{b}{c} + -1 \cdot \frac{-1 \cdot \left(c \cdot \left(\left(0.5 \cdot \left(c \cdot {a}^{2}\right) + -1 \cdot \left(c \cdot {a}^{2}\right)\right) \cdot a\right)\right) + \left(-0.125 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{{c}^{2} \cdot a} + {c}^{2} \cdot {a}^{3}\right)}{{b}^{5}}\right)\right)} \]

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

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

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

    \[ \frac{0.5}{\color{blue}{-0.5 \cdot \frac{b}{c} + \left(\left(-1 \cdot \frac{-1 \cdot \left(c \cdot \left(\left(0.5 \cdot \left(c \cdot {a}^{2}\right) + -1 \cdot \left(c \cdot {a}^{2}\right)\right) \cdot a\right)\right) + \left(-0.125 \cdot \frac{{\left(-2 \cdot \left({c}^{2} \cdot {a}^{2}\right)\right)}^{2} + 16 \cdot \left({c}^{4} \cdot {a}^{4}\right)}{{c}^{2} \cdot a} + {c}^{2} \cdot {a}^{3}\right)}{{b}^{5}} + -1 \cdot \frac{0.5 \cdot \left(c \cdot {a}^{2}\right) + -1 \cdot \left(c \cdot {a}^{2}\right)}{{b}^{3}}\right) + 0.5 \cdot \frac{a}{b}\right)}} \]
  7. Taylor expanded in a around -inf 5.7

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

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

    [Start]5.7

    \[ \frac{0.5}{-0.5 \cdot \frac{b}{c} + \left(0.5 \cdot \frac{a}{b} + \left(c \cdot \left(0.5 \cdot \frac{{a}^{2}}{{b}^{3}}\right) + \left(-\frac{-1 \cdot \left({a}^{3} \cdot \left(-0.5 \cdot {c}^{2} + \left(0.125 \cdot \frac{4 \cdot {c}^{4} + 16 \cdot {c}^{4}}{{c}^{2}} + -1 \cdot {c}^{2}\right)\right)\right)}{{b}^{5}}\right)\right)\right)} \]

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

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

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

    \[ \frac{0.5}{-0.5 \cdot \frac{b}{c} + \left(0.5 \cdot \frac{a}{b} + \left(c \cdot \left(0.5 \cdot \frac{{a}^{2}}{{b}^{3}}\right) + \left(-\frac{\color{blue}{\left(-0.5 \cdot {c}^{2} + \left(0.125 \cdot \frac{4 \cdot {c}^{4} + 16 \cdot {c}^{4}}{{c}^{2}} + -1 \cdot {c}^{2}\right)\right) \cdot \left({a}^{3} \cdot -1\right)}}{{b}^{5}}\right)\right)\right)} \]
  9. Final simplification5.7

    \[\leadsto \frac{0.5}{-0.5 \cdot \frac{b}{c} + \left(0.5 \cdot \frac{a}{b} + \left(c \cdot \left(0.5 \cdot \frac{{a}^{2}}{{b}^{3}}\right) + \left(-\frac{\left(\left(20 \cdot \frac{{c}^{4}}{{c}^{2}}\right) \cdot 0.125 + {c}^{2} \cdot -1.5\right) \cdot \left(-{a}^{3}\right)}{{b}^{5}}\right)\right)\right)} \]

Alternatives

Alternative 1
Error6.5
Cost21636
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -3:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{-0.5 \cdot \frac{b}{c} + 0.5 \cdot \left(\frac{a}{b} + c \cdot \frac{{a}^{2}}{{b}^{3}}\right)}\\ \end{array} \]
Alternative 2
Error9.4
Cost14916
\[\begin{array}{l} \mathbf{if}\;\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a} \leq -0.9:\\ \;\;\;\;\frac{0.5}{a} \cdot \left(\left(-b\right) + \sqrt{b \cdot b - 4 \cdot \left(a \cdot c\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\frac{0.5}{0.5 \cdot \frac{a}{b} + -0.5 \cdot \frac{b}{c}}\\ \end{array} \]
Alternative 3
Error11.6
Cost832
\[\frac{0.5}{0.5 \cdot \frac{a}{b} + -0.5 \cdot \frac{b}{c}} \]
Alternative 4
Error23.0
Cost256
\[-\frac{c}{b} \]

Error

Reproduce?

herbie shell --seed 2023064 
(FPCore (a b c)
  :name "Quadratic roots, narrow range"
  :precision binary64
  :pre (and (and (and (< 1.0536712127723509e-8 a) (< a 94906265.62425156)) (and (< 1.0536712127723509e-8 b) (< b 94906265.62425156))) (and (< 1.0536712127723509e-8 c) (< c 94906265.62425156)))
  (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))