Re: Manipulate (from Wolfram Demonstrations)

*To*: mathgroup at smc.vnet.net*Subject*: [mg76838] Re: [mg76774] Manipulate (from Wolfram Demonstrations)*From*: DrMajorBob <drmajorbob at bigfoot.com>*Date*: Mon, 28 May 2007 01:04:54 -0400 (EDT)*References*: <22023933.1180258032363.JavaMail.root@m35>*Reply-to*: drmajorbob at bigfoot.com

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[2] 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