Skip to content

Commit d2905e9

Browse files
The square root of a complex number with real and imaginary parts has real and imaginary parts too.
1 parent d4912c5 commit d2905e9

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/Math-Tests-Complex/PMComplexTest.class.st

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,6 +626,17 @@ PMComplexTest >> testSquareRootOfANegativeRealNumberIsPureImaginary [
626626
self assert: squareRoot equals: 2 i.
627627
]
628628

629+
{ #category : #tests }
630+
PMComplexTest >> testSquareRootOfComplexNumberIsAComplexNumber [
631+
| squareRoot z |
632+
z := PMComplex real: 2 imaginary: 2.
633+
634+
squareRoot := z sqrt.
635+
636+
self assert: squareRoot real closeTo: 1.55377397.
637+
self assert: squareRoot imaginary closeTo: 0.643594253
638+
]
639+
629640
{ #category : #tests }
630641
PMComplexTest >> testSquareRootOfNegativePureImaginaryNumberIsAComplexNumberWithRealAndImaginaryParts [
631642
| squareRoot expected pureImaginaryNumber |

0 commit comments

Comments
 (0)