The PscFunctions Package
by Peter G. Dolya, faringoval@yahoo.com
Geometry department of mathematical faculty, Kharkov National University, Kharkov, Ukraine.
Version 2.2
November 17, 2006
Content
1.
Introduction
2.
Examples
3. What's New in version 2.
Solutions of many mathematical problems are represented by nonsmooth functions. Great number of geometrical figures has edges. Solutions of many boundary value problems of mathematical physics are not smooth functions. The axis of a beam,
which carries concentrated loads,
is in the form of a cubic spline. These problems have one common characteristic. The functions representing solutions are the continuous and express on various segments by different formulas. Ability to formulate the equations of such functions by unified formula considerably simplifies solutions of many problems.
PSCFunctions
package routines allow to generate unified formulas and equations of
P
iecewise
S
mooth
C
ontinuous
Functions
,
curves and surfaces composed from several portions with various equations.
The PscFunctions formulas are used in Geometric Simulation. With their help it is possible to find parametric equations of a triangle, a square, a polygon or any polygonal line. For the piecewise smooth curve consisting of several curvilinear segments with known parametric equations also it is possible to find a unified parametric equation. One can obtain the unified equation of a spline. It is possible to formulate parametric equations of the surfaces with edges and borders. Routines of the package can generate parametric equations of a cube, a pyramid, a surface of cylinder with both bases and many other surfaces.
In Scientific Graphics when it is required to represent result of computing experiment it is impossible to do without rigorous mathematical description of geometrical objects. The package routines allow to equate and graphically represent the twist mode and
longitudinal waves
.
It is possible to represent a deformation of the beam. Using
PscFunctions
formulas and graphical Maple routines you can show a fluid motion in a pond or a surface wave of Rayleigh.
With the help of the package routines in a number of problems of Mathematical Physics and Mechanics it is possible to arrive at an exact formula solution. In the embedded to the package executable worksheets we give a series examples in which are obtained formula solutions of the boundary value problems for the one-dimensional homogeneous wave equation and for the heat conduction equation.
Deflection of a simple beam, which carries concentrated loads
, can be represented as a cubic spline and now it can be expressed as the unified formula.
The
PscFunctions
package contains a collection of routines, which generate equations of piecewise smooth continuous functions, curves and surfaces. The package also contains some embedded executable worksheets covering topics that demonstrate application of the package routines for various fields of applied mathematics.
| > | restart; with(PscFunctions); |
PscFunctions package propose a new point of view to geometric simulation. It contains a new way to modelling composite geometrical figures. The package routines allow to generate with the help of elementary functions formulas of
piecewise smooth continuous functions
,
curves and surfaces composed from several segments with various equations. Now one can formulate the unified equation of a polyline or a cubic spline, can generate an equation of
periodic extension of the function to entire real axis
, can obtain the unified equation of a piecewise-bilinear surface and many other things.
Bellow, you will find examples of usage of routines of the package. Each example starts with creation of equation of the object. After that we use standard Maple functions to plot the graph of the figure.
2.1. Equations of Piecewise Smooth Continuous Functions
2.1.1. FPolyline routine creates a function with a piecewise-linear continuous graph passing through the given points. Function is linear between these points. The list of lists of coordinates of these points is an argument of the routine.
| > | f1:=FPolyline([[0,-1],[1,1],[2,0],[3,2],[4,1]]): print('y'=f1(x)); plot(f1(x),x=-1..6,thickness=2,scaling=CONSTRAINED); |
2.1.2. FPscPolyline
routine generates a function with a
piecewise
smooth continuous
graph
consisted from pieces of graphs of given functions
over the given segments.
The first argument of the routine is a list of functions.
The second argument is a list of numbers dividing the real axis into segments each of which corresponds to the given functions.
| > | fun1:=x->6*(x-x^2): fun2:=x->sin(Pi*x): fun3:=x->-(x-3)^2: f2:=FPscPolyline([fun1,fun2,fun3],[0,1,2,4]): print('y'=f2(x)); plot(f2(x),x=-1..5,thickness=2,scaling=CONSTRAINED); |
2.1.3. FPscBilinear routine generates a function of two varia bles that represents the equation of a piecewise-bilinear surface passing through the given points above the given grid.
| > | Lx:=[0,1,2]: # X coordinates of points of a grid Ly:=[0,1,2]: # Y coordinates of points of a grid LLz:=[[0,1,2],[1,1,1],[1,2,1]]: # Z coordinates of points above a grid Z:=FPscBilinear(LLz,Lx,Ly): print('z'=Z(x,y)); plot3d(Z(x,y),x=0..2,y=0..2,axes=BOXED,scaling=CONSTRAINED,grid=[4,4]); |
2.1.4. FPeriodic routine generates a function that represents periodic extension of the function segment to the entire real axes. At continuation the function Mod(x,y) is used. It gives the remainder on division of x by y . It's equivalent to x-y*floor(x/y) . In the following example periodic extension from segment [1,3] is executed.
| > | f:=x->(x-1)*(3-x): F:=FPeriodic(f,1..3,style='periodic'): print('F'=F(x)); plot(F(x),x=-4..5,thickness=2); |
2.1.5. FPscSpline routine generates a function that represents explicit equation of a cubic spline with specified end conditions . The spline passes through the given point set. The type of end conditions is determined by the second (optional) parameter. By default, natural end conditions are used.
| > | LL:=[[0,0],[1,1],[2,1],[3,2],[4,-1],[5,0]]: # data points Z:=FPscSpline(LL): print('z'=Z(x)); pnts:=plots[pointplot](LL,symbolsize=20): py:=plot(Z(x),x=0..5,thickness=2,scaling=CONSTRAINED,color=BLACK): plots[display](pnts,py); |
2.2. Parametric Equations of Piecewise Smooth Continuous Curves
2.2.1. CPolyline
routine creates a sequence of two or three functions that represent a parametric equation of the
polygonal line passing through 2D or 3D points.
Example 2.2.1.1.
Here is an example giving a parametric equation of the square with the vertexes at the points [1,1], [-1,1], [-1,-1], [1,-1].
| > | sq:=CPolyline([[1,1],[-1,1],[-1,-1],[1,-1],[1,1]]): print('x'=sq[1](t)); print('y'=sq[2](t)); plot([sq(t),t=0..4],-1.5..1.5,-1.5..1.5,thickness=2,scaling=CONSTRAINED); |
Example 2.2.1.2 Here is an example of the parametric equation of the triangle in space.
| > | tr3:=CPolyline([[0,0,0],[2,1,1],[1,2,2],[0,0,0]]): print('x'=tr3[1](t)); print('y'=tr3[2](t)); print('z'=tr3[3](t)); with(plots,spacecurve): spacecurve([tr3(t)],t=-1..4,thickness=2,axes=BOXED,color=black,numpoints=200,orientation=[-60,60]); |
2.2.2. CPscPolyline
routine
creates two or three functions that represent parametric equation of a piecewise smooth continuous curve on the plane or in space.
The routine takes a list of lists of functions each of which is a parametric equation of a curvilinear segment. The routine also takes a list of lists of values of the parameter at starting and end points of each curvilinear segment.
Example 2.2.2.1.
Here is an example of the parametric equation of the curvilinear polygon, which is a rectangle smoothed by the circular arcs at its upper left and upper right vertexes.
| > | crv1:=CPscPolyline([[t->2,t->t],[t->cos(Pi*t),t->sin(Pi*t)],[t->t,t->2],[t->cos(Pi*t),t->sin(Pi*t)],[t->-2,t->t],[t->t,t->0]],[[0,1],[0,1/2],[1,-1],[1/2,1],[1,0],[-2,2]]): print('x'=crv1[1](t)); print('y'=crv1[2](t)); plot([crv1(t),t=0..6],x=-2.5..2.5,y=-0.5..2.5,thickness=2,scaling=CONSTRAINED); |
Example 2.2.2.2 . Here is an example of the parametric equation of a curvilinear triangle in space.
| > | trsp:=CPscPolyline([[t->1+cos(Pi*t),t->0,t->sin(Pi*t)],[t->2,t->t,t->0],[t->1+cos(Pi*t),t->-t,t->sin(Pi*t)]],[[1,0],[0,1],[0,1]],[0,1,2,3]): print('x'=trsp[1](t)); print('y'=trsp[2](t)); print('z'=trsp[3](t)); with(plots,spacecurve): spacecurve([trsp(t)],t=0..3,thickness=2,axes=BOXED,color=black,numpoints=100,orientation=[-45,45],labels=["X","Y","Z"]); |
2.2.3. CRegularGon . To generate a parametric equation of a regular n-gon it is possible to use CRegularGon routine. It generates a sequence of two functions. The routine arguments are the number of sides of a polygon and a circumradius.
| > | gon6:=CRegularGon(6,1): print('x'=gon6[1](t)); print('y'=gon6[2](t)); plot([gon6(t),t=0..6],-1.5..1.5,-1.5..1.5,thickness=2,scaling=CONSTRAINED); |
2.2.4. CPscSpline routine generates a sequence of two or three functions that represents a parametric equation of a cubic spline with specified end conditions. The spline curve passes through the given point set (first argument of the routine). The type of end conditions is determined by the second (optional) argument.
| > | x,y:=CPscSpline([[0,0],[-12,4],[-9,6],[-15,14],[-6,12],[-15/2,18],[-3,16],[0,22],[3,16],[15/2,18],[6,12],[15,14],[9,6],[12,4],[0,0]],endpoints=natural): plot([x(t),y(t),t=0..14],thickness=2,scaling=CONSTRAINED); print('x'=x(t)); print('y'=y(t)); |
2.3. Parametric Equations of Plane Regions
In this section as a plane region we mean a simply connected piece of the plane
z=0
bounded by some closed curves. Mathematical expressions, which will be generated by routines of the package will represent the parametric equation of the plane region in the form
x=x(u,v),y=y(u,v)
. The fact that enlargement of ranges of parameters in equations does not change the shape of the region allows to call these expressions as equations of plane regions. When plotting the graph of a region as a surface in space one should add to two generated functions a zero function representing third coordinate of the surface.
2.3.1. DRectDomain
.
DRectDomain
routine
generates a sequence of two functions that represents a parametric equation of a plane region located between two curves with orthogonal grid inside.
This routine is used in two forms.
Example 2.3.1.1.
In the first form its arguments are two functions, which represent the explicit equations of the upper and lower curves of the region and a variable range for these equations.
| > | doml:=DRectDomain(x->sqrt(1-x^2),x->-1,-1..1): print('x'=doml[1](u,v)); print('y'=doml[2](u,v)); plot3d([doml(u,v),0],u=-1..1,v=-1..1,axes=BOXED,grid=[21,21],scaling=CONSTRAINED); |
Example 2.3.1.2.
In the second form the procedure
DRectDomain
uses three functions. The first pair of functions represents a parametric equation of the lower boundary curve. The first and third functions represent a parametric equation of the upper curve.
The following example shows how to find a parametric equation of the plane region of the M letter(the first letter in the word Maple). At the beginning we find a parametric equation of lower and upper boundary curves.
| > | fd1:=CPolyline([[0,0],[1,0],[1,2],[2,1],[3,2],[3,0],[4,0]],[0,1,2,3,4,5,6]): print('xd'=fd1[1](t)); print('yd'=fd1[2](t)); fu1:=CPolyline([[0,3],[1,3],[1,3],[2,2],[3,3],[3,3],[4,3]],[0,1,2,3,4,5,6]): print('xu'=fu1[1](t)); print('yu'=fu1[2](t)); plot({[fd1(t),t=0..6],[fu1(t),t=-1..7]},-1..5,-0.1..3.1,thickness=2,scaling=CONSTRAINED); |
Pay attention, that the function that represents x coordinate is the same to both curves. Now with the help of DRectDomain routine we generate a parametric equation of the plane domain in the shape of the letter M.
| > | x:=t->fd1[1](t): f1:=t->fd1[2](t): f2:=t->fu1[2](t): Mletter:=DRectDomain(x,f1,f2): print('x'=Mletter[1](u,v)); print('y'=Mletter[2](u,v)); plot3d([Mletter(u,v),0],u=0..6,v=0..3,axes=BOXED,grid=[31,16],scaling=CONSTRAINED,orientation=[-120,30]); |
2.3.2. DPolarPolygon
routine
generates a sequence of two functions that represents a parametric equation of the plane region
bounded outside by polyline
. It uses the list of lists of coordinates of nodal points of the boundary polygonal line and the list of two numbers that represents coordinates of the polar point.
Here is an example of the parametric equation of the region in the shape of the maple leaf.
| > | lstMpl:=[[0,1],[-12,4],[-9,6],[-15,14],[-6,12],[-15/2,18],[-3,16],[0,22],[3,16],[15/2,18],[6,12],[15,14],[9,6],[12,4]]: Mpl:=DPolarPolygon(lstMpl,[0,6]): print('x'=Mpl[1](u,v)); print('y'=Mpl[2](u,v)); plot3d([Mpl(u,v),0],u=0..14,v=0..1,grid=[43,11],axes=BOXED,style=PATCHNOGRID,orientation=[-60,15]); |
2.3.3. DPscPolygon routine generates a sequence of two functions that represents a parametric equation of a plane region bounded outside by a piecewise smooth continuous curve. The first argument is a list of two functions that represents a parametric equation of the region contour. The second argument assigns the range of parameter of the boundary curve. Here is an example of the parametric equation of the region bounded outside by the ellipse.
| > | el:=DPscPolygon([t->2*cos(t),t->sin(t)],0..2*Pi): print('x'=el[1](u,v)); print('y'=el[2](u,v)); plot3d([el(u,v),0],u=0..2*Pi,v=0..1,axes=BOXED,grid=[21,8],scaling=CONSTRAINED); |
2.3.4. DPscRing
routine generates
a sequence of two functions that represents a parametric equation of a
plane region bounded from two sides by two piecewise smooth continuous curves.
The first and the second arguments are lists of two functions that represent parametric equations of the boundary curves. The third and fourth arguments are
ranges
of parameters of these curves. The fifth optional argument informs the procedure, if the parametric equations of the boundary curves are generated with the help of routines of the package. It allows the routine to generate more simpler equation of the region.
Here is an example of the equation of a ring domain bounded from inside by a square, and from outside by a circle. In this example equations of a circle and a square are generated by routines of our package.
| > | c1:=CPscPolyline([[t->2*cos(t),t->2*sin(t)]],[[0,2*Pi]],[0,2*Pi]): c2:=CPolyline([[1,0],[0,1],[-1,0],[0,-1],[1,0]]): plot({[c1(t),t=-3..7],[c2(t),t=-1..5]},-2.5..2.5,-2.5..2.5,thickness=2,scaling=CONSTRAINED); ring1:=DPscRing([c1],[c2],0..2*Pi,0..4,psc=true): print('x'=ring1[1](u,v)); print('y'=ring1[2](u,v)); plot3d([ring1(u,v),0],u=0..2*Pi,v=0..1,axes=BOXED,grid=[21,9],scaling=CONSTRAINED,orientation=[-60,30]); |
2.3.5. DRegularPolygon . With the help of DRegularPolygon routine it is possible to generate a parametric equation of the region bounded by a regular polygon. The first argument is a number of sides of the regular polygon. The second argument is a circumradius.
| > | triangle:=DRegularPolygon(3,1): print('x'=triangle[1](u,v)); print('y'=triangle[2](u,v)); plot3d([triangle(u,v),0],u=0..3,v=0..1,axes=BOXED,grid=[19,6],scaling=CONSTRAINED); |
2.3.6. DRegularRing . With the help of DRegularRing routine it is possible to generate parametric equation of the region bounded by two regular polygons with common centre. The first and the second arguments of the routine are a number of sides and a circumradius of the internal polygon. The third and the fourth arguments of the procedure are a number of sides and a circumradius of the external polygon. Option param1 assigns a range for the first parameter in generated equation of the region.
| > | ring36:=DRegularRing(3,1,6,2,param1=0..1): print('x'=ring36[1](u,v)); print('y'=ring36[2](u,v)); plot3d([ring36(u,v),0],u=0..1,v=1..2,grid=[37,8],axes=BOXED,scaling=CONSTRAINED); |
Note. Parametric equations of the plane regions can be used for construction of curvilinear surfaces. For this purpose as third z coordinate of the surface one should take any nonzero function.
2.4. Parametric Equations of Piecewise Smooth Continuous Surfaces
2.4.1. SCone routine generates a sequence of three functions that represents a parametric equation of a cone, a blunted cone or a cylinder. Its first argument is height of the figure. The second and the third arguments are radii of bases of the blunted cone
| > | tc:=SCone(3,2,1): print('x'=tc[1](u,v)); print('y'=tc[2](u,v));print('z'=tc[3](u,v)); plot3d([tc(u,v)],u=0..2*Pi,v=0..6,scaling=CONSTRAINED,grid=[21,25],axes=BOXED); |
2.4.2. SRegularPyramid routine generates a sequence of three functions that represents parametric equation of a regular n-sided pyramid, a regular n-gonal prism or a regular truncated pyramid. Its first argument is a number of sides of a regular polygon in the base of the figure. The second argument means height of the figure. The third argument means circumradius of the polygon in the base.
| > | pir:=SRegularPyramid(6,2,1): print('x'=factor(pir[1](u,v))); print('y'=factor(pir[2](u,v))); print('z'=factor(pir[3](u,v))); plot3d([pir(u,v)],u=0..6,v=0..3,scaling=CONSTRAINED,grid=[25,19],axes=BOXED); |
2.4.3. SCuboid routine generates a sequence of three functions that represents a parametric equation of a cuboi d. Its arguments are length, width and height of the figure.
| > | Cube:=SCuboid(1,1,1): print('x'=Cube[1](u,v)); print('y'=Cube[2](u,v)); print('z'=Cube[3](u,v)); plot3d([Cube(u,v)],u=0..4,v=-1..2,scaling=CONSTRAINED,grid=[21,16],axes=BOXED); |
2.4.4. SPolyhedral routine generates a sequence of three functions that represents a parametric equation of a polyhedron of a polyhedral sphere shape. The first argument means a number of sides of a regular polygon in the equatorial section of the surface. The second argument means a number of sides of a regular polygon in the meridian section of the surface. The third argument is radius of the circumscribed sphere.
| > | pl6:=SPolyhedral(6,6,1): print('x'=pl6[1](u,v)); print('y'=pl6[2](u,v)); print('z'=pl6[3](u,v)); plot3d([pl6(u,v)],u=0..6,v=-1.5..1.5,scaling=CONSTRAINED,grid=[31,19],axes=BOXED); |
2.4.5. SToralPolyhedron routine generates a sequence of three functions that represents a parametric equation of a surface of the shape of a toroidal polyhedron. The surface is formed by motion of the centre of one regular polygon along the contour of the other. The first and the second arguments mean a number of sides and circumradius of the directing polygon. The third and the fourth arguments mean a number of sides and circumradius of the generating polygon. Option rotatem=true implements rotation of the generating polygon in its plane by the angle Pi/m, where m is a number of sides of the polygon.
| > | tr3:=SToralPolyhedron(infinity,2,4,1,rotatem=true): print('x'=tr3[1](u,v)); print('y'=tr3[2](u,v)); print('z'=tr3[3](u,v)); plot3d([tr3(u,v)],u=0..2*Pi,v=0..4,axes=BOXED,grid=[25,17],scaling=CONSTRAINED); |
2.4.6. SPolarPscExtrude routine generates a sequence of three functions that represents a parametric equation of the surface formed by extrusion of a plane piecewise smooth continuous curve in the direction perpendicular to the plane . The first argument is a list of two functions that represents a parametric equation of the plane curve. The second argument is the height to which this curve is extruded. The third argument represents a range for parameter in the equation of the curve.
| > | extr1:=SPolarPscExtrude([t->2*cos(t),t->sin(t)],1,0..2*Pi): print('x'=extr1[1](u,v)); print('y'=extr1[2](u,v)); print('z'=extr1[3](u,v)); plot3d([extr1(u,v)],u=0..2*Pi,v=0..3,axes=BOXED,grid=[21,16],scaling=CONSTRAINED); |
2.4.7. SPscRuled routine generates a sequence of three functions that represents a parametric equation of a continuous piecewise ruled surface. The first argument is a list of lists of three functions that represents parametric equations of space curves. The second argument is a list of lists of pairs of numbers giving ranges of parameters in the equations of the curves. Pieces of the ruled surface are stretched between consecutive curves.
| > | tube:=SPscRuled([[t->4,t->cos(t),t->sin(t)],[t->2,t->cos(t),t->sin(t)],[t->cos(t),t->2,t->sin(t)],[t->cos(t),t->4,t->sin(t)]],[[0,2*Pi],[0,2*Pi],[0,2*Pi],[0,2*Pi]]): print('x'=tube[1](u,v)); print('y'=tube[2](u,v)); print('z'=tube[3](u,v)); plot3d([tube(u,v)],u=0..1,v=0..3,axes=BOXED,labels=["X","Y","Z"],scaling=CONSTRAINED); |
As the examples shows, with help of
SPscRuled
routine it is possible to find parametric equations of pyramids with various shapes of the bases, a circular cone with the base, a cylinder with the plane bases and others. Even the equation of the surface of a cube can be found with the help of this function.
2.4.8. SFuncOnContour
routine generates a sequence of three functions that represents a parametric equation of a cylindrical surface that visualizes the graph of a function over the contour of a plane domain
. Its first argument is a list of two functions that represents a parametric equation of the plane contour. The second argument is a function whose graph above the contour will be plotted.
| > | graph3:=SFuncOnContour([t->cos(t),t->sin(t)],t->1+cos(4*t)): print('x'=graph3[1](u,v)); print('y'=graph3[2](u,v)); print('z'=graph3[3](u,v)); plot3d([graph3(u,v)],u=0..2*Pi,v=0..1,grid=[81,2],axes=BOXED,style=HIDDEN,thickness=2,orientation=[60,55]); |
Brief acquaintance to advanced possibilities you can receive from Featured Applications web page of the package or from Demo of Applications example worksheet of the package.
In the version 2.1 of the package some new routines are added. Examples of usage of the new routines
FPeriodic, FPscBilinear, FPscSpline, CPscSpline
are introduced above in the present document. The new routines also are:
PolarPeriodic
routine that generates a sequence of two functions representing a parametric equation of the polar-periodic continuation of the given curvilinear segment;
SPscBilinear
routine generates a sequence of three functions that represents parametric equation
of
a piecewise-bilinear surface;
SPscSpline
routine generates a sequence of three functions that represents parametric equation
of a surface
formed by cubic splines spanned the curves of the given set;
SProjection
routine generates a sequence of three functions that represents a parametric equation
of projection of a
given surface onto the given plane;
IPscTetragon
routine generates a function that represents implicit equation of a convex tetragon;
some more base functions are added. The version 2.1 of the package also contains 6 new embedded executable worksheets covering topics that demonstrate application of the package routines for various fields of applied mathematics.
In version 2.2 some routines extending geometric simulation potential of the
PscFunctions
package are added. For the version 2.2 the following routines and functions are new:
fPscSpline, FPscHermite, PscToPiecewise, PiecewiseToPsc, CPscHermite, stc, std
. In version 2.2 it is added also two new example worksheets.