numeric education - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


find a numerical solution of a PDE using a specified method


Calling Sequence





Calling Sequence

pdsolve(PDE, conditions, numeric, meth, options)




single partial differential equations in two independent variables



set or list initial and boundary conditions



keyword indicating a numerical solution is to be obtained



name (symbol or indexed) of the form method=meth; select method to use for solution



(optional) equations of the form keyword = value



In addition to the default interface to pdsolve/numeric, which uses the default theta methods (the theta family of methods), additional functionality is available for use of numerical pdsolve for educational purposes.


This additional functionality includes the use of 11 standard methods, specification of numerical boundary conditions, specification of startup schemes for two-stage methods, and extensibility for your custom methods.


The use of pdsolve/numeric with these methods is restricted to a single parabolic/hyperbolic PDE that is first order in time.


As with the default method, pdsolve/numeric/method returns a module that can be used to plot solutions, or obtain procedures that provide their values. For information on the plot, animate, plot3d, value, and settings module members, see pdsolve/numeric.


The method argument specifies the method to use for the problem. The available methods are:













For a description of each method, including related problems, and instructions on creating a custom scheme, see pdsolve/numeric/methods.



The options available to pdsolve/numeric/method for these additional methods are as follows.





















set, list or expression









set, list or expression


The time=name, range=l..r, spacestep=numeric, timestep=numeric, bcpts=integer, and optimize=boolean/symbol options are the same as for the default method.


- The time and range options must be specified for problems that are first order in time and space with a boundary condition that involves only one end point (otherwise the time/space variables and range are detected automatically).


- The value of the spacestep option is the size of the spatial step to use for the discrete problem. It defaults to 1/20th the spatial range.


- The value of the timestep option is the size of the temporal step to use for the discrete problem. It defaults to the value of spacestep.


- The value of the bcpts option is the number of points used in the approximation of derivatives present in the boundary conditions.


- The optimize option controls the level of optimization used for generating the solution module. For more information, see pdsolve/numeric.


The numericalbcs=set, list or expression argument describes the numerical boundary conditions. It is required for the use of some methods with some PDEs.


For example, the Euler method relates the values of the solution for 3 consecutive points in the spatial domain. This means that boundary conditions must specify solution values at 2 points in the spatial domain. If the PDE is first order in space, only one natural boundary condition can be specified, and the scheme cannot be used directly.


Numerical boundary conditions allow specification of additional discrete equations, on the spatial mesh, which allow the method to be used for the PDE problem. These are often derived from an extrapolation, or a discretization of the PDE at or near the boundary that requires the additional condition.


The pdsolve command currently accepts two forms of numerical boundary conditions.


The first form specifies that the numerical boundary condition be obtained from one of the specified methods (likely more compact) applied to the input PDE near the boundary.


The second form allows significantly more control, but requires that numerical boundary condition be provided as a discrete equation that is a relationship amongst the discrete values of the dependent variable at the boundary. This form of numerical boundary condition can depend on the time and space variables of the problem, as well as the time and space step sizes (though the names used for the step sizes must be specified), and must be linear in the discrete dependent variable values.


The numericalbcs argument can be specified using the following forms:

`numericalbcs` =

[method, point]

`numericalbcs` =


`numericalbcs` =

{expression, 'timestep'=symbol, 'spacestep'=symbol}

`numericalbcs` =

{[method[1], point[1]], ..., [method[n], point[n]],


expression[1], ..., expression[m],


'timestep'=symbol, 'spacestep'=symbol}


where method describes a method accepted by pdsolve (for example, Euler) or a custom method, point describes the boundary and offset to be used for the scheme generated by the method, timestep,spacestep specify the names used for the time and space step sizes in the numerical boundary condition, and the expression arguments are discrete forms of the numerical boundary conditions.


For the method specified numerical boundary conditions, the value of point indicates the leftmost or rightmost point to be used in the discrete formula obtained by the method. For example, if point is specified as 'n'-1 (where 'n' is some symbol) and the specified method has a width of 2, the condition is applied at the right boundary, and the solution values at the discrete points 'n'-1 and 'n'-2 are used in the discrete formula. As another example, if point is specified as 1 for the same method, the condition is applied at the left boundary, and the solution values at the discrete points 1, 2 are used in the discrete formula.


As a more detailed example, consider solution of the PDE ut+0.1ux=0 using the LaxFriedrichs method. Since this problem is first order in space, only one natural boundary condition can be applied (one boundary condition on the left boundary). However, the method has a width of 3, so two conditions are needed, thus requiring the specification of a numerical boundary condition.


The additional argument numericalbcs=Box,n specifies the use of the Box method to obtain the required additional relation for the right boundary, and in fact is equivalent to the more complicated specification numericalbcs=spacestep=h,timestep=k,v1,nv0,n+v1,n1v0,n12k+0.05000000000v1,nv1,n1+v0,nv0,n1h=0 that corresponds to using expression specified numerical boundary conditions.


The expression specified numerical boundary conditions must be provided in a very particular form. The discrete dependent variable values must be given as indexed variables with the time index first, followed by the space index (that is, utimeidx,spaceidx). Values of the time index can range from −1 to 1, where a value of 1 indicates a value at the new time step (Note: The range is from 0 to 1 for single stage method). Values of the space index can range from 1 (left boundary) to n (right boundary) where n is any symbol that is consistent over the numerical boundary condition. If n is present in the space index, it must be of the form ni where i=0,... (for example, u1,n2 and u1,2n are not allowed).


