Re: RE: Trace a function
- To: mathgroup at smc.vnet.net
- Subject: [mg34999] Re: [mg34990] RE: [mg34978] Trace a function
- From: Murray Eisenberg <murraye at attbi.com>
- Date: Wed, 19 Jun 2002 05:52:32 -0400 (EDT)
- Organization: Mathematics & Statistics, Univ. of Mass./Amherst
- References: <200206180648.CAA23362@smc.vnet.net>
- Reply-to: murray at math.umass.edu
- Sender: owner-wri-mathgroup at wolfram.com
This is very useful! Note the typo in the Animate cell: "gpoints" should be "pts" to be consitent with the example GeneratePlotPoints cell. David Park wrote: > > Declan, > > With a little work you can duplicate the graphical calculator trace plot > function. > > Here are are a couple of routines and an example. > > Needs["Graphics`Animation`"] > Needs["Graphics`Colors`"] > > This routine extracts the plot points from a plot statement. You use it just > like you use a Plot statement. > > GeneratePlotPoints[f_, iter_, opts___?OptionQ] := > Block[{g, pts, $DisplayFunction = Identity}, > g = First[Plot[f, iter, opts]]; > First[Cases[g, Line[pts_] -> pts, Infinity]] > ] > > This generates the points for a sample curve. The points are the ones that > Mathematica's adaptive plotting routine generated. > > pts = GeneratePlotPoints[x^2, {x, 0, 1}]; > > We are going to generate an animation that will plot the line in black, a > selected point in Red, and label the coordinates of the point at a user > specified text position in the plot. > > trace[npoint_, pts_, textposition_] := > Module[{x, y}, > {x, y} = pts[[npoint]]; > Show[Graphics[ > {Line[pts], > AbsolutePointSize[5], Red, > Point[{x, y}], > Black, > Text[SequenceForm["x = ", NumberForm[x, 3], "\ny = ", > NumberForm[y, 3]], textposition, {-1, 0}]}], > Frame -> True, > FrameLabel -> {"x", "y"}, > ImageSize -> 500]]; > > You could look a a specific point by evaluating trace with the point index, > or better yet produce an animation. > > Animate[trace[n, pts, Scaled[{0.1, 0.9}]], {n, 1, Length[gpoints], 1}] > SelectionMove[EvaluationNotebook[], All, GeneratedCell] > FrontEndTokenExecute["OpenCloseGroup"] > FrontEndTokenExecute["SelectionAnimate"] > > Use the up and down arrow keys to trace the point along the curve and see > the coordinate values. (Using the up and down arrow keys are often the best > method for viewing an animation.) > > David Park > djmp at earthlink.net > http://home.earthlink.net/~djmp/ > > > From: Declan O'Reilly [mailto:declan at mcs.com] > > > > > > Hi > > Is there a way to trace along the plot of a function similar to the > > 'Trace' functionality on a graphing calculator. > > > > Thanks > > Declan O'Reilly > > > > -- Murray Eisenberg murray at math.umass.edu Mathematics & Statistics Dept. Lederle Graduate Research Tower phone 413 549-1020 (H) University of Massachusetts 413 545-2859 (W) 710 North Pleasant Street Amherst, MA 01375
- References:
- RE: Trace a function
- From: "David Park" <djmp@earthlink.net>
- RE: Trace a function