       Re: Manipulate with specified step size

• To: mathgroup at smc.vnet.net
• Subject: [mg91044] Re: Manipulate with specified step size
• From: "David Park" <djmpark at comcast.net>
• Date: Mon, 4 Aug 2008 03:25:24 -0400 (EDT)
• References: <g6h5em\$h1k\$1@smc.vnet.net>

```The key is to precompute and simplify the conv[x,y,z] function.

c[z_] = conv[x, y, z] // Simplify
\[Piecewise] {
{6 - z, 5 < z <= 6},
{-4 + z, 4 < z <= 5}
}

Substitute that into your Manipulate statement and everything will work
smoothly. Also, you don't have to move in steps of 1.

Here is a Presentations package version of it:

Needs["Presentations`Master`"]

conv[f_, g_, t_] = \!\(
\*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t\)]\(f[s]
g[t - s] \[DifferentialD]s\)\);

x[t_] = UnitStep[t - 2] - UnitStep[t - 3];
y[t_] = UnitStep[t - 2] - UnitStep[t - 3];

c[z_] = conv[x, y, z] // Simplify

Manipulate[
Draw2D[
{Draw[{x[s], y[t - s]}, {s, 0, 8},
PlotRange -> {{-.01, 8}, {-.4, 2}},
PlotStyle -> {{GrayLevel[.85]}, {GrayLevel[.85]}},
Exclusions -> None],
Draw[x[s] y[t - s], {s, t, 8.1}, PlotRange -> {{0, 8.1}, {0, 16}},
PlotStyle -> Black, Exclusions -> None],
Draw[Evaluate[x[s] y[t - s]], {s, -.01, t}, Filling -> Axis,
PlotRange -> {{0, 8.1}, {0, 16}}, PlotStyle -> Black,
Exclusions -> None],
Draw[c[z], {z, -.01, t}, PlotRange -> {{-.01, 8}, {0, 16}},
PlotStyle -> Blue, Exclusions -> None], {Dashed,
Line[{{t, -6}, {t, c[t]}}]},
Text[Style["t", Italic, Bold, Blue, 14], {t - .1, -1.5 + .2}]},
Frame -> False,
PlotRange -> {{-.5, 8.5}, {-1.5, 2}}
],
Style["Convolution Demonstration", 16],
Delimiter,
{t, 0, 8, Appearance -> "Labeled"}
]

--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/

"J Davis" <texasAUtiger at gmail.com> wrote in message
news:g6h5em\$h1k\$1 at smc.vnet.net...
>I wanted to revisit the issue in this thread:
>
>
> I have the following:
>
> conv[f_, g_, t_] = \!\(
> \*SubsuperscriptBox[\(\[Integral]\), \(0\), \(t\)]\(f[s]
>    g[t - s] \[DifferentialD]s\)\);
>
> x[t_] = UnitStep[t - 2] - UnitStep[t - 3];
> y[t_] = UnitStep[t - 2] - UnitStep[t - 3];
>
>
> Manipulate[
> Show[
>  Plot[{Tooltip[x[s], "f(s)"], Tooltip[y[t - s], "g(t-s)"]}, {s, 0,
>    8}, PlotRange -> {{-.01, 8}, {-.4, 2}},
>   PlotStyle -> {{GrayLevel[.85]}, {GrayLevel[.85]}},
>   Exclusions -> None],
>  Plot[Tooltip[x[s] y[t - s], "f(s)g(t-s)"], {s, t, 8.1},
>   PlotRange -> {{0, 8.1}, {0, 16}}, PlotStyle -> Black,
>   Exclusions -> None],
>  Plot[Evaluate[x[s] y[t - s]], {s, -.01, t}, Filling -> Axis,
>   PlotRange -> {{0, 8.1}, {0, 16}}, PlotStyle -> Black,
>   Exclusions -> None],
>  Plot[Evaluate[Tooltip[conv[x, y, z], "(f*g)(t)"]], {z, -.01, t},
>   PlotRange -> {{-.01, 8}, {0, 16}}, PlotStyle -> Blue,
>   Exclusions -> None],
>  Graphics[{Dashed, Line[{{t, -6}, {t, conv[x, y, t]}}]}],
>  Graphics[
>   Text[Style["t", Italic, Bold, Blue, 14], {t - .1, -6 + .2}]]
>  ]
> , {t, 0, 8, 1}
>
> When I move the slider the dynamics are slow to evaluate. I would be
> content to simply "play" the animation at the discrete values t=0 to
> t=8 in increments of 1. However, I have been unable to obtain that
> result.
>
> Suggestions?
>
> Thanks,
> John
>
> PS I am also surprised that these computations are slow since these
> are rather simple functions involved in the convolution.
>

```

• Prev by Date: Re: Manipulate with specified step size
• Next by Date: Re: When is a List not a List
• Previous by thread: Re: Manipulate with specified step size
• Next by thread: Re: When is a List not a List