Chapter 7 - Looping in Maple

7.5 Function on a Grid

The loop construct allows us to build a function on a numerical grid. This use of the loop in in the spirit of our previous use of Excel whereby we calculated a function on an equally spaced numerical grid and plotted it. Here we use Maple as a "computing language" much as we were to use FORTRAN, C, C++, or any other high level language. In fact, even the syntax for the loop in Maple is reminiscent of these other languages.

The steps are:

  1. define the numerical grid ( x_min, x_max, N_points ) and and calculate dx
  2. calculate the grid values ( values of x ) and store in an array
  3. calculate the function values on this grid
  4. plot the function ( grid x and function values in array - plot the arrays )

The following worksheet defines and calculates the numerical grid.

The following calculates and plots the function on the grid.

The graph shows the Skewed-Mexican-Hat function.

Note that the notation xx[k] and yy[k] is used to store the values of x and of the function y = f(x) on the grid respectively.


  Section 7.4 Chapter 7 Section 7.6       TOC

Any questions or suggestions should be directed to
Michel Vallières at vallieres@physics.drexel.edu