Skip to main content

Object-Oriented Implementation of Numerical Methods

An Introduction with Java & Smalltalk

  • 1st Edition - October 25, 2000
  • Latest edition
  • Author: Didier H. Besset
  • Language: English

Numerical methods naturally lend themselves to an object-oriented approach. Mathematics builds high- level ideas on top of previously described, simpler ones. Once a property is… Read more

Purchase options

Sorry, this title is not available for purchase in your country/region.

World Book Day celebration

Where learning shapes lives

Up to 25% off trusted resources that support research, study, and discovery.

Description

Numerical methods naturally lend themselves to an object-oriented approach. Mathematics builds high- level ideas on top of previously described, simpler ones. Once a property is demonstrated for a given concept, it can be applied to any new concept sharing the same premise as the original one, similar to the ideas of reuse and inheritance in object-oriented (OO) methodology.

Few books on numerical methods teach developers much about designing and building good code. Good computing routines are problem-specific. Insight and understanding are what is needed, rather than just recipes and black box routines. Developers need the ability to construct new programs for different applications.Object-Oriented Implementation of Numerical Methods reveals a complete OO design methodology in a clear and systematic way. Each method is presented in a consistent format, beginning with a short explanation and following with a description of the general OO architecture for the algorithm. Next, the code implementations are discussed and presented along with real-world examples that the author, an experienced software engineer, has used in a variety of commercial applications.

Key features

* Reveals the design methodology behind the code, including design patterns where appropriate, rather than just presenting canned solutions.
* Implements all methods side by side in both Java and Smalltalk. This contrast can significantly enhance your understanding of the nature of OO programming languages.
* Provides a step-by-step pathway to new object-oriented techniques for programmers familiar with using procedural languages such as C or Fortran for numerical methods.
* Includes a chapter on data mining, a key application of numerical methods.

Readership

Programmers, developers, engineers, scientists and computer scientists who create or maintain industrial or scientific software applications.

Table of contents

Code Listings



Preface




1 Introduction



1.1 Object-Oriented Paradigm and Mathematical Objects


1.2 Object-Oriented Concepts in a Nutshell


1.3 Dealing with Numerical Data


1.3.1 Floating Point Representation


1.3.2 Rounding Errors


1.3.3 Real Example of Rounding Error


1.3.4 Outsmarting Rounding Errors


1.3.5 Wisdom from the Past



1.4 Finding the Numerical Precision of a Computer


1.4.1 Computer Numerical Precision—General Implementation


1.4.2 Computer Numerical Precision—Smalltalk Implementation


1.4.3 Computer Numerical Precision—Java Implementation



1.5 Comparing Floating-Point Numbers


1.5.1 Comparing Floating-Point Numbers—Smalltalk Code



1.6 Speed Consideration


1.6.1 Smalltalk Particular



1.7 Conventions


1.7.1 Class Diagrams


1.7.2 Smalltalk Code


1.7.3 Java Code



1.8 Road Map




2 Function Evaluation



2.1 Function Concept


2.1.1 Function—Smalltalk Implementation


2.1.2 Function—Java Implementation



2.2 Polynomials


2.2.1 Mathematical Definitions


2.2.2 Polynomials—General Implementation


2.2.3 Polynomials—Smalltalk Implementation


2.2.4 Polynomials—Java implementation



2.3 Error Function


2.3.1 Mathematical Definitions


2.3.2 Error Function—Smalltalk Implementation


2.3.3 Error Function—Java Implementation



2.4 Gamma Function


2.4.1 Mathematical Definitions


2.4.2 Gamma Function—Smalltalk Implementation


2.4.3 Gamma Function—Java Implementation



2.5 Beta Function


2.5.1 Mathematical Definitions


2.5.2 Beta Function—Smalltalk Implementation


2.5.3 Beta Function—Java Implementation




3 Interpolation



3.1 General Remarks


3.1.1 Interpolation Concepts and Examples



