Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #11303
| From | Sune <sunenj@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Nested numerical integral - speed: Is it suppose to be so slow? |
| Date | 2012-08-10 06:43 +0000 |
| Message-ID | <k02aid$2tf$1@smc.vnet.net> (permalink) |
| References | <jvvqoq$rfp$1@smc.vnet.net> |
| Organization | Time-Warner Telecom |
W Craig Carter and Bob Hanlon made some suggestions that resulted in a speed up of roughly a factor of 20. I include the code here in case anybody else is interested. (further suggestions are of course also welcome!)
Code:
In[17]:= trap[t_, t1_, t2_, a_] :=
Piecewise[{{a t, 0 < t < t1}, {a t1, t1 < t < t2}, {a (t1 - t + t2),
t2 < t < t2 + t1}}, 0]
In[18]:= Ga[t_, t1_, t2_, a_, \[CapitalDelta]_] :=
trap[t, t1, t2, a] - trap[t - 2 \[CapitalDelta], t1, t2, a]
In[19]:= Fa[t_, g_, a_, \[CapitalDelta]_, \[Delta]_] :=
Integrate[Ga[u, g/a, \[Delta] - g/a, a, \[CapitalDelta]], {u, 0, t},
Assumptions -> Element[{t, g, a, \[Delta], \[CapitalDelta]}, Reals]]
In[20]:= ba[g_,
a_, \[CapitalDelta]_, \[Delta]_] := (2.675222/10)^2 Integrate[
Fa[x, g, a, \[CapitalDelta], \[Delta]]^2, {x,
0, \[Delta] + 2 \[CapitalDelta]},
Assumptions -> Element[{g, a, \[Delta], \[CapitalDelta]}, Reals]]
In[21]:= Timing[ba[5.5, 100000, 12, 0.25]]
Out[21]= {0.702, 3.23471}
Back to comp.soft-sys.math.mathematica | Previous | Next — Previous in thread | Find similar | Unroll thread
Nested numerical integral - speed: Is it suppose to be so slow? Sune <sunenj@gmail.com> - 2012-08-09 08:01 +0000 Re: Nested numerical integral - speed: Is it suppose to be so slow? Sune <sunenj@gmail.com> - 2012-08-10 06:43 +0000
csiph-web