       Re: Re: Manipulate (from Wolfram Demonstrations)

• To: mathgroup at smc.vnet.net
• Subject: [mg76824] Re: Re: [mg76774] Manipulate (from Wolfram Demonstrations)
• From: Bruce Colletti <vze269bv at verizon.net>
• Date: Mon, 28 May 2007 00:57:36 -0400 (EDT)

```Bobby (and others)

Thanks for the explanation.  Although I reviewed the original code several times, I missed the forest thru the trees, and didn't see the substitution x -> xi in the original code.

Mine was a dumb question, but that substitution just didn't register.

Problem solved.  Moral is to read the whole problem.  Sorry for the false alarm.

Bruce

=====================
From: DrMajorBob <drmajorbob at bigfoot.com>
Date: 2007/05/27 Sun AM 05:28:35 CDT
To: Bruce Colletti <vze269bv at verizon.net>, mathgroup at smc.vnet.net
Subject: [mg76824] Re: [mg76774] Manipulate (from Wolfram Demonstrations)

p is not a function; it's an expression. The difference is similar to that
between a function f and a value f[x]. f[x] or f is a result, not the
function itself. If x is undefined, though, f[x] is the RHS or definition
of the function.

Here's a version WITH functions for p and pp.

Clear[p, pp]
Manipulate[Block[{p}, p[x_] = a x^3 + b x^2 + c x;
Block[{pp}, pp[x_] = D[p[x], x];
Plot[{p[x]}, {x, -2, 2}, Ticks -> None, PlotRange -> All,
Epilog -> ({Orange, PointSize[.02], Point[{xi, p[xi]}],
Thickness[.005],
Line[{{-2, p[xi] + pp[xi] (-2 - xi)}, {xi, p[xi]}, {2,
p[xi] + pp[xi] (2 - xi)}}]} /. x -> xi),
PlotRange -> All]]], {{xi, 0, Subscript[x, 0]}, -2,
2}, Delimiter, {{a, -2, "a"}, -2, 2}, {{b, -2, "b"}, -2,
2}, {{c, -2, "c"}, -2, 2}, ControllerLinking -> True]

Notice that xi, second argument to Manipulate, is the value of a slider
(labeled x0). The Epilog is computed in terms of x, but then x -> xi.
Hence the x0 slider affects only the orange tangent line. The a, b, and c
sliders affect the curve AND the tangent line.

Bobby

On Sun, 27 May 2007 03:53:37 -0500, Bruce Colletti <vze269bv at verizon.net>
wrote:

> Re Mathematica 6.0 under WinXP.
>
> The code below (from Wolfram Demonstrations site) plots a tangent at the
> point set by the slider.
>
> Point[{xi,p}] baffles me:  Point requires two numbers, but p is a
> function...I don't see how it evaluates to a number AT THIS location in
> the Manipulate statement.
>
> What is the mechanism that makes p evaluate to a number?  Is it somehow
> referring to Plot's {x,-2,2} ?
>
> Thankx.
>
> Bruce
>
> Manipulate[
>  With[{p = a x^3 + b x^2 + c x, dx = .8},
>   With[{pp = D[p, x]},
>    Plot[p, {x, -2, 2}, Ticks -> None, PlotRange -> All,
>     Epilog -> ({Orange, PointSize[.02], Point[{xi, p}],
>         Thickness[.005],
>         Line[{{xi - dx, p - dx pp}, {xi + dx, p + dx pp}}]} /.
>        x -> xi)]]], {{xi, 0, Subscript[x, 0]}, -2,
>   2}, Delimiter, {{a, -2, "a"}, -2, 2}, {{b, -2, "b"}, -2,
>   2}, {{c, -2, "c"}, -2, 2}, ControllerLinking -> True]
>
>

--
DrMajorBob at bigfoot.com

```

• Prev by Date: Re: Quadratic form: symbolic transformation
• Next by Date: the hard way, the easy way and the accepted way...
• Previous by thread: Re: Manipulate (from Wolfram Demonstrations)
• Next by thread: Re: Manipulate (from Wolfram Demonstrations)