Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Web Development

Graphing Calculators Meet PCs


Sep00: Graphing Calculators Meet PCs

David develops software to illustrate classical topics in mathematics and physics. he holds a doctorate in electrical engineering from Columbia University. He can be reached at [email protected].


The HP Vee Programming Environment


Graphing calculators are used by scientists and engineers for visual assistance with computational problems. However, hand-held calculators are limited in terms of their displays, keyboards, and processing speed. Notebook computers, which continue to shrink in size and grow in power, can improve upon the functionality of the graphing calculator. To this end, I've developed Maxwell, a program that exploits the notebook PC's hardware advantages over the calculator. The result is an instrument that is more capable and easier to use than a graphing calculator. Maxwell can logically and accurately compose and colorfully chart numerical solutions to difficult problems of mathematical physics, especially field theory.

Maxwell was built using a visual object-oriented programming language called "HP Vee," developed by Hewlett-Packard. HP Vee (http://www.hp.com/go/hpvee/) facilitates the development of user-friendly interfaces, and is used primarily for instrument control. I've used it to develop an interface in which mnemonic commands are used to draw electric and other kinds of fields on the computer screen. To assist in the logical solution of a problem, Maxwell presents command-line panels sequentially on the screen. The interface lets users draw the loci of analytic geometry, as is routinely done with a calculator. Additional commands bring within the scope of the application complex variable theory, which can require two planes for representation of mappings and is therefore beyond the capabilities of a calculator display. Building upon these capabilities, Maxwell's algorithms are extended to cover field theory, in which accurate renderings of families of curves are essential. In extending the application to encompass field theory, I've made sure that the commands used are familiar to users versed in the specialized notation of the topic.

The algorithms that make it possible for Maxwell to accurately draw the curves that arise in field theory are implemented in the HP Vee Win32-based programming environment; see Figure 1. All of the algorithms necessary for Maxwell to draw the loci of analytic geometry and the curves of field theory are implemented in iterative structures similar to the for-next loop in Figure 1. (For more details on HP Vee, see the accompanying text box entitled "The HP Vee Programming Environment.")

A Win32 executable version of Maxwell (bundled with the HP Vee run-time library) is available electronically (see "Resource Center," page 5). Additionally, I have included portions of the Maxwell source code for review. It is important to note that HP Vee source code doesn't look like regular source code, and can only be perused if you have HP Vee 5.0. (An evaluation version of HP Vee 5.0 is available at no charge via download or CD-ROM; see http://www.tmo.external.hp.com/tmo/ pia/HPVEE/PIAProd/English/HPVEE_B_ evalkitform.html.)

Mathematical Structure

An interface for graphical presentation of field theory must provide solutions to Laplace's equation so as to fulfill arbitrary boundary conditions encountered in practice. Several applications are currently available for drawing fields on the computer screen. These usually (but not always) use finite element techniques to solve Laplace's equation to display the field solution for the particular geometry and boundary conditions specified by users. An alternative approach to this problem is more effective for the graphical task at hand. Families of field lines are drawn as given by a potential function, while all other loci on the screen are drawn as given geometrically. This alternative approach actually dates to the 19th-century physicist James Clerk Maxwell, whom the program is named after. Applications for drawing fields often falter on the complexity of the graphical task. I've tackled this difficulty by following not only Maxwell, but also Faraday and Euclid.

The feel and interactivity of the Maxwell program is that of a construction or proof in Euclidian geometry, and the notation of vector differential calculus is employed as the command-line syntax. Behind these characteristics of the interface, the mathematical structure of the program is that of conformal mapping, a powerful analytic tool also employed by Maxwell. Several other applied physics techniques are integrated into this structure, including the method of harmonic functions, the method of images, and the method of Green functions. In fact, most of the important techniques of solving Laplace's equation are at Maxwell's disposal. Because of the analytic breadth of the application, users can chart solutions to a variety of problems posed in mathematical physics. It is not, however, necessary that users actually understand the techniques just cited (at least not in the conventional sense) to chart solutions. The techniques are simply called by mnemonic command lines. The program prompts users to supply the potential function and analytic transformation that define every problem in conformal mapping; users need not understand the analytic basis of conformal mapping. It is better to view the application as enabling students of field theory to draw solutions to all kinds of problems using classical techniques, and to learn these techniques in interaction with the program. It is a graphical tool for developing intuition as to the behavior of fields by making them easy to draw. In the hands of users who understand the methods of field theory in the conventional sense, the Maxwell application presents extraordinary graphical capabilities.

Zoom, a feature of HP Vee graphics, contributes to Maxwell's tutorial capabilities. Field theory is an example of differential calculus. The essence of calculus is the linearization of curves when examined minutely. With Zoom, solutions to Laplace's equation can be charted and examined on all spatial scales, to illustrate this crucial idea.

The Interface

Every problem in the operation of Maxwell is defined by a potential function and, if necessary, an analytic transformation. The first command-line panel to present itself, the Fields panel (Figure 2), contains the command lines for specification of the potential function and analytic transformation. In this example, the potential function U yields a uniform horizontal field in the uv plane. The analytic transformation j×w indicates a rotation of the uv plane by 90 degrees into the xy plane. The uv and xy planes correspond exactly to the conventional notation of conformal mapping. After these expressions are ratified with the Set button, the Traces panel is called (Figure 2).

Maxwell initiates with a blank uv plane and blank xy plane. To view the uv plane at any time, the command uvPlane() is typed in any command line on the Traces panel and executed by pressing the OK button at the top. Similarly, the xy plane can be viewed by executing the command xyPlane(); these commands are to be used repeatedly in the course of the development of a chart; see Figure 2.

To draw a curve or any other locus in the planes, mnemonic commands are typed in command lines on the Traces panel and invoked. This is analogous to the process of construction in Euclidian geometry.

To draw a typical line segment in the uv plane, command uvLine(1,0,2,3,1000) is executed. This causes a line consisting of 1001 points (1000 intervals) to be drawn from (1,0) to (2,3) in the uv plane. Note the transparent role of each argument in the specification of the locus to be drawn. The image of this segment appears concurrently in the xy plane.

In certain problems it is essential to draw a locus directly in the xy plane. Drawing a line in the xy plane is formally the same; for example, with the command xyLine(0,0,1,1,200), which draws a line from the origin (0,0) to (1,1) in the xy plane. The image of this segment appears concurrently in the uv plane.

Most commands for drawing loci in Maxwell leave users free to specify the number of points that constitute the locus, giving users some control over the appearance of the locus. Each locus is given additional texture and color with the command tr(color,point type), where values for color and point type are found in a command glossary. Naturally, a locus in the uv plane will have the same color and point type as its image in the xy plane, as it is helpful to have corresponding loci related visually. The command Origin() draws the origin and unit vectors in each plane.

The Traces panel of Figure 2 shows a typical collection of commands for construction of an arbitrary geometry. Figure 3 shows the resulting uv plane on the left and the xy plane on the right. At the bottom of Figure 3, the markers indicate the endpoints of the blue line segment drawn in the uv plane and mapped into the xy plane. The HP Vee graphical interface places the markers on any point of any locus, to retrieve numerical data.

Drawing the Field

Once a geometry has been drawn on the plane(s), the electric field lines (or other field lines) surrounding this geometry are drawn. In the spirit of Faraday, these curves are drawn by specifying a curve on the screen from which the lines of force or equipotential surfaces are to emerge. Additionally, users specify with command-line arguments the number of lines in the family and other parameters of transparent significance. The critical spacing between the lines of the family, which indicates the intensity of the field, is accurately determined by the field-drawing algorithm. Figure 3 shows the uv and xy planes, in which the lines of force (red) are drawn using the command Efield( 1,100,7,5,0,200,1), and equipotential surfaces (green) are drawn using EQPot(1,100,7,5,0,200,1).

The field lines are straight and equally spaced in the uv plane, because the potential function U called for in the Fields panel is a linear function of the coordinates, characteristic of a uniform field. The lines remain straight in the xy plane because the conformal mapping j×w is linear. The families of curves resulting from Efield and EQPot commands will always be orthogonal for any potential function and analytic transformation -- linear or not -- in both planes. This is the essence of conformal mapping.

Although the number of arguments necessary in Efield and EQPot commands to completely specify a family of lines of force or equipotential surfaces may seem large, in practice the commands are simple, and it is easy to draw all manner of fields in this way. The arguments in the use of Efield and EQPot just described provide that the families consist of seven lines of 101 points each. They emerge from locus #5 (magenta), and traverse 1 volt of potential or 1 unit of flux. Each of these arguments can be changed and the command reinvoked, to achieve the best looking family of curves. The last three arguments in each function add control. Experimentation with commands Efield(,,,,,,) and EQPot(,,,,,,) lets users discover how field lines and equipotential surfaces look under various potential functions.

A Solved Problem

Consider a difficult problem encountered in texts on electromagnetics, the electrostatic field inside and outside a conducting cylinder in which four insulated quadrants are held alternately at 1 and -1 volt potential. This problem is composed on the Fields and Traces panels, see Figure 4, and the solution in Figure 5. The problem is developed further in the Functional panel of Figure 6 and the Cartesian display of Figure 7.

The potential function interior to the cylinder is entered as required in the Fields panel. The potential exterior to the cylinder is found by conformally mapping the potential within the unit circle using the analytic transformation 1/w, also entered on the Fields panel, to the region around the cylinder.

On the Traces panel, the quadrants of the cylinder are drawn in lines 1-4. The electric field is drawn in lines 5 and 6. Equipotential surfaces are drawn in lines 7 and 8.

In lines 9 and 10, loci are drawn to examine the field around the cylinder, along these loci. A concentric circle within the conducting surfaces, (locus 9) and a line segment joining adjacent quadrants (locus 10), are drawn in the uv plane. Their image loci will be examined on the Functional panel, called by line 11.

Figure 6 shows the functional panel on which the following vector expressions are computed along locus 9:

j phi(9) Potential

E·n dot(E(9),Normal(9)) Electric field normal to the locus

E·t dot(E(9),Tang(9)) Electric field tangent to the locus

The command-line syntax corresponds exactly to the conventional syntax of vector analysis.

At the bottom of the functional panel, a glossary of differential forms available is shown. In Figure 7, the potential and tangent fields around the cylinder are charted, as computed on the functional panel. The chart of Figure 7 shows in green the intense tangential electric field near the insulated transitions of the cylinder. It is easy to return to the Traces panel to change the radius of locus 9, and then reexamine the tangential field.

Conclusion

Dozens of charts, taken from problems in advanced texts in electromagnetics and hydrodynamics, are available to illustrate the use of Maxwell in many branches of mathematical physics. Often a proposed problem is most easily charted by selecting a preexisting composition most similar. Usually by changing a few command arguments, the desired chart can be quickly achieved. Figures 8, 9 and 10 are examples of Maxwell compositions.

DDJ


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.