SlideShare a Scribd company logo
Numerical Methods ESUG, Gent 1999 Didier Besset Independent Consultant
Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
Dealing With Numerical Data Besides integers, Smalltalk supports two numerical types Fractions Floating point numbers
Using Fractions Results of products and sums are exact. Cannot be used with transcendental functions. Computation is slow. Computation may exceed computer’s memory. Convenient way to represent currency values when combined with rounding.
Using Floating Point Numbers Computation is fast. Results have limited precision  (usually 54 bits, ~16 decimal digits). Products preserve relative precision. Sums may keep only wrong digits.
Using Floating Point Numbers Sums may keep only wrong digits. Example: Evaluate 2.718 281 828 459 0 5  -   2.718 281 828 459 0 4   … =   9.76996261670138   x  10 -15   Should have been 10 -14  !
Using Floating Point Numbers Beware of meaningless precision! In 1424, Jamshid Masud al-Kashi published    = 3.141 592 653 589 793 25… … but noted that  the error in computing the perimeter of a circle with a radius 600’000 times that of earth would be less than the thickness of a horse’s hair .
Using Floating Point Numbers Donald E. Knuth : Floating point arithmetic is by nature inexact, and it is not difficult to misuse it so that the computed answers consist almost entirely of “noise”. One of the principal problems of numerical analysis is to determine how accurate the results of certain numerical methods will be.
Using Floating Point Numbers Never use equality between two floating point numbers. Use a special method to compare them.
Using Floating Point Numbers Proposed extensions to class Number relativelyEqualsTo: aNumber upTo: aSmallNumber | norm | norm := self abs max: aNumber abs. ^norm <= aSmallNumber or: [ (self - aNumber) abs < ( aSmallNumber * norm)]   equalsTo: aNumber ^self relativelyEqualsTo: aNumber upTo: DhbFloatingPointMachine  default  defaultNumericalPrecision  
Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
Iterative Processes Find a result using successive approximations Easy to implement as a  framework Wide field of application
Successive Approximations Begin Compute or choose initial object Compute next object Object sufficient? Yes End No
Iterative Processes NewtonZeroFinder TrapezeIntegrator SimpsonIntegrator RombergIntegrator EigenValues MaximumLikelihoodFit LeastSquareFit GeneticAlgorithm SimplexAlgorithm HillClimbing IterativeProcess FunctionalIterator ClusterAnalyzer InfiniteSeries ContinuedFraction
Implementation Begin iterations := 0 Yes Perform clean-up Compute next object iterations :=  iterations  + 1 No iterations < maximumIterations Compute or choose initial object End No Yes precision < desiredPrecision
Methods evaluate finalizeIteration hasConverged evaluateIteration initializeIteration Compute or choose initial object Yes No Compute next object iterations :=  iterations  + 1 Perform clean-up No Yes iterations := 0 iterations < maximumIterations Begin End precision < desiredPrecision
Simple example of use | iterativeProcess result | iterativeProcess :=  <a subclass of IterativeProcess>  new. result := iterativeProcess evaluate. iterativeProcess hasConverged ifFalse:[  <special case processing> ].
Advanced example of use | iterativeProcess result precision | iterativeProcess := < a subclass of DhbIterativeProcess > new. iterativeProcess desiredPrecision: 1.0e-6; maximumIterations: 25. result := iterativeProcess evaluate. iterativeProcess hasConverged ifTrue: [ Transcript nextPutAll: ‘Result obtained after ‘. iterativeProcess iteration printOn: Transcript. Transcript nextPutAll: ‘iterations. Attained precision is ‘. iterativeProcess precision printOn: Transcript. ] ifFalse:[ Transcript nextPutAll: ‘Process did not converge’]. Transcript cr.
Class Diagram IterativeProcess evaluate initializeIteration hasConverged evaluateIteration finalizeIteration precisionOf:relativeTo: desiredPrecision (g,s) maximumIterations (g,s) precision (g) iterations (g) result (g)
Computation of precision should be made relative to the result General method: Case of Numerical Result precisionOf: aNumber1 relativeTo: aNumber2 ^aNumber2 > DhbFloatingPointMachine default defaultNumericalPrecision ifTrue: [ aNumber1 / aNumber2] ifFalse:[ aNumber1] Result Absolute precision
Example of use | iterativeProcess result | iterativeProcess  := <a subclass of FunctionalIterator>  function: ( DhbPolynomial new: #(1 2 3). result := iterativeProcess evaluate. iterativeProcess hasConverged ifFalse:[  <special case processing> ].
Class Diagram initializeIteration computeInitialValues   relativePrecision setFunction: functionBlock (s) FunctionalIterator IterativeProcess value: AbstractFunction
Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
Newton’s Zero Finding It finds a value  x  such that  f(x)  = 0. More generally, it can be used to find a value  x  such that  f(x)  =  c .
Newton’s Zero Finding Use successive approximation formula x n+1  = x n  – f(x n )/f’(x n ) Must supply an initial value overload  computeInitialValues Should protect against  f’(x n )  = 0
Newton’s Zero Finding x 1 f(x) x 2 x 3 y = f(x 1 ) + f’(x 1 ) · (x- x 1 )
Example of use | zeroFinder result | zeroFinder:= DhbNewtonZeroFinder function: [ :x | x errorFunction - 0.9] derivative: [ :x | x normal]. zeroFinder initialValue: 1. result := zeroFinder evaluate. zeroFinder hasConverged ifFalse:[  <special case processing> ].
Class Diagram evaluateIteration computeInitialValues   (o) defaultDerivativeBlock   initialValue: setFunction: (o) NewtonZeroFinder IterativeProcess FunctionalIterator value: AbstractFunction derivativeBlock (s)
Newton’s Zero Finding x 1 Effect of a nearly 0 derivative during iterations x 2 x 3
Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
Eigenvalues & Eigenvectors Finds the solution to the problem M · v  =   · v where  M  is a square matrix  and  v  a non-zero vector.    is the  eigenvalue .  v  is the  eigenvector .
Eigenvalues & Eigenvectors Example of uses: Structural analysis (vibrations). Correlation analysis (statistical analysis and data mining).
Eigenvalues & Eigenvectors We use the Jacobi method applicable to symmetric matrices only. A 2 x 2 rotation matrix is applied on the matrix to annihilate the largest off-diagonal element. This process is repeated until all off-diagonal elements are negligible.
Eigenvalues & Eigenvectors When  M  is a symmetric matrix, there exist an orthogonal matrix  O  such that:   O T · M · O  is diagonal. The diagonal elements are the eigenvalues. The columns of the matrix  O  are the eigenvectors of the matrix  M .
Eigenvalues & Eigenvectors Let  i  and  j  be the indices of the largest off-diagonal element. The rotation matrix  R 1  is chosen such that ( R 1 T · M · R 1 ) ij   is 0. The matrix at the next step is:   M 2  =  R 1 T · M · R 1 .
Eigenvalues & Eigenvectors The process is repeated on the matrix  M 2 . One can prove that, at each step, one has:  max |( M n  ) ij  | <= max |( M n-1 ) ij  | for all  i  j . Thus, the algorithm must converge. The matrix  O  is then the product of all matrices  R n .
Eigenvalues & Eigenvectors The  precision  is the absolute value of the largest off-diagonal element. To finalize, eigenvalues are sorted in decreasing order of absolute values. There are two results from this algorithm: A vector containing the eigenvalues, The matrix  O  containing the corresponding eigenvectors.
Example of use | matrix jacobi eigenvalues transform | matrix := DhbMatrix rows: #( ( 3 -2 0) (-2 7 1) (0 1 5)). jacobi := DhbJacobiTransformation new: matrix. jacobi evaluate. iterativeProcess hasConverged ifTrue:[ eigenvalues := jacobi result.   transform := jacobi transform.   ] ifFalse:[  <special case processing> ].
Class Diagram evaluateIteration largestOffDiagonalIndices transformAt:and: finalizeIteration sortEigenValues exchangeAt: printOn: JacobiTransformation IterativeProcess lowerRows (i) transform (g)
Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
Cluster Analysis Is one of the techniques of  data mining. Allows to extract unsuspected similarity patterns from a large collection of objects. Used by marketing strategists (banks). Example: BT used cluster analysis to locate a long distance phone scam.
Cluster Analysis Each object is represented by a vector of numerical values. A metric is defined to compute a similarity factor using the vector representing the object.
Cluster Analysis At first the centers of each clusters are defined by picking random objects. Objects are clustered to the nearest center. A new center is computed for each cluster. Continue iteration until all objects remain in the cluster of the preceding iteration. Empty clusters are discarded.
Cluster Analysis The  similarity  metric is essential to the performance of cluster analysis. Depending on the problem, a different metric may be used. Thus, the metric is implemented with a  S TRATEGY  pattern.
Cluster Analysis The  precision  is the number of objects that changed clusters at each iteration. The result is a grouping of the initial objects, that is a set of clusters. Some clusters may be better than others.
Example of use | server finder | server := < a subclass of DhbAbstractClusterDataServer  > new. finder := DhbClusterFinder new: 15 server: server type: DhbEuclidianMetric. finder evaluate. finder tally
Class Diagram evaluateIteration accumulate: indexOfNearestCluster: initializeIteration finalizeIteration ClusterFinder IterativeProcess dataServer (i) clusters (i,g) accumulate: distance: isEmpty: reset Cluster openDataStream closeDataStream dimension seedClusterIn: accumulateDataIn: ClusterDataServer accumulator (i) metric (i) count (g)
Conclusion When used with care numerical data can be processed with Smalltalk. OO programming can take advantage of the mathematical structure. Programming numerical algorithms can take advantage of OO programming.
Questions ? To reach me:  [email_address]

More Related Content

PPTX
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
PDF
2. polynomial interpolation
PPTX
Application of interpolation and finite difference
PPT
numerical methods
PPTX
Signal Processing Homework Help
PDF
Numerical
PPT
Applications of numerical methods
PPTX
Statistics Assignment Help
NUMERICAL & STATISTICAL METHODS FOR COMPUTER ENGINEERING
2. polynomial interpolation
Application of interpolation and finite difference
numerical methods
Signal Processing Homework Help
Numerical
Applications of numerical methods
Statistics Assignment Help

What's hot (20)

PDF
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
PPTX
Signal Processing Assignment Help
PPTX
Presentation on application of numerical method in our life
DOC
algorithm Unit 4
PPTX
Diffusion Homework Help
PPTX
Statistical Physics Assignment Help
PPTX
Greedy Algorithms
PPTX
Interpolation and its applications
PPTX
Computer Science Assignment Help
PPTX
Data Analysis Homework Help
PPT
CS8451 - Design and Analysis of Algorithms
DOC
algorithm Unit 2
PPTX
PPTX
Mechanical Engineering Assignment Help
PDF
Intro. to computational Physics ch2.pdf
PPTX
Machnical Engineering Assignment Help
RTF
algorithm unit 1
PDF
design and analysis of algorithm
PPTX
Bisection method
PDF
Introduction to comp.physics ch 3.pdf
Numerical Method Analysis: Algebraic and Transcendental Equations (Non-Linear)
Signal Processing Assignment Help
Presentation on application of numerical method in our life
algorithm Unit 4
Diffusion Homework Help
Statistical Physics Assignment Help
Greedy Algorithms
Interpolation and its applications
Computer Science Assignment Help
Data Analysis Homework Help
CS8451 - Design and Analysis of Algorithms
algorithm Unit 2
Mechanical Engineering Assignment Help
Intro. to computational Physics ch2.pdf
Machnical Engineering Assignment Help
algorithm unit 1
design and analysis of algorithm
Bisection method
Introduction to comp.physics ch 3.pdf
Ad

Viewers also liked (20)

PDF
Introduction to Numerical Methods for Differential Equations
PDF
Numerical analysis using Scilab: Error analysis and propagation
PPTX
PDF
Hpcc euler
PDF
Day 4 examples
PPTX
Eulermethod3
PDF
Euler method notes sb
PDF
PDF
DLR_DG_AZIZ_2003
PDF
AP Calculus AB March 25, 2009
PDF
Class 16 floating and proportional control mode
PPTX
Perturbation methods last
PDF
Successive iteration method for reconstruction of missing data
KEY
Calculus II - 13
PPTX
Euler Method using MATLAB
PPTX
Power method
PPTX
Automobile 3rd sem aem ppt.2016
PPTX
Differential equations intro
PDF
metode euler
PPTX
Interactives Methods
 
Introduction to Numerical Methods for Differential Equations
Numerical analysis using Scilab: Error analysis and propagation
Hpcc euler
Day 4 examples
Eulermethod3
Euler method notes sb
DLR_DG_AZIZ_2003
AP Calculus AB March 25, 2009
Class 16 floating and proportional control mode
Perturbation methods last
Successive iteration method for reconstruction of missing data
Calculus II - 13
Euler Method using MATLAB
Power method
Automobile 3rd sem aem ppt.2016
Differential equations intro
metode euler
Interactives Methods
 
Ad

Similar to Numerical Methods (20)

PDF
PDF
Beginners Guide to Non-Negative Matrix Factorization
PDF
Sienna 13 limitations
PPTX
Nelder Mead Search Algorithm
PPTX
Analysis Framework, Asymptotic Notations
PDF
Analysis Framework for Analysis of Algorithms.pdf
PDF
Cs6402 design and analysis of algorithms may june 2016 answer key
PDF
Research Inventy : International Journal of Engineering and Science
PPT
PDF
Algorithm chapter 1
PPT
Perform brute force
 
PPT
Introducción al Análisis y diseño de algoritmos
PPTX
Data Structure Algorithm -Algorithm Complexity
PPT
PDF
Computational Intelligence Assisted Engineering Design Optimization (using MA...
PDF
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
PPT
algo_vc_lecture8.ppt
PPTX
Machine learning and linear regression programming
PPTX
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
PPTX
Lecture 7.pptx
Beginners Guide to Non-Negative Matrix Factorization
Sienna 13 limitations
Nelder Mead Search Algorithm
Analysis Framework, Asymptotic Notations
Analysis Framework for Analysis of Algorithms.pdf
Cs6402 design and analysis of algorithms may june 2016 answer key
Research Inventy : International Journal of Engineering and Science
Algorithm chapter 1
Perform brute force
 
Introducción al Análisis y diseño de algoritmos
Data Structure Algorithm -Algorithm Complexity
Computational Intelligence Assisted Engineering Design Optimization (using MA...
CS345-Algorithms-II-Lecture-1-CS345-2016.pdf
algo_vc_lecture8.ppt
Machine learning and linear regression programming
Undecidable Problems - COPING WITH THE LIMITATIONS OF ALGORITHM POWER
Lecture 7.pptx

More from ESUG (20)

PDF
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
PDF
Micromaid: A simple Mermaid-like chart generator for Pharo
PDF
Directing Generative AI for Pharo Documentation
PDF
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
PDF
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
PDF
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
PDF
Analysing Python Machine Learning Notebooks with Moose
PDF
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
PDF
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
PDF
Package-Aware Approach for Repository-Level Code Completion in Pharo
PDF
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
PDF
An Analysis of Inline Method Refactoring
PDF
Identification of unnecessary object allocations using static escape analysis
PDF
Control flow-sensitive optimizations In the Druid Meta-Compiler
PDF
Clean Blocks (IWST 2025, Gdansk, Poland)
PDF
Encoding for Objects Matters (IWST 2025)
PDF
Challenges of Transpiling Smalltalk to JavaScript
PDF
Immersive experiences: what Pharo users do!
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
PDF
Cavrois - an Organic Window Management (ESUG 2025)
ShowUs: Pharo Stream Deck (ESUG 2025, Gdansk)
Micromaid: A simple Mermaid-like chart generator for Pharo
Directing Generative AI for Pharo Documentation
Even Lighter Than Lightweiht: Augmenting Type Inference with Primitive Heuris...
Composing and Performing Electronic Music on-the-Fly with Pharo and Coypu
Gamifying Agent-Based Models in Cormas: Towards the Playable Architecture for...
Analysing Python Machine Learning Notebooks with Moose
FASTTypeScript metamodel generation using FAST traits and TreeSitter project
Migrating Katalon Studio Tests to Playwright with Model Driven Engineering
Package-Aware Approach for Repository-Level Code Completion in Pharo
Evaluating Benchmark Quality: a Mutation-Testing- Based Methodology
An Analysis of Inline Method Refactoring
Identification of unnecessary object allocations using static escape analysis
Control flow-sensitive optimizations In the Druid Meta-Compiler
Clean Blocks (IWST 2025, Gdansk, Poland)
Encoding for Objects Matters (IWST 2025)
Challenges of Transpiling Smalltalk to JavaScript
Immersive experiences: what Pharo users do!
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
Cavrois - an Organic Window Management (ESUG 2025)

Recently uploaded (20)

PPTX
Big Data Technologies - Introduction.pptx
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Cloud computing and distributed systems.
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Approach and Philosophy of On baking technology
PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Encapsulation_ Review paper, used for researhc scholars
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Understanding_Digital_Forensics_Presentation.pptx
Big Data Technologies - Introduction.pptx
MYSQL Presentation for SQL database connectivity
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Unlocking AI with Model Context Protocol (MCP)
Cloud computing and distributed systems.
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Approach and Philosophy of On baking technology
“AI and Expert System Decision Support & Business Intelligence Systems”
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Per capita expenditure prediction using model stacking based on satellite ima...
NewMind AI Monthly Chronicles - July 2025
Encapsulation_ Review paper, used for researhc scholars
Mobile App Security Testing_ A Comprehensive Guide.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Understanding_Digital_Forensics_Presentation.pptx

Numerical Methods

  • 1. Numerical Methods ESUG, Gent 1999 Didier Besset Independent Consultant
  • 2. Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
  • 3. Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
  • 4. Dealing With Numerical Data Besides integers, Smalltalk supports two numerical types Fractions Floating point numbers
  • 5. Using Fractions Results of products and sums are exact. Cannot be used with transcendental functions. Computation is slow. Computation may exceed computer’s memory. Convenient way to represent currency values when combined with rounding.
  • 6. Using Floating Point Numbers Computation is fast. Results have limited precision (usually 54 bits, ~16 decimal digits). Products preserve relative precision. Sums may keep only wrong digits.
  • 7. Using Floating Point Numbers Sums may keep only wrong digits. Example: Evaluate 2.718 281 828 459 0 5 - 2.718 281 828 459 0 4 … = 9.76996261670138 x 10 -15 Should have been 10 -14 !
  • 8. Using Floating Point Numbers Beware of meaningless precision! In 1424, Jamshid Masud al-Kashi published  = 3.141 592 653 589 793 25… … but noted that the error in computing the perimeter of a circle with a radius 600’000 times that of earth would be less than the thickness of a horse’s hair .
  • 9. Using Floating Point Numbers Donald E. Knuth : Floating point arithmetic is by nature inexact, and it is not difficult to misuse it so that the computed answers consist almost entirely of “noise”. One of the principal problems of numerical analysis is to determine how accurate the results of certain numerical methods will be.
  • 10. Using Floating Point Numbers Never use equality between two floating point numbers. Use a special method to compare them.
  • 11. Using Floating Point Numbers Proposed extensions to class Number relativelyEqualsTo: aNumber upTo: aSmallNumber | norm | norm := self abs max: aNumber abs. ^norm <= aSmallNumber or: [ (self - aNumber) abs < ( aSmallNumber * norm)]   equalsTo: aNumber ^self relativelyEqualsTo: aNumber upTo: DhbFloatingPointMachine default defaultNumericalPrecision  
  • 12. Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
  • 13. Iterative Processes Find a result using successive approximations Easy to implement as a framework Wide field of application
  • 14. Successive Approximations Begin Compute or choose initial object Compute next object Object sufficient? Yes End No
  • 15. Iterative Processes NewtonZeroFinder TrapezeIntegrator SimpsonIntegrator RombergIntegrator EigenValues MaximumLikelihoodFit LeastSquareFit GeneticAlgorithm SimplexAlgorithm HillClimbing IterativeProcess FunctionalIterator ClusterAnalyzer InfiniteSeries ContinuedFraction
  • 16. Implementation Begin iterations := 0 Yes Perform clean-up Compute next object iterations := iterations + 1 No iterations < maximumIterations Compute or choose initial object End No Yes precision < desiredPrecision
  • 17. Methods evaluate finalizeIteration hasConverged evaluateIteration initializeIteration Compute or choose initial object Yes No Compute next object iterations := iterations + 1 Perform clean-up No Yes iterations := 0 iterations < maximumIterations Begin End precision < desiredPrecision
  • 18. Simple example of use | iterativeProcess result | iterativeProcess := <a subclass of IterativeProcess> new. result := iterativeProcess evaluate. iterativeProcess hasConverged ifFalse:[ <special case processing> ].
  • 19. Advanced example of use | iterativeProcess result precision | iterativeProcess := < a subclass of DhbIterativeProcess > new. iterativeProcess desiredPrecision: 1.0e-6; maximumIterations: 25. result := iterativeProcess evaluate. iterativeProcess hasConverged ifTrue: [ Transcript nextPutAll: ‘Result obtained after ‘. iterativeProcess iteration printOn: Transcript. Transcript nextPutAll: ‘iterations. Attained precision is ‘. iterativeProcess precision printOn: Transcript. ] ifFalse:[ Transcript nextPutAll: ‘Process did not converge’]. Transcript cr.
  • 20. Class Diagram IterativeProcess evaluate initializeIteration hasConverged evaluateIteration finalizeIteration precisionOf:relativeTo: desiredPrecision (g,s) maximumIterations (g,s) precision (g) iterations (g) result (g)
  • 21. Computation of precision should be made relative to the result General method: Case of Numerical Result precisionOf: aNumber1 relativeTo: aNumber2 ^aNumber2 > DhbFloatingPointMachine default defaultNumericalPrecision ifTrue: [ aNumber1 / aNumber2] ifFalse:[ aNumber1] Result Absolute precision
  • 22. Example of use | iterativeProcess result | iterativeProcess := <a subclass of FunctionalIterator> function: ( DhbPolynomial new: #(1 2 3). result := iterativeProcess evaluate. iterativeProcess hasConverged ifFalse:[ <special case processing> ].
  • 23. Class Diagram initializeIteration computeInitialValues relativePrecision setFunction: functionBlock (s) FunctionalIterator IterativeProcess value: AbstractFunction
  • 24. Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
  • 25. Newton’s Zero Finding It finds a value x such that f(x) = 0. More generally, it can be used to find a value x such that f(x) = c .
  • 26. Newton’s Zero Finding Use successive approximation formula x n+1 = x n – f(x n )/f’(x n ) Must supply an initial value overload computeInitialValues Should protect against f’(x n ) = 0
  • 27. Newton’s Zero Finding x 1 f(x) x 2 x 3 y = f(x 1 ) + f’(x 1 ) · (x- x 1 )
  • 28. Example of use | zeroFinder result | zeroFinder:= DhbNewtonZeroFinder function: [ :x | x errorFunction - 0.9] derivative: [ :x | x normal]. zeroFinder initialValue: 1. result := zeroFinder evaluate. zeroFinder hasConverged ifFalse:[ <special case processing> ].
  • 29. Class Diagram evaluateIteration computeInitialValues (o) defaultDerivativeBlock initialValue: setFunction: (o) NewtonZeroFinder IterativeProcess FunctionalIterator value: AbstractFunction derivativeBlock (s)
  • 30. Newton’s Zero Finding x 1 Effect of a nearly 0 derivative during iterations x 2 x 3
  • 31. Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
  • 32. Eigenvalues & Eigenvectors Finds the solution to the problem M · v =  · v where M is a square matrix and v a non-zero vector.  is the eigenvalue . v is the eigenvector .
  • 33. Eigenvalues & Eigenvectors Example of uses: Structural analysis (vibrations). Correlation analysis (statistical analysis and data mining).
  • 34. Eigenvalues & Eigenvectors We use the Jacobi method applicable to symmetric matrices only. A 2 x 2 rotation matrix is applied on the matrix to annihilate the largest off-diagonal element. This process is repeated until all off-diagonal elements are negligible.
  • 35. Eigenvalues & Eigenvectors When M is a symmetric matrix, there exist an orthogonal matrix O such that: O T · M · O is diagonal. The diagonal elements are the eigenvalues. The columns of the matrix O are the eigenvectors of the matrix M .
  • 36. Eigenvalues & Eigenvectors Let i and j be the indices of the largest off-diagonal element. The rotation matrix R 1 is chosen such that ( R 1 T · M · R 1 ) ij is 0. The matrix at the next step is: M 2 = R 1 T · M · R 1 .
  • 37. Eigenvalues & Eigenvectors The process is repeated on the matrix M 2 . One can prove that, at each step, one has: max |( M n ) ij | <= max |( M n-1 ) ij | for all i  j . Thus, the algorithm must converge. The matrix O is then the product of all matrices R n .
  • 38. Eigenvalues & Eigenvectors The precision is the absolute value of the largest off-diagonal element. To finalize, eigenvalues are sorted in decreasing order of absolute values. There are two results from this algorithm: A vector containing the eigenvalues, The matrix O containing the corresponding eigenvectors.
  • 39. Example of use | matrix jacobi eigenvalues transform | matrix := DhbMatrix rows: #( ( 3 -2 0) (-2 7 1) (0 1 5)). jacobi := DhbJacobiTransformation new: matrix. jacobi evaluate. iterativeProcess hasConverged ifTrue:[ eigenvalues := jacobi result. transform := jacobi transform. ] ifFalse:[ <special case processing> ].
  • 40. Class Diagram evaluateIteration largestOffDiagonalIndices transformAt:and: finalizeIteration sortEigenValues exchangeAt: printOn: JacobiTransformation IterativeProcess lowerRows (i) transform (g)
  • 41. Road Map Dealing with numerical data Framework for iterative processes Newton’s zero finding Eigenvalues and eigenvectors Cluster analysis Conclusion
  • 42. Cluster Analysis Is one of the techniques of data mining. Allows to extract unsuspected similarity patterns from a large collection of objects. Used by marketing strategists (banks). Example: BT used cluster analysis to locate a long distance phone scam.
  • 43. Cluster Analysis Each object is represented by a vector of numerical values. A metric is defined to compute a similarity factor using the vector representing the object.
  • 44. Cluster Analysis At first the centers of each clusters are defined by picking random objects. Objects are clustered to the nearest center. A new center is computed for each cluster. Continue iteration until all objects remain in the cluster of the preceding iteration. Empty clusters are discarded.
  • 45. Cluster Analysis The similarity metric is essential to the performance of cluster analysis. Depending on the problem, a different metric may be used. Thus, the metric is implemented with a S TRATEGY pattern.
  • 46. Cluster Analysis The precision is the number of objects that changed clusters at each iteration. The result is a grouping of the initial objects, that is a set of clusters. Some clusters may be better than others.
  • 47. Example of use | server finder | server := < a subclass of DhbAbstractClusterDataServer > new. finder := DhbClusterFinder new: 15 server: server type: DhbEuclidianMetric. finder evaluate. finder tally
  • 48. Class Diagram evaluateIteration accumulate: indexOfNearestCluster: initializeIteration finalizeIteration ClusterFinder IterativeProcess dataServer (i) clusters (i,g) accumulate: distance: isEmpty: reset Cluster openDataStream closeDataStream dimension seedClusterIn: accumulateDataIn: ClusterDataServer accumulator (i) metric (i) count (g)
  • 49. Conclusion When used with care numerical data can be processed with Smalltalk. OO programming can take advantage of the mathematical structure. Programming numerical algorithms can take advantage of OO programming.
  • 50. Questions ? To reach me: [email_address]

Editor's Notes

  • #9: At that time, the radius of the earth was not known exactly. The radius of the circle corresponding to the error quoted by Jamshid Masud (0.7mm) is 20 times larger than the half axis of the orbit of Pluto.
  • #12: DhbFloatingPointMachine is a class which determines automatically the parameters of the floating point representation on the current machine.
  • #16: In this talk, only the classes in “pink” boxes will be discussed.
  • #17: Tasks in green boxes are the responsibility of the subclasses.
  • #18: Methods “evaluate” and “hasConverged” are methods of the super class. Methods “initializeIterations”, “evaluateIterations” and “finalizeIterations” are the responsibility of the subclasses.
  • #21: This is the abstract class at the top of the hierarchy of any iterative process. The class diagram shows the class name at top (without prefix), the methods (other than “get” and “set” of instance variables) in the middle and the instance variables at bottom. Instance variables have a corresponding “get” methods when tagged with a “g” and a corresponding “set” method when tagged with a “s”. The code is available in Listing 1.
  • #24:   The code is available in Listing 2.
  • #30:   The code is available in Listing 3.
  • #41:     The code is available in Listing 4.
  • #49:    The code is available in Listing 5.