Content uploaded by Raafat Al-Gburi
Author content
All content in this area was uploaded by Raafat Al-Gburi on Sep 25, 2018
Content may be subject to copyright.
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
580
Computerized System for Numerical Methods
Simulation using Visual Basic Programming
Language
Raafat K. Oubida
Department of E. E., College of Engineering, University of Babylon, Babil, Iraq.
raafatoubida@gmail.com
Abstract
This paper presents a reasonable computer application solution of the numerical methods, which
have been designed and implemented of a Computerized System for Numerical Methods Simulation
(CSNMS) as teaching tool furnishes a background necessary for studying numerical analysis (numerical
methods) theory. This program is a simple application tool, which provides an interactive and simplified
interface for students. The system consists of different techniques with different algorithms has been
implemented to provide wider choice for the students in order to make it easier for them to understand
the fundamentals of numerical methods.
The simulation results from the testing of the system demonstrated that the system works correctly and
meant all constraints.
Keywords: CSNMS , Teaching tools, Numerical analysis, Simulation, Integration, Runge-Kutta, Euler,
Newton-Raphson, , Visual Basic programming Language.
CSNMS
I. Introduction
With the development of speed and efficient digital computers, the role of
numerical methods in solving scientific and engineering problems has been increasing
at rapid pace in recent years. Currently, Introduction to numerical methods course for
engineering students at the undergraduate level as a general and fundamental tool for
all engineering disciplines. Computer programming languages will be essential, some
are compulsory some are elective and there are some that don’t need to be given in
some departments or are not needed for later purposes; many today’s popular
commercial software packages widely used in science and engineering such as Matlab
[Mathworks Inc.2012], Maple, Mathcad and Mathematica [Castillo, et al., 1994].
Beside programming languages such as Fortran, Basic, Pascal, C ,C++, and Microsoft
Excel/VBA [Deitel, 1999; Walkenbach, 2004]. These resources often termed as
“teaching tools” in academic environment.
In our experience, when I was teaching the numerical methods class for Civil
Engineering students at Almuthana University during 2011-2013. The students should
learned how to use MATLAB and Excel to implement their own numerical methods.
In addition, through meticulous observation, which is found out that engineering
student lack of a programming skills and knowledge skills that can aid them to
understand the basic concepts of fundamentals of numerical methods.
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
581
Most of previous researches were using packages or programming languages as
mentioned above such as [Conte, 1965; Haggerty ,1972; Aslan et al., 2002;Hassan, et
al., 2006;Wlodkowski, 2006] for solving problems.
Conte (1965), uses of Fortran IV programming language they make a comparison
between analytical and programming method of solving numerical and came up with a
conclusion that programming method of solving numerical iterations using computer is
faster than using analytical method and safe time with a very negligible errors or no
errors incurred at all. Haggerty G.B(1972), He also used FORTRAN IV programming
languages for the algorithms. (Yüncü, Aslan, 2002), C++ was used in numerical
analysis learning as a developed visual package program. (Hassan, etc., 2006) , for the
execution of numerical iterations.
Above all, these researchers make uses of FORTRAN IV programming language
which is a text based language. Text based language do not allow the users to work
directly with graphics and this is one disadvantages why the use of FORTRAN IV
programming language is not consider for use in this research work, rather visual basic
programming language is consider for use. In addition, the recent work with visual
basic to implemented the application for the limited iteration solution.
But our software system aims to provide both simple and user-friendly tool for
students to investigate numerical methods basic concepts that allow students with less
programming knowledge and skill and the ability to select the appropriate numerical
method to be used with the particular problem under consideration.
In this paper we will describe a computerized system called CSNMS that designed
and implemented at Al-Muthana University that provides their numerical solutions
which are taught in most engineering disciplines for examples, the solution of sets of
equations, curve fitting, interpolation, differentiation and integration, and ordinary
differential equation ODEs. The rest of this paper is organized as follows:
Section II we give an overview of Visual Basic programming language. Section III
we provide a flowchart for the system analysis, followed by system design in Section
IV. Simulation results are presented in Section V. Finally, conclusions are given in
Section IV.
II. Overview of Visual Basic
Visual Basic (VB) is the advanced version of the BASIC programming languages
is developed by Microsoft corporation in 1991 and Visual basic 6, it creates visualized
interface between the user [Holzner, 1999; Brown, 2000]. Visual basic version 6 has
become one of the most important role in solving engineering problems.
This language has revolutionized and widely used because of its salient features with in
an integrated development environment (IDE), graphical user interface (GUI) (Rapid
Application Development (RAD) [Halvorson, 2002] is the process of rapidly creating
an application, and has the ability to generate a Dynamic Link Libraries (DLL). In
addition, object-oriented features, error handling, and much more. Therefore, it is
suitable to create simple educational software to achieve the required for engineering
students to solve problems .
III. System Analysis
The glance through the methodology workflow of this system presented in a
flowchart manner as shown in the figure below to gain an overview of the work done
during this project. This paper is only going to consider, application of Visual Basic to
solutions of seven different numerical methods. These are Trapezoidal, Simpson’s 1/3,
Simpson’s 3/8, Euler, and Runge- kutta 2nd order via three methods and this is the limit
of this paper.
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
582
Figure 1 : flowchart of the system
Start
Stop
Exit
Display the main widow system
Trapezoidal
Simpson’s 1/3
Huen’s method
Euler
Simpson’s 3/8
Runge Kuta 2nd order
Mid-point method
Ralston’s
method
Integration estimating
ODE Solving
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
583
IV. System design
This section gives an overview about the system design used in this project.
The main window of the program as shown in the Figure 2 consists of two categories
(topic areas) these being an integration estimating category, and an ordinary differential
equation (ODE) solving category (Figure 3).
The student may choose to perform any of the function in the list from the main menu.
We described seven methods for numerical methods namely, the Trapezoidal, Simpson,
Euler, and Runge Kuta (RK).
Each method is represented as an item in the menu. The student can insert equation and
the initial guesses or called starting value for the problem, on clicking on the estimate
or calculate button, this software can self calculate the equation , and also view the
result to the problem as shown in Figure 4. The design program was developed using
Visual basic 6.0.
When the students enter the system, they are presented with several choices that are
listed down the left side of the screen (Figure 1).
Figure 2: Screen shot 1 for main window of the program
Select a method from the menu.
Initialize input data: a, b, and n
Click the Estimation/Compute push button to view the results.
Specify a function f (x)
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
584
Figure 3: Screen Shot 2 for main window of the CSNMS system
Figure 4: Iterative Solution Results Screenshot
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
585
V. Results and Discussions
In order to compare the performance of the computerized system, we are now in
possession of three numerical methods for the numerical integration solutions. They are
Euler's method, Trapezoidal rule, and Simpson methods.
We take two limited integrals for example, exponential function,
This functions were solved by using three numerical methods with analytically
approach, so, the results which we obtained represents the exact values for these
integrals.
Then we solved these integrals using the same numerical methods in our system.
Example 1: Use the trapezoidal rule, Simpson’s 1/3 rule and Simpson’s 3/8 rule to
numerically integrate:
dxeI x
3
0
Solution:
The true solution is
R = 19.0855 the real value.
Trapezoidal rule:
In this example, y = ex , a = 0 , b = 3 , n = 6
The true solution is
n
xn
y=ex
0
0
1
1
0.5
1.64872
2
1
2.71828
3
1.5
4.48169
4
2
7.38906
5
2.5
12.18249
6
3
20.08554
Therefore the result is:
= 19.48151
= 19.482 (3 d.p.)
P = 19.482 the approximated value.
error = 19.0855 – 19.482 = 0.3965
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
586
Simpson’s rules
= 19.092
P= 19.092 the approximated value.
error = 19.0855 – 19.092 = 0.0065
Example 2: Use the Simpson’s 1/3 rule and Simpson’s 3/8 rule to numerically
integrate:
dxeI x
1
0
2
By using Trapezoidal rule:
n
value
4
1.4907
8
1.4697
By using Simpson’s 1/3 Rule:
n
value
4
1.4637
8
1.4627
In table below we summarized the result of integrating the functions with each of the
three methods.
Table 1 : Real values and approximate values of integrals
Functions
True Value
Approximate Value
Trapezoidal rule
Simpson’s 1/3 rules
Simpson’s 3/8 rule
dxeI x
3
0
19.0855
19.482
19.092
19.0857
dxeI x
1
0
2
1.4626
1.4697
1.4627
1.4626
From the previous table that shows the true values and using approximate numerical
methods for the proposed two examples in our research .
And now we got to evaluate the proposed system through the application of the same
functions and using numerical methods themselves and note the results and the extent
of convergence and accuracy, as shown in graphical interfaces for the computerized
system.
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
587
Screenshot for related examples:
Example1:
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
588
Example2:
Is clear to us is evident from the results that we have obtained over the accuracy and
efficiency of the computerized system.
Journal of Babylon University/Pure and Applied Sciences/ No.(3)/ Vol.(24): 2016
589
VI. Summary and Conclusions
By using state of the art computing and information technology tools in education
environment; as early stated in this research Visual Basic programming language has
been chosen for using to implemented and in addition that demonstrated how effective
tool in an undergraduate numerical methods class.
Manual calculations has been done as shown in Section V having true and approximate
values and that were compared with the simulation solutions obtained with the help of
software system. It was found that they are nearly equal but hand calculations were
time consuming. On the other hand, system solved the functions in the fraction of
seconds and also requires a less programming knowledge or skill.
Beside using Visual Basic is convenient to simulation of numerical methods and is less
prone to errors. Our system is working and completely functional but there are other
options that could be added to the next future work. In addition, the testing results show
that the system is working as expected.
References
Aslan C et al 2002: “Error Analysis of Numerical Methods and Preparation of a
Numerical Solution Package”, J.Fac.Eng. Arch. Gazi University vol.17,No2,87-
102.2002.
Brown R.L 2000: "Computer programming fundamentals with applications in visual
basic 6.0". Reading, Mass: Addison-Wesley, 2000.
Castillo,E.et al 1994: “Mathematica. Editorial Parninfo.” 1994
Chapra, S.C. 2008 “Applied numerical methods with MATLAB for engineers and
scientists”. McGraw-Hill. 2008
Conte S. A. et al 1965: Elementary Numerical Analysis, An Algorithmic Approach,
McGraw-Hill Book Company, New York, 1965.
Deitel H. M.1999 : “Visual Basic 6 How to Program”, USA: Prentice-Hall, 1999.
Halvorson 2002:”Microsoft Visual Basic 6.0 Professional Step by Step”, Microsoft
Press, 2002.
Hassan, et al., 2006 “The Application of Visual Basic Programming Language to
Simulate Numerical Iterations”, Leonardo Journal of Sciences ISSN 1583-0233,
Issue 9, p. 125-136.
Holzner S.1999: “Visual Basic-6 Programming Black Book”, Dreamtech Press 1999
Mathworks Inc.2012, MATLAB®, 2012, www.themathworks.com
Walkenbach, J.2004:” Excel 2003 Power Programming with VBA”, Wiley, New York
2004
Wlodkowski P. 2006:“Teaching Numerical Methods in Engineering with Mathcad”.
American Mathematical Society for Engineering Education -1549. 2006