NumericalMethods[ODENumericTaylor] - approximates solution of an explicit ODE initial problem

Calling Sequence
    ODENumericTaylor(ODE, yinit=[y0,y1,...], x=a..b, degree=d, options)

Parameters
    ODE - equation; an explicit differential equation of the form diff(y(x),x,x,...)=f(x,y(x),diff(y(x),x),...)
    y0,y1,... - numeric; initial conditions, the values of solution and its derivatives at x=a
    a..b - range(numeric); the interval where the solution is to be approximated
    d - posint; degree of approximating Taylor polynomials, it must be equal or greater than the order of the ODE
    options - (optional) parameters of the form keyword = value, where keyword is one of stepsize, numsteps, output, style, solution, plotops, digits, silent. One of the options stepsize, numsteps must be used.

Description
The ODENumericTaylor command approximates the solution of the initial value problem y(n) = f(x, y, y',..., y(n-1)),  y(a) = y0, y'(a) = y1,..., y(n-1)(a) =... on the interval [a,b] using the Taylor method. Its main purpose is to exhibit behaviour of this method. Controls are similar to ODENumeric.

The user must specify the step of the chosen method either directly or by specifying the number of intervals in a partition.

This command is part of the NumericalMethods package, so it can be used in the form ODENumericTaylor(..) only after executing the command with(NumericalMethods). However, it can always be accessed through the long form of the command by using NumericalMethods[ODENumericTaylor](..).

Options

The options argument can be one or more of the following equations.

stepsize = positive
Determines the step size for the iteration. If necessary, the given value is corrected to the nearest step size that can be obtained using (b - a) / n for some integer n. This n then becomes the value for numsteps. If stepsize is not specified, the option numsteps must be used to determine it. If stepsize was either redefined or determined from numsteps, the actual value is reported by the procedure unless prevented by silent.

numsteps = posint

Determines the number of steps (number of intervals in partition) used for the iteration; the step size is then set accordingly and reported by the procedure unless prevented by silent. If numsteps is not specified, the option stepsize must be used.

output = plot, fullplot, graph, fullgraph, list, information, or totalerror
Specifies what information is given by the procedure.
- plot returns a plot of the approximate solution.
- fullplot returns a plot of the approximate solution. The points of the approximation are not connected with straight lines but with relevant portions of the actual Taylor polynomials that we used in the method.
- graph returns a plot of the approximate solution, and of a quality numeric solution from Maple's numeric solver or the actual solution if supplied by the solution option.
- fullgraph returns a plot of the approximate solution, and of a quality numeric solution from Maple's numeric solver or the actual solution if supplied by the solution option. The points of the approximation are not connected with straight lines but with relevant portions of the actual Taylor polynomials that we used in the method.
- list returns a list of pairs [xk , yk ]. This list can be used directly as argument in the plot command.
- information has an empty return, it prints rows with index k, the value of xk, the value of the approximation yk, the value ysol at xk of Maple's high quality numerical solution or the solution supplied by solution, and the error ek = | ysol(xk) - yk | at xk .
- totalerror: returns the global error En = max(ek ), where ek = | ysol(xk) - yk |.
The default value is output = plot.

style = line, point, or both
- line plots a graph: a curve consisting of straight segments connecting points [xk, yk] or parts of Taylor polynomials depending on the output setting.
- point plots the points [xk, yk].
- both plots both the points [xk, yk] and the connecting curve.
The default value is style = line for plots and style = both for graphs.

solution = algebraic
Supplies a function (an expression with variable x) that is to be used for comparison with approximate solution when output is set to graph, fullgraph, information, or totalerror. The procedure checks whether the given expression does solve the given equation. Since deciding equality of two algebraic expressions is not totally reliable, failure of the check does not interrupt the procedure, just a warning is issued unless prevented by silent.

plotops = list
These options are passed to plotting commands if output is set to plot, fullplot, graph, or fullgraph. Some options are overridden by the procedure: the style for approximation is determined by the style option, and if output = [full]graph, then legends are supplied automatically and the solution is shown in line style and color navy.

digits = posint
Specifies how many decimal places should be shown when output = information is specified.
If digits is set to a value greater than Digits, the latter is set to digits for the duration of this procedure. This will influence precision of all calculations during this procedure.
The default value is digits = Digits.

silent = on or off
Controls whether the procedure should print reports while running. Two possible reasons: 1) Solution supplied by solution is incorrect. 2) The stepsize has been set based on numsteps or redefined to fit the range.
- on: such instances are not reported.
- off: such instances are reported.
The default value is silent = off.

Examples

For a quick method introduction, the output = graph option works quite well.
> ODENumericTaylor(diff(y(x),x)=-y(x), yinit=[1], x=0..6, degree=2, stepsize=1.2, output=graph);

[Plot]

This is the same output as we would see using the command ODENumeric. However, here we have a chance to see how the approximations were achieved. We will also supply the actual solution.
> ODENumericTaylor(diff(y(x),x)=-y(x), yinit=[1], x=0..6, degree=2, stepsize=1.2, output=fullgraph, solution=exp(-x), style=both);

[Plot]

Default output (plot) connects approximate points with straight lines. We will ask for Taylor curves (fullplot) and for points to be shown, and add some options. We will specify an incompatible step size that will be corrected to 0.7, but we supress reporting it with silent.
> ODENumericTaylor(diff(y(x),x,x)=-2*diff(y(x),x)-y(x), yinit=[0,1], x=0..3.5, degree=2, stepsize=0.707, output=fullplot, style=both, plotops=[symbol=box,symbolsize=10], silent=on);

[Plot]

For the final example we will compare the Taylor solution with the known precise solution of the harmonic oscillation equation.
> ODENumericTaylor(diff(y(x),x,x)=-y(x), yinit=[1,0], x=0..2*Pi, degree=4, numsteps=10, output=fullgraph, solution=cos(x), plotops=[symbolsize=15]);
Using step size 0.628319.

[Plot]

When we supply a wrong function for the solution, the procedure usually recognizes it and tells us about it. Then it draws the picture anyway on the off chance that its human masters may be actually right.
> ODENumericTaylor(diff(y(x),x,x)=-y(x), yinit=[1,0], x=0..2*Pi, degree=4, numsteps=10, output=fullgraph, solution=cos(2*x), plotops=[symbolsize=15]);
Using step size 0.628319.
Warning: The supplied solution does not seem to solve the given equation.

[Plot]