1 MATHCAD – Exercise guide Program MATHCAD is very

advertisement
MATHCAD – Exercise guide
Program MATHCAD is very useful tool for the solution of the technical problems. The
program is user friendly. All students of VŠB-TUO, Faculty of Mechanical Engineering are
able to solve the technical problems using this software in the faculty computer rooms. The
program is suitable for dealing with team or individual projects.
In this guide, there are clarified the basic mathematical operations. For the better
understanding, the text is supplemented practical examples.
CONTENT
1. CHAPTER – BASIC MATHEMATICAL OPERATIONS
2. CHAPTER – CREATION OF TEXT
3. CHAPTER – MATRIX
4. CHAPTER – SYSTEM OF EQUATIONS
5. CHAPTER – SYMBOLIC OPERATION
6. CHAPTER – GRAPHS -2D
7. CHAPTER – GRAPHS – 3D
8. CHAPTER – FUNCTION “ROOT”
9. CHAPTER – VECTORS
10. CHAPTER – EULEROVA NUMERICAL METHOD
11. EXAMPLES FOR REPETITION
1
1. CHAPTER
Philosophy of MATHCAD is very similar as other Microsoft products, it means
saving of files, opening of files, print of files and so on. All information on using
MATHCAD are in English language in “Help”, look at fig.1.1
Fig. 1.1 – Help
In Help, there are clearly describe mathematical operations which is possible to do in
MATHCAD and there are simple examples for the better understanding (look at fig.
1.2.)
Fig. 1.2 – Help and its using
2
Fig. 1.3 – Help and Its Using
1.1 BASIC MATHEMATICAL OPERATION
There is possibility to do the basic mathematical operation using “calculator” (look at
fig. 1.4.).
Fig. 1.4 – Calculator.
Types of the equal signs and their using is at fig. 1.5..
3
Fig. 1.5. Types of the Equals Signs
If the wrong equal sign is used, it is not possible to receive the numerical result.
If the Assigned sign is used, it is possible to solve the problem symbolically and
receive the different numerical results for different numeric entry.
It is necessary to choose the letters for the variables carefully. Some letters are
predefined in MATHCAD.
Example:
4
If in expression is red color, it means “mistake”.
If “click” on the expression, the explanation of the mistake appears.
There is possibility to use the right of the keyboard for the input.
1.2 UNITS
Basic information on units are in help (look at fig.1.6.) icon “scoop”.
Fig. 1.6 – Units
During the numerical solution, there is not necessary to transfer units. The numerical
result is always in SI system.
Example:
5
If is necessary to receive the result in the different units, it is possible to transfer it by
“click” on the unit and to the black place holder to write the request unit.
The red color signalizes the mistake.
Example:
Angles
If the value is given in angles, it is necessary to add unit “deg” …..degree.
Otherwise, the value is given in radians.
Example:
6
Multiple units
In MATHCAD, there are not given multiple unites. It is necessary to predefine it.
Example:
2. CHAPTER – CREATION OF TEXT
Text is input to the file by“click” on the space bar. It means, write the text and click
on the space bar. Text is possible to edit by the same way as in Word and so on.
If the text is ready in Word and after that is input to MATHCAD, it is possible to “reopen” input text and edit it by double click on the right button of the mouse.
Edit the text is possible by opening the icon “Format” on the scroll bar (look at fig.
2.1.).
Fig. 2.1 – Text Editor
Greek letters
Greek letters is possible to input:
1. Using the icon with Greek letters (look at fig. 2.2)
Fig. 2.2. – Greek Letters
7
2. Hot-key - write letter and press key “ctrl g”.
a
α
b
β
It is possible to input “pictures” to the MATHCAD file without any restriction.
3. MATRIX
3.1. CREATION OF THE MATRIX
1. Matrix is created by click to icon “Matrix” (look at fig. 3.1)
Fig. 3.1. Creation of the Matrix_1
2. The second click to the opened window Matrix to icon matrix again (fig. 3.2)
Fig. 3.2 Creation of the Matrix_2
3. Fill the requested dimension of the matrix to the window “Insert Matrix” (fig. 3.3)
8
Fig. 3.3 Creation of the Matrix_3
3.2. OPERATION WITH MATRIX
For the work it is better to name the matrix (fig. 3.4). After that, the work is more
easy.
Fig. 3.4. Matrix Name
All operation possible to do in MATHCAD with matrix are described with simple
examples in Help (fig. 3.5.)
Fig. 3.5 Using Help
Determinant matrix A
Matrix inverse
9
Matrix transponse
Extract of the one element from
the matrix
Extract is done by one instruction
The first row and the fist column have the index “0”.
Matrix addition
Adding the number
Symbolic operation with matrix.
All operations is possible to do by symbolic way (fig. 3.6.).
Fig. 3.6. Symbolic Operation with Matrix
10
4. SYSTEM OF EQUATIONS
4.1. SYSTEM OF LINEAR EQUATIONS
If it is linear system of equations, it is possible to solve it using matrix operations.
A - matrix of constants
X – matrix of “unknown”
V – matrix of result
The way is described in the following example.
System of equations
The first row of the vector X is unknown x
The second row of the vector X is unknown y
The third row of the vector X is unknown z
(Because vector has one column, for the identification of one element is one number
enough).
11
Checking of the results:
Practical example:
Determine the force in the all beam of the truss as shown in the fig.3.7.
h = 4 m, b = 6 m, Q = 10 kN
Fig. 4.1. – Truss System
System of equilibrium equations for every joint.
12
A – matrix of constant
X – matrix of unknowns
V – matrix (vector) of results
Reaction in the support B
4.2 SYSTEM OF THE EQUATIONS (LINEAR, NON-LINEAR SYSTEM)
It is possible to solve the system of equations in MATHCAD using Given-Find.
Solution procedure will be illustrated on the example.
System of equations:
1. step - estimation result
2. step - given
3. step - system of equations
4. step - find
13
Checking of the results:
The result is not zero but the number is very small. The result has sufficient accuracy.
Warning: If the system is linearly dependent (infinitely solutions) , the results will be
the nearest value to the first guess result.
If the unknowns have units, it is necessary to solve the problems with respect to it.
It will be explain in example.
Determine the force in the all beam of the truss as shown in the picture bellow.
h = 4 m, b = 6 m, Q = 10 kN
14
15
5. SYMBOLIC OPERATION
5.1 SYSTEM OF THE QUADRATIC
SYMBOLIC SOLUTION
AND
CUBIC
EQUATIONS
–
The way of solution is explained on the picture bellow (fig. 5.1.).
Fig. 5.1. – Way of Solution
Procedure:
•
Write equation with “bold” equal sign (fig. 5.2.).
•
Click by cursor to unknown what is needed to solve
•
Click by cursor to icon “Symbolics – Variable - Solve” .
•
For quadratic equation there are two results.
Fig. 5.2. – Equal Sign
Procedure for the cubic equation is the same.
16
There are three results (Fig. 5.3.)
Fig. 5.3. – Way of Soulution
5.2
SYMBOLIC DERIVATION
5.2.1 USING ICON SYMBOLIC DERIVATION
The way of solution is described at fig. 5.4.
The procedure is following:
•
Write the function
•
Click by cursor to the variable
•
Click by cursor to the icon Symbolice-Variable-Differentater
17
Fig. 5.4. – Symbolic Derivation
If the function has two variable, it is necessary to click by cursor to variable
according to which to derivation (fig. 5.5).
Fig. 5.5 – Symbolic Derivation Function with Two and More Unknowns
18
5.2.2
USING ICON “CALCULUS”
The procedure of the derivation is described at fig. 5.6. For the result is
necessary to use equal sign for the symbolical operation.
Fig.
5.6 –
Symbolic Derivation.
Procedure for the numerical result is described bellow:
•
All values have to be given
•
Function
19
Solution of the practical problems is shown bellow.
Practical example:
Determine the function of the velocity and acceleration of the piston of the crank
mechanism as shown in the scheme 5.7.
5.7. Scheme of the Crank Mechanism
Procedure of solution:
•
Find the function of the angle ψ as the function of the time ψ= ψ(t)
•
Find the function of the angle φ as the function of the time φ= φ (t)
•
Find the coordinate x as the function of the time x=x(t). Coordinate x describe
the position of the piston.
•
Velocity of the piston v(t) - [m/s] – velocity is the first derivation of the
coordinate x with respect time t.
•
Acceleration of the piston a(t) - [m/s2] - acceleration is the first derivation of
the velocity function with respect to time t or the second derivation of the
coordinate x with respect time t (fig. 5.8).
20
Fig. 5.8 - Solution of Kinematics Values of the Crank Mechanism
5.3
SYMBOLIC INTEGRATION
The procedure of the integration is very similar as procedure of the derivation described
above.
5.3.1 USING ICON SYMBOLIC INTEGRATION
The procedure of the integration is described at fig. 5.9.
Procedure
•
Write the function
•
Click by cursor to the variable
•
Click by cursor to the icon Symbolic-Variable-Integrate
•
If the function has two variable, it is necessary to click by cursor to variable according
to which to integration. (fig. 5.9).
21
Fig. 5.9 – Symbolic Integration
5.3.2
USING ICON “CALCULUS”
The procedure of the derivation is described at fig. 5.10. For the result is
necessary to use equal sign for the symbolical operation.
Fig. 5.10 – Symbolic Integration
22
The procedure for the numerical result of integration is the same as the procedure for
the derivation. It is described at fig. 5.11.
Fig. 5.11 – Numerical Solution
23
6. GRAPHS – 2D
The Graph toolbar (fig.6.1) button allows to insert 2-D or 3-D graphs. There are
several way of the procedure of the graph creation.
Fig. 6.1 – Graph Toolbar
6.1.
CREATING AN X-Y PLOT
1. step – creation the plot of the variable x
x :=
0
,
1
..
10
The step of the variable is given by difference between value x1
and x2. “Two dots” is necessary to insert from the icon Matrix (Fig. 6.2)
Fig. 6.2 – Creation of the Plot
2. f ( x) :=
3⋅x
2
+ 2⋅x +
1
Function of the variable x
3. Choose the type of the graph from the icon Graph (Fig. 6.3) and fill the variable to
the placeholder in axis “x” and function in axis “y”.
24
Fig. 6.3 – Creation of the 2-D Graph
Using double click on the graph, the table Formattin Currently Selected X-Y Plot is
opened (Fig. 6.4).
Fig. 6.4 – Formatting Currently Selected X-Y Plot
25
There is possible to change the type, the colour and the weigh of the curve (Fig.
6.5_1).
Fig. 6.5 – Formatting Currently Selected X-Y Plot _1
There is possible to describe the graph (Fig. 6.5_2).
Fig. 6.5 – Formatting Currently Selected X-Y Plot _2
26
CREATING OF THE GRAPH – 2ND WAY
6.2.
The procedure is described bellow and the graph is at fig. 6.6.
•
ORIGIN :=
•
n :=
10
•
i :=
0
•
xi :=
•
Open icon „Graph“ ( fig.6.1 – Graph Toolbar)
•
Choose the type of the graph
•
On axis x – variable
•
On axis y – function value
0
It has to done on the beginning
number of steps
..
n plot for the variable
3⋅i
2
+ 2⋅i +
1
function
Fig. 6.6 – Graph – 2nd Way
6.3.
CREATING OF THE GRAPH – 3RD WAY
There is possibility to create the graph using icon “PROGRAMMING. It is possible to
use it for one and more different function in the common graph. The procedure is described
bellow (Fig. 6.7).
27
•
Write the name of the function with assigned sign (look at fig. 1.5)
•
Open the icon PROGRAMMING
•
Write the first unction
•
Click at “Add line” and write the second function
•
Other steps are the same as described above in chap. 6.1 and 6.2
Fig. 6.7 – Graph – 3rd Way
Practical example.
At chapter 5.2.2 there are derived the equations for the velocity and acceleration of
the piston for the crank mechanisms. The timing values of the velocity and acceleration is
created bellow. The final graph is at Fig. 6.8.
Given:
R := 0.4 ⋅m
L := 0.8 ⋅m
−1
ω := 0.5 ⋅s
T …..time for one turn
28
Fig. 6.8. – Final Graph
6.4.
CREATION THE GRAPH OF THE MORE FUNCTIONS
The way the creation is described bellow for three functions in the three different
plots. The functions have to have different “name”. The plot can be the same.
•
Write the functions and their plots
•
Open icon Graph and fill the placeholders. The different domains are on
the axis X
•
The functions are on axis Y. The other functions give on the axis Y when
writing comma after the previous function (Fig. 6.9).
29
•
The next steps are the same as described in chapter 6.1 and 6.2.
•
The result is at Fig. 6.10.
Fig. 6.10 – Final Graph
7. GRAPH – 3D
The procedure is described bellow.
•
Write the function
•
Create the domain
•
Write the formula for the creation of the matrix of the function value - M i,j
•
Creating of the graph from the icon “Graph”. The final graph is at Fig. 7.1.
30
It is possible to read the all members the matrix M.
Fig. 7.1 – Final Graph
8. FUCTION “ROOT”
8.1 FUNCTION ROOT USING FOR SOLUTION OF EQUATIONS
In special occasion, the equations is no possible to solve as mentioned in the chapter 4. It is
for example equation
31
There is no possibility to solve it by symbolic operation. Using Given-Find, one result is
found and value depends on the estimation of the result. There is no information on the
number of the correct values of the result (Fig.8.1.). The result depends on the first estimation
of the uknown x.
Fig. 8.1. – Way of the Solution
Solution of the equation
is value x so that the left and right side of the equation has the same value. For the better
understanding look at Fig. 8.2.
32
Fig. 8.2. – Number of the Results
The procedure for the solution of the equation using „Root“ is described at Fig. 8.3.
Fig. 8.3. – Solution by Using “Root”.
33
8.2 ROOTS OF POLYNOMIAL – SOLUTION
The procedure for the solution of the polynomial root is described bellow on the practical
example.
Given polynomial:
Constants:
The cubic polynomial has three roots. It is possible to check, if the graph of the function for
the polynomial is drawn (Fig. 8.1).
The procedure of the solution by MATHCAD is described bellow:
34
Checking:
9. VECTORS
Vector in 2-D is given by 2 parts, in 3-D is given by 3 parts.
Vector A in 3-D is given
Value of A is:
In 3-D problems, the orientation of the vector is determined by three angles (α,β,γ), as shown
in the picture (Fig. 9.1)
Fig. 9.1. – Orientation of the Vector
35
9.1.
SCALAR PRODUCTS OF 2 VECTORS
2 vectors A and B are given.
Scalar product of the 2 vectors is scalar C.
9.2.
VECTOR PRODUCT OF 2 VECTORS
2 vectors A and B is given. The result of the
vector product is vector D. The mark for the vector
product is given from icon MATRIX ( Fig. 9.2.)
Fig. 9.2. – Mark for Vector Product
Practical example:
Find the resultant of force F. F is given by 3 parts Fx,Fy,Fz. Point of acction of force F is in
the point A (coordinates xA, yA and zA – look at Fig. 9.3). Determine the moment of the
force F to the beginning of the coordinate systém (point 0).
36
Fig. 9.3. – Force in 3-D
Given:
Fx := 30 ⋅ N
xA := 2 ⋅ m
Fy := 20 ⋅ N
yA := 3 ⋅ m
Fz := 50 ⋅ N
zA := 4 ⋅ m
Value of the force F:
Determine of the position vector R
(radius vector R).
Value of R – it is length between
points 0-A [m] .
Mo – moment of the force F to the point 0. Moment of the force to the point is vector product
radius vector R and force F.
37
10. EULLER NUMERICAL METHOD
The procedure of the solution will be described on the practical example – Projectile
motion in an environment that resists.
Given:
Projectile with mass mt motions from the point O (Fig.10.1). Initial velocity is vo initial angle
is the force φo . The force acting against motion is Fb and the value of the force is the
function of the constant b - Fb= b*v2.
Find the range of the projectile.
vo := 800 ⋅ m ⋅ sec
−1
φo := 40 ⋅ deg
mt := 0.1 ⋅ kg
b := 5 ⋅ 10
−6
2
⋅ N ⋅ sec ⋅ m
−2
g := 9.81 ⋅ m ⋅ sec
−2
Fig. – 10.1. – Description of the Problem
The velocity v is vector and in every positioon of the projectile has two parts (vx and vy).
For angle φ is dependence:
38
The force Fb acting against the motion depends:
- in axis x
- in axis y
-
The equilibrium of the motion:
- in axis x
Acceleration a in axis x as the function velocity vx and vy
- in axis y
Procedure for Euler method of the numerical integration
n := 10000
Tc := 75 ⋅ sec
i := 0 ..
xi := 0 ⋅ m
i := 1 ..
n
∆t :=
yi := 0 ⋅ m
Tc
n
∆t = 7.5 × 10
vx i := 0 ⋅ m ⋅ sec
−1
−3
s
vy i := 0 ⋅ m ⋅ sec
−1
ti := i ⋅ ∆t
n
n…....number of steps
Tc….time of the solution
∆t…..time for one step
vxo…initial velocity in axis x
39
vyo…initial velocity in axis y
The equations are based on the equations for the moition with constant acceleration.
s
so + vo ⋅t +
v
vo + a ⋅ t
1
2
⋅a ⋅t
2
The result is graf (fig. 10.2 – Trajectory of the projectile)
Fig. 10.2 – Trajectory of the Projectile
40
41
Download