numerical integration – Double NIntegrate

The functions I have are

i(d_,(Tau)_,g_,w_)=-FractionBox("1", "8") (-1+SqrtBox(RowBox({"1", "-", SuperscriptBox("d", "2")}))) (2 SuperscriptBox("g", "2")+SuperscriptBox("w", "2")-SuperscriptBox("w", "2") Cos(2g*(Tau)))

a((Tau)_,g_,d_)=ArcCos(FractionBox("1", "4") SqrtBox(RowBox({"1", "-", "d"})) (SqrtBox(RowBox({"1", "-", "d"}))+SqrtBox(RowBox({"1", "+", "d"}))+(SqrtBox(RowBox({"1", "-", "d"}))-SqrtBox(RowBox({"1", "+", "d"}))) Cos(g *(Tau)))+FractionBox("1", "4") SqrtBox(RowBox({"1", "+", "d"})) (SqrtBox(RowBox({"1", "-", "d"}))+SqrtBox(RowBox({"1", "+", "d"}))+(-SqrtBox(RowBox({"1", "-", "d"}))+SqrtBox(RowBox({"1", "+", "d"}))) Cos(g *(Tau))))

b(t_,w_,g_,d_)=Sqrt(-FractionBox("1", "8") (-1+SqrtBox(RowBox({"1", "-", SuperscriptBox("d", "2")}))) (2 SuperscriptBox("g", "2")+SuperscriptBox("w", "2")-SuperscriptBox("w", "2") Cos(2g*t)))



Where all parameters except t and g are fixed (tau=4, d=0.5, w=5)

(sorry for the format but if you copy it to Mathematica you get the right functions)

Now as you can see my function c is a numerical Integral and my function e contains c as one of the building blocks. As vizaluisation here is the Code that plots my function e (just so you see that in theory a mean value should be existent):


enter image description here

My Problem now is that I want to plot the Mean of function e over the interval and to do that I would need to calculate something along the Lines of


and to plot this function


which is the mean of e over g in (0,5).
But if I enter a code above in Mathematica it gives me a ton of errors. I guess this is due to the fact that mathematica has no explicit expression for the function I want to integrate because it in itself contains a numerical integration.

A double Integral does not work because my first integration of c is the denominator of the function e and I dont want to Integrate over 1/c by just putting

1/j*NIntegrate({a((Tau),g,d)*(Tau)/(Sqrt(-FractionBox("1", "8") (-1+SqrtBox(RowBox({"1", "-", SuperscriptBox("d", "2")}))) (2 SuperscriptBox("g", "2")+SuperscriptBox("w", "2")-SuperscriptBox("w", "2") Cos(2g*t))))},{{t,0,(Tau)}},{g,0,j})

some help yould be highly apreciated. Thank you in advance!