# Operators and functions of the MathCAD system

Operators in the system are commands expressed in the form of special characters designed to perform various mathematical operations:

degree X^Y X Y

factorial X! 4!=24

root /X Ö9=3

absolute value |x |-5|=5

subscript X[i X i

+, -, *, / – in the usual way

summation of the terms of the series i\$X åX i

multiplication of terms of series ii#x

definite integral x&f(x)

derivative x?f(x)

Functions – exp(x), ln(x), log(x), cos(x), etc.

Summation of terms of a series i \$ x i:=1.5

X i :=2*i

åx i =30

i

Vector and matrix variables in the MathCAD system are variables with specified limits of change.

You can use another construction:

variable name:=N start , N sl …N end ; the step in this case is equal to N slu -N initial

Loop with non-integer change

An example of the implementation of a double loop with nesting.

i:=1..4 – outer loop

k:=1..3 – internal

ik :=i*k

+The MathCAD system operates with two types of arrays. The first is one-dimensional arrays or vectors, the second is two-dimensional or matrices.  k:=1..4 0

x:=1

Y k :=exp[X k ]  Y:= 2 7 1

7 3 8

20 0 8

54 59

To specify an Alt+M vector, the number of rows and columns can then be entered.

Vectors are denoted by V, matrices by M, scalars by z.

z*v multiplication of a vector by a scalar

v1*v2 multiplication of two vectors

m1-m2 matrix subtraction

m n Raising a matrix to the n-power

m t matrix transport (denoted as M[Alt]!)

Sv is the sum of all vector elements (denoted as Alt+\$+V)

The system also has a number of functions:

length(v) number of vector elements

last(v) returns the index of the last element of the vector max(v) the maximum value

min(v) minimum value

rows(m) number of matrix rows

cols(m) number of columns

tr(m) trace of matrix m, sum of its diagonal elements

Standard and Custom Functions

Arbitrary dependencies between input and output parameters are specified using functions. Functions take a set of parameters and return a value, either scalar or vector (matrix). Formulas can use standard built-in functions as well as user-defined functions.

Custom functions must first be defined. The definition is specified using the assignment operator. The name of the user-defined function is indicated on the left side and, in parentheses, the formal parameters are the variables on which it depends. To the right of the assignment sign, these variables must be used in the expression. When using a user-defined function in subsequent formulas, its name is entered manually. It does not appear in the Insert Function dialog box.

Here are the designations of the main ones:

1. Trigonometric and inverse functions:

sin(z), cos(z), tan(z), asin(z), acos(z), atan(z)

z – angle in radians

2. Hyperbolic and inverse functions:

sinh(z), cosh(z), tanh(z), asinh(z), acosh(z), atanh(z)

3. Exponential and logarithmic:

exp(z) – e z

ln(z) – natural logarithm

log(z) – decimal logarithm

4. Statistical functions:

mean(x) – mean value

var(x) – variance

stdev(x) – standard deviation

cnorm(x) – normal distribution function

erf(x) – error function

Г(x) – Euler gamma function

5. Bessel functions:

J0(x), J1(x), Jn(n,x) – first-order Bessel functions

Y0(x), Y1(x), Yn(n,x) – second-order Bessel functions

6. Functions of a complex variable:

Re(z) – real part of complex number

Im(z) – imaginary part of a complex number

arg(z) – complex number argument

7. Fourier transform:

U:=fft(V) – direct conversion (V- real)

V:=ifft(U) – inverse transformation (V- real)

U:=cfft(V) – direct transformation (V-complex)

V:=icfft(U) – inverse transformation (V-complex)

8. Correlation function – allows you to calculate the correlation coefficient of two vectors vx and vy and determine the linear regression equation:

corr(vx,vy) – correlation coefficient

slope(vx,vy) – slope coefficient of the regression line

intercept(vx,vy) – initial coordinate of the regression line

9. Linear interpolation:

linterp(vx,vy,x)

vx,vy are vectors of argument and function values. x is the value of the argument,

for which interpolation is carried out

10.Function for determining the roots of algebraic and transcendental equations:

root(equations, variable) – the value of the variable when the equation is zero

11.Random Number Sensor:

rnd(x) – random number with uniform distribution from 0 to x

12.Integer part of variable:

floor(x) – nearest smallest integer

ceil(x) – nearest largest integer

13.Isolation of the remainder:

mod(x,y) – remainder of x divided by y

14.Stop iteration:

until(x,y) – when x<0

15. Conditional jump function:

if(condition,x,y) – if the condition is true, then the function equals x, otherwise y

16.Single function (Heaviside function):

Ф(x) – if x>0. Then the function is equal to 1, otherwise 0

17. Logical expressions and operations. The simplest types of logical expressions are the following: logical constant, logical constant, logical constant, logical variable, relation expression. For example, for x:=0.5, the relational operators assign L to true or false (1 or 0):

L := x£1 L=0

L := x³1 L=0

L := x»1 L=0

L := x<1 L=1

L := x>1 L=0

18.Functions defined by the user. The user can independently determine the functions he needs that are not among the built-in functions of the package.

Entering text

The text placed on the worksheet contains comments and descriptions and is intended for reference and not for use in calculations. MathCad determines the destination of the current block automatically the first time you press the SPACEBAR. If the entered text cannot be interpreted as a formula, the block is converted to text and subsequent data is treated as text. Create a text block without using automatic tools allows the command Insert > Text Region (Insert> Text block).

Sometimes you want to embed a formula inside a text block. To do this, use the command Insert > Math Region (Insert> Formula).

Solving equations and systems To numerically search for the roots of an equation in the MathCad program, the root function is used. It serves to solve equations of the form f (x) u003d 0, where f (x) is the expression whose roots must be found, ax is the unknown. To search for roots using the root function, you need to assign the initial value to the desired variable, and then calculate the root using the function call: r oot (f (x), x). Here f(x) is a function of the variable x used as the second parameter. The root function returns the value of the independent variable, which sets the function f(x) to 0. For example:

If the equation has multiple roots (as in this example), then the result given by the root function depends on the chosen initial approximation. If you need to solve a system of equations (inequalities), use the so-called solution block, which begins with the keyword given (given) and ends with a call to the find function (find). Between them are “logical statements” that set restrictions on the values of the sought quantities, in other words, equations and inequalities. All variables used to denote unknown quantities must be pre-assigned initial values.

To write an equation that states that the left and right sides are equal, use the Boolean Equals button on the Evaluation toolbar. Other logical condition signs can also be found on this panel. The solution block ends with a call to the find function, in which the required values u200bu200bare to be listed as arguments. This function returns a vector containing the computed values of the unknowns.

Plotting

To build a two-dimensional graph in the X-Y coordinate axes, you need to give the command

Insert> Graph > XY Plot (Insert > Graph> Cartesian coordinates). The chart placement area contains placeholders for specifying the displayed expressions and the range of values. The placeholder at the middle of the coordinate axis is for the variable or expression displayed along that axis. Typically a range or vector of values is used. Limit values along the axes are selected automatically according to the range of change of the value, but they can also be set manually. You can draw multiple graphs in one graphics area.

Analytical calculations

With the help of analytical calculations, analytical or complete solutions of equations and systems are found, and complex expressions are transformed (for example, simplification). In other words, with this approach, you can get a non-numeric result. In the MathCad program, specific values assigned to variables, while

ignored – Variables are treated as undefined parameters. Commands for performing analytical calculations are mainly concentrated in the Symbolics menu (Analytical calculations). To simplify an expression (or part of an expression), you need to select it with the corner cursor and give the command Symbolics > Simplify (Analytical calculations > Simplify). In this case, arithmetic operations are performed, common factors are reduced and similar terms are given, trigonometric identities are applied, expressions with radicals are simplified, as well as expressions containing direct and inverse functions (such as e Inx ). Some actions to expand brackets and simplify complex trigonometric expressions require the use of the Symbolics > Expand command (Analytical calculations> Expand). The Symbolics > Simplify command (Analytical calculations > Simplify) is also used in more complex cases. For example, you can use it to:

• calculate the limit of the numeric sequence given by the common member;
• find a general formula for the sum of members of a numerical sequence given by a common member;
• calculate the derivative of this function;
• find the antiderivative of a given function or the value of a definite integral.

Other possibilities of the Symbolics menu (Analytical Calculations) are to perform analytical operations focused on the variable used in the expression. To do this, select a variable in the expression and select a command from the menu Symbolics> Variable (Analytical calculations > Variable). The Solve command (Solve) looks for the roots of the function specified by the given expression, for example, if you select the variable x in the expression x 2 + bx + c with the corner cursor , then as a result of using the Symbolics > Variable > Solve command (Analytical calculations > Variable > Solve), will be all roots found: Other uses for this menu include:

• analytical differentiation and integration: Symbolics> Variable > Differentiate (Analytical calculations > Variable > Differentiate) and Symbolics > Variable > Integrate (Analytical calculations > Variable > Integrate);
• variable replacement: Symbolics> Variable> Substitute (Analytical calculations > Variable > Substitute) – the contents of the clipboard are substituted for the variable;
• expansion in a Taylor series: Symbolics > Variable > Expand to Series (Analytical calculations > Variable > Expand in a series),
• representation of a fractional rational function as a sum of simple fractions with linear and quadratic denominators: Symbolics > Variable > Convert to Partial Fraction (Analytical calculations > Variable > Convert to simple fractions).

Finally, the most powerful analytical calculation tool is the analytical calculation operator, which is entered using the Symbolic Evaluation button on the Evaluation toolbar. It can, for example, be used to analytically solve a system of equations and inequalities. The solve block is specified in exactly the same way as in the numerical solution (although the initial values of the variables can be omitted), and the last formula of the block should look like find(x,y,…)®, where the list of values to be found is given in brackets, followed by the sign of the analytical calculation, displayed as an arrow pointing to the right. Any analytical calculation can be applied using a keyword. To do this, use the Symbolic Keyword Evaluation button on the Evaluation toolbar. Keywords are entered through the Symbolics toolbar (Analytical Calculations). They fully cover the possibilities contained in the Symbolics menu (Analytical Calculations), while also allowing you to set additional parameters.

Programming

The most notable “highlight” of MathCAD, which was immediately appreciated by users, is the built-in programming language. MathCAD, in fact, does not have a built-in programming language, but simply removes the restriction on the use of compound operators in the body of algorithmic control structures selection and repetition . In addition, a loop with a parameter and an early exit operator break have been added. Algorithmic constructions and compound statements in the MathCAD environment are entered by pressing one of the seven buttons on the control panel:

 Add line if while for break otherwise

Add line – add a program line, loop body, alternative shoulder, etc.

– sign of assignment.

While – when this button is pressed, a loop blank with a pre-check appears on the screen: the word while with two empty squares. In the box to the right of while you need to write a Boolean expression (variable) that controls the loop, and in the second box (below while ) – the body of the loop.

If – allows you to enter an alternative with one leverage into the program.

Otherwise – allows you to turn an incomplete alternative into a complete one:

CD if A > B

EF otherwise

for – button for entering into loop programs with a parameter.

Break – a button for early exit from a program or loop.