function[ u ] = truss_analysis(y)

E = 29e3;% kips/sq. in.
L = 60; % ft
D = 120;% ft
W1 = 100;% kips
W2 = 1000; % kips

% mapping between optimization variables and actual variables
a1 = y(1); a2 = y(2); a3 = y(3); 
x = y(4); %in ft

%(E/L)*cross-section : kips/sq. in * sq in = kips (inch taken care of)

% Find theta and alpha

theta = acot(x/L);
alpha = acot((D-x)/L);
% Constraint scaling

scale = 5e-3;

% Structure stiffness matrix

cost = cos(theta); sint = sin(theta);
cosa = cos(alpha); sina = sin(alpha);

K = scale*(E/L)*[a1*sint*(cost^2) + a3*sina*(cosa^2) , a1*(sint^2)*cost - a3*(sina^2)*cosa ;
	a1*(sint^2)*cost - a3*(sina^2)*cosa, a1*(sint^3) + a2 + a3*(sina^3)];

K 


inv_K = inv(K)
analytic_inv = (1/det(K))*[K(2,2), -K(1,2); -K(2,1), K(1,1)]
 

load = scale*[W1; W2];

u = (K\load)*12 % in inches