3.2 Lagrange Interpolation


3.2.1 Lagrange Interpolation—Smalltalk Implementation


3.2.2 Lagrange Interpolation—Java Implementation



3.3 Newton Interpolation


3.3.1 Newton Interpolation—General Implementation


3.3.2 Newton Interpolation—Smalltalk Implementation


3.3.3 Newton Interpolation—Java Implementation



3.4 Neville Interpolation


3.4.1 Neville Interpolation—General Implementation


3.4.2 Neville Interpolation—Smalltalk Implementation


3.4.3 Neville Interpolation—Java Implementation



3.5 Bulirsch-Stoer Interpolation


3.5.1 Bulirsch-Stoer Interpolation—General Implementation


3.5.2 Bulirsch-Stoer Interpolation—Smalltalk Implementation


3.5.3 Bulirsch-Stoer Interpolation—Java Implementation



3.6 Cubic Spline Interpolation


3.6.1 Cubic Spline Interpolation—General Implementation


3.6.2 Cubic Spline Interpolation—Smalltalk Implementation


3.6.3 Cubic Spline Interpolation—Java Implementation



3.7 Which Method to Choose?




4 Iterative Algorithms



4.1 Successive Approximations


4.1.1 Iterative Process—Smalltalk Implementation


4.1.2 Iterative Process—JAVA Implementation



4.2 Evaluation with Relative Precision


4.2.1 Relative Precision—Smalltalk Implementation


4.2.2 Relative Precision—Java Implementation



4.3 Examples




5 Finding the Zero of a Function



5.1 Introduction


5.2 Finding the Zeroes of a Function—Bisection Method


5.2.1 Bisection Algorithm—General Implementation


5.2.2 Bisection Algorithm—Smalltalk Implementation


5.2.3 Bisection Algorithm—Java Implementation



5.3 Finding the Zero of a Function—Newton's Method


5.3.1 Newton's Method—Smalltalk Implementation


5.3.2 Newton's Method—Java Implementation



5.4 Example of Zero Finding—Roots of Polynomials


5.4.1 Roots of Polynomials—Smalltalk Implementation


5.4.2 Roots of Polynomials—Java Implementation



5.5 Which Method to Choose?




6 Integration of Functions



6.1 Introduction


6.2 General Framework—Trapeze Integration Method


6.2.1 End Game Strategy


6.2.2 Trapeze Integration—General Implementation


6.2.3 Trapeze Integration—Smalltalk Implementation


6.2.4 Trapeze Integration—Java Implementation



6.3 Simpson Integration Algorithm


6.3.1 Simpson Integration—General Implementation


6.3.2 Simpson Integration—Smalltalk Implementation


6.3.3 Simpson Integration—Java Implementation



6.4 Romberg Integration Algorithm


6.4.1 Romberg Integration—General Implementation


6.4.2 Romberg Integration—Smalltalk Implementation


6.4.3 Romberg Integration—Java Implementation



6.5 Evaluation of Open Integrals


6.5.1 Bag of Tricks



6.6 Which Method to Choose?


6.6.1 Smalltalk Comparison


6.6.2 Java Comparison




7 Series



7.1 Introduction


7.2 Infinite Series


7.2.1 Infinite Series—Smalltalk Implementation


7.2.2 Infinite Series—Java Implementation



7.3 Continued Fractions


7.3.1 Continued Fractions—Smalltalk Implementation


7.3.2 Continued Fractions—Java Implementation



7.4 Incomplete Gamma Function


7.4.1 Mathematical Definitions


7.4.2 Incomplete Gamma Function—Smalltalk Implementation


7.4.3 Incomplete Gamma Function—Java Implementation



7.5 Incomplete Beta Function


7.5.1 Mathematical Definitions


7.5.2 Incomplete Beta Function—Smalltalk Implementation


7.5.3 Incomplete Beta Function—Java Implementation




8 Linear Algebra



8.1 Vectors and Matrices


