_{}_{ }_{}
The Mathcad software package is frequently called a supercalculator
because it displays a numeric answer for almost any expression containing
constants, variables, operators and functions. To obtain the result you need
only type «=» after the expression:
125 + a^{2}
– sin (b) = 2.753
Of course, the variables included in this expression (a and b) should be defined as numeric
values beforehand. An assignment
(input) statement in the Mathcad environment is shown as «:=», and is often
typed with the «:» (colon) key.
Mathcad conveniently inserts the second symbol «=» itself, giving:
a: =
However, it is better to use the «=» key, rather than the «:»
key, when assigning a value to a variable in a Mathcad worksheet. If the
variable has not yet been defined, then Mathcad will automatically convert the
«=» operator (output) to the «:=»
operator (input). If the variable has been defined, then its numeric value is
displayed. By using the «=» key, it is possible to determine whether or not the
given variable is free
; i.e. neither defined by the user nor used internally by
Mathcad. This provides security against a number of potential mistakes. First, a system variable can be overwritten,
for example by typing å: = 5, m: =
1, A: = 2 (å – is the base of the natural logarithm, m and A are units of length and
current, respectively). Secondly, one may forget that the variable has been
already assigned, and assign a new value to it. It is usually not desirable for
a variable to have one value in one part of a Mathcadworksheet and another in a
later second part.
You can turn off the automatic replacement mode, when the operator «=» is replaced by «:=» (this hybrid of two operators is called a Smart Operator), by choosing “Options” from the “Math” menu, and selecting the “display” tab” (see appendix 1).
Note. The figure shows a Mathcadworksheet in a
mode when separate operators are displayed on a white background, while free
space in the document is gray. From this point on this mode will be used to
display Mathcadworksheets if it can help clarify the tip.
_{}_{ }_{}
Sometimes it is better to use the «®» operator (symbolic value output) instead of the «=» operator (numeric value
output). Figure 2
illustrates three reasons for choosing symbolic output:
Example 1: the «=» operator displays up to 15 decimal places in the mantissa, whereas the «®» operator displays up to 250 decimal places. (Numeric value output instruction in the Symbolic menu allows up to 4000 points).
Example 2: the «®» operator allows exact answers by outputting all significant digits (Example 2.2), or by representing a number as a simple fraction (Example 2.4).
Example 3: the «®» operator, in
conjunction with the expression k:=k (for symbolic mathematics, this frees a variable
from any numeric value), displays a numeric answer that also includes symbolic constants (this result can also be obtained by
simply inserting a variable after the answer, in the same manner as physical
units; see Example 3.3).
The operator for symbolic
calculation, «®», instead of numeric calculation, «=», can solve a
task where some of the variables have no numeric value – see Fig. 2b.,
which shows the solution of the “chemistryeconomics” task (If gold is selling for $320 per ounce, how many atoms
of gold can you buy for one dollar?).
After inputting the initial data Mathcad highlights the $
symbol (the $ symbol is entered using ShiftCtrlk) in red because it is an
undefined variable, with no numeric value. This is not a problem, however, if
the answer is displayed on the screen using the «®» operator, instead of the «=» operator.
_{}_{ }_{}_{ }_{}
Sometimes it is necessary to combine symbolic and numeric output operators in one expression. The figure shows three example applications:
Example 1: in an arithmetic expression it is possible to see the answer both in the form of a simple and a decimal fraction.
Example 2: when solving an equation one can see both exact
and approximate, answers.
Example 3: An expression can be simplified before calculation.
This operation can be performed automatically by the “Optimize” mode, but
Mathcad only shows the numeric answer. In our example we once again observe
both analytical and numeric answers.
_{}_{ }_{}
Many users do not know that the basic operator in
Mathcad (see Tip 1), «=», the operator for numeric output, has two operands
rather than one:
˜ = ˜[˜]
The Mathcad user fills in the
first placeholder with an algebraic expression, and the numeric value appears
in the second placeholder. The third placeholder may contain (square brackets indicate that this second operand is
not necessary) any constant or variable that has been defined earlier.
Usually system variables or
builtin Mathcad physical units are inserted in this placeholder:
The figure demonstrates another two examples:
Example 1: In the
Russian cartoon “Thirtyeight parrots” the length of a Boa is measured in
Parrots, Marmosets and Elephants. If to assign (to select) animal’s size, than
Boa will “fit” in 38 parrots and one more parrots wing, in 5 Marmosets or in 2
Elephants. «You see, in parrots I am much longer!».
Example 2: The
solution of a trigonometric equation quite often contains the number p. It is possible to place this number in the
second operand of the «=» operator. This can be used to obtain the exact
answer, and also to find all the answers.
PS
The above figure represents a typical fragment of
a Mathcadworksheet: a user types some text describing a variable (Time), inserts a variable (t), assigning it with a
numeric value and possibly a unit (360 sec), and then displays it
with the same or some other (min) units. One can pack the whole
Mathcadworksheet with such sets of three regions and solve a problem this way,
as shown. This methodology is inconvenient, however, when moving fragments to a
new location, because it is possible to lose regions included in the fragments.
Furthermore, if after movement the output operators are arranged a little bit
higher than the input operator, then the relationship of cause and effect will
be broken and the error message “This variable or function is not defined
above” will be displayed. (Unnumbered part of Tip: when creating a new
Mathcadworksheet it is worth placing operators in columns, with only one on a
line. In the final document you may convert this so that there are a number of
operators on one line of the worksheet, thus making it more compact).
Another method
of calculation is shown at the bottom of the figure. A comment was written with
six spaces on the end; then, at the center and at the end of this series of
spaces mathematical areas (select “Math Region” from the “Insert” menu) were
inserted. These mathematical areas were filled with input and output operators.
In this manner, the single “conglomerate” region obtained can be dragged from
place to place without any fear of losing one part. It is possible to transform
the three regions at
the bottom of the figure, constituting a certain fragment of the calculations,
into a single region: text including six mathematical areas. Although one could
try to force the whole calculation into one text region, however, such a region
becomes difficult to edit so it is important to know where to stop.
The above figure represents a typical fragment of
a Mathcadworksheet: a user types some text describing a variable (Time), inserts a variable (t), assigning it with a
numeric value and possibly a unit (360 sec), and then displays it
with the same or some other (min) units. One can pack the whole
Mathcadworksheet with such sets of three regions and solve a problem this way,
as shown. This methodology is inconvenient, however, when moving fragments to a
new location, because it is possible to lose regions included in the fragments.
Furthermore, if after movement the output operators are arranged a little bit
higher than the input operator, then the relationship of cause and effect will
be broken and the error message “This variable or function is not defined
above” will be displayed. (Unnumbered part of Tip: when creating a new
Mathcadworksheet it is worth placing operators in columns, with only one on a
line. In the final document you may convert this so that there are a number of
operators on one line of the worksheet, thus making it more compact).
Another method
of calculation is shown at the bottom of the figure. A comment was written with
six spaces on the end; then, at the center and at the end of this series of
spaces mathematical areas (select “Math Region” from the “Insert” menu) were
inserted. These mathematical areas were filled with input and output operators.
In this manner, the single “conglomerate” region obtained can be dragged from
place to place without any fear of losing one part. It is possible to transform
the three regions at
the bottom of the figure, constituting a certain fragment of the calculations,
into a single region: text including six mathematical areas. Although one could
try to force the whole calculation into one text region, however, such a region
becomes difficult to edit so it is important to know where to stop.
_{}_{ }_{}
The above figure represents a
typical fragment of a Mathcadworksheet: a user types a some text commenting
describing further actions a variable (Time), puts into calculationinserts
a variable (t), assigning it with a numerical numeric value and with or without
possibly a dimensionality unit (360 sec), and then «prints displays» it out and
accompanies it with the same or some other (min) dimensionality units. One can
pack the whole Mathcadworksheet with such sets of three operators regions and
solve a problem put by this way, as shown. But this technology methodology is
inconvenient, however, for when carrying moving fragments to a new place
location, because it is possible to lose operators regions included in this the
fragments «on the way». Furthermore, if after movement the output operators are
arranged a little bit higher than the input operator, then a
the relationship of cause and effect will be broken and the error
message “This variable or function is not defined above” will be displayed:
«This variable or function is not defined above». (Not Unnumbered piece part of
Tip: when creating a new Mathcadworksheet it is worth to placeing
operators in columns, with only one on a line. In the ready final document you
may proceed convert this so that there are «from a line to a surface», placing
some a number of operators on one line of the worksheet, thus making it thereby
more compact.).
Another technology method of
calculation is displayed shown at the bottom of the figure: .
a A comment was written with six spaces on the end;
then, in at the center and in at the end of this chain series of spaces
mathematical areas (select “Math Region” from the “Insert” menu) there were
inserted mathematical areas (Math Region instruction in the menu Insert). And
these mathematical areas were filled in with input and output operators. Thus, In this manner, anthe single
obtained “conglomerate” region obtained can be dragged from place to place
without any caution fear of losing one part. So iIt
is possible to transform the three bottom operators regions at the bottom of
the figure, constituting a certain semantic fragment of the calculations, into
a single operator region: text including six mathematical areas. Although one
may could try to «push»force the whole calculation into one commentary text
region, however, but such a operator region becomes difficult to edit so: it is
necessary important to know where to stop.
_{}_{ }_{}
Very frequently variables in computation have a limited range of reasonable values. In this case it is expedient to test correctness of entered value. The figure «asks» user to assign variable t with a value of room temperature. Let us assume that it can not be less than minus 20 degrees Celsius (at this point addition statement is functioning as logic addition: AND) and more than 40 degrees Celsius (units of measurement — are accepted by default in this example). And if the user makes an intentional or an accidental mistake, then variable t takes a string value and blocks further numerical computations. (Expression containing function if can be enclosed in collapsing frameworks in order to protect user from embarrassment.)
_{}_{ }_{}
To put into calculation a vector or a matrix the Mathcad users usually resort to the instruction Matrix… in the menu Insert (or press button with the matrix image). This technique displays a number of disadvantages. First, in this case the size of a matrix is bounded by the value of 100 elements, while any matrix can keep up to 8 millions elements in Mathcad. Many users solve this problem by creating several matrices and «gluing» them together into a large one using stack and/or augment operators. The second disadvantage is in that all elements of a matrix defined through the Matrix instruction are unfilled. In this case matrix elements have to be inserted manually. And maybe this is a reason for a limitation of 100 elements, which can be inserted manually yet.
Solution of this problem is
shown in the figure: a matrix containing any standard element (we have set it
as 1.0) is automatically created and displayed. This
matrix can be of any size. Then it is copied to the right operand of the
assignment statement and subsequently edited. (We have assumed here, that the
matrix elements — are numbers ranged from 1 to 2. We should not type units and
points manually — it is sufficient to edit zeroes. Through the use of function Matrix it becomes possible to record various numbers in such
semifinished matrix). (Not numbered piece of Tip. It is better to insert such
matrices into a Mathcadworksheet by introducing a table from Excel.)
_{}_{ }_{}
There may appear some difficulties not only at input of a bulky matrix (see a piece of Tip 7), but also at displaying its elements. By default there is displayed only upper left corner of a bulky matrix in the form of a table. Its sidehead keeps line numbers and headline keeps column numbers. A matrix which is not entirely displayed has vertical and horizontal scrolling regions with a runner to the right and at the bottom of a table. To look through the whole matrix one should move the runner. (Scrolling technology). Another possibility — output of a bulky matrix not in the form of a table but in the form of a matrix. In this case you can look through it by scrolling the Mathcadworksheet window itself.
And if a bulky matrix has to be printed out (unfortunately, a sheet of paper has not scrolling regions), then we can recommend to print this matrixtable several times, having preliminarily displayed its separate regions with the help of the runner (see the figure).
_{}_{ }_{}
Beginning with the 7th version the Mathcad environment
does not strictly require a multiplication
sign to multiply a constant by a variable. This method seemingly brings
Mathcadworksheets more closer to documents written in
handwriting: 2 à, not 2 × à, 5 kg,
not 5 × kg and so on.
But
here are three reasons against this technique that runs counter to the
programmer tradition to put a multiplication sign (asterisk) between two
factors: 2 _{* }à, 5 _{* }kg
and so on.
Firstly; speaking about numerical rather than symbolical mathematics of Mathcad, design 2 × à is more or less clear: two is multiplied by variable a. And expression 2 a carries (at least, superficially) some ambiguity: this is both the product of 2 by a and a postfix operator named a, which operand is a constant (two).
Secondly; the behavior of
expression 2 a is not known in the case when this construction is
applied in symbolical mathematics.
The figure illustrates the third «contra» argument. If two is reduced by unit, then it should remain unit, but by no means two and furthermore with minus? The answer has appeared to be evident, but this simplicity is, indeed, «worth than larceny». The point is that not unit is subtracted from two, but two is multiplied by minus unit in the given example. This service of Mathcad (programmer does not have to enter a multiplication sign) has turned out to be an ill turn (involuntary pun). There is another ambiguity: what is k a — is that variable k, multiplied by variable a, or is that a variable, with a name of three symbols, where the second one is a space.
_{}_{ }_{}_{ }_{}_{}
The Mathcad environment offers the builtin function Find for solution of the system of algebraic equations and inequalities. A system is commonly solved this way: the first approximation to the system is being set with the help of assignment statements «:=». Then the key word Given is being written, a system of equations and/or inequalities is being set (it is not allowed to use only Boolean operator «¹») and, at last, function Find is being called. This function returns values of its arguments, converting a system of equations into a system of identities. The answer is presented as a columnvector. Besides, in a number of cases in order to solve the system the standard values of builtin variables TOL and CTOL should be changed. These variables influence on the accuracy of calculations. Very often this technique requires successive approximations to the right answer (and there may take place not only one approximation). In this situation it is advisable to change the abovementioned sequence of operators (but not sequence of their satisfaction) and to use the successive approximation technique, described in a piece of Tip ?. This technique implies that the first approximation is «omitted» by means of «º» operator, and other initial settings are placed more closer to the answer. If the system is bulky and display can not find room for it then the shown sequence of operators will obviate the necessity for scrolling a Mathcadworksheet to adjust input data and to browse the answer. (Note. The described successive approximation technique is impossible to be automated through programming since the key word Given is not inserted into the program body).
_{}_{ }_{}_{}
Many Mathcad functions have a vector or a matrix (array) as their argument. Vectors and matrices represent a collection of scalar values contoured with brackets. On the other hand, brackets also are an attribute of the function call operation. This feature leads to appearance of double brackets at the conventional call of a function with a rowvector argument (see the first operator in the figure). Double brackets can embarrass a user who may try to remove a «superfluous» pare of brackets not understanding a reason why it is impossible. The way out — lies in the call of a «matrix» function in the form of a prefix operator, which operand does not need a «brackets’» design (the second operator in the figure).
_{}_{ }_{}_{}
The Mathcad environment does not present builtin
Boolean (logic) functions And and Or, which are an integral part of
all programming languages and which support implementation of all sorts of
logic constructions, cycles and alternatives. And what is to be done here!?
Firstly, it is necessary to recollect, that «logic AND» and «logic OR» have
also such names as «logic multiplication» and «logic addition»: the given
functions are realized through customary multiplication
and addition operators (see item 1 in
the figure).
Secondly, logic And and logic OR functions can be defined (see item 2 in the figure). In so doing there can be defined any quantity of Boolean arguments — that is elements of associated vectors of multiplication and addition operators. (Not numbered piece of Tip. It is possible to define two pairs of functions with various names ÈAnd — ÈËÈOr to satisfy both Slavophiles and Westerners.)
Thirdly, the Mathcad environment
already has builtin functions that are well suited for logic tasks, — they are
min and max (see item 3 in the figure).
Moreover, they are also convenient for the following reasons:
·
It is not necessary to «litter» a Mathcadworksheet with supplementary
builtin functions AND — OR;
·
Functions min and max accept both matrix,
columnvector and rowvector arguments;
·
Functions min and max accept not only Boolean expressions (yes – no, 1 – 0) as
their arguments (array elements), but also real
expressions, varying smoothly from zero to unit. Thus it is possible to
operate not only with precise but also with fuzzy
logic.
_{}_{ }_{}_{}
Mathcad offers user an opportunity of renaming and even redefinition of builtin functions. Renaming seems more or less
intelligible (the old substance in the new frame): a new user function is being
defined which is completely or partially coincident with one of the builtin
functions. What is the reason for that? Items 1 and 2 of the figure illustrate
two examples of the builtin function renaming. First, it is possible to
replace a short English name of the function with a more integrated national
one (item 1). We obtain a certain hybrid of a function name and a comment.
Renamed function in item 1 is being called as a prefix operator (fx), that makes possible to get
rid of brackets and to make the namecomment absolutely natural. This effect is
also aided by three spaces in a new function name (see a piece of Tip 14).
The opposite object is being
achieved in item 2: the builtin function name (augment  the «horizontal» confluence of two matrices) is abbreviated to one symbol. It allows drastic reduction of the program size
because this program use the renamed function
repeatedly.
Item 3 demonstrates redefinition (the old substance in the new frame) of the builtin function stack to visualize its essence. Function augment, as noted above, accomplishes the «horizontal» confluence of two matrices – its arguments are positioned also «horizontally». Function stack is dedicated to the «vertical» confluence of two matrices but its arguments are positioned still horizontally. Redefinition of function stack – replacement of two arguments by one columnvector with two elements – restores «geometrical» logic of two functions for matrix confluence described above.
_{}_{ }_{}_{ }_{}_{}
The most significant distinction between the Mathcad
variable names and their analogues in conventional programming languages is
that variable names in Mathcad allow Greek letters and subscripts.
Programming environments always
place certain restrictions on the
variable (function) name. As compared to conventional languages Mathcad has
less restrictions: the variable name in Mathcad can include Greek letters
(Cyrillic letters deserve particular investigation – see a piece of Tip ?) and subscripts. All these peculiarities of Mathcad
enable names assigned to different variables long ago in mathematics (p, for instance), physics, chemistry etc. On the
other hand, Mathcadvariables have, in a manner of speaking, a bad «heredity»
preventing the variable name from insertion of some symbols: «$», «&», «?» etc. The point is that these and other symbols (keyboard
keys) are loaded with a purpose of input in a Mathcadworksheet of sum
operators («$»), integration operators («&»), differentiation («?»), product («#») etc. But, if you are eager for that, it
is possible to enter special symbols and spaces into a name of user’s function.
And, moreover, Mathcad permits such «wild» name of a variable as a space or a
chain of spaces.
This technique of the restriction removal from the variable (function) names has its own history. Tip ? recommends to use string variables — series of symbols framed by inverted commas — for comments of the Mathcadprogram operators. Such series may include spaces and other symbols («$», «?», «&» and so on). Sometimes when editing such Mathcadprogram there may happen «a glitch», that will result in a loss of inverted commas by string constants. Constants will «turn red» indicating an error situation. But every cloud has a silver lining — it is possible to take advantage of this situation (transformation of a string constant into the variable name), and that is described in the figure. The «ablush» series of symbols should be copied and subsequently utilized as a name of a variable or a function. The story is to be continued in the next piece of Tip.
_{}_{ }_{}_{ }_{}_{}
Previous piece of Tip shows how to lift some
restrictions from the Mathcad variable names — for example, how to insert
special symbols and spaces into a name. But some restrictions on the variable
names still remain. In particular, it is impossible to start a name with a number. But…
It is meant an Arabic number (by
default).And there also exist Roman
numbers apart from Arabic ones. The figure illustrates solution of a
conventional linear programming task: a furniture factory can produce two
models of chairs at the cost of 70 US dollars and 12 Euro. On this order human
and material resources are allocated. Besides, quantity of boards, cloth and
time for producing of each chair is known:
Chair 
Board consumption, meters 
Cloth consumption, square meters 
Time consumption, manhours 
The first model 
2 
0.5 
2 
The second model 
4 
0.25 
2.5 
Resources 
440 
65 
320 
The question is
to project manufacture of chairs so that their cost is highest possible.
There are two unknown variables
in this task which are enumerated and have special symbols within their names
(minus sign and space): Ist chair and IInd
chair. Special
symbols are also applied for user units of measurement: physical (length and
area), financial (US dollars and European currency), calculating (pieces) and
mixed (manhours). American currency unit is put into calculation on the
principle «Time is money»: the given calculations does not use a physical
quantity «time» and it can be temporarily «loaded» with another duty.
Certainly, it is easier to write down: $US := 1, and pieces := 1 (our pieces are «attached» to grammolecules, which are
also not equipped at the given calculations), but it is fraught with such a
mistake:
$US + pieces = 2
There should
appear not a numerical answer (two), but an error message «Incompatible
dimensions».
Physical and other quantities
are used in the described calculation not only for making it more «readable»
but also for the dimension conformity control in the inserted formulas.
_{}_{ }_{}_{ }_{}_{}
Authors have published their
technique of insertion spaces and special symbols into the variable names,
described in the previous piece of Tip, on the Collaboratory
site (http://webserve.mathsoft.com/mathcad/collab) of Mathsoft
(Mathcad designer firm). That was quite intriguing:
I have spaces in varname := 10
Can you do it? := 2
I have spaces in varname
+ Can you do it? = 12
There were two kinds of
responses to this quiz:
a) How do you contrive to do
that?
b) I have been inserted special
symbols into the variable names for a long time, but I did not know, that it is
possible to enter spaces too.
The second response leans upon the fact, that one may use special chord (Shift+Ctrl+k) for names of functions and variables to block the Mathcad system perception of special symbols (space, $ and so on) as instructions (the name envelopment with cursor) or operators (sum, differential and so on). The figure displays definition of the variable with two spaces and «$» symbol within its name (Cost in $US). And the second variable with a space inside (Russian ruble) is obtained by editing the first one. It is impossible to insert spaces and special symbols at editing. To do that the above mentioned chord is required.
_{}_{ }_{}_{ }_{}_{}
The previous piece of Tip recommends to
write down not Arabic (it is impossible) but Roman numbers starting the
variable name to enumerate variables.
But many people can count Roman
only up to twelve (lets recollect clockdial). The
figure shows the function of Arabic to Roman numbers conversion. (We face Roman
numbers very frequently, keeping financial payments: amount of money — is an Arabic number, and its cash fragmentation — a Roman
one. Our program will prove useful to the automatic teller operation, for
example).
But it is not the very purpose
to cite this program. The object is to give the reader another piece of Tip.
A lot of Mathcad builtin
functions and operators have their inverse analogues: sin ¾ arcsin, å^{x} ¾ ln(x), differentiation
— integration etc. Producing a pare of user functions (direct — inverse), one
may act in a such way: produce the first function, and
define the second (inverse) function employing the first one. If the function
has a real argument then the task is reduced to the equation root search, and
if argument is integer, the task may be solved through selection.
Apotheosis of the technique of
insertion special symbols and spaces into the variable names — is a user
variable or function, with a name of single
space. The question is, what can this variable or function
give a user except a headache.
The figure illustrates operation
of such anonymous function. This function returns a Roman number, if its
argument is an Arabic one, and, vice versa, it returns an Arabic number, if its
argument is a Roman one. Single function incorporates both direct and inverse
algorithms. The given function determines the direction of conversion
identifying argument’s type. If it is of string type (if IsString — see the figure), then Arabic
number is searched, otherwise (otherwise) — a Roman one.
The anonymous function allows
not only recalculation without overloading a Mathcadworksheet with unnecessary
words and symbols ("XXV" =25 is clear without any comments),
but also simulation of calculations (subtraction, root extraction, sine
computation) with Roman numbers (see the end of the figure). The focus is that
our function is called not conventionally, but in the form of prefix and
postfix operators: there are no brackets framing an argument, and the symbol of
operator itself is invisible. Thus it leads to the absolute illusion of Mathcad’s ability to operate with Roman numbers without any
supplementary tools — operators and functions.
There follow some pieces of Tip
from the figure:
1. Sometimes it is expedient to give an
invisible name to an object of a Mathcadworksheet. There can be a space or a
chain of spaces.
2. In specific cases it is expedient to combine
direct and inverse calculation algorithms into a single function. The reason is
that these algorithms may have the same base (our pairs of Roman and Arabic
numbers, for example).
3. The function displayed in the figure can
appear useful for a partial encryption of messages. For instance, you may send
such a message to your trade agent: «Minimum price is MM, and maximum — MMCD».
If you apprehend that the competitor, you protect the message by encryption, is
acquainted with Roman numbers, then another pair of numbers may fit: Arabic
numbers are, for example, Fibonacci numbers, (1, 2, 3, 5, 8, 13 and so on indefinitely),
and their Roman analogues —are their serial numbers («1», «2», 3», «4», «5»,
«6» and so on indefinitely).
_{}_{ }_{}_{}
The reader has likely already noticed that some pieces of
Tip in the book interfere each other. The Tip 11 has
recommendations to exclude
superfluous brackets from Mathcadexpressions. And now we will discuss insertion of auxiliary brackets.
The 1st
item in the figure once more time notes that the Mathcad environment, as well
as all other programming environments and mathematics on the whole, value
involution operator «superior» to multiplication operator, which in its turn,
is valued «superior» to addition operator. These brackets once again accentuate
the given hierarchy of operators, which can be familiar not to everyone (see
example 2 in the figure, a piece of Tip ?).
Item 2 by means of function
(treelike operator) augment simulates a reshuffled pack of cards — a
rowvector with 52 elements (cards). In the pack simulating «tree» brackets
look far from superfluous (compare items 2.1 and 2.2).
In the 3rd item a Boolean
function Verdict is formed, which returns results of voting (the
participant votes (1 — pro, 0 — contra) are stored in a vectorargument X): verdict is approved when more than two thirds of voters vote «pro»
(function mean returns an arithmetic mean of the array
elements). Brackets here also stress an algorithm of function operation and the
satisfaction sequence of operators «>» and «:=».
_{}_{ }_{}_{ }_{}_{}
Sometimes user of the finished
Mathcaddocument has to input not a simple value of the input variable, but a
value with a fixed dimension of a
physical quantity. Input of a dimensionless quantity or a quantity with another
dimension should result in an emergency halt of the Mathcadworksheet
execution. Such scenario is realized by operators of the figure: user should
set a length into the variable d, i.e. he should set a constant multiplied by either a builtin or user
unit of length. An input dimension is checked as follows: variable d (it deserves an individual examination) is firstly raised by and
immediately reduced by a unit meter (m). The value of the variable d does not suffer any variations
but, in the case that the length is added by anything else, there occurs an
error. The focus of the displayed Mathcadworksheet is in that it contains two different variables of the same name d (it is feasible in the Mathcad
environment – see a piece of Tip ?.?.). To avoid
possible muddle one may give another name to the second variable — D, for example.
_{}_{ }_{}_{ }_{}_{}
Mathcadworksheet in the figure of a piece of Tip 15
solves the linear programming task. Many mathematical program packages (Maple
V, for instance) offer graphic facilities for visualization of a such task: a plane polygon is constructed edging the
feasible solution area of the task.
The Mathcad environment does not
offer special visualization facilities for solution of the linear programming
task. But with a certain skill this problem is solvable by means of a
conventional Cartesian diagram – see the figure. The essence of the problem is
described in a piece of Tip 15.
To solve the linear programming
task graphically there are defined two functions Constr
(Constraints) and ÖÔ (criterion function, Russian ‘Öåëåâàÿ
Ôóíêöèÿ’) with one argument Chair1 (quantity of chairs of the first model[1]).
Application of symbolical mathematics at the function output is dictated rather
not by needs of inequality solution (solve) — that is easy manually, it
serves for the graphical solution essence illustration: straight line of the of
criterion function slides upwards (animation
of Mathcad is very pertinent here) — solution will be achieved at the moment
when the straight line «takes leave» of a polygon. The graphical solution in
question both suits for an integer task
(a polygonal line is substituted by a chain of points) and for a nonlinear task (line segments are
replaced with portions of a curve: convex or concave).
_{}_{ }_{}_{}
The given piece of Tip extends the subject of the Mathcad nontypical graphics,
started in the previous piece of Tip.
Mathcad (as well as, however, almost all mathematical packages) offers the threedimensional diagram coloring facilities: for example, surface vertexes can be colored more «warmly» while a concave remains more «cold». Unfortunately, this principle cannot be applied to a twodimensional diagram. But if something impossible is very desirable, then it becomes possible. The figure exhibits a single argument function diagram, so that — see comments to the right of the diagram. Unfortunately, this book is not colored, but the reader can trust the author, that this line on the diagram is displayed with all rainbow hues. The trick of this figure lies in that it presents not a Cartesian diagram but a colored surface, turned to a spectator in a special way (with one «side»). It is worth to hide operators and the forming matrix Ì, which elements — are values of the function under analysis, by locking up an appropriate area (see the top of the figure). This operation produces an absolute illusion of a colored Cartesian diagram.
(It is expedient to «pull»
operators, the forming user function y(x) and diversity limits of the
diagram (x _{íà÷}x _{êîí}) up to the diagram. Operator «º» (global assignment) proves useful here, it
spreads its influence not only downwards (that is executed by operator «:=»
(«semiglobal» assignment) but also upwards).
_{}_{ }_{}_{}
To solve the problem of this piece of Tip heading one should graph two Cartesian diagrams and verify a point of their intersection. But this task may appear arduous for systems are not consistently represented in a suitable for graphing form: y1(x):=…, y2(x):= …. Equation sets are generally assigned in a different way — f1(x, y)=0, f2(x, y)=0 — variables in this notation are very seldom dividable to reduce this task to a straightforward one:
x
+ y = 5 

y1(x):=
5 – x 

® 

y
= x^{2} 

y2(x):=
x^{2} 
The figure depicts this
problem solution: matrix M is filled up by means of two loops with
a parameter (x value and y value). The matrix elements display
status of equations on the xy plane: if selection of x and y
values shows any expression to reverse its sign in the given point, then
corresponding element of matrix M takes the value unit, and
zero — otherwise. We are scanning the diagram area as though as «popping up» (oscillographing — on
the level line diagram) our curves (at the center of Bernoulli lemniscate («entwined with ribbons»). How long will this
«scanning» take — this is another question. Constant 300 allows compromise settlement
between speed of the diagram construction and its quality.
[1]??? There is used an English (Chair1)
rather than Russian (Iûé ñòóë) variable name for the
Mathcad 8 pro symbolical mathematics is not capable of operating with such
variables.