Skip to content

Commit

Permalink
comment: added documentation that shows how to get the answer using D…
Browse files Browse the repository at this point in the history
…e Moivre's theorem.
  • Loading branch information
hemalvarambhia committed Jan 15, 2024
1 parent d64a1bd commit f96485e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/Math-Tests-Complex/PMComplexNumberTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,11 @@ PMComplexNumberTest >> testRaisedToInteger [

{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToNegativeInteger [
"
Suppose z = cos(pi / 3) + i sin(pi / 3). By De Moivre's theorem, z**-3 is
z ** 3 = cos(-3 pi / 3) + i sin(-3 pi / 3) = cos(-pi) + sin(pi) = cos(pi) - i sin(pi)
z ** 3 = 0 - i
"
| z |
z := (1 / 2) + (3 sqrt / 2) i.
self assert: (z raisedTo: -3) closeTo: (-1 + 0 i).
Expand All @@ -665,6 +670,10 @@ PMComplexNumberTest >> testRaisedToNegativeInteger [
{ #category : #'testing - mathematical functions' }
PMComplexNumberTest >> testRaisedToPositiveInteger [
| z zCubed |
"
Suppose z = cos(pi / 6) + i sin(pi / 6). By De Moivre's theorem, z**3 is
z ** 3 = cos(3 pi / 6) + i sin(3 pi / 6) = cos(pi / 2) + sin(pi / 2) = 0 + i
"
z := (3 sqrt / 2) + (1 / 2) i.
zCubed := (z raisedTo: 3) .
self assert: zCubed closeTo: (0 + 1 i).
Expand Down

0 comments on commit f96485e

Please sign in to comment.