Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Loop termination issues' topicStudent Support Forum > General > "Loop termination issues"

< Previous CommentHelp | Reply To Comment | Reply To Topic
Author Comment/Response
Quinn McKinsey
11/26/11 08:22am

I tried the following modified code and got answers:

\[Lambda] = 635*10^-9;
f = 10^4;
a = 10^-9;
\[Theta][0] = \[Theta]i = \[Pi]/4;
\[Theta][n_] := \[Theta][n] =
N[ArcSin[(Sin[\[Theta]i] + n*f*\[Lambda])]];
P[n_] := P[n] =
N[((2*\[Pi]*a)/\[Lambda])^2*Cos[\[Theta]i]*Cos[\[Theta][n]]];
For[n = 1, \[Theta][n] < 20, n++,
\[Theta][n];
P[n];
Print["\[Theta]", n, "= ", \[Theta][n], "\nP", n, "= ", P[n], "\n"]
];
For[n = -1, \[Theta][n] > -\[Pi]/2, n--,
\[Theta][n];
P[n];
Print["\[Theta]", n, "= ", \[Theta][n], "\nP", n, "= ", P[n], "\n"]
]

Hope that helps,
Quinn McKinsey

URL: ,

Subject (listing for 'Loop termination issues')
Author Date Posted
Loop termination issues Sam 10/18/11 10:26pm
Re: Loop termination issues Quinn McKinsey 11/26/11 08:22am
< Previous CommentHelp | Reply To Comment | Reply To Topic