MathGroup Archive 1995

[Date Index] [Thread Index] [Author Index]

Search the Archive



I am taking my first Differential Equations course and encountered Direction 
Field Plot.

I wrote a mma program to do the plot. Included below.

Execute the following and you'll see the plot.

(*variables used*)
Clear[xMin, xMax, xStep, yMin, yMax, yStep, ll, fun]
Clear[gridList, slopeList, destList, GP1, g1]

{xMin,xMax,xStep} = {-3,3,.2};   (*specify the grid points*)
{yMin,yMax,yStep} = {-3,3,.2};
ll = 1 (*ll = line length*);      (* specify the slop length to be drawn*)
fun = (#1^2-#2)&;                 (* specify the function to be ploted*)

gridList = N@Flatten[ Table[{x,y}, 
  {x,xMin,xMax,xStep},{y,yMin,yMax,yStep}], 1];
slopeList = fun[Sequence@@#]& /@ gridList;
destList = gridList + ll * ( {Cos@#,Sin@#}& /@ (ArcTan /@ slopeList) );

GP1 = N @ Line /@ Transpose[{gridList, destList}];
g1 = Graphics[{Hue[0.00], GP1 }, Axes->True, AspectRatio->Automatic];
Show[ g1 ]

(*GP stand for GraphicPrimitive. g1 is an graphic object that can be used 
with Show[]*)

I am going to modify this into a package that contain a function 
DirectionFieldPlot[] that can be used as easily as Plot, with online 
documentations. I may upload this to MathSource sometimes in the future.

I wrote another program that do Trochoid animations. MathSource item number:

 Xah Lee      xyl10060 at    74631.731 at
 A stud at Foothill College.
 Mountain View, CA
 Quote of the day: Can you tell me how to get to Sesame Street?

  • Prev by Date: Shortening Polynomials
  • Next by Date: Fourier transforming TIFF (2D) images
  • Previous by thread: Re: Shortening Polynomials
  • Next by thread: Fourier transforming TIFF (2D) images