In [2]:
from numpy import *
%pylab inline

Populating the interactive namespace from numpy and matplotlib


### 9.2¶

In [3]:
import sympy as s
E0_par, E1_par, E2_par, E0_perp, E1_perp, E2_perp = s.symbols('E_{0\parallel} E_{1\parallel} E_{2\parallel} E_{0\perp} E_{1\perp} E_{2\perp}')
th_0, th_2 = s.symbols('\\theta_0 \\theta_2')
n1, n2 = s.symbols('n_1 n_2')
s.init_printing()
E1_par = s.tan(th_0-th_2)/s.tan(th_0+th_2)*E0_par
E1_perp = s.sin(th_2-th_0)/s.tan(th_2+th_0)*E0_perp
E2_par = 2*s.cos(th_0)*((n1/n2*s.sin(th_0)))/s.sin(th_0+th_2)/s.cos(th_0-th_2)*E0_par
E2_perp = 2*s.cos(th_0)*(n1/n2*s.sin(th_0))/s.sin(th_0+th_2)*E0_perp
E0 = E0_par**2 + E0_perp**2
E1 = E1_par**2 + E1_perp**2
E2 = E2_par**2 + E2_perp**2
E2/E0

Out[3]:
$$\frac{1}{E_{0\parallel}^{2} + E_{0\perp}^{2}} \left(\frac{4 E_{0\parallel}^{2} n_{1}^{2} \sin^{2}{\left (\theta_0 \right )} \cos^{2}{\left (\theta_0 \right )}}{n_{2}^{2} \sin^{2}{\left (\theta_0 + \theta_2 \right )} \cos^{2}{\left (\theta_0 - \theta_2 \right )}} + \frac{4 E_{0\perp}^{2} n_{1}^{2} \sin^{2}{\left (\theta_0 \right )} \cos^{2}{\left (\theta_0 \right )}}{n_{2}^{2} \sin^{2}{\left (\theta_0 + \theta_2 \right )}}\right)$$

### 9.5¶

In [1]:
def theta(lam,n,w):
return lam/pi/n/w
print theta(790e-9,1.,1e-6)
print .25*pi*1e-7

---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-1-69ddc06e87fb> in <module>()
1 def theta(lam,n,w):
2     return lam/pi/n/w
----> 3 print theta(790e-9,1.,1e-6)
4 print .25*pi*1e-7

<ipython-input-1-69ddc06e87fb> in theta(lam, n, w)
1 def theta(lam,n,w):
----> 2     return lam/pi/n/w
3 print theta(790e-9,1.,1e-6)
4 print .25*pi*1e-7

NameError: global name 'pi' is not defined
In [ ]: