lib/polynomials/formulas.rb in polynomials-0.4.2 vs lib/polynomials/formulas.rb in polynomials-0.4.3

- old
+ new

@@ -38,12 +38,12 @@ end def roots_of_quadratic_function(a,b,c) p = b/a q = c/a - denom = (p/2.0)**2 - q - return Set[] if denom < 0 - root = Math.sqrt(denom) + radicand = (p/2.0)**2 - q + return Set[] if radicand < 0 + root = Math.sqrt(radicand) Set.new([:+,:-].map{ |operator| (-(p/2.0)).send(operator, root)}.map { |n| n.round(10) }) end def roots_of_quartic_function(*args) a,b,c,d,e = args.map { |n| n/args.first }