       Re: Nested numerical integral - speed: Is it suppose to be so slow?

• To: mathgroup at smc.vnet.net
• Subject: [mg127646] Re: Nested numerical integral - speed: Is it suppose to be so slow?
• From: Sune <sunenj at gmail.com>
• Date: Fri, 10 Aug 2012 02:44:01 -0400 (EDT)
• Delivered-to: l-mathgroup@mail-archive0.wolfram.com
• Delivered-to: l-mathgroup@wolfram.com
• Delivered-to: mathgroup-newout@smc.vnet.net
• Delivered-to: mathgroup-newsend@smc.vnet.net
• References: <jvvqoq\$rfp\$1@smc.vnet.net>

```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:= 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:= Ga[t_, t1_, t2_, a_, \[CapitalDelta]_] :=
trap[t, t1, t2, a] - trap[t - 2 \[CapitalDelta], t1, t2, a]

In:= 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:= 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:= Timing[ba[5.5, 100000, 12, 0.25]]

Out= {0.702, 3.23471}

```

• Prev by Date: Re: Nested numerical integral - speed: Is it suppose to be so slow?
• Next by Date: Re: Simplify Binomial
• Previous by thread: Re: Nested numerical integral - speed: Is it suppose to be so slow?
• Next by thread: Re: Nested numerical integral - speed: Is it suppose to be so slow?