# numerical integration question

The actual expressions is quite complicated so I will use a trivial example.

Let

In:= f[u_] := 1/3 - (5/18)*(Cos[u]*a + Sin[u]*b)^2


Then

In:= Integrate[f[u], {u, 0, 2*Pi}]

Out= 1/18 \[Pi] (12 - 5 (a^2 + b^2))


In the actual situation I have complicated integrands of u like above multiplied by various combinations of a[i], b[i] (i=1,2,3). So, I have to perform numerical integration.

What I want is to "persuade" Mathematica to make the numerical integration without bothering that a[i], b[i] do not have numerical values. That is, I want somehow the output of

NIntegrate[f[u], {u, 0, 2*Pi}]


to be something like

2.0944 - 0.872665 a^2 - 0.872665 b^2


Is it possible to do so?

This works on the simple example:

vars = Array[a, 1]~Join~Array[b, 1];
FromCoefficientRules[
MapAt[
NIntegrate[
#,
{u, 0, 2 Pi},
AccuracyGoal -> 14] &,
CoefficientRules[f[u], vars],
{All, -1}],
vars]
(*
2.0944 - 0.872665 a^2 - 1.3713*10^-17 a b - 0.872665 b^2
*)

Chop[%]
(*
2.0944 - 0.872665 a^2 - 0.872665 b^2
*)