# How to specify an element of a list when using RecurrenceTable

My problem is that I'm trying to get a list of refraction angles in a multilayer structure (for the sake of this example - with two types of refraction indices and eleven layers of them). The code is as follows:

theta0 = (1.535/2)*(Pi/180)
n = 11
nGaAs = 3.4;
nAlAs = 2.9;
nlayers =
{1, nGaAs, nGaAs, nAlAs, nGaAs, nAlAs, nGaAs,
nAlAs, nGaAs, nAlAs, nGaAs, nAlAs, nGaAs};
RecurrenceTable[
{theta[i] ==
ArcSin[(Extract[nlayers, i]/Extract[nlayers, i + 1])*Sin[theta[i - 1]]],
theta[0] == theta0},
theta, {i, 1, n}]


I'm getting the following error:

Extract::psl1: Position specification i in Extract[{1,3.4,3.4,2.9,3.4,2.9,3.4,2.9,3.4,2.9,3.4,2.9,3.4},i] is not applicable.

Is there any way to use a list of variables in RecurrenceTable? I'm fairly new to this, so maybe I missed something in the desctiption of RecurrenceTable or Extract, but still, does anyone know how to correctly formulate this in Mathematica?

• Welcome to MSE! It was already answered here. Do[nl[i]=nlayers[[i]],{i,Length[nlayers]}], then use this nl instead of nlayers. – Alx Sep 15 '19 at 15:17