title

u[x_] = -u1 Cos[1* 2 π x /a]-u2 Cos[2* 2 π x /a]-u3 Cos[3* 2 π x /a]

ρ1[x_] = b Cos[π x/a]^2;

Integrate[u[x]* ρ1[x],{x,0,a}]/Integrate[ρ1[x],{x,0,a}]

ρ2[x_] = c Sin[π x/a]^2;

Integrate[u[x]* ρ2[x],{x,0,a}]/Integrate[ρ2[x],{x,0,a}]

r={a->1,u1-> 1,u2->0,u3->0,b->1,c->1};

Plot[u[x]/.r,{x,0,3a/.r}]

Plot[ρ1[x]/.r,{x,0,3a/.r}]

Plot[ρ2[x]/.r,{x,0,3a/.r}]