I thought of a slightly different approach using the general method proposed here. I'm not great with Mathematica shortcuts so I'm sure that the code can be simplified, but start by splitting the expression into lists.
I should mentioned that I assumed Q[x,t]
should be:
qxt = p1[x]*u1[t] + p2[x]*u2[t] + p3[x]*u3[t]
though it can easily be changed to the form originally written. The total integrand is
exp = qxt^3*(p1[x] + p2[x]+p3[x])^3;
expandexp = Expand@exp;
Listing the terms:
terms = List @@@ List @@ expandexp;
Split the list based on function type:
elemtest[k_] := MemberQ[k, x, Infinity]
ints = SplitBy[#, elemtest] & /@ terms;
Function definitions:
p1num[x_]:=-Cos[4.73 x]+Cosh[4.73 x]-0.9825 (-Sin[4.73 x]+Sinh[4.73 x])
p2num[x_]:=-Cos[7.85 x]+Cosh[7.85 x]-1.00077 (-Sin[7.85 x]+Sinh[7.85 x])
p3num[x_]:=-Cos[10.99 x]+Cosh[10.99 x]-0.99996 (-Sin[10.99 x]+Sinh[10.99 x])
Now solving the integral:
NIntegrate[
Table[Times @@
Flatten[ints[[i, ;; (Length[ints[[i]]] - 1)]], 1], {i, 1,
Length@ints}] /. p1 -> p1num /. p2 -> p2num /. p3 -> p3num, {x,
0, 1}].Table[Times @@ Last@ints[[i]], {i, 1, Length@ints}]
Yielding:
(*8.43022 u1[t]^3 + 31.985 u1[t]^2 u2[t] + 44.6085 u1[t] u2[t]^2 +
21.3727 u2[t]^3 + 17.1899 u1[t]^2 u3[t] +
56.9567 u1[t] u2[t] u3[t] + 48.9372 u2[t]^2 u3[t] +
27.9564 u1[t] u3[t]^2 + 45.872 u2[t] u3[t]^2 + 15.9643 u3[t]^3*)
Verifying the solution:
Checking for u1[t]==1
, u2[t]==2
, and u3[t]==3
directly:
NIntegrate[(p1[x] + p2[x] + p3[x])^3 (p1[x] 1 + p2[x] 2 + p3[x] 3)^3 /.
p1 -> p1num /. p2 -> p2num /. p3 -> p3num, {x, 0, 1}]
(*2910.71*)
and using the extraction method:
NIntegrate[
Table[Times @@
Flatten[ints[[i, ;; (Length[ints[[i]]] - 1)]], 1], {i, 1,
Length@ints}] /. p1 -> p1num /. p2 -> p2num /.
p3 -> p3num, {x, 0, 1}].Table[
Times @@ Last@ints[[i]], {i, 1, Length@ints}] /. {u1[t] -> 1,
u2[t] -> 2, u3[t] -> 3}
(*2910.71*)
NIntegrate[]
can only gives numeric calculations and results. $\endgroup$f[x] u[t]
; I think the OP wants to automatically dou[t] NIntegrate[f[x],{x,0,1}]
for all such terms. $\endgroup$Q[x,t]
, this might contain a possible solution. $\endgroup$