Intro into real world numerical libraries/packages.

Slides:



Advertisements
Similar presentations
Numerical Computation Lecture 4: Root Finding Methods - II United International College.
Advertisements

Lecture 5 Newton-Raphson Method
Introduction to Programming in C++ John Galletly.
Polynomial Approximation PSCI 702 October 05, 2005.
Optimization.
Modeling Basics: 4. Numerical ODE Solving In Excel 5. Solving ODEs in Mathematica By Peter Woolf University of Michigan Michigan Chemical Process Dynamics.
CSE 330: Numerical Methods
Teaching Courses in Scientific Computing 30 September 2010 Roger Bielefeld Director, Advanced Research Computing.
Introduction to Function Minimization. Motivation example Data on height of a group of people, men and women Data on gender not recorded, not known.
CSCE Review—Fortran. CSCE Review—I/O Patterns: Read until a sentinel value is found Read n, then read n things Read until EOF encountered.
MA5233: Computational Mathematics
Chapter 1 Introduction The solutions of engineering problems can be obtained using analytical methods or numerical methods. Analytical differentiation.
ECIV 301 Programming & Graphics Numerical Methods for Engineers Lecture 3 Programming and Software.
Programming Logic and Design, Introductory, Fourth Edition1 Understanding Computer Components and Operations (continued) A program must be free of syntax.
Chapter 3 Root Finding.
Principles of the Global Positioning System Lecture 10 Prof. Thomas Herring Room A;
MathMore Lorenzo Moneta, Andràs Zsenei ROOT Workshop 30/9/2005.
Python quick start guide
MATH 685/ CSI 700/ OR 682 Lecture Notes Lecture 8. Nonlinear equations.
First, some left-overs… Lazy languages Nesting 1.
CS (CCN 27241) Software Engineering for Scientific Computing Lecture 5: C++ Key Concepts.
Joshua Alexander University of Oklahoma – IT/OSCER ACI-REF Virtual Residency Workshop Monday June 1, 2015 Deploying Community Codes.
Introduction to MATLAB adapted from Dr. Rolf Lakaemper.
CIS Computer Programming Logic
Wavelet Transforms CENG 5931 GNU RADIO INSTRUCTOR: Dr GEORGE COLLINS.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Chapter 17 Boundary Value Problems. Standard Form of Two-Point Boundary Value Problem In total, there are n 1 +n 2 =N boundary conditions.
Chapter 1 Introduction Dr. Frank Lee. 1.1 Why Study Compiler? To write more efficient code in a high-level language To provide solid foundation in parsing.
CISE301_Topic11 CISE-301: Numerical Methods Topic 1: Introduction to Numerical Methods and Taylor Series Lectures 1-4:
Numerical Methods Applications of Loops: The power of MATLAB Mathematics + Coding 1.
CSE 541 Rick Parent ELEMENTARY NUMERICAL METHODS Winter 2012.
Introduction to GSL CS 3414 From GNU Scientific Library Reference Manual at
Review Taylor Series and Error Analysis Roots of Equations
Eng Ship Structures 1 Introduction to Matlab.
1 Computer Programming (ECGD2102 ) Using MATLAB Instructor: Eng. Eman Al.Swaity Lecture (1): Introduction.
1 Lesson 8: Basic Monte Carlo integration We begin the 2 nd phase of our course: Study of general mathematics of MC We begin the 2 nd phase of our course:
Question of the Day  On a game show you’re given the choice of three doors: Behind one door is a car; behind the others, goats. After you pick a door,
MA/CS 375 Fall MA/CS 375 Fall 2002 Lecture 31.
Lecture 6 Numerical Analysis. Solution of Non-Linear Equations Chapter 2.
1 EPSII 59:006 Spring Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive.
© 2011 Autodesk Freely licensed for use by educational institutions. Reuse and changes require a note indicating that content has been modified from the.
Numerical Methods for Engineering MECN 3500
Numerical Methods.
Introduction to GAMS, Netlib, Numerical Recipes CS 3414.
BOĞAZİÇİ UNIVERSITY DEPARTMENT OF MANAGEMENT INFORMATION SYSTEMS MATLAB AS A DATA MINING ENVIRONMENT.
Numerical Analysis - Advanced Topics in Root Finding - Hanyang University Jong-Il Park.
Lecture 5 - Single Variable Problems CVEN 302 June 12, 2002.
Linear Algebra Libraries: BLAS, LAPACK, ScaLAPACK, PLASMA, MAGMA
CIS 601 Fall 2003 Introduction to MATLAB Longin Jan Latecki Based on the lectures of Rolf Lakaemper and David Young.
Chapter 2-OPTIMIZATION G.Anuradha. Contents Derivative-based Optimization –Descent Methods –The Method of Steepest Descent –Classical Newton’s Method.
SOLVING NONLINEAR EQUATIONS. SECANT METHOD MATH-415 Numerical Analysis 1.
INTRO TO OPTIMIZATION MATH-415 Numerical Analysis 1.
Lecture 4 – Function (Part 1) FTMK, UTeM – Sem /2014.
MathMore Lorenzo Moneta, Andràs Zsenei ROOT Meeting 19/8/2005.
Anders Nielsen Technical University of Denmark, DTU-Aqua Mark Maunder Inter-American Tropical Tuna Commission An Introduction.
CIS 595 MATLAB First Impressions. MATLAB This introduction will give Some basic ideas Main advantages and drawbacks compared to other languages.
CSE 330: Numerical Methods. What is true error? True error is the difference between the true value (also called the exact value) and the approximate.
An Introduction to AD Model Builder PFRP
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 2 / Chapter 5.
S5.40. Module Structure 30% practical tests / 70% written exam 3h lectures / week (except reading week) 3 x 2h of computer labs (solving problems practicing.
Certification of Reusable Software Artifacts
Quiz 2.
Matlab.
APPENDIX a WRITING SUBROUTINES IN C
C Basics.
Introduction to GSL CS 3414 From GNU Scientific Library Reference Manual at
Introduction to MATLAB
SOLUTION OF NONLINEAR EQUATIONS
Simulation And Modeling
Presentation transcript:

Intro into real world numerical libraries/packages

A realistic scenario: You are solving Using an iterative method (e.g. SOR). Leads to matrix equations A n x = b n. Iterate. Need to solve lots of them. No need to write all of the code. Use well- developed code for the A n x = b n part. Use your own for the rest.

Introduction to Numerical Recipes, GSL, GAMS, Netlib

The starting point:

Numerical Recipes Numerical Recipes: The Art of Scientific Computing" is the title of a series of books "Numerical Recipes" also refers to the copyrighted computer software that is in those books. There are approximately 200 routines, which cover a large range of subjects. The source code for the routines are available, and the book documents and explains the mathematics behind the routines.

Why is it good? Intuitive, yet fairly rigorous description of key algorithms and ideas And the code, all in one place Good rules of thumb, examples. Code from the classic book is available, free (or almost free). Ansi C – guaranteed to compile anywhere.

Numerical recipes. Example text

Numerical recipes

Compile and Link for C Three header files – complex.h – nr.h – nrutil.h One library – librecipes_c gcc example.o –lm –lrecipes_c

Introduction to GSL

What is GSL? The GNU Scientific Library GSL is a numerical library for C and C++ programmers. GSL is free software distributed under the terms of the GNU General Public License.GNU General Public License

Functionality GSL provides a well-defined C language Applications Programming Interface (API) for common numerical functions, such as: – Random Numbers – Least-Squares Fitting – Fast Fourier Transforms – Root-Finding – Minimization GSL is thread-safe.

Compiling and Linking The library header files are installed in their own `gsl' directory. You should write include statements with a `gsl/' directory prefix like: #include Compile: gcc -c example.c Link: gcc example.o -lgsl -lgslcblas -lm

One dimensional Root-Finding The header file `gsl_roots.h' contains prototypes for the root finding functions and related declarations. The library provides low level components for a variety of iterative solvers and convergence tests. These can be combined by the user to achieve the desired solution, with full access to the intermediate steps of the iteration.

Root Finding Algorithms Two classes – root bracketing begin with a bounded region known to contain a root uses only function evaluations (not derivatives). – root polishing improve an initial guess to the root require both the function and its derivative to be supplied by the user

Framework The user provides a high-level driver for the algorithms. The library provides the individual functions necessary for each of the steps. There are three main phases of the iteration. The steps are, – initialize solver state, s, for algorithm T – update s using the iteration T – test s for convergence, and repeat iteration if necessary The state for solver is held in a gsl_root_fsolver /gsl_root_fdfsolver struct.

Initializing the Solver gsl_root_fsolver * gsl_root_fsolver_alloc (const gsl_root_fsolver_type * T) int gsl_root_fsolver_set (gsl_root_fsolver * s, gsl_function * f, double x_lower, double x_upper) void gsl_root_fsolver_free (gsl_root_fsolver * s)

Providing the function to solve Data Type: gsl_function – This data type defines a general function with parameters. – double (* function) (double x, void * params) this function should return the value f(x,params) for argument x and parameters params – void * params a pointer to the parameters of the function

Iteration int gsl_root_fsolver_iterate (gsl_root_fsolver * s) – perform a single iteration of the solver s to update its state double gsl_root_fsolver_root (const gsl_root_fsolver * s) – The solver maintains a current best estimate of the root at all times.

Search Stopping Parameters A root finding procedure should stop when one of the following conditions is true: – A root has been found to within the user-specified precision. – A user-specified maximum number of iterations has been reached. – An error has occurred.

Precision Test int gsl_root_test_interval (double x_lower, double x_upper, double epsabs, double epsrel) – |a - b| < epsabs + epsrel min(|a|,|b|) int gsl_root_test_delta (double x1, double x0, double epsrel, double epsabs) – |x1 - x0| < epsabs + epsrel |x1| int gsl_root_test_residual (double f, double epsabs) – |f| < epsabs

Root Bracketing Algorithms bisection algorithm - gsl_root_fsolver_bisection false position algorithm - gsl_root_fsolver_falsepos Brent-Dekker method - gsl_root_fsolver_brent

Root Finding Algorithms using Derivatives Newton's Method - gsl_root_fdfsolver_newton secant method (a simplified version of Newton's method which does not require the computation of the derivative on every step) - gsl_root_fdfsolver_secant Steffenson Method - gsl_root_fdfsolver_steffenson

Resource Read GNU Scientific Library Reference Manual at ref_toc.html

Netlib Netlib Repository at UTK and ORNL A repository contains freely available software, documents, and databases of interest to the numerical, scientific computing, and other communities.

Search Netlib Do a field search by using the syntax : – fieldname=whatever Use the GAMS class hierarchy

Field Names file (global) -- any portion of the pathname for a regular file lib (global) -- any portion of the pathname for a directory for (global) -- problem solved or description gams -- GAMS class prec -- Fortran precision (single, double, complex, or doublecomplex) title (global) alg -- algorithm or method by (global) -- author (name ) keywords (global) -- terms as would be drawn from a subject thesaurus lang -- programming language

Search Examples To seach for single precision routines in the lapack directory that do Schur factorization: – file=lapack and file=single and Schur – since the lapack single precision routines are in the lapack/single directory To search for curve fitting or gams class E1 and its subclasses: – (curve and fitting) or gams=e1* To do a literal search for 'cosine transform': – 'cosine transform'

GAMS Guide to Available Mathematical Software (a sleek portal to NetLib) An on-line cross-index of available mathematical software A virtual software repository, providing centralized access to abstracts, documentation, and source code of software modules that it catalogs (including Netlib)

Search for Software by Problem Each software module indexed in GAMS is assigned one or more problem classifications from the GAMS Problem Classification System. Three ways to locate software modules: – Use the taxonomy as a decision tree. – Browse through the entire taxonomy. – Search for problem classes that match a keyword.

Problem Decision Tree - Subclasses – A Arithmetic, error analysis – B Number theory – C Elementary and special functions (search also class L5) – D Linear Algebra – E Interpolation – F Solution of nonlinear equations – G Optimization (search also classes K, L8) – H Differentiation, integration – I Differential and integral equations – J Integral transforms – K Approximation (search also class L8) – L Statistics, probability – M Simulation, stochastic modeling (search also classes L6 and L10) – N Data handling (search also class L2) – O Symbolic computation – P Computational geometry (search also classes G and Q) – Q Graphics (search also class L3) – R Service routines – S Software development tools – Z Other

Other Ways for Search Search by Packages – Browse list of packages Search by Modules – Give Name of module Search by keyword – search for text in the abstracts of individual modules

Take home message Buy Numerical Recipes In real life, use Mathematica if you want to explore an algorithm Then go to GSL and/or Num. recipes and take what you need. When you become a pro, consider GAMP