clc
clear all
close all
                          %% COMBINATION OF TWO THIN LENSES - S. Memarzadeh, June 29, 2016 %%
syms f1 f2 d l1 l2 x1
M1  = [1 0; -1/f2 1];
M2 = [1 0 ; -1/f1 1];
M = M1 * M2 
                      %% Two Thin Lenses Seperated by a Distance d %%          

M3 = [1 d; 0 1];
MM = M1 * M3 * M2 
% % simplify (MM)

               %% Two Thin Lens of Opposite Polarity Separated a Distance d %%
M4 = [1 0 ; 1/f1 1];
MMM = M4 * M3 * M2
% % simplify (MMM)


%%
M5 = [1 l1; 0 1];
M6 = [1 l2; 0 1];
MMMM = M5 * M4 * M3 * M2 * M6
Y = MMMM * [x1; 0];


%% Evaluation (Example OF RAY propagation)
f1 = input ('Enter value for f1 :')
f2 = input ('Enter value for f2 :')
d  = input ('Enter value for d :')
x1  = input ('Enter value for x1 :')

subs(M)
subs(MM)
subs(MMM)
subs(MMMM)
subs(Y)



               
               