1 epsii 59:006 spring 2004. 2 real engineering problem solving analyzing results of designs is...
TRANSCRIPT
1
EPSII
59:006
Spring 2004
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)
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
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
5
Focus: IMSL C Functions
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
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.
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
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
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
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
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
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
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
15
IMSL Manual Front Interface
Links to C FunctionLibraries
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)
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
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
19
IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations
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
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
22
IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations
23
IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations
24
IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations
25
IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations
26
IMSL Example 1: 2 x 2 System of Non-Linear Algebraic Equations
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!
28
IMSL Example 1: 2 x 2 System of Non-Linear Algebraic EquationsExample 1. C Code
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
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
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
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
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