# A workaround found when Integrate returns SystemException[“MemoryAllocationFailure”]

This is the integration I intended to do.

lw = 8;
psi = x^2;
Proietto[a_, b_] :=
Integrate[a b, {x, 0, lw},
Assumptions -> {u > 0, phi \[Element] Reals, w \[Element] Reals,
beta \[Element] Reals, rp \[Element] Reals, rw \[Element] Reals,
rb \[Element] Reals}]
theolift = (-HeavisideTheta[-38/5 + x] +
HeavisideTheta[-32/5 +
x])*((763*Pi*(6/5 - x/20)^2*
Cos[21375/(7*Pi*
u^2)]*(-((u*((7*
Sqrt[1 - (49*(6/5 - x/20)^2)/400]*(6/5 - x/20))/
20 - ArcCos[(7*(6/5 - x/20))/20])*
Derivative[1][beta][t])/
Pi) - ((6/5 -
x/20)*(-(Sqrt[
1 - (49*(6/5 - x/20)^2)/
400]*(2 + (49*(6/5 - x/20)^2)/400))/
3 + (7*(6/5 - x/20)*ArcCos[(7*(6/5 - x/20))/20])/20)*
Derivative[2][beta][t])/(2*Pi)))/
4000 + (763*Pi*u*(6/5 - x/20)*
Cos[21375/(7*Pi*
u^2)]*((17577*u^2*x^2*
rb[t])/(50000*(6/5 - x/20)^2) - (393*u*x^2*
Derivative[1][rb][t])/(250*(6/5 - x/20)) +
x^2*Derivative[2][rb][t]))/2000) +
HeavisideTheta[
x]*(0.8400759670307388*u^2*(1 - x^2/64)^0.5*
Sin[21375/(7*Pi*u^2)]*(21375/(7*Pi*u^2) -
3.990764000117581*^-9*x +
x*phi[t] + (3*(6/5 - x/20)*x*Derivative[1][phi][t])/4)^2 +
Cos[21375/(7*Pi*
u^2)]*((763*Pi*
u*(6/5 -
x/20)*((17577*u^2*x*
rp[t])/(50000*(6/5 - x/20)^2) + (17577*u^2*x^2*
rw[t])/(50000*(6/5 - x/20)^2) - (393*u*x*
Derivative[1][rp][t])/(250*(6/5 - x/20)) - (393*u*
x^2*Derivative[1][rw][t])/(250*(6/5 - x/20)) +
x*Derivative[2][rp][t] + x^2*Derivative[2][rw][t]))/
2000 + (763*
Pi*(6/5 - x/20)^2*(u*x*
Derivative[1][phi][
t] + ((6/5 - x/20)*x*Derivative[2][phi][t])/4 -
x^2*Derivative[2][w][t]))/4000));
Proietto[theolift, psi]


This seamed to not get solved, until I mystically thought of this workaround.

 expan = Expand[theolift];
Proietto[expan, psi]


I'm happy to have solved this, yet why does it work? Finding out could be helpful.