 # PSOD Lecture 2.

## Presentation on theme: "PSOD Lecture 2."— Presentation transcript:

PSOD Lecture 2

Matrix operations Multiply by constant Matrix transpose [ctrl]+ Inverse [^][-] Matrix multiplying Determinant

To read the matrix elements Ar, k: key [[] r- row nr, k – column nr e.g. element A1,1 keys: [A][[][,][=] To chose matrix column First column A( A<0>): keys [A][ctrl]+ Default first column number is 0, (to change : Math/Options/Array Origin)

Calculations of dot product and cross product of vectors

Special definition of matrix elements as a function of row-column number Mi,j=f(i,j) E.g. Value of element is equal to product of column and row number Argumenty funkcji są liczbami całkowitymi nieujemnymi od zera do ilości wierszy i/lub kolumn Constrain: function arguments have to be integer

3D graphs of function on the base of matrix : [ctrl]+ [M]
MathCAD 3D graphs 3D graphs of function on the base of matrix : [ctrl]+ [M] M – matrix defined earlier

3D Graphs of function of real type arguments
MathCAD 3D graphs 3D Graphs of function of real type arguments Using procedure: CreateMesh(function, lb_v1, ub_v1, lb_v2, ub_v2, v1grid, v2grid) Assign result to variable Plot of the variable similarly to plot of matrix ([ctrl]+) Boundaries can be the real type numbers. (def. –5,5) Grids have to be integer type numbers (def. 20)

MathCAD 3D graphs – formatting: fill options

MathCAD 3D graphs – formatting: fill options
Contours colour filled

MathCAD 3D graphs – formatting: line options

MathCAD 3D graphs – formatting: Lighting
Oświetlać - lighten

MathCAD 3D graphs – formatting: Fog and perspective

MathCAD 3D graphs – formatting: Backplane and Grids

Predefined constants e = 2,718 – natural logarithm base
g = 9,81 m/s2 – acceleration of gravity  = 3,142 – circle perimeter/diameter ratio

Single equation (one unknown value) Given-Find method Input start point of variable Type "Given" Type equation with using [=] ([ctrl]+[=]) Type Find(variable)= Variable that satisfy an equation

Given-Find – solving methods Linear (function of type c0x0 + c1x cnxn) –starting point do not affects on results, it only defines size of matrix/vector of the solution. Nonlinear – according to nonlinear equation. Obtained result could depend on starting point. Available methods: Conjugate Gradient Quasi – Newton Levenberg-Marquardt Quadratic The choice of method is automatic by default. User can choose method from the pop-up menu over word Find.

Single equation (one unknown value) Root procedure: Root(function, variable, low_limit, up_limit)= Values of function at the bounds must have different signs or

Single equation (one unknown value) Root procedure methods: Secant method Mueller method (2nd order polynomial) y1 x2 x3 x5 x4 x1 y3 y2

Single equation (one unknown value) Special procedure: polyroots for the polynomials. Argument of procedure is a vector of polynomial coefficients (a0, a1...). The result is a vector too. Methods: Laguerre's method companion matrix

MathCAD, the system of equations solving
The system of linear equations Solving on the base of matrix toolbar: Prepare square matrix of equations coefficients (A) and vector of free terms (B) Do the operation x:=A-1B and show result: x= Or Use the procedure LSOLVE: lsolve(A,B)=

MathCAD, the system of equations solving

MathCAD, the system of equations solving
The system of nonlinear equation Can be solved using given-find method Assign starting values to variables Type Given Type the equations using = sign (bold) Type Find(var1, var2,...)=

MathCAD, the system of equations solving

Ordinary differential equations solving
Numerical methods: Gives only values not function Engineer usually needs values There is no need to make complicated transformations (e.g. variables separation) Basic method implemented in MathCAD is Runge-Kutta 4th order method.

Ordinary differential equations solving
Numerical methods principle Calculation involve bounded range of independent variable only Every point is being calculated on the base of one or few points calculated before or given starting points. Independent variable is calculated using step: xi+1 = x i + h = xi+Dx Dependent value is calculated according to the method yi+1 = y i +Dy= y i +Ki

Ordinary differential equations solving
Runge-Kutta 4th order method principles: New point of the integral is calculated on the base of one point (given/calculated earlier) and 4 intermediate values

Single, first order differential equation Assign the initial value of dependent variable (optionally) Define the derivative function Assign to the new variable the integrating function rkfixed: R:=rkfixed(init_v, low_bound, up_bound, num_seg, function) Initial condition

Result is matrix (table) of two columns: first contain independent values second dependent ones To show result as a plot:

System of first order differential equations Assign the vector of initial conditions of dependent variables (starting vector) Define the vector function of derivatives (right-hand sides of equations) Assign to the variable function rkfixed: R:=rkfixed(init_vect, low_bound, up_bound, num_seg, function)

Result is matrix (table) of three columns: first contain independent values, 2nd first dependent values, third second ones : Results as a plot: R<0>

Single second order equation Transform the second order equation to the system of two first order equations: Initial condition