8.1.1 Vector and Matrix—Smalltalk Implementation


8.1.2 Vector and Matrix—Java Implementation



8.2 Linear Equations


8.2.1 Backward Substitution


8.2.2 Gaussian Elimination


8.2.3 Fine Points


8.2.4 Linear Equations—General Implementation


8.2.5 Linear Equations—Smalltalk Implementation


8.2.6 Linear Equations—Java Implementation



8.3 LUP Decomposition


8.3.1 LUP Decomposition—General Implementation


8.3.2 LUP Decomposition—Smalltalk Implementation


8.3.3 LUP Decomposition—Java Implementation



8.4 Computing the Determinant of a Matrix


8.4.1 Computing the Determinant of Matrix—General Implementation


8.4.2 Computing the Determinant of Matrix—Smalltalk Implementation


8.4.3 Computing the Determinant of Matrix—Java Implementation



8.5 Matrix Inversion


8.5.1 Implementation Strategy


8.5.2 Matrix Inversion—Smalltalk Implementation


8.5.3 Matrix Inversion—Java Implementation


8.5.4 Matrix Inversion—Rounding Problems



8.6 Matrix Eigenvalues and Eigenvectors of a Nonsymmetrical Matrix


8.6.1 Finding the Largest Eigenvalue—General Implementation


8.6.2 Finding the Largest Eigenvalue—Smalltalk Implementation


8.6.3 Finding the Largest Eigenvalue—Java Implementation



8.7 Matrix Eigenvalues and Eigenvectors of a Symmetrical Matrix


8.7.1 Jacobi's Algorithm


8.7.2 Jacobi's Algorithm—General Implementation


8.7.3 Jacobi's Algorithm—Smalltalk Implementation


8.7.4 Jacobi's Algorithm—Java Implementation




9 Elements of Statistics



9.1 Statistical Moments


9.1.1 Statistical Moments—General Implementation


9.1.2 Statistical Moments—Smalltalk Implementation


9.1.3 Statistical Moments—Java Implementation



9.2 Robust Implementation of Statistical Moments


9.2.1 Robust Central Moments—General Implementation


9.2.2 Robust Central Moments—Smalltalk Implementation


9.2.3 Robust Central Moments—Java Implementation



9.3 Histograms


9.3.1 Histograms—General Implementation


9.3.2 Histograms—Smalltalk Implementation


9.3.3 Histograms—Java Implementation



9.4 Random Number Generator


9.4.1 Linear Congruential Random Generators


9.4.2 Additive Sequence Generators


9.4.3 Bit-Pattern Generators


9.4.4 Random Number Generator—Smalltalk Implementation


9.4.5 Random Number Generator—Java Implementation



9.5 Probability Distributions


9.5.1 Probability Distributions—General Implementation


9.5.2 Probability Distributions—Smalltalk Implementation


9.5.3 Probability Distributions—Java Implementation



9.6 Normal Distribution


9.6.1 Normal Distribution—Smalltalk Implementation


9.6.2 Normal Distribution—Java Implementation



9.7 Gamma Distribution


9.7.1 Gamma Distribution—Smalltalk Implementation


9.7.2 Gamma Distribution—Java Implementation



9.8 Experimental Distribution


9.8.1 Experimental Distribution—General Implementation


9.8.2 Experimental Distribution—Smalltalk Implementation


9.8.3 Experimental Distribution—Java Implementation




10 Statistical Analysis



10.1 F-Test and the Fisher-Snedecor Distribution


10.1.1 Fisher-Snedecor Distribution—Smalltalk Implementation


10.1.2 Fisher-Snedecor Distribution—Java Implementation



10.2 t-Test and the Student Distribution


10.2.1 Student Distribution—Smalltalk Implementation


10.2.2 Student Distribution—Java Implementation



10.3 . 2 -Test and . 2 Distribution


10.3.1 . 2 Distribution—Smalltalk Implementation


