% Book: Laser Electronics by Verdeyen
% Problem: Chapter 7 problem 1a
% Script Author: meg noah meg_noah@student.uml.edu
function Lasers_Ch7_Pr1a

c=3e10;Volume=2.0*5.0*6.0;d=6;

dv = 0.01;p=9.3:dv:10.1;v=10.^p;
n2=floor((2*d/c)*v);
A = ((8*pi*Volume)/(3*c^3));
n= floor(A*v.^3);

figure(2);hold off;
plot(v,n2*4,'-*r');hold on;
plot(v,n,'-+b');hold on;
xlabel('Frequency \nu [Hz]');ylabel('Number of Modes');
legend(['Counting nMode=8*Length*\nu/c';
        'DOS nMode=8*\pi*Volume/3*c^3 ']);
figure(3);hold off;
plot(c./v,n2*4,'-*r');hold on;
plot(c./v,n,'-+b');hold on;
xlabel('Wavelength \lambda [cm]');ylabel('Number of Modes');
legend(['Counting nMode=8*Length*\nu/c';
        'DOS nMode=8*\pi*Volume/3*c^3 ']);

p=9.3:dv:10.5;v=10.^p;
n2=floor((2*d/c)*v);
A = ((8*pi*Volume)/(3*c^3));
n= floor(A*v.^3);

figure(4);hold off;
semilogy(v,n2*4,'-*r');hold on;
semilogy(v,n,'-+b');hold on;
xlabel('Frequency \nu [Hz]');ylabel('Number of Modes');
legend(['Counting nMode=8*Length*\nu/c';
        'DOS nMode=8*\pi*Volume/3*c^3 ']);
figure(5);hold off;
semilogy(c./v,n2*4,'-*r');hold on;
semilogy(c./v,n,'-+b');hold on;
xlabel('Wavelength \lambda [cm]');ylabel('Number of Modes');
legend(['Counting nMode=8*Length*\nu/c';
        'DOS nMode=8*\pi*Volume/3*c^3 ']);

