Skip to content

Commit 22005cb

Browse files
test: added a simple test for x^2 + 2x + 1, whose roots are x = -1 and -1
1 parent a585d96 commit 22005cb

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Math-Tests-Polynomials/PMPolynomialTest.class.st

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,16 @@ PMPolynomialTest >> testPolynomialRoots [
242242
self assert: (roots at: 3) - 5 closeTo: 0
243243
]
244244

245+
{ #category : #'iterative algorithms' }
246+
PMPolynomialTest >> testPolynomialRootsForQuadratic [
247+
| polynomial roots |
248+
polynomial := PMPolynomial coefficients: #(1 2 1).
249+
roots := polynomial roots .
250+
self assert: roots size equals: 2.
251+
self assert: (roots at: 1) closeTo: -1 .
252+
self assert: (roots at: 2) closeTo: -1 .
253+
]
254+
245255
{ #category : #'function evaluation' }
246256
PMPolynomialTest >> testPolynomialSubtraction [
247257
| polynomial |

0 commit comments

Comments
 (0)