For example, a numerical boundary condition that forces the value of the solution on the right boundary to be the same as the value of the solution at the first interior point can be specified as numericalbcs=u1,nu1,n1. A similar condition for the left boundary can be specified as numericalbcs=u1,1u1,2.


The independent variable values also require some description. The spatial values must be given as the space variable indexed in the same manner as the spatial index described for the dependent variable values (for example, xn1 or x1). The temporal values must be given relative to the 0 time index. For example, for the time for the dependent variable value u1,0, use the time value timevar+timestep instead of timevar.


As a summary example, consider the use of a backward time backward space discretization of the PDE ut+uxsinxt as a numerical boundary condition for the right boundary. You can obtain the discretizations of the derivatives as ut=u1,nu0,nk, and ux=u1,nu1,n1h. Because the expansion point of the discretization is at t+k,xn, replace the time and space variables in the discrete equation with these values. Hence, the specification of this numerical boundary condition is numericalbcs={u[1,n]u[0,n]k+ux=u[1,n]u[1,n1]hsint+kxn,timestep=k,spacestep=h} 


Note: This condition can be specified using the method form as numericalbcs=BackwardTime1Spacebackward,n.


Numerical boundary conditions must be provided if needed. Otherwise, Maple returns an error.


The startup=symbol, startupsteps=integer, and startupnumbc=set, list or expression arguments specify how to compute the additional stage required for two stage methods, such as Leapfrog and DuFortFrankel. Methods such as these require the solution values at the current and prior time step to compute the solution at a future time step. This is an issue in the first step of the time integration of the PDE, as only values at one time step are known (that is, the initial condition of the problem).


The startup argument can take two forms, a method specified form, or a function specified form. For the method specified form, the argument must be specified as startup=method, where method is any of the one stage methods available for use with numerical pdsolve. For the function specified form, the argument must be specified as startup=expression, where expression is any fully specified function of the time and space variables of the problem. If no startup argument is provided, the method form is used with the default Theta scheme.


The startupsteps argument (default value is 1) improves the accuracy of the computed solution if the startup method is of lower accuracy than the two stage method. It specifies one greater than the number of doubling steps used to compute the additional stage required by the main method, and is best described through an example.


Consider a PDE where the Leapfrog method is to be used as the primary method, and the Euler method is to be used as the startup method.


* If startupsteps=1, then for the current step size k, the Euler method is used to compute the solution value at t0+k, which is then used as the required additional stage.


* If startupsteps=2, then the Euler method is used to compute the solution value at t0+k2, and the Leapfrog method is used to compute the solution value at t0+k, which is then used as the required additional stage.


* If startupsteps=3, then the Euler method is used to compute the solution value at t0+k4, and the Leapfrog method is used to compute the solution value at t0+k2, then at t0+k.


* In general, for startupsteps=n, the Euler method is used to compute the solution value at t0+k2n1, then the Leapfrog scheme is used to compute the solution value n1 times at t0+k2n2,t0+k2n3,...,t0+k2,t0+k. The value at t0+k is used as the required additional stage.


This approach allows lower accuracy methods to be used as startup methods with little or no accuracy loss.


The startupnumbc argument specifies the numerical boundary conditions to use for the startup scheme. By default, pdsolve first attempts to obtain the startup solution using the startup method and the same numerical boundary conditions as the primary method. If this fails, pdsolve attempts to obtain the startup solution using the startup method with no numerical boundary conditions. This option is provided to cover cases where neither of these approaches are sufficient. For example, if the primary method requires two numerical boundary conditions, and the startup method requires only one, this approach fails, and startupnumbc must be used. Note that the specification of startupnumbc with the incorrect number of conditions, or use of the option if it is not needed, results in an error.


Basic one-way wave equation with boundary condition on the left using the ForwardTime1Space[backward] method.








smod1moduleexportplot,plot3d,animate,value,settings;...end module


The exact solution to this problem is known. Obtain an error function at t=1.25





errfuncx=procx...end proc,t=1.25,ux,tsinπxt2=procx...end proc



errfuncprocx...end proc


Compute the maxnorm error over the interval.




Adjust half the step sizes and check that the error halves.


errfunc2x=procx...end proc,t=1.25,ux,tsinπxt2=procx...end proc



errfunc2procx...end proc








Use the CrankNicholson method on an inhomogeneous one-way wave equation. This requires a numerical boundary condition.







As a numerical boundary condition, choose a Box discretization of the PDE at the right boundary using the first interior point.







Note: You do not need to specify time and range. They are implicitly defined using the periodic boundary condition.


smod2moduleexportplot,plot3d,animate,value,settings;...end module


Again the exact solution of this problem is known. Examine the error.





errfuncprocx...end proc





And with half the step size:


errfunc2procx...end proc








The improvement is better than expected.

The Box scheme on the right boundary (without explicitly deriving the scheme) can be specified by using numericalbcs=[Box,n].


smod2bmoduleexportplot,plot3d,animate,value,settings;...end module



errfuncprocx...end proc





As an example of a two stage scheme, apply the DuFortFrankel method to a convection/diffusion equation with insulated boundary conditions.








smod3moduleexportplot,plot3d,animate,value,settings;...end module


From this solution a series of plots at different times can be generated and displayed in the same plot.



See Also