I fixed doing:
syms C0 C1 C2 C3 X L P EI1 EI2
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
dY(X)=diff(Y(X),X);
d2Y(X)=diff(dY(X),X);
f0 = Y(0) == 0;
f1 = Y(L) == 0;
U=(EI1/2)*int(d2Y(X)^2,[0 L/2])+(EI2/2)*int(d2Y(X)^2,[L/2 L]);
V=-P*Y(L/2);
PI(C2,C3)=U+V;
dPIdC2=diff(PI(C2,C3),C2);
dPIdC3=diff(PI(C2,C3),C3);
f2 = dPIdC2 == 0;
f3 = dPIdC3 == 0;
S=solve([f0,f1,f2,f3],[C0,C1,C2,C3]);
C0=S.C0;
C1=S.C1;
C2 = S.C2;
C3 = S.C3;
C= ([C0;C1;C2;C3]);
disp(C);
Y(X)=C0+C1*X+C2*X^2+C3*X^3;
disp Y(X);
disp (Y(X));
FLECHA = Y(L/2)