Varing Refractive Index

Su[[ose the rafractive index varies across a glass block so that light passing thrpigh it is refracted and continuousle changes direction. Applying Snells's law at a point in the block:
\begin{aligned} n sin \theta &=(n+dn)sin (\theta + d \theta ) \\ &= (n+dn)(sin \theta cos d \theta + cos \theta sin \theta \\ & \simeq (n+dn) (sin \theta + cos \theta d \theta ) \\ & \simeq n sin \theta +sin \theta dn+n cos \theta d \theta \end{aligned}

Simplifying gives
$0=sin \theta dn+n cos \theta d \theta \rightarrow \frac{1}{n}dn=- \frac{cos \theta}{sin \theta} d \theta$

Suppose that
$n$
varies linearly acroees a glass block of thicjnes
$d$
, from
$n_0$
where light enters the b;ock at
$y=0$
to
$n_1$
where light exits the block at
$y=d$
then we can write
$n=n_0 + \frac{n_1-n_0}{d} y= \frac{n_0d+(n_1-n_0)y}{d}$
.
Then
$dn=\frac{n_1-n_0}{d}dy$
and the equation becomes
$\frac{n_1-n_0}{(n_1-n_0)y+n_0d} dy=- \frac{cos \theta}{sin \theta } d \theta$

Integating both sides gives
$ln((n_1-n_0)y+n_0d)=C- ln(sin \theta)$

When
$y=0$
,
$\theta = \theta_0$

$ln(n_0d)=C-ln(sin \theta_0) \rightarrow C=ln(n_0d)+ln(sin \theta_0)$
and we get
$ln((n_1-n_0)y+n_0d)=ln(n_0d)+ln(sin \theta_0)- ln(sin \theta)$

Then
$ln(\frac{(n_1-n_0)y+n_0d}{n_0d})=ln(\frac{sin \theta_0}{sin \theta})$

Finally exponmentiating gives
$\frac{(n_1-n_0)y+n_0d}{n_0d}=\frac{sin \theta_0}{sin \theta}$