I'm performing a definite integral on a sum of 66 fairly complicated
terms. Sample term + integral (a[2]
is a constant):
temp1733[n_, lat_] =
-27501.974166279517*a[2]*
ArcCos[-0.014543897651582656*Sec[lat]*
Sec[0.005782961777094692 - 0.4001419318234436*Cos[0.017167172970436028*n] -
0.0060922154967620835*Cos[0.034334345940872056*n] -
0.002387468786938206*Cos[0.05150151891130809*n] +
0.0711242550022214*Sin[0.017167172970436028*n] +
0.0005863132618294766*Sin[0.034334345940872056*n] +
0.0013462049383894524*Sin[0.05150151891130809*n]] -
1.*Tan[lat]*Tan[0.005782961777094692 - 0.4001419318234436*
Cos[0.017167172970436028*n] - 0.0060922154967620835*
Cos[0.034334345940872056*n] - 0.002387468786938206*
Cos[0.05150151891130809*n] + 0.0711242550022214*
Sin[0.017167172970436028*n] + 0.0005863132618294766*
Sin[0.034334345940872056*n] + 0.0013462049383894524*
Sin[0.05150151891130809*n]]]*Cos[(2*n*Pi)/183]
temp1734 = Integrate[temp1733[n,lat], {n, 0.5, 366.5}, {lat,
-60*Degree, 60*Degree}]
On my machine, the definite integral above times out. Since almost all my values are numerical, I'd like to use NIntegrate
, but can't, because a[2]
isn't a numerical value. Of course, in this case, I can simply do:
a[2]*NIntegrate[temp1733[n,lat]/a[2], {n, 0.5, 366.5}, {lat,
-60*Degree, 60*Degree}]
to get the answer (it happens to be -18229.40312917879*a[2]
in this case).
However, I don't want to have to look at each of my terms to factor out the constants.
Is there any way I can tell NIntegrate
to use linearity of integration for constants? I understand why NIntegrate
can't handle more deeply nested constants (see Using NIntegrate with constants), but it seems constants used in a purely linear way should work.
I did try things like Coefficient
and CoefficientList
, but they won't work in my case because the function I'm using isn't a polynomial in my constants. Even if I can't coerce NIntegrate
to handle my functions, there must be a way to separate out and then rejoin the constant parts?
This question is a followup of sorts to the answer https://mathematica.stackexchange.com/a/165937/1722 which shows a more complicated (in my opinion) way to solve a similar problem.