8
Numerical Analysis with Maple 1 Mirko Navara 2 and Aleˇ s Nˇ emeˇ cek 3 Abstract We summarize more than 10 years of our experience with a course of Numerical Analysis with the use of Maple. Besides software packages, we discuss also the principles of education. History of the course Numerical Analysis with computer support has been taught at our university since late 80’s. During the first years, the main subject was programming of numerical methods in Pascal. The students gained experience with common errors in numerical programming, however, this reduced the time spent with the use of these methods. Students were usually satisfied when the program worked and they considered it useless to make further experiments with it. The skills of our incoming students do not allow to put sufficient emphasis on both programming and the use of the programs. We have decided to concentrate on the latter. Thus we prepared programs which perform the studied methods at least in their standard form. Then we used MathCAD on Apple Macintosh computers for several years. In 1994 the Numerical Methods course changed significantly with the introduction of Maple for demon- strations and calculations. Students can use Maple worksheets which implement standard algorithms. They are expected to extend them for the use in non-standard situations requiring some additional hints to solve the given tasks. We decided to use open Maple worksheets whose structure is visible and can be modified arbitrarily. As an option, we considered object-oriented programs (particularly impressive in Maple 11 document style or Maplets) which allow to handle all possibilities by several components and buttons. (Both approaches have been tested in a novel course of Multivariate Calculus in winter semester 2007/08.) We have decided not to follow this line because students should see what is behind their commands. Thus the source code has to be visible and subject to potential change (on the students’ own risk). Maple worksheets are subject to permanent updates and improvements. The course still has a theoretical core of lectures that cover definitions and theorems with proofs. This helps students see properties and connections of methods and design of specific algorithms for computers. This core is demonstrated by graphical presentation of methods including animations. Principles of the current course Our present course is based on programs which are modified by students. Having too short time for program- ming (the total length of the course is 28 hours of lectures and 28 hours of work in computer laboratory), the students are not expected to build up completely new programs, but adapt basic algorithms to the needs of specific tasks, i.e., to extend standard tools to non-standard situations. The use of floating point operations is natural in Numerical Analysis. In Maple, symbolic computation had to be suppressed in order to demonstrate the properties of numerical algorithms and round-off errors. On the other hand, symbolic algebra is useful in derivation of estimates of errors and modifications of problems (e.g., substitution in integration). Last but not least, graphical facilities of Maple are useful for demonstration of results and view of the properties of methods which are mathematically correct, but possibly inappropriate 1 The first author acknowledges the support by the Czech Government under the reseach program MSM 6840770038. The second author is supported by project Interactive Information Portal Construction for Research Applications, No. 1N04075. 2 Czech Technical University, Faculty of Electrical Engineering, Department of Cybernetics, Center for Machine Perception, Technick´ a 2, 166 27 Prague 6, Czech Republic, Phone: +420 224357388, Fax: +420 224357385, e-mail: [email protected] 3 Czech Technical University, Faculty of Electrical Engineering, Department of Mathematics, Technick´ a 2, 166 27 Prague 6, Czech Republic, Phone: +420 224353482, Fax: +420 233339238, e-mail: [email protected] 163

Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

Numerical Analysis with Maple1

Mirko Navara2 and Ales Nemecek3

Abstract

We summarize more than 10 years of our experience with a course of Numerical Analysis with the useof Maple. Besides software packages, we discuss also the principles of education.

History of the course

Numerical Analysis with computer support has been taught at our university since late 80’s. During the firstyears, the main subject was programming of numerical methods in Pascal. The students gained experiencewith common errors in numerical programming, however, this reduced the time spent with the use of thesemethods. Students were usually satisfied when the program worked and they considered it useless to makefurther experiments with it.

The skills of our incoming students do not allow to put sufficient emphasis on both programming andthe use of the programs. We have decided to concentrate on the latter. Thus we prepared programs whichperform the studied methods at least in their standard form. Then we used MathCAD on Apple Macintoshcomputers for several years.

In 1994 the Numerical Methods course changed significantly with the introduction of Maple for demon-strations and calculations. Students can use Maple worksheets which implement standard algorithms. Theyare expected to extend them for the use in non-standard situations requiring some additional hints to solvethe given tasks.

We decided to use open Maple worksheets whose structure is visible and can be modified arbitrarily. Asan option, we considered object-oriented programs (particularly impressive in Maple 11 document style orMaplets) which allow to handle all possibilities by several components and buttons. (Both approaches havebeen tested in a novel course of Multivariate Calculus in winter semester 2007/08.) We have decided notto follow this line because students should see what is behind their commands. Thus the source code hasto be visible and subject to potential change (on the students’ own risk). Maple worksheets are subject topermanent updates and improvements.

