Average Error: 43.5 → 0.2
Time: 16.3s
Precision: binary64
Cost: 7360
\[\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(4 \cdot a\right) \cdot c}}{2 \cdot a} \]
\[\frac{c \cdot -2}{b + \sqrt{c \cdot \left(a \cdot -4\right) + b \cdot b}} \]
(FPCore (a b c)
 :precision binary64
 (/ (+ (- b) (sqrt (- (* b b) (* (* 4.0 a) c)))) (* 2.0 a)))
(FPCore (a b c)
 :precision binary64
 (/ (* c -2.0) (+ b (sqrt (+ (* c (* a -4.0)) (* b b))))))
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 (c * -2.0) / (b + sqrt(((c * (a * -4.0)) + (b * 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) - ((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 = (c * (-2.0d0)) / (b + sqrt(((c * (a * (-4.0d0))) + (b * b))))
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 (c * -2.0) / (b + Math.sqrt(((c * (a * -4.0)) + (b * b))));
}
def code(a, b, c):
	return (-b + math.sqrt(((b * b) - ((4.0 * a) * c)))) / (2.0 * a)
def code(a, b, c):
	return (c * -2.0) / (b + math.sqrt(((c * (a * -4.0)) + (b * b))))
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(c * -2.0) / Float64(b + sqrt(Float64(Float64(c * Float64(a * -4.0)) + Float64(b * b)))))
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 = (c * -2.0) / (b + sqrt(((c * (a * -4.0)) + (b * b))));
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[(c * -2.0), $MachinePrecision] / N[(b + N[Sqrt[N[(N[(c * N[(a * -4.0), $MachinePrecision]), $MachinePrecision] + N[(b * b), $MachinePrecision]), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\frac{\left(-b\right) + \sqrt{b \cdot b - \left(4 \cdot a\right) \cdot c}}{2 \cdot a}
\frac{c \cdot -2}{b + \sqrt{c \cdot \left(a \cdot -4\right) + b \cdot b}}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 43.5

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

    \[\leadsto \color{blue}{\left(\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - b\right) \cdot \frac{0.5}{a}} \]
    Proof

    [Start]43.5

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

    /-rgt-identity [<=]43.5

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

    metadata-eval [<=]43.5

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

    *-commutative [=>]43.5

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

    associate-/l* [=>]43.5

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

    associate-/l* [<=]43.5

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

    associate-*r/ [<=]43.5

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

    /-rgt-identity [<=]43.5

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

    metadata-eval [<=]43.5

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right) - \left(-b\right) \cdot \left(-b\right)}{\frac{a}{0.5} \cdot \left(\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)\right)}} \]
  4. Simplified42.9

    \[\leadsto \color{blue}{\frac{\frac{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - b \cdot b}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right)}} \]
    Proof

    [Start]43.0

    \[ \frac{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right) - \left(-b\right) \cdot \left(-b\right)}{\frac{a}{0.5} \cdot \left(\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)\right)} \]

    associate-/r* [=>]43.0

    \[ \color{blue}{\frac{\frac{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right) - \left(-b\right) \cdot \left(-b\right)}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)}} \]

    fma-def [<=]42.9

    \[ \frac{\frac{\color{blue}{\left(b \cdot b + \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right) \cdot \left(-b\right)}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)} \]

    +-commutative [=>]42.9

    \[ \frac{\frac{\color{blue}{\left(\left(a \cdot c\right) \cdot -4 + b \cdot b\right)} - \left(-b\right) \cdot \left(-b\right)}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)} \]

    *-commutative [=>]42.9

    \[ \frac{\frac{\left(\color{blue}{\left(c \cdot a\right)} \cdot -4 + b \cdot b\right) - \left(-b\right) \cdot \left(-b\right)}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)} \]

    fma-def [=>]42.9

    \[ \frac{\frac{\color{blue}{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right) \cdot \left(-b\right)}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)} \]

    sqr-neg [=>]42.9

    \[ \frac{\frac{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - \color{blue}{b \cdot b}}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(b, b, \left(a \cdot c\right) \cdot -4\right)} - \left(-b\right)} \]

    fma-def [<=]42.9

    \[ \frac{\frac{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - b \cdot b}{\frac{a}{0.5}}}{\sqrt{\color{blue}{b \cdot b + \left(a \cdot c\right) \cdot -4}} - \left(-b\right)} \]

    +-commutative [=>]42.9

    \[ \frac{\frac{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - b \cdot b}{\frac{a}{0.5}}}{\sqrt{\color{blue}{\left(a \cdot c\right) \cdot -4 + b \cdot b}} - \left(-b\right)} \]

    *-commutative [=>]42.9

    \[ \frac{\frac{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right) - b \cdot b}{\frac{a}{0.5}}}{\sqrt{\color{blue}{\left(c \cdot a\right)} \cdot -4 + b \cdot b} - \left(-b\right)} \]

    fma-def [=>]42.9

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

    \[\leadsto \frac{\frac{\color{blue}{-4 \cdot \left(c \cdot a\right)}}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right)} \]
  6. Simplified0.2

    \[\leadsto \frac{\frac{\color{blue}{c \cdot \left(-4 \cdot a\right)}}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right)} \]
    Proof

    [Start]0.2

    \[ \frac{\frac{-4 \cdot \left(c \cdot a\right)}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right)} \]

    *-commutative [=>]0.2

    \[ \frac{\frac{\color{blue}{\left(c \cdot a\right) \cdot -4}}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right)} \]

    associate-*r* [<=]0.2

    \[ \frac{\frac{\color{blue}{c \cdot \left(a \cdot -4\right)}}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right)} \]

    *-commutative [=>]0.2

    \[ \frac{\frac{c \cdot \color{blue}{\left(-4 \cdot a\right)}}{\frac{a}{0.5}}}{\sqrt{\mathsf{fma}\left(c \cdot a, -4, b \cdot b\right)} - \left(-b\right)} \]
  7. Applied egg-rr0.2

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

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

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

    [Start]0.2

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

    *-commutative [=>]0.2

    \[ \frac{\color{blue}{c \cdot -2}}{\sqrt{c \cdot \left(a \cdot -4\right) + b \cdot b} - \left(-b\right)} \]
  10. Final simplification0.2

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

Alternatives

Alternative 1
Error5.8
Cost1344
\[\frac{\frac{c \cdot \left(a \cdot -4\right)}{\frac{a}{0.5}}}{-2 \cdot \frac{c \cdot a}{b} + b \cdot 2} \]
Alternative 2
Error5.9
Cost832
\[\frac{0.5}{0.5 \cdot \frac{a}{b} + -0.5 \cdot \frac{b}{c}} \]
Alternative 3
Error12.2
Cost256
\[\frac{-c}{b} \]
Alternative 4
Error63.0
Cost192
\[\frac{b}{a} \]

Error

Reproduce

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