kill(all);

I name "1" the supported node, and I replace the constraint with its reaction "R": subsequently I will impose the compatibility condition of null vertical (z) displacement at this node.
To define linear functions along segments, I use a normalized curvilinear abscissa xi, which
it is 0 at the first point of the segment, and 1 at the final point.

Mf_12: -R*a*xi;
Mf_23: -R*b*xi;

Mt_12: 0;
Mt_23: -R*a-C;

U: integrate( (Mf_12^2/2/E/J + Mt_12^2/2/G/Jp) *a, xi, 0, 1)
  +integrate( (Mf_23^2/2/E/J + Mt_23^2/2/G/Jp) *b, xi, 0, 1);

delta_R: diff(U,R);

linsolve(delta_R=0,R),globalsolve=true;

U: ev(U);

U:fullratsimp(U);

theta_C: diff(U,C);

dim:	[a=800,b=1000,c=600,F=1000,C=500000,
	 E=210000,G=210000/2/(1+3/10),
	 J=(40^4-36^4)*%pi/64,Jp=(40^4-36^4)*%pi/32];

ev(theta_C,dim)$
%,numer;