next up previous contents
Next: POLYNOMIAL FUNCTIONS Up: SIMULATION LANGUAGE TKSL/386 Previous: SIMULATION LANGUAGE TKSL/386

Programming in TKSL/386

Programming in TKSL/386 is very easy. The menu system in TKSL/386 is very similar to that in TURBO PASCAL 6.0. Using TKSL/386 is demonstrated again on the equation (3)

$ y' = aycost, \hspace{0.5cm} y(0) = 1, \hspace{0.5cm}a=2.$

The corresponding source text in TKSL/386 is

var y;
const a=2,
      tmax=10,
      dt=0.2,
      eps=1e-20;
system
      y'= a*y*cos(t)    & 1;
sysend.

All variables that will be needed are declared in the line starting with var. All necessary constants are declared in the line starting with const ( a is a constant in the equation, tmax is the maximal computation time , dt is the step size and eps is the required accuracy).


 
Figure 2.1:
\begin{figure}\begin{center}
\epsfig{file=esin1.eps, height=8.3cm, width=12cm}\end{center}\end{figure}

The equation (3) is declared in block mode (between system and sysend). The initial condition for differential equation (3) is written in the form & initial condition.

The two typical windows which are displayed on the screen immediately after the program is started can be seen in Fig.2.1. In the right-hand part of Fig.2.1 the symbol $ \leftrightarrow $ marks the variable which is plotted on the horizontal axis (in this case the time T).

The variable T is increased by the preset step size dt and at the same time the corresponding values of the variables ORD and y (ORD stands for the method order) are shown in the right-hand part of Fig.2.1. In the left-hand part of Fig.2.1 two functions of time are shown in the course of the computation. There are graphs of y and ORD . The last function has not yet been published in any paper on this subject.

In the above example ( for a=2, integration step h=0.05s ) the value of ORD ranges between the values 11 and 13.


 
Figure 2.2:
\begin{figure}\begin{center}
\epsfig{file=esin2.eps, height=8.3cm, width=12cm}\end{center}\end{figure}

If the value of integration step increases to h=0.1s , the corresponding resulting solution of the equation (3) (again for a=2) is in Fig.2.2 . The value Y of the numerical solution at time T=10s is of course the same, only the value of ORD, as expected, has increased ( ORD ranges between 13 and 16).

The value of the coefficient a can be changed easily in the simulation language TKSL/386. The numerical solution of the equation (3) (for a=100, h=0.02 ) and the value of ORD as functions of time are shown in Fig.2.3 .


 
Figure 2.3:
\begin{figure}\begin{center}
\epsfig{file=esin4.eps, height=8.3cm, width=12cm}\end{center}\end{figure}

It is typical of the Modern Taylor Series Method that the value of ORD changes during the computation.


The high accuracy of the TKSL/386 is demonstrated on the following system of equations


$ y' =\hspace{0.4cm} a y cost \hspace{0.4cm} y(0) = 1
\hfill (8)$

$ x' = -a x cost \hspace{0.4cm} x(0) = 1
\hfill (9)$

$ z =\hspace{0.5cm} x y \hfill
(10)$


 
Figure 2.4:
\begin{figure}\begin{center}
\epsfig{file=expcos.eps, height=8.3cm, width=12cm}\end{center}\end{figure}

In the left-hand part of Fig.2.4, x, y, z and ORD as functions of time are shown in the course of the computation (for a=2, h=0.1s). In the right-hand part of Fig.2.4 the values of ORD, x, y, z are plotted (for T=10s).

The system of equations (8), (9), (10) was deliberately designed for the variable z to characterize the accuracy of the computation.

For the test function

$ z = x \cdot y\hspace{0.5cm} we \hspace{0.5cm}have\hspace{0.5cm}
z =1,$

since the exact solution of (8) is

y = ea sint

and the exact solution of (9) is

x = e-a sint.

The accuracy of the computation is preserved even if the variables reach values of 1043 and 10-44 by order of magnitude. The numerical solution of the system (8),(9),(10) reaches these values for a=100 (Fig.2.5).


 
Figure 2.5:
\begin{figure}\begin{center}
\epsfig{file=expcos3.eps, height=8.3cm, width=12cm}\end{center}\end{figure}

The corresponding test function Z and the values of ORD as a function of time ( for h=0.01s, a =100) are shown in Fig.2.6 - in the part labelled EXPCOS5. In the part labelled EXPCOS6 time functions of Z and ORD (for h= 0.1s, a=100) are shown. The value of the test function z is constantly at z=1, only the values of the function ORD increase as h grows, as expected.


 
Figure 2.6:
\begin{figure}\begin{center}
\epsfig{file=expcos5.eps, height=8.3cm, width=12cm}\end{center}\end{figure}

The achieved high accuracy of the computation of the expression

\begin{displaymath}z = x \cdot y = 1\end{displaymath}


is based on the fact that the new value of yn+1 is calculated in each step automatically until the adding of the next Taylor series terms has no effect.


next up previous contents
Next: POLYNOMIAL FUNCTIONS Up: SIMULATION LANGUAGE TKSL/386 Previous: SIMULATION LANGUAGE TKSL/386