1 epsii 59:006 spring 2004. 2 real engineering problem solving analyzing results of designs is...

33
1 EPSII 59:006 Spring 2004

Upload: jordan-weaver

Post on 04-Jan-2016

213 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

1

EPSII

59:006

Spring 2004

Page 2: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

2

Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

2-D Model of Oxygen Distribution in a Cell with Consumption at the Mitochondria

(Tilakaratne et al., Mathematical Biosciences, 2002)

Page 3: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

3

Real Engineering Problem Solving

Engineers Need to Concentrate on Solutions without Writing All Code

Can Use a Number of “Packages” Mathematica Maple Matlab IMSL Many Others

Page 4: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

4

Real Engineering Problem Solving

Care in Using ‘Packaged’ Programming Engineering Savvy Needed to Verify Results Some ‘Packages’ Do Not Explain Methodology

(This Can Have Significant Impact on Results) For Important Work, Choose Code that is

Engineering Friendly (Not Necessarily User Friendly)

Understanding Code Writing is Paramount for the Best Engineers

Page 5: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

5

Focus: IMSL C Functions

Page 6: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

6

Focus: IMSL C Functions

IMSL C Functions Provide Sophisticated Code that Is Well Documented

Requires Simple C Program Front-end Call IMSL Functions That Are Needed Functions Information on the Algorithm is

Well Documented Give Clear Examples that can be Used to

Develop Your Code

Page 7: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

7

IMSL Usage IMSL C libraries are compiled into shared and static

libraries Shared Libraries

References to the IMSL subroutines are resolved at run time. Your executable program is significantly smaller because it does

not contain the actual code for the IMSL subroutines. Static Libraries

means that the actual IMSL subroutine code is included in your executable

The libraries are single- and double-precision To access any IMSL subprograms you must bind your

own compiled program with the IMSL Libraries.

Page 8: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

8

How IMSL Used in Your Code #include <imsl.h> #include <math.h> main() {

int n = 7; int i; float p[7]; float *q; float pi; pi = imsl_f_constant("pi", 0); /* fill p with a pure sine wave */ for (i=0; i<n; i++)

p[i] = sin((float)(i+1)*pi/(float)(n+1)); q = imsl_f_fft_sine (n, p, 0); printf (" index\t p\t q\n"); for (i=0; i<n; i++)

printf("\t%1d\t%5.2f\t%5.2f\n", i, p[i], q[i]);}

Included IMSL Library

IMSL functions that are called

Page 9: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

9

IMSL Math Subprograms (>400)

Linear systems Eigensystem analysis Interpolation and approximation Integration and differentiation Differential equations transforms Nonlinear equations Optimization basic matrix/vector

operations

Page 10: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

10

IMSL Math Special Functions

Fundamental functions Trigonometric and hyperbolic functions Exponential integrals and related functions Error function and related functions Bessel functions Kelvin functions Bessel functions of fractional order Elliptic integrals Weierstrass elliptic functions Probability distribution functions and inverses Miscellaneous functions

Page 11: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

11

IMSL STAT Subprograms (>350) Basic statistics Regression Correlation Analysis of variance Categorical and discrete data analysis Nonparametric statistics Tests of goodness of fit and randomness Time series analysis and forecasting Covariance structures and factor analysis Discriminant analysis Cluster analysis Survival analysis, life testing and reliability Multidimensional scaling Density and hazard estimation Line printer graphics Probability distribution functions and inverses Random number generation

Page 12: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

12

IMSL at Iowa

C Numerical Library, HP PA-RISC HP-UX, Shared (32-bit):5.000

C Numerical Library, HP PA-RISC HP-UX, Static (32-bit):5.000

C Numerical Library Online Documentation:5.000

Currently Need to Use PA-RISC machines

Page 13: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

13

IMSL How to Configure Environment for IMSL Functions Login

login-pa.engineering.uiowa.edu

To configure your environment, source the setup procedure in a shell: C shell users, type:

L-ecn041% source /usr/ui/class/aux/imsl_setup.csh

Bash shell users, type:bash-2.04$ source /usr/ui/class/aux/imsl_setup.sh

Korn shell users, type:$ . /usr/ui/class/aux/imsl_setup.sh

Page 14: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

14

IMSL How to Access Documentation

On HP PA-RISC HP-UXLeft Mouse Click Comm App IMSL IMSL Manuals

Working on Accessing IMSL Manuals through WebCT

Page 15: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

15

IMSL Manual Front Interface

Links to C FunctionLibraries

Page 16: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

16

IMSL How to Compile and Link to IMSL Functions for code prog.c

$cc -o prog.exe $CFLAGS prog.c $LINK_CNL

(IMSL MAY NOT RUN WITH THE gcc COMPILER)

Page 17: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

17

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

f1(x1,x2) = 3x12 + 4x2 − 399

f2(x1,x2) = x1 + 2x2 −167

Here

f1(x) = f2(x) = 0

when the correct x1 and x2 are found

Page 18: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

18

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Check IMSL Manual to See How (and If) IMSL Functions Can Help You

Click here, Go to Chapter 7: Nonlinear Equations

Page 19: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

19

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Page 20: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

20

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations IMSL Offers a Number of Function Options Your Background Knowledge and IMSL

Information Help You Make a Decision Let Try

Page 21: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

21

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations The Information Provided Is At First

Overwhelming Overview Contains Pertinent Information

of Parameters and the Algorithm Used to Solve Problem

Examples Very Useful for Providing Insight to Problem

Page 22: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

22

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Page 23: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

23

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Page 24: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

24

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Page 25: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

25

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Page 26: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

26

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Page 27: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

27

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations Use the Example to Begin Understanding

and To Build Your Problem First, Make Sure the Example Problem

You Choose Works!

Page 28: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

28

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic EquationsExample 1. C Code

Page 29: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

29

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic EquationsExample 1. Output

The solution to the system is 1 2 0 3

Check solution. These are the values for x1 and x2, respectively

Page 30: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

30

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic EquationsNow Our Problem (vics_problem)

Review Example 1 Information Recognize Where the Input Function for Their System of Equations Were Placed in the Code

Page 31: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

31

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Now our problem (vics_problem)Modify function fcn for our problem as first test::

void fcn(int n, float x[], float f[]) { f[0] = 3.0 * x[0] * x[0] + 4.0 * x[1] - 399.0; f[1] = x[0] + 2.0 * x[1] - 167.0; }

f1(x1,x2) = 3x12 + 4x2 − 399

f2(x1,x2) = x1 + 2x2 −167

Page 32: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

32

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic EquationsOur Problem Output

Check solution. These are the values for x1 and x2, respectively!

The solution to the system is 1 2 5 81

Page 33: 1 EPSII 59:006 Spring 2004. 2 Real Engineering Problem Solving Analyzing Results of Designs is Paramount Problems are Difficult, Code Writing Exhaustive

33

IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations

Make sure solution makes sense Can modify code to get correct initial

guess (Example 2) Knowledge of numerical methods

help better understand algorithms