Skip to content

Commit f96485e

Browse files
comment: added documentation that shows how to get the answer using De Moivre's theorem.
1 parent d64a1bd commit f96485e

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,11 @@ PMComplexNumberTest >> testRaisedToInteger [
657657

658658
{ #category : #'testing - mathematical functions' }
659659
PMComplexNumberTest >> testRaisedToNegativeInteger [
660+
"
661+
Suppose z = cos(pi / 3) + i sin(pi / 3). By De Moivre's theorem, z**-3 is
662+
z ** 3 = cos(-3 pi / 3) + i sin(-3 pi / 3) = cos(-pi) + sin(pi) = cos(pi) - i sin(pi)
663+
z ** 3 = 0 - i
664+
"
660665
| z |
661666
z := (1 / 2) + (3 sqrt / 2) i.
662667
self assert: (z raisedTo: -3) closeTo: (-1 + 0 i).
@@ -665,6 +670,10 @@ PMComplexNumberTest >> testRaisedToNegativeInteger [
665670
{ #category : #'testing - mathematical functions' }
666671
PMComplexNumberTest >> testRaisedToPositiveInteger [
667672
| z zCubed |
673+
"
674+
Suppose z = cos(pi / 6) + i sin(pi / 6). By De Moivre's theorem, z**3 is
675+
z ** 3 = cos(3 pi / 6) + i sin(3 pi / 6) = cos(pi / 2) + sin(pi / 2) = 0 + i
676+
"
668677
z := (3 sqrt / 2) + (1 / 2) i.
669678
zCubed := (z raisedTo: 3) .
670679
self assert: zCubed closeTo: (0 + 1 i).

0 commit comments

Comments
 (0)