- Demoivre's Theorem Program Problems
- 06 May 2014 05:13:32 pm
- Last edited by MrDew25 on 06 May 2014 05:27:10 pm; edited 1 time in total

If you don't know, Demoivre's Theorem is a way to find out the powers of complex number, such as (1+i)^5.

Right now, I am having trouble with a variable not stopping. Here is the code for my program. By the way, I will be editing the code to match the corrections when they become available.

Right now, I am having trouble with a variable not stopping. Here is the code for my program. By the way, I will be editing the code to match the corrections when they become available.

**Code:**```
ClrHome
```

1->P

1->Q

1->R

1->S

Disp "(a+bi)^n"

Input "a: ",A

Input "b: ",B

Input "n: ",N

If abs(A/S)=1 and abs(B/S)=1

Goto C

Lbl S

If A/S<=1 and A/S>=~1

Then

If B/S<=1 and B/S>=~1

Then

Goto B

Else

Goto C

End

Else

Goto C

End

End

Lbl C

If Q=1

Then

~Q->Q

sqrt(2)P->P

P->S

Goto S

End

If Q=~1

Then

~Q->Q

2+R->R

R->S

Goto S

End

Lbl B

cos^-1(A/S)->C

sin^-1(B/S)->D

C/5->G

D/5->H

If iPart(G)!=G and iPart(H)!=H

Goto C

If A<0 and B>0

180-D->D

If A<0 and B<0

Then

360-C->C

180-D->D

End

If A>0 and B<0

~C->C

cos(NC)->E

sin(ND)->F

If fPart(F)=~2|E~13 or fPart(F)=~4|E~13

iPart(F)->F

(S^N)(E+Fi)->E

ClrHome

Output(1,1," The Answer Is: ")

Output(2,1,E)

Pause

ClrHome

Output(1,1,"")