Re: Speeding Up Known Integrations
- To: mathgroup at smc.vnet.net
- Subject: [mg120978] Re: Speeding Up Known Integrations
- From: Daniel Lichtblau <danl at wolfram.com>
- Date: Sat, 20 Aug 2011 06:16:19 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201108191034.GAA24006@smc.vnet.net>
On 08/19/2011 05:34 AM, Sean Violante wrote: > I have a large collection of iterated integrals to evaluate. > These are basically sums of terms of the form. > > t_1^n1 E^{ k1 t_1}] t_2^n2 E^{ k2 t_2} t_3^n3 E^{ k3 t_3} > > Is there any way of speeding up this evaluation? I was wondering > whether gathering up terms in the above form, and then applying the > integral to each would work out faster, or is this effectively what > Integrate is doing anyway? > > If faster, how would you suggest gathering up terms? > I have tried a few simple things eg multiplying by exp[n (k+c)W0t2] > ( where n is the largest negative power of Exp[ k t] and Exp [c t] ie so > expression becomes polynomial) > and then using CoefficientList [ %,{W0t2, e^k W0t2, e^c W0t2} ] > However, I never quite manage to pull out all the exponential terms > > Thanks for your help > > Sean > > below is an example ( where Integrate1 will be replaced by integrate). > It takes about 100 seconds on my machine. > Integrate1[ > 1/StdF1[t] \[ExponentialE]^(-t \[Kappa] + > 2 W0t2 \[Kappa]) (VC0 + \[ExponentialE]^(-c W0t2) > VCC + \[ExponentialE]^(-W0t2 \[Kappa]) > VCK)^2 Integrate1[\[ExponentialE]^( > W0t1 \[Kappa]) (VC0 + \[ExponentialE]^(-c W0t1) > VCC + \[ExponentialE]^(-W0t1 \[Kappa]) > VCK) \[Rho] ((\[ExponentialE]^(-t \[Kappa] + > W0t1 \[Kappa]) (VpC0 + \[ExponentialE]^(-c W0t1) > VpCC) \[Kappa] Subscript[a, 1] Subscript[\[Xi], 2])/( > c StdF1[t] - \[Kappa] StdF1[t]) + (\[ExponentialE]^(-c t + > c W0t1) (VpC0 + \[ExponentialE]^(-c W0t1) > VpCC) \[Kappa] Subscript[a, 1] Subscript[\[Xi], > 2])/(-c StdF1[t] + \[Kappa] StdF1[ > t]) + (\[ExponentialE]^(-c t + > c W0t1) (VpC0 + \[ExponentialE]^(-c W0t1) VpCC) Subscript[ > a, 2] Subscript[\[Xi], 2])/StdF1[t]), {W0t1, 0, > W0t2}] Subscript[a, 1] Subscript[\[Xi], 1], {W0t2, 0, t}] \! > \*SubsuperscriptBox[\(\[Xi]\), \(1\), \(2\)] /. This did not parse correctly when I tried to cut and paste it into Mathematica. Below is what I think was intended, with Greek and subscripted items renamed to similar in straight ascii. What seems to give better speed is to expand the integrand, and map the integration over that sum. In[86]:= integrand = Expand[E^(W0t1*kappa)*(VC0 + VCC/E^(c*W0t1) + VCK/E^(W0t1*kappa))* rho*((E^((-t)*kappa + W0t1*kappa)*(VpC0 + VpCC/E^(c*W0t1))* kappa*a1* eps2)/(c*StdF1[t] - kappa*StdF1[t]) + (E^((-c)*t + c*W0t1)*(VpC0 + VpCC/E^(c*W0t1))*kappa*a1* eps2)/ ((-c)*StdF1[t] + kappa*StdF1[t]) + (E^((-c)*t + c*W0t1)*(VpC0 + VpCC/E^(c*W0t1))*a2*eps2)/ StdF1[t])*a1*eps1]; In[87]:= Timing[ result = Map[ Integrate[#, {W0t1, 0, W0t2}, {W0t2, 0, t}, Assumptions -> {0 < W0t2 < t}] &, integrand];] Out[87]= {5.88, Null} If you have conditions on the various variables (positivity, etc.) then adding those to the Assumptions might improve speed further. Or maybe not, but worth experimenting with if possible. Daniel Lichtblau Wolfram Research
- References:
- Speeding Up Known Integrations
- From: Sean Violante <sean.violante07@imperial.ac.uk>
- Speeding Up Known Integrations