The course still has a theoretical core of lectures that cover definitions and theorems with proofs. Thishelps students see properties and connections of methods and design of specific algorithms for computers.This core is demonstrated by graphical presentation of methods including animations.

Principles of the current course

Our present course is based on programs which are modified by students. Having too short time for program-ming (the total length of the course is 28 hours of lectures and 28 hours of work in computer laboratory),the students are not expected to build up completely new programs, but adapt basic algorithms to the needsof specific tasks, i.e., to extend standard tools to non-standard situations.

The use of floating point operations is natural in Numerical Analysis. In Maple, symbolic computationhad to be suppressed in order to demonstrate the properties of numerical algorithms and round-off errors. Onthe other hand, symbolic algebra is useful in derivation of estimates of errors and modifications of problems(e.g., substitution in integration). Last but not least, graphical facilities of Maple are useful for demonstrationof results and view of the properties of methods which are mathematically correct, but possibly inappropriate

1 The first author acknowledges the support by the Czech Government under the reseach program MSM 6840770038. Thesecond author is supported by project Interactive Information Portal Construction for Research Applications, No. 1N04075.

2 Czech Technical University, Faculty of Electrical Engineering, Department of Cybernetics, Center for Machine Perception,Technicka 2, 166 27 Prague 6, Czech Republic, Phone: +420 224357388, Fax: +420 224357385, e-mail: [email protected]

3 Czech Technical University, Faculty of Electrical Engineering, Department of Mathematics, Technicka 2, 166 27 Prague 6,Czech Republic, Phone: +420 224353482, Fax: +420 233339238, e-mail: [email protected]

163

Page 2: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

in a particular application. We put emphasis on practical experience with numerical methods. The two basicprinciples of our course are:

1. Do not trust all results obtained by a computer. Verify them by alternative solutions and tests.

2. Learn what to do when the results are correct for the method chosen, but different from your expec-tation.

These principles might look too crude, but we need to emphasize them for users who believe in technologyand computer results too much. (We often observe this attitude of our students.) Weaker forms of thisstatment (by Peter Henrici and Nick Trefethen, originally due to Wilkinson, see [1]) are: “A good numericalmethod gives you the exact solution to a nearby problem,” or “Some problems are sensitive to changes.”Nevertheless, we remind our students that it is them who will sign the final results and take responsibility(neither the computers, nor the authors of software). Beside a large majority of correct results, some errorsare so crucial that they cannot be explained as mere “sensitivity to changes.” It is important that thegraduates recognize these situations.

We had to make a crucial decision:

Should the students follow a plan prepared in detail, or improvise on their individual problems?

We decided to implement the latter – more general and less restricted – approach. Besides problems suggestedby the teachers, the students may apply the methods on data obtained in other courses (e.g., ElectricalMeasurements) and encounter situations not planned by the teacher. This approach requires less preparation,but more improvisation of the teachers during the course. Still our worksheets may be useful for standardsolutions and their presentation. They contain input and output interfaces, choice of methods, algorithms(with optional levels of information about intermediate results), error estimates, graphical outputs, andmostly also comparison with the standard tools of Maple (which sometimes succeed and sometimes fail tosolve the tasks correctly). Because we teach future electrical engineers, we collected a database of problemsmotivated by electrical circuits and measurements or by general physics.

Contribution of Maple

The greatest changes in education were introduced at seminars. These take place in a computer labora-tory using Maple. The first classes (four hours) are devoted to a quick introduction to the system (workenvironment and commands) which is new to most students.

We have prepared modules (Maple worksheets) for all numerical methods that are covered by the course.These contain not only the necessary algorithms, but also selection of input formats and solving methods,error estimate construction section, graphical presentation of results, sometimes also a comparison with theprecise (symbolical) solution. Some exercises allow to compare the numerical results with those of standardMaple procedures. Maple solutions are only sometimes satisfactory, the students have to compare differentmethods and make their own conclusions about the validity of results and error estimates. Whenever possible,we present the graphs of absolute and/or relative errors and their estimates.

In some cases, not only the choice of method, but also its proper application to the given task is important.E.g., we created a collection of difficult exercises on numerical integration which require modifications forobtaining sufficiently precise results. A change may lead to a task which is mathematically equivalent, butits numerical error is of a different order. The students are expected to find such tricks and validate theachieved precision. Standard methods are usually insufficient to solve these tasks by brute force.

