/* Laser Teaching Center Stony Brook University Title: Reflection Through Multiple Layers Author: Gregory Caravelli gjc@jhu.edu http://laser.physics.sunysb.edu/~greg/ Created: 6/30/2005 Problem Definition: Calculate the reflection and transmission coefficients of a multiple layered substance where each subsequent layer has a larger index of refraction than the one before it. Compare this to what they would be with no layers. */ #include<iostream> #include<iomanip> #include<cstdlib> #include<math.h> using namespace std; // Main function int main() { float nfirst=0, nlast=0, nk=0, ni=0, dn=0, tmp=0; float refl=0, trans=0, refl1=0, trans1=0; int num=0; cout << endl << "Beginning index of refraction? "; cin >> nfirst; cout << "Ending index of refraction? "; cin >> nlast; cout << "Number of interfaces? "; cin >> num; dn=(nlast-nfirst)/num; cout << "\nDifference between layers: " << dn; for (int i=0; i < num; i++) { tmp=1; for (int k=1; k < i; k++) { nk=nfirst+(k-1)*dn; tmp=tmp*pow(4*nk*(nk+dn)/pow(2*nk+dn,2),2); } // end for ni=nfirst+i*dn; refl=refl+tmp*pow(dn/(2*ni+dn),2); } // end for trans=1-refl; trans1=4*nfirst*nlast/pow(nfirst+nlast,2); refl1=1-trans1; cout << "\n\nResults with one interface:\n"; cout << "Transmission: " << trans1 << endl << "Reflection: " << refl1; cout << endl << endl; cout << "Results with " << num << " interfaces:\n"; cout << "Transmission: " << trans << endl << "Reflection: " << refl; cout << endl << endl; return 0; } // Main function