kill(all)$

print( " linear elements'finite element'")$

TT:T(x):=a1+a2*x$
T11:T(0)=T1;
T22:T(h)=T2;

T1;

eq1:algsys([T11,T22],[a1,a2]);

p1:eq1[1][1];
p2:eq1[1][2];

p4:subst([p1,p2],T(x));

p4;

p5:ratsimp(p4);

p6:expand(p5);

p6;

print("N1(x),N2(x) 'shape functions'")$
print("N1 = N1(x) ")$
print("N2 = N2(x) ")$

N1:coeff(p6,T1);
N2:coeff(p6,T2);

print("N1'(x),N2'(x) 'first derivatives shape functions'")$
print("N1_D = N1'(x) ")$
print("N2_D = N2'(x) ")$

N1_D:diff(N1,x,1);
N2_D:diff(N2,x,1);