Even the seminar work is assigned in electronic form. During the semester the students receive five filesin their home directories (the ownership properties are set in such a way that students cannot change them).The text is already in the proper format which can be directly loaded into a Maple worksheet. They seethe formulation of the problem and at the same time variables are assigned proper values needed for furthercalculations. Students can solve their assignments in the computer laboratory with the help of an instructor

164

Page 3: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

or at home4. The seminar work is collected in the lab, where the student presents the calculations and theexaminer has a chance to ask questions to see whether the student really understands the subject. Besides,Maple allows to check particular outputs of the algorithm and other criteria needed to decide whether theimplemented method really solves the task. The course is supported by a textbook [3] (in Czech) which wasalso prepared with the help of Maple (examples, figures, etc.). The choice of topics covers approximation,numerical differentiation and integration, roots finding, and differential equations. We follow mainly theapproach of [5] with reference to [2, 6]. Emphasis is put on approximation. This topic is frequently usedby graduates and it allows a wide use of computer graphics in experiments. Maple allows to demonstratethe results quickly and thus obtain experience with numerous methods. The students see that even correctsolutions of a mathematical task may be of low practical value if the choice of methods was inappropriate.Sample worksheets for approximation and differential equations are shown in Appendix B.

It is no exaggeration to say that the students leave the course with practical skills at a much higher levelthan before the introduction of this type of course. The subject matter is thus much clearer and exercisesfrom older textbooks seem a distant memory.

Links to other activities

As a support, we established also a course of Computer Algebra Systems where we teach different CAS’s(Derive, Maple, Mathematica, Matlab) with emphasis on Maple. This course is intended for students whowant to learn more about software tools and apply them as regular instruments for their engineering work.It also offers them a comparison of different computer algebra systems and their facilities.

Some of our students use Maple extensively in their diploma and PhD theses as a tool for scientificcomputing. Besides, we supervised several semestral projects and one diploma thesis [7] dealing only withthe use of Maple as a computational environment.

In a separate lecture within the course of Computer Algebra Systems, we also summarize advantages anddrawbacks of the CAS’s used. A collection of benchmark problems [4] has been developed for this purposewith a help of [7, 8] and others.

Keywords: Numerical Analysis, Maple, classroom materials, student training.

Intended audience: Teachers of mathematics at undergraduate level, Maple users interested in numericalmethods.

4 In 1996 and several subsequent years, our activity was supported by a grant which, among others, allowed to pay amultilicence of Maple. It allows for installation of Maple on home computers of students participating in education or projectsrelated to Maple.

165

Page 4: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

References

[1] Corless, R.: AM372/272: Numerical Analysis for Engineers, AM361b Numerical Analysis for Scientists.Course curricula, 2008, http://www.apmaths.uwo.ca/ rcorless/BIO/dossier/node13.html

[2] Knuth, D. E.: Fundamental Algorithms. Vol. 1 of The Art of Computer Programming, Addison-Wesley,Reading, MA, 1968.

[3] Navara, M., Nemecek, A.: Numerical Analysis (in Czech). Czech Technical University, Prague, 2005.

[4] Navara, M., Nemecek, A.: Long-term experience with Maple: Advantages and challenges of Maple 10.Book of Proceedings, Maple Conference 2006, Wilfrid Laurier University, Maplesoft; Waterloo, Ontario,Canada, 2006, 353–354.

[5] Press, W. H., Flannery, B. P., Teukolsky, S. A., Vetterling, W. T.: Numerical Recipes (The Art ofScientific Computing). Cambridge University Press, Cambridge, 1986.

[6] Stoer, J., Bulirsch, R.: Introduction to Numerical Analysis. Springer Verlag, New York, 2000.

[7] Vrba, L.: Comparison of Computer Algebra Systems (in Czech). Diploma thesis, Czech Technical Uni-versity, Prague, 1999.

[8] Wester, M.: A Review of CAS Mathematical Capabilities. Preprint, University of New Mexico, Albu-querque, 1994.

166

Page 5: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

f := x, y( )�

1 + y2

x0 := 0

y0 := 0

xk := 1.5

Page 6: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

infolevelres := 16

k := 5

2.811692434

3.717804351

Page 7: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late

10.61331010

Page 8: Numerical Analysis with Maple - cvut.czmath.feld.cvut.cz/ftp/nemecek/texty/nemecek_MICA2008.pdfNumerical Analysis with computer support has been taught at our university since late