






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







www.ce.ufl.edu/~kgurl
‘ Numerical Methods for Engineers ’, Chapra and Canale Fourth Edition, McGraw-Hill
Mathcad 2000 (Circa labs and 200 Weil lab) Mathcad 2001 (current version available for purchase, differences from 2000 minimal for our purposes)
Learn fundamentals of programming skills in general and Mathcad in particular ~ 5 or 6 weeks Use Mathcad as a medium to investigate a variety of numerical methods of problem solving. The context will generally be civil engineering-type problems.
A more detailed list of topics covered can be found in the syllabus, avaiable at the class web site: www.ce.ufl.edu/~kgurl -->classes/syllabi
Example: Write a program to calculate the mass of a hollow sphere. The outer diameter is 10.2, the den- sity is 1.25, the thickness is variable (the program user decides)
Apply the Programming Process :
gather all necessary input (diameter, density, thickness) calculate outer and inner radius calculate volume of the solid material multiply volume by density to get mass display result
Now test the code I’ll use a calculator to run an example and compare with my results
NOTE: Mathcad knows the value of , unless it has been redefined as a new variable
Please enter a value for the thickness of the skin of the sphere
thickness := 2 These variables will remain constant
Density := 1.25 Diameter :=10.
Calculate outer and inner radius
Router Diameter 2
:=
Rinner :=Router −thickness
Volume 4 3
Volume =430.
π
Let’s go to the Mathcad worksheet to play around with units...
There are some tricks to using units properly. We’ll discuss when the proper context comes up.
The following list breaks down programming into 9 basic topics. We’ll discuss each in detail and learn them all in the next few weeks. Once we understand the basics, even the most complicated programming tasks are just the proper combination fo basic concepts.
Operators Order of Operations
Please enter a value for the thickness of the skin of the sphere
thickness :=2m
These variables will remain constant
Density 1.25 kg m^3
:= Diameter :=10.2m
Calculate outer and inner radius
Router Diameter 2 := Rinner :=Router −thickness
Volume 4 3
1) Data Types
Types of information that can be stored and manipulated
2) Variables / Arrays
Named locations for storing data types. We can represent quantities with whatever names we like.
example: x is a variable assigned the constant 5, then 15
x := 5 x := 15
what is the value of x?
Using a single array (grade) to store student grades
grade 1 := 23
grade 2 := 25
grade 3 := 18
grade=
we’ll see later why there are four values although we only entered 3 values
Array types
scalar - single piece of information (no index) x := 8
vector (1-D array)- column of information (one index)
x := Ctrl+M pick # rows and 1 column, enter values
x := 1 column, 3 rows
x 2 =
2-D array - multiple rows and columns
x := Ctrl+M pick # rows and columns, enter values
x:= 2 rows, three columns
x1,3= 9.
3) Input / Output
Input - methods of including data needed to begin or continue
4) Assignment statements
Assign information to a variable using : =
Conditional loops - repeat if condition is true
Use a conditional loop when the number of times we want to run it is dependent on satisfying certain con- ditions that change as the loop iterates.
while (condition is true) instructions to be looped
e.g. while the value of mass is greaterthan 100, continually multiply mass by 0.9, and automatically stop when the value of mass falls below 100
8) Subprograms / functions
User-created smaller programs used by the main program when needed. Users can create any set of instructions that they wish to apply often, and assign that set of instructions a name. These functions do not need to appear in the same Mathcad worksheet. They can be in a different worksheet and called from the current sheet. In this manner, we can create whole suites of complicated functions, and not have to actually see them in the worksheet in which we use them.
9) Built in Functions
built-in (comes with Mathcad) smaller programs used by main program when needed same attributes as in 8) above
mass := 200 out x( ) x (^) ←x 0.9⋅
while x > 100
x
:=
mass :=out mass( )
mass =95.
e.g. enter in several student grades and calculate the mean
mean is a built in function that calculates an average value of the data sent to it.
Operators
Order of Operations
x
3 8 9
:=
mean x( ) =6.