10.3.2 . 2 Distribution—Java Implementation


10.3.3 Weighted-Point Implementation



10.4 . 2 -Test on Histograms


10.4.1 . 2 -Test on Histograms—Smalltalk Implementation


10.4.2 . 2 -Test on Histograms—Java Implementation



10.5 Definition of Estimation


10.5.1 Maximum-Likelihood Estimation


10.5.2 Least-Square Estimation



10.6 Least-Square Fit with Linear Dependence


10.7 Linear Regression


10.7.1 Linear Regression—General Implementation


10.7.2 Linear Regression—Smalltalk Implementation


10.7.3 Linear Regression—Java Implementation



10.8 Least-Square Fit with Polynomials


10.8.1 Polynomial Least-Square Fits—Smalltalk Implementation


10.8.2 Polynomial Least-Square Fits—Java Implementation



10.9 Least-Square Fit with Nonlinear Dependence


10.9.1 Nonlinear Fit—General Implementation


10.9.2 Nonlinear Fit—Smalltalk Implementation


10.9.3 Nonlinear Fit—Java Implementation



10.10 Maximum-Likelihood Fit of a Probability Density Function


10.10.1 Maximum-Likelihood Fit—General Implementation


10.10.2 Maximum-Likelihood Fit—Smalltalk Implementation


10.10.3 Maximum-Likelihood Fit—Java Implementation




11 Optimization



11.1 Introduction


11.2 Extended Newton Algorithms


11.3 Hill-Climbing Algorithms


11.3.1 Optimizing—General Implementation


11.3.2 Common Optimizing Classes—Smalltalk Implementation


11.3.3 Common Optimizing Classes—Java Implementation



11.4 Optimizing in One Dimension


11.4.1 Optimizing in One Dimension—Smalltalk Implementation


11.4.2 Optimizing in One Dimension—Java Implementation



11.5 Bracketing the Optimum in One Dimension


11.5.1 Bracketing the Optimum—Smalltalk Implementation


11.5.2 Bracketing the Optimum—Java Implementation



11.6 Powell's Algorithm


11.6.1 Powell's Algorithm—General Implementation


11.6.2 Powell's Algorithm—Smalltalk Implementation


11.6.3 Powell's Algorithm—Java Implementation



11.7 Simplex Algorithm


11.7.1 Simplex Algorithm—General Implementation


11.7.2 Simplex Algorithm—Smalltalk Implementation


11.7.3 Simplex Algorithm—Java Implementation



11.8 Genetic Algorithm


11.8.1 Mapping the Search Space on Chromosomes


11.8.2 Genetic Algorithm—General Implementation


11.8.3 Genetic Algorithm—Smalltalk Implementation


11.8.4 Genetic Algorithm—Java Abstract Implementation


11.8.5 Genetic Algorithm—Java Implementation with Vectors



11.9 Multiple Strategy Approach


11.9.1 Multiple Strategy Approach—General Implementation




12 Data Mining



12.1 Data Server


12.1.1 Data Server—Smalltalk Implementation


12.1.2 Data Server—Java Implementation



12.2 Covariance and Covariance Matrix


12.2.1 Using Covariance Information


12.2.2 Covariance Matrix—General Implementation


12.2.3 Covariance Matrix—Smalltalk Implementation


12.2.4 Covariance Matrix—Java Implementation



12.3 Multidimensional Probability Distribution


12.4 Covariance Data Reduction


12.5 Mahalanobis Distance


12.5.1 Examples of Use


12.5.2 Mahalanobis Distance—General Implementation


12.5.3 Mahalanobis Distance—Smalltalk Implementation


12.5.4 Mahalanobis Distance—Java Implementation



12.6 Cluster Analysis


12.6.1 Algorithm Details


12.6.2 Cluster Analysis—General Implementation


12.6.3 Cluster Analysis—Smalltalk Implementation


12.6.4 Cluster Analysis—Java Implementation



12.7 Covariance Clusters


12.7.1 Covariance Clusters—General Implementation



App. A Decimal Floating-Point Simulation



App. B Smalltalk Primer for Java Programmers


B.1 Syntax in a Nutshell

B.1.1 Smalltalk Expressions

B.1.2 Precedence

B.1.3 Assignment, Equality, and Identity


B.2 Class and Methods

B.2.1 Instance Methods

B.2.2 Class Methods

B.2.3 Block Context


B.3 Iterator Methods

B.3.1 do:

B.3.2 collect:

B.3.3 inject:into:


B.4 Double Dispatching

B.5 Multiple Dispatching



App. C Java Primer for Smalltalk Programmers


C.1 Remarks on the Syntax

C.1.1 Classes

C.1.2 Instance Variables

C.1.3 Method Declaration and Method Calling

C.1.4 Objects and Nonobjects

C.1.5 Packages

C.1.6 Scope qualifiers

C.1.7 Static Qualifier


C.2 Abstract Class and Interface

C.3 Exception Handling

C.4 Collections and Related Topics



App. D Additional Probability Distributions


D.1 Beta Distribution

D.1.1 Beta Distribution—Smalltalk Implementation

D.1.2 Beta Distribution—Java Implementation


D.2 Cauchy Distribution

D.2.1 Cauchy Distribution—Smalltalk Implementation

D.2.2 Cauchy Distribution—Java Implementation


D.3 Exponential Distribution

D.3.1 Exponential Distribution—Smalltalk Implementation

D.3.2 Exponential Distribution—Java Implementation


D.4 Fisher-Tippett Distribution

D.4.1 Fisher-Tippett Distribution—Smalltalk Implementation

D.4.2 Fisher-Tippett Distribution—Java Implementation


D.5 Laplace Distribution

D.5.1 Laplace Distribution—Smalltalk Implementation

D.5.2 Laplace Distribution—Java Implementation


D.6 Log Normal Distribution

D.6.1 Log Normal Distribution—Smalltalk Implementation

D.6.2 Log Normal Distribution—Java Implementation


D.7 Triangular Distribution

D.7.1 Triangular Distribution—Smalltalk Implementation

D.7.2 Triangular Distribution—Java Implementation


D.8 Uniform Distribution

D.8.1 Uniform Distribution—Smalltalk Implementation

D.8.2 Uniform Distribution—Java Implementation


D.9 Weibull Distribution

D.9.1 Weibull Distribution—Smalltalk Implementation

D.9.2 Weibull Distribution—Java Implementation



App. E Accurate Accumulation of Expectation Values


E.1 Accurate Accumulation of Central Moments

E.2 Accurate Accumulation of the Covariance



App. F Accompanying CD-ROM


F.1 Smalltalk code

F.1.1 non-ENVY users

F.1.2 ENVY users


F.2 Java code

F.2.1 Visual Age for Java

F.2.2 Other Java systems


F.3 Utilities

F.3.1 Distribution demo

F.3.2 File reader


References



Index

Review quotes

"There are few books that show how to build programs of any kind. One common theme is compiler building, and there are shelves full of them. There are few others. It's an area, or a void, that needs filling. this book does a great job of showing how to build numerical analysis programs."—David N. Smith, IBM T J Watson Research Center

Product details

  • Edition: 1
  • Latest edition
  • Published: November 6, 2000
  • Language: English

About the author

DB

Didier H. Besset

Didier Besset obtained a degree in physics at the Swiss Federal Institute of Technology Zurich (ETH Zurich) and a Ph.D. in high-energy physics at the University of Geneva. He did postgraduate research at the Stanford Linear Accelerator Center and was Adjunct Professor at Princeton University where he taught physics. Since 1990 he has worked as an independent consultant on decision-support systems based on medical or technical data, all written using object-oriented technology. He has been programming in Smalltalk since 1987 and in Java since 1997.
Affiliations and expertise
Consultant, Geneva, Switzerland.