680 likes | 693 Views
Learn programming and digital computer usage. Develop problem-solving skills and algorithms. Educate STEM students in spreadsheet, symbolic computation, and numerical computation. Features Excel, Open Office, Numbers, and Excel functions with examples.
E N D
SYCS 165 SCIENTIFIC COMPUTING FOR ENGINEERS Ronald J. Leach
From the Catalog • Introduces programming and use of digital computers. • Programming includes general problem-solving and the systematic development of algorithms • Use includes the coding of programs and practical experience in operating computers and peripheral equipment.
Purpose of course • Educate STEM students in the use of three types of software to solve appropriate problems in their major fields: • Spreadsheets • Symbolic computation using computer algebra systems • Numerical computation using standard modern computer languages, primarily C.
Why do this? • A new paradigm – data driven science. • Data modeling, analysis, and simulation are becoming increasingly important in STEM.
Why three types of software? • There are different types of applications. • There are differences in resources. • There are differences in what you have to interface with.
Why spreadsheets? • Spreadsheets are readily available. • They have surprising functionality. • The Excel spreadsheet software may be free to students at Howard University due to the special Howard-Microsoft connection.
Other spreadsheets • Open Office – available for Apple, Windows, and Linux computers – free download from OpenOffice.org. • The spreadsheet is Calc • Numbers – available for Apple computers –not usually free.
Excel capabilities • Many functions are available for • Statistical computations • Graphing • Arrays • Matrices • etc
Functions – a glorified calculator • ABS Returns the absolute value of a number • ACOS Returns the arccosine of a number • ACOSH Returns the inverse hyperbolic cosine of a number • ASIN Returns the arcsine of a number • ASINH Returns the inverse hyperbolic sine of a number • ATAN Returns the arctangent of a number • ATAN2 Returns the arctangent from x- and y-coordinates • ATANH Returns the inverse hyperbolic tangent of a number
CEILING Rounds a number to the nearest integer or to the nearest multiple of significance • COMBIN Returns the number of combinations for a given number of objects • COS Returns the cosine of a number • COSH Returns the hyperbolic cosine of a number • DEGREES Converts radians to degrees • EVEN Rounds a number up to the nearest even integer • EXP Returns e raised to the power of a given number
FACT Returns the factorial of a number • FACTDOUBLE Returns the double factorial of a number • FLOOR Rounds a number down, toward zero • GCD Returns the greatest common divisor • INT Rounds a number down to the nearest integer • LCM Returns the least common multiple • LN Returns the natural logarithm of a number • LOG Returns the logarithm of a number to a specified base • LOG10 Returns the base-10 logarithm of a number
ODD Rounds a number up to the nearest odd integer • PI Returns the value of pi • POWER Returns the result of a number raised to a power • PRODUCT Multiplies its arguments • QUOTIENT Returns the integer portion of a division • RADIANS Converts degrees to radians • ROMAN Converts an arabic numeral to roman, as text • ROUND Rounds a number to a specified number of digits • ROUNDDOWN Rounds a number down, toward zero • ROUNDUP Rounds a number up, away from zero
SIGN Returns the sign of a number • SIN Returns the sine of the given angle • SINH Returns the hyperbolic sine of a number • SQRT Returns a positive square root • SQRTP Returns the square root of (number * pi) • TAN Returns the tangent of a number • TANH Returns the hyperbolic tangent of a number • TRUNC Truncates a number to an integer
Some Array and Matrix Functions • MDETERM Returns the matrix determinant of an array • MINVERSE Returns the matrix inverse of an array • MMULT Returns the matrix product of two arrays • SUMX2MY2 Returns the sum of the difference of squares of corresponding values in two arrays • SUMX2PY2 Returns the sum of the sum of squares of corresponding values in two arrays • SUMXMY2 Returns the sum of squares of differences of corresponding values in two arrays
Some Statistical Functions • AVERAGE Returns the average of its arguments • DEVSQ Returns the sum of squares of deviations • LINEST Returns the parameters of a linear trend • LOGEST Returns the parameters of an exponential trend • MEDIAN Returns the median of the given numbers • MODE Returns the most common value in a data set • STDEV Estimates standard deviation based on a sample • TDIST Returns the Student's t-distribution • … • …
Functions in Excel • Easy to create in the Visual Basic editor • Standard syntax Function Fcn_Name (arg) Fcn_Name = xxx End Function
User-defined Functions in Excel • Easy to create in the Visual Basic editor • Standard syntax – reserved words Function Fcn_Name (arg) Fcn_Name = xxx End Function
Example Function Square_It(num) Square_It = num * num End Function (Create in VB Macro editor – use the Tools menu)
Numerical computation • Standard technique for many complex problems • Many well-established libraries of subprograms • Works well on many classes of supercomputers • Most numerical approximation is applied linear algebra
A lot of hand craftsmanship • Wires had to be cut by hand to make sure there were no timing delays or bottlenecks • The speed of light was too slow to have several of these older machines act in tandem.
Supercomputers • Vector computers could do vector operations (+, -) in a single clock cycle for long vectors 256 or more entries. • Parallel computers could do computations in parallel (think dual-core, but much larger) • The good scientific developers had the target computer’s architecture in mind when developing algorithms and programs
A cheaper idea- clusters • Originally, place multiple CPUs in racks, with an operating system to control communication of data and instructions. • Now, place boards with many processors in racks with an operating system to control communication of data and instructions.
Many types of clusters • Linux • Windows • Mac
Even “cheap” machines are expensive • To buy • To operate • utilities • To program
Good quality numerical software • Extensive libraries geared to the particular machine’s architecture. • Nearly all the most useful numerical libraries are written in FORTRAN or C. • Often interface with other languages.
We won’t be using supercomputers or clusters as a basic part of this course. • Exception – some students will do some of their C programming on a cluster, depending on the situation and the needs of their major. • Personal computers are sufficient for an introductory course
Why three types of software? • Computer algebra systems can: • Create exact answers to problems • Produce infinite-precision arithmetic (a better term is “unlimited-precision”) • Many well-tested routines • Perform mathematical calculation in fields such as algebra and calculus much muchmuch better than humans
What about computer algebra systems? • Run on many computers, even some parallel computers and clusters • Not much gain by running on vector machines
Computer algebra systems • Many of the older ones were written in Lisp (a language often used for AI) • Macsyma • Maxima • MuMath • Derive • Some use C (Maple) • Hard to tell for Mathematica, Matlab
One unfortunate flaw of CAS • They run out of room! • The CAS will generate lists (in Lisp, C, or whatever language) as necessary. • Sometimes these lists stay in memory even after they are no longer needed. • This means that memory can be exhausted.
Types of arithmetic • Integer • Real (or floating point) • Extended precision (double precision) • Complex • Other?
Integer arithmetic • Often limited by the size of a computer “word” • Integers can be too big or small • Largest unsigned integer in a 32-bit machine is 232 – 1 • Largest positive integer in a 32-bit machine is 231 – 1 • Smallest unsigned integer in a 32-bit machine is often - 231
Arithmetic with decimals Floating point arithmetic: • Has largest and smallest numbers. • Has positive number that is closest to 0. • Has negative number that is closest to 0. • Has truncation errors (3.14 is not 3.14159) • Has round-off errors (3.14 * 3.14 is 9.8596)
Arithmetic with decimals, cont. Fixed point arithmetic • Usually two decimal places • Round-off can be severe • Who stole my bank interest example • No problem with smallest positive number
CAS • Can have “infinite precision” or, at least, “unlimited precision” • The trade-off is that arithmetic takes much longer and requires more space
For next class • Download Maxima from sourceforge.net and install it, along with some documentation. • Bring laptop to class.
There are many computer algebra systems • Maxima (successor to Macsyma) • MIT Macsyma, later to Symbolics • DOE Macsyma • Now free under GPL • Can use, modify, bundle according to Gnu Public License • Must release source code in any development
Other high quality software • Mathematica • Elaborate, good graphics • Student versions available for yearly license • Some university-wide licenses (here?) • Matlab • Currently available in CLDC • Maple • Canadian-made