polynomials 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/core_ext/math.rb +1 -1
- data/lib/polynomials.rb +1 -0
- data/polynomials.gemspec +1 -1
- data/test/math_test.rb +2 -2
- data/test/polynomial_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.2
|
data/lib/core_ext/math.rb
CHANGED
@@ -40,7 +40,7 @@ module Math
|
|
40
40
|
denom = (p/2.0)**2 - q
|
41
41
|
return Set[] if denom < 0
|
42
42
|
root = Math.sqrt(denom)
|
43
|
-
Set.new([:+,:-].map{ |operator| (-(p/2.0)).send(operator, root)})
|
43
|
+
Set.new([:+,:-].map{ |operator| (-(p/2.0)).send(operator, root)}.map { |n| n.round(10) })
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.roots_of_quartic_function(*args)
|
data/lib/polynomials.rb
CHANGED
data/polynomials.gemspec
CHANGED
data/test/math_test.rb
CHANGED
@@ -16,10 +16,10 @@ class TestMath < MiniTest::Unit::TestCase
|
|
16
16
|
q = -40.0/3.0
|
17
17
|
root = Math.sqrt((p/2)**2 - q)
|
18
18
|
fraction = -(p/2)
|
19
|
-
assert_equal Set[fraction - root, fraction + root],polynomial.nulls
|
19
|
+
assert_equal Set[(fraction - root).round(10), (fraction + root).round(10)],polynomial.nulls
|
20
20
|
|
21
21
|
polynomial = Polynomial.parse('3x^2 - 40')
|
22
|
-
assert_equal Set[Math.sqrt(40.0/3), -Math.sqrt(40.0/3)], polynomial.nulls
|
22
|
+
assert_equal Set[Math.sqrt(40.0/3).round(10), -Math.sqrt(40.0/3).round(10)], polynomial.nulls
|
23
23
|
end
|
24
24
|
|
25
25
|
def test_nulls_for_cubic_functions
|
data/test/polynomial_test.rb
CHANGED
@@ -69,6 +69,6 @@ class TestPolynomial < MiniTest::Unit::TestCase
|
|
69
69
|
|
70
70
|
def test_two_inflection_points
|
71
71
|
polynomial = Polynomial.parse('+ 1.0 x^4 + 5.0 x^3 - 1.0 x^2 + 3.0 x + 5.0')
|
72
|
-
assert_equal({left:Set[-1.0/0..-2.
|
72
|
+
assert_equal({left:Set[-1.0/0..-2.5649778198, 0.0649778198..1.0/0], right: Set[-2.5649778198..0.0649778198] } , polynomial.curvature_behaviour)
|
73
73
|
end
|
74
74
|
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 2
|
9
|
+
version: 0.1.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Manuel Korfmann
|
@@ -130,7 +130,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
130
130
|
requirements:
|
131
131
|
- - ">="
|
132
132
|
- !ruby/object:Gem::Version
|
133
|
-
hash:
|
133
|
+
hash: -894786567939167734
|
134
134
|
segments:
|
135
135
|
- 0
|
136
136
|
version: "0"
|