[ Prev | Main | Next ]

# IntegralCurves Applet

This applet draws integral curves of a vector field. The vector at a point (x,y) is given by (f1(x,y),f2(x,y)) where f1 and f2 are functions of x and y. The field is represented in the applet as a "direction field" of arrows. The arrow at a given point points in the direction of the vector at that point, but the length of the vector is not represented. You can start a curve at a given initial point by clicking the mouse at that point. You can also enter the x and y coords of the initial point in the text input boxes labeled "x=" and "y=". Press return in one of these input boxes or click the "Start Curve at" button to start the curve. The curves are animated. At each step of the animation, a new segment of each curve is computed and drawn. The segment represents an approximation of the exact integral curve over a time interval of length dt. The approximation method can be either Runge-Kutta order 4, Runge-Kutta order 2, or Euler's method. Since Runge-Kutta order 4 is the most accurate, the other methods should generally only be used for demonstration purposes. You can stop the progress of the curves by clicking the "Stop Curves" button. The curves will also be stopped automatically if their coordinates become undefined or unreasonably large. You can clear any curves that have been drawn by clicking the "Clear" button. Curves will also be cleared if a new vector field is drawn. Here is the applet with no applet params:

Even though the applet is called "IntegralCurves", it is possible to turn off the integral curve features entirely by setting the applet param "DoCurves" to "no". In this case, you have an applet for displaying direction fields. There are also applet params for turning off each of the animation controls, except for the "Stop Curves" and "Clear" buttons.

Examples for this applet can include a set of points where curves are to be started when the example is loaded. This button will open an applet that has several examples for you to try, The first two examples will start several integral curves automatically:

The applet tag for this version of the applet is:

```   <applet archive="jcm1.0-config.jar" code="IntegralCurves.class" width=200 height=35>
<param name="UseEqualizeButton" value="yes">
<param name="UseZoomButtons" value="yes">
<param name="UseRestoreButton" value="yes">
<param name="Example" value="Spiraling Into the Center; y - 0.1*x; -x - 0.1*y; -5 5 -5 5 0.1, 3,0 3.2,0 3.4,0 3.6,0 3.8,0 4.0,0">
<param name="Example1" value="Pendulum Phase Space; y; sin(x); -10 10 -4 4 0.1,  -3,0.5 -3,1 -3,1.5 -3,2 -3,2.5 -3,3 -3,3.5 -3,4 -3,4.5">
<param name="Example2" value="Four Singularities; x^2 + y^2 - 1; (x-y)*(x+y); -2 2 -2 2">
<param name="Example3" value="A More Complicated Field; x*sin(y); y*sin(x); -6 6 -6 6">
</applet>

```

Many of the applet params are processed by the source code in the base class, GenericGraphApplet. See the list of params for that class for information about those parameters. Here is a table of the additional applet parameters processed by IntegralCurves:

Param Name Type Default Description
CurveColor Color magenta The color used to draw the integral curves.
VectorColor Color lightGray The color used to draw the direction field.
VectorStyle string Arrows Specifies how the vector field is to be represented. Only the first character of the value is examined. The styles are: Arrows, Lines, Vectors. "Arrows" is the default style, giving a direction field made up of equal-length arrows. In the "Lines" style, a vector at a point (x,y) is represented by a line with no arrowhead, centered at (x,y). In the "Vectors" style, the vector field is represented by varying-length arrows. The arrows are sized proportionately to the length of the vector, so you get something more like a vector field (although you only see the relative size, not the absolute size, of the vectors). Unfortunately, it usually turns out that most of the vectors are really short, so they just look like points.
VectorSpacing integer 20 or 30 The number of pixels between points where vectors are drawn. The default value is 20 if the VectorStyle is Lines. Otherwise, the default is 30.
Variable2 String y The name of the second variable. The first variable, usually x, is already defined in GenericGraphApplet as the value of the "Variable" param.
Function String y - 0.1*x The function that defines the horizontal component of the vector field. If there are input boxes for the functions, this is the initial content of the first box. Actually, as usual, "y" and "x" are replaced by the names of the two variables.
Function String -x - 0.1*y The function that defined the vertical component of the vector field. If there are input boxes for the functions, this is the initial content of the second box.
FunctionLabel String f1(x,y) = The label shown to the left of the first input box, if any.
FunctionLabel2 String f2(x,y) = The label shown to the left of the second input box, if any.
DoCurves yes/no yes If this is not "yes", then the applet doesn't do anything at all with integral curves. All the following parameters which pertain to integral curves are ignored.
DeltaT number 0.1 The change in time between consecutive points along the curve. If there is a "dt" input box, then this number gives the initial contents of that box.
MouseStartsCurves yes/no yes If this is "no", then clicking a point on the canvas will not start a curve at that point.
UseStartInputs yes/no yes If this is "no", then the input boxes for inputting a starting point for a curve are omitted, along with the "Start Curve at" button.
UseMethodChoice yes/no yes If this is "no", then the pop-up menu for specifying the approximation method is omitted.
UseDeltaInput yes/no yes If this is "no", then the "dt" input box is omitted.
Example,
Example1,
Example2,
...
String (none) These params, if present, define examples that appear in an Examples menu at the top of the applet. You can define "Example1" whether or not you define "Example". However, you can only have an "Example2" if you have an "Example1", you can only have "Example3" if you have "Example2", and so on. An example takes the following form: First, a descriptive title that will appear in the example menu, followed by a semicolon. This is followed by an expression, a semicolon, and another expression. These expressions give the horizontal and vertical components of the vector field. These can optionally be followed by another semicolon and a list of numbers, separated by commas and/or spaces The first four numbers give the x- and y-limits to be used for the example. If they are not present, then -5,5,-5,5 is used. The next number is the value of dt. If there are more numbers, they must occur in pairs. Each pair gives the x- and y-coordinates of a point. An integral curve will be started at each of these points when the example is loaded.

[ Prev | Main | Next ]