One chapter from the book Mathcad 12 for Students and Engineers

7. Mathcad Application Server

7.1. Continuation of preface or conclusion of the previous chapters

The history of using computers for engineering and technical calculations is divided into three stages:

r    working with computer code;

r    programming in high level languages;

r    using mathematical packages such as Mathcad, Maple, MatLab, Mathematica, etc.


The list of the packages does not contain Excel that is still the most popular application for computing. Excel stands between the programming languages and the mathematical programs.

These listed stages (technologies) have not distinct bounders. Working, for example, in Mathcad we can call, if necessary, the user functions written in C (see ch. 6) which code has fragments in assembler. Apropos computers codes remain in the programmable calculators still widely used in scientific and technical calculations. We should rather speak here about the tendency which in particular shortens time of creating calculation techniques and mathematical models than about certain isolated stages of tool development for solving problems. This tendency results in excluding the programmer as additional and often muddled (in the view of applied specialist) link between a developer and a computer, increasing openness in calculations themselves when we can see both results and intermediate data and also all formulae.

We should note here one more aspect of the person-computer issue. The programming languages do not tolerate amateurishness of an investigator. That means programming demands involving of an investigator (engineer) that brings to skill loss in the basic profession. The mathematical packages, especially Mathcad, do not cause such dependence. One can postpone working with Mathcad to half a year, or a year, but does not loss the basic skills and if need be the posed problem will be solved without help of other programmers.

The way of computer using can be also divided into three historical stages:

r    batch processing, when one computer worked for many users that brought their problems written on card batches and other forgotten data mediums;

r    time of personal computers;

r    wide-area and local networks that, in essence, return us to batch processing on another level, more qualitative; input data and results transfer on the Internet as e-documents not written to the paper. The calculations themselves can be paralleling (cluster, distributing computing)

And again, Mathcad was created as application alternative to traditional programming languages. Many specialists in particular subjects (physics, chemistry, biology, mechanical engineering and others) and students cannot use computer effectively though difficult programming languages. Mathcad allow us to solve wide range of scientific, engineering and educational problems without using traditional programming.

Today the situation has notably changed: as a rule, a student starting education in his future profession knows well one of programming languages and can solve their problems with studied programming application. In this case Mathcad may be unnecessary. Although, Mathcad has some features which not only enable surviving but also make it popular among experienced programmers.

The point is that Mathcad allow us to speed up definition and solving a problem. There was such a dash when high level programming languages (Fortran, Pascal, BASIC etc.) substituted for computer codes. Changing languages for Mathcad we remove the additional link between a computer and a specialist, a programmer.

It is worth using Mathcad to define and checkout a mathematical model even if a user knows the programming languages well. The developer group under the guidance of the Author created and sells successfully the program package WaterSteamPro designed for computing heat and physical properties of water and steam, the basic heat carrier in thermal and nuclear power stations, heat supply systems of cities and settlements ( The final version was written and compiled in Visual C++ (see sec. 6.9), but this project could not be done without previous analysis of the formulae and algorithms in Mathcad.

No rose without a thorn. The main limitation of mathematical packages is that, as a rule, they cannot generate exe-files which start without progenitress program. In particular, that prevent from dividing people working with computer into users and developers. Those using Mathcad occupy natural economy: work out calculation techniques only for personal use or for circle of Mathcad users. We could give that only to users having installed Mathcad. Such a user would not buy this file but will try to recreate the necessary calculation.


It is a question of small calculations, which creation and checkout time is comparable with time for search of the ready-made worksheet, installing and study of the new program. Although, large calculations hardly pave the way on the market because we can always extend and modernize own worksheet and not others. Here we can draw an analogy with another intra-Mathcad situation. Sometimes it is better create a function instead of searching that ready-made in the labyrinth of Mathcad built-in function. Fig. 7.16 illustrates this thesis in which the cumulative interest is computed via user algorithm and not by built-in function hidden among Finance group.

We could sell a Mathcad worksheet to a user who does not have installed Mathcad and has not studied it with the load: installing required Mathcad version that often results in changing of Windows or even hardware. Besides it is necessary to study Mathcad

Mathsoft Engineering & Education, Inc has changed this abnormal situation.

First, Mathcad Explorer, free crippled version, was released together with eighth Mathcad version that enables us open the worksheets and compute but does not save or edit them (read-only version). Mathcad Explorer could be downloaded from the Internet.

Second, tools for publication Mathcad worksheet online were developed strongly. The main Mathcad user is educational branch where the way of obtaining a result, studying calculation methods, is more important than a result itself. In particular, Mathcad 2001i was aimed to that which letter i means interactive.

Nevertheless all these steps were incomplete. It is better to install Mathcad itself than download rater bulky Mathcad Explorer, the crippled version. On the other hand, we want not only read Mathcad worksheets accessed from the Internet, or rather html or MathML copies, but change inputs and see (print, save) new results.

The quite clear solution of this problem came from the Internet too.

Mathsoft released so called Mathcad Application Server (MAS) at the end of 2003, home page at, the server, that allow us to run Mathcad worksheets and call them distantly on the Internet.

MAS enables us to solve the following problems:

r    There is no necessity to install required version of Mathcad, determine whether you have a virus, run applied mcd-files. It is enough to access the Internet and call MAS over the Internet Explorer browser (version 5.5 and later). That gives the illusion of opened Mathcad worksheet in which we can change inputs and obtain (print, save on a disk) the results. The calculation technique (a set of formulae in tradition mathematical notation but not as a program, a feature that makes Mathcad so attractive) and intermediate data could be displayed or hidden completely or partially (sell of results but not the technique).

r    New calculation techniques become accessible at once to every member of the Internet commodity. We should only inform the possible users of correspondent IP-address. To turn the calculations into the article we can administrate site, make it paid (partially paid, reasonably paid), place banners round the references.

r    Any mistake, misprint, assumption, defect, noted by developer or by a user, could be corrected at once quickly and imperceptibly for the users. It is also possible to extend and modernize a worksheet imperceptibly for users

r    MAS remains tradition option of downloading the worksheets from server to improve or extend them. For that we should reference them correspondingly. Thus, the site of this book references, as was noted in preface, pictures (pic), Mathcad files (mcd), and MAS documents

MAS solve the problem of licensing cardinally: there is no need to buy expensive Mathcad or to palter and install an illegal copy, as well as to update or change continuously the program itself, Windows, and a computer; we should just call MAS. Only a developer of calculation techniques published on MAS should buy the expensive program.

It is also needless to study how to work with Mathcad worksheets. We should not be afraid to damage it: changing the inputs requires the methods that people had learnt long ago in various network forums, chats, network games.

This chapter tells how to adjust an existing Mathcad document to publish it on the Internet, the calculation techniques to make it usable both as WorkSheet and WebSheet.

7.2. Preparation of Mathcad document for publication online or from WorkSheet to WebSheet

We should rather title this section Adjustment of Mathcad document to publication The point is that many of the mathematical programs do not allow us to adjust the existing document, but demand that the document should be created for publication on the Internet from the start.

As a rule the Mathcad worksheets have the structure consisting from three parts (a kind of a triptych): inputs, formulas, and results. Fig. 7.1 shows such a structure in extremely simplified form: these parts are divided into three titled areas which could be operated independently -- Lock/Unlock and (or) Collapse/Expand.

Fig. 7.1. The structure of a simplest Mathcad worksheet

The structure of a real Mathcad worksheet is usually more complicated and has the fuzzy borders between these three areas: the result may be displayed just after the formula, the souse data may be duplicated in a summary table etc. If the area containing calculation itself occupies several pages it is usually collapsed during checkout to see the source data and the results at the same time. We may divide the worksheet into several areas, place the results between them and expand them in turn. Fig. 7.1 shows that a user changes the values of variables a and (or) b and obtains the result, the value of c. The user may extend the worksheet: define new variables, insert formulae and graphs etc. In that case, the user turns into the developer. The MAS technology divides people clearly into two categories.

The first stage of preparation is to indicate assignment operators (not only := and  ( global definition) but also so called Controls appeared in Mathcad 2001, see Fig. 1.13) for souse data adjustment. We should replace these operators with Web Controls. The reader knows the analogues of that by entering information on various Internet queries.

7.2. Web Controls the network elements of the interface

Web Controls appeared in Mathcad 11.1 Enterprise Edition and in Mathcad 12 (all realizations), see Fig. 7.2 that duplicate somewhere Fig. 1.14.

Fig. 7.2. Calling of the dialog box for inserting Mathcad network elements

A Web Control distinguishes from its standard analogue. We need not write or edit the programs in form of Active Scripting (JScript and VBScript) for its operating, see Fig. 1.16, 6.3, and7.21. Such programs are not desirable on the network because they often spread the viruses. Over that reason many of the users do not insert Controls into the worksheet but use := and  as before. Mathcad 2001i enables us to fix such scriptable components in opening worksheet in a fashion similar to Word or Excel. Fig. 7.3 shows Script Security tab from the References dialog box which enables three security levels: Low Security -- opens the worksheet with no protection against harmful scriptable components; Medium Security the user can choose disabling present scriptable components or not; High Security -- disables all present in a worksheet.

Fig. 7.3. Setting the security level in the Mathcad worksheet containing scriptable components

In Medium Security, opening the Mathcad worksheet containing scriptable components follows the prompt shown in Fig. 7.4.

Fig. 7.4. Setting the security level in the Mathcad worksheet containing scriptable components

For these reasons (threat of the viruses, increase of file size) it is recommended using Web Controls not only in documents converted for publication online but also in standard worksheets. Besides, Web Controls are more convenient comparing with standard Controls because setting the security level on such worksheet allow us to introduce the data into these interface elements but prevent us from touching the variable itself. If the worksheet contains Controls, both the access to the variable and changing its value are disabled (see Fig. 7.4a).

Fig. 7.4a.

There is one more reason that Controls with their scriptable components are useless. As we noted in the beginning of the book, Mathcad was created as a tool alternative to programming languages for users who cannot or do not want to program. As with Controls, we left something to come to it again: we shut the door on programming but it got in through the window.

After converting and publication on MAS the worksheet shown in Fig. 7.1 should look like that shown in Fig. 7.5.

Fig. 7.5. The simplest Mathcad document converted to operate on MAS

Fig.  7.5 shows that Text boxes substitutes for operators := and b:= .The Submit button was inserted additionally which default marking Recalculate. When this document is published on MAS the lines and comments "Input Data", , "Answer output", indicating areas boarders, should not be displayed. The area "Calculations" could be collapsed to hide operator : = a + b. The developer can hide part of the calculation online allowing a user only computing. On the contrary he (she) can display and highlight most interesting and important parts of the worksheet, for example, for checking the method of calculation as well as inputs. Opportunely, if the variables a and (or) b from Fig. 7.1 and 7.5 should be within defined range (for example, 0<a<3) it will be useful to insert a kind of check-point:

a := if(0 < a < 3, a, "Error!")

that blocks computing when the user enters wrong data purposely or unwittingly.


For that purpose a user usually inserts a slider but the list of Web Controls does not contain it.

It is better to insert such check-points above the results. That should block the result if a certain inputs combination gives wrong (unreal) result. That shows the worksheet containing design output of water treatment plant for power stations at It returns text Wrong source data, not a value, if the user has entered impossible data combination of designed station, for example, the station is nuclear and the fuel to be used is coal.

The name Text box is not quite right for Web Controls or rather it is right for the standard analogue, Controls. We can enter text constants and numbers, real (as in Fig.7.6) or complex (for example, 5+3i), through this network element. At that, the number should be entered in old format (DOS): +3 (+3instead of 103, see Fig. 7.6. If entered symbols are not like a number it is understood as a text. In the standard analogue of the Text box any symbol file is recognized as text that could be converted into the number if needed by built-in function str2num (see Fig. 7.21) from the String category.

Fig. 7.6. Entering constants through the Text box

Tom Gudman and the Author developed the technique of entering arrays (vectors and matrixes) and user functions through the Text box as shown in Fig. 7.77.9.

Fig. 7.7. Entering the vector through the Text box (mcd-file)

Fig. 7.7 shows that the symbol file entered into the Text box is converted into the vector by the user function Str2VMat. At that, any symbol differing from 1, 29, the point (decimal delimiter), and minus sign can be used as the delimiter. In this case blanks are used as the delimiters. We can change its number aligning these numbers across if, for example, we enter some vectors of the same size through several Text boxes located upright (see Fig. 4.17).

Complicating the method shown in Fig.7.7 it is possible to fill the matrix in by rows or by columns. If the matrix is square and its size is arbitrary we can enter it as a vector of the size n2 and than pack it up the square matrix as shown in Fig. 7.8.

Fig. 7.8. Entering the square matrix through the Text box

Another way to enter a matrix is to specify the number of rows and columns at first and than fill the matrix in through the Text box as the horizontal vector that converted into square matrix.

You can find the method of solving equations of the kind = at where the arrays A (the square matrix of the unknown quantity coefficients) and B (vector of absolute terms) are filled in by the technique shown in Fig. 7.7.and 7.8.


The built-in function vec2str is changed in Mathcad 12. Thus the program shown in Fig. 7.7 requires revision.

Besides, the problem of entering formulae through the Text box has been partially solved, particularly user functions. Thus, Fig. 7.9 shows entering function with one argument, on which we created a plot. The algorithm of converting text into formula is rather bulky and it is not represented in Fig. 7.9, being hidden in collapsed area "Expless Compiler". The same algorithm could be used for entering the variable not as a constant (for example, 1.25) but as expression (45/12+11) including defined before and built-in variables (for example, pi/4*d^2, where pi is build-in and d defined before, i.e. the user). If it is needed to make arguments of a user-defined function grouped in a vector we use the additional operator (X):=f(X0, X1, ...). For example, this method was used for computing of global minimum through genetic algorithm, //, which discussed in ch. 3, see Fig. 3.33.

Fig. 7.9. Entering the function through the Text box

You can see the example of work with the function entered through the Text box at This technique is limited because we cannot apply symbol mathematics to this function and include the variables defined before into it, still the list of its arguments could be changed or extended (see the example at

The following symbols and functions are acceptable in the Text box for entering formulae:

r    Arithmetic + plus, - minus, * multiply, and / divide.

r    Involution ^.

r    Mathematical constants e is the radix of the natural logarithm; pi p number. Other constants can be entered only if they are defined in the concrete worksheet.

There is another situation. To the left of the Text box we can place a user-defined function with a list of required constants and variables followed by definition operator, for example f(x,a,b,c):=. As was noted before, entering the number we use a period as decimal delimiter and letter e or E as decimal exponent: it is possible to enter 0.001, or 1E3, or 10e4.

r    Parentheses changing the order of operations: 2+2*2=6 but (2+2)*2=8. It is recommended that a user types the left parenthesis ( followed by a right one ) and then moves a cursor left to one position and enters the required expression. Thus we can control the number of initial and close parentheses in the expression (formula). We cannot enter brackets and braces.

r    Built-in functions and operators sqrt()  square root, abs()  absolute value, !  factorial, sin()  sine, cos()  cosine, tan()  tangent, asin()  arcsine, acos()  arccosine atan()  arctangent. It is possible to work with other functions if they have been defined before.


Fig. 7.9anew. Derivative what is it? (pic) (mas)

Fig. 7.9bnew. Integral what is it? (pic) (mas)

Fig. 7.9cnew. Input functions thru WebTextBox by Mathcad/Maple undocumented tools (pic) (pic) (mas)


The Reader may want to use the authors ideas on entering the formula through the Text box. For that, download the file from Internet description of MAS at and enter required changes into two functions VARS and Eval shown in Fig. 7.10 and 7.11.

Fig. 7.10. Source functions VARS and Eval

Fig. 7.11. Modified function VARS and Eval

Fig. 7.11 shows changes in functions VARS and Eval that allow us to form the function named lp1 (the left part of the first equation) having seven arguments x, y, p, a, b, ang and g. These variables are used in the problem (Fig. 7.12) which suggests a user form and enter the set of three equations with three unknown quantities describing the beam equilibrium(

Fig. 7.12. Entering the equation set through the Text box

If we open that WebSheet all six boxes will be empty. We should type left and right parts of equations there and push the button Ready. That WebSheet is aimed not for computing but for checking knowledge of students (also see sec. 7.8).

The very useful Mathcad feature is work with physical quantities (see sec. 1.4). Fig. 7.13 shows that operator :=123 mm was replaced by the Text box and additional definition operator (reassignment of the variable).

Fig. 7.13. Entering the dimensional quantity through the Text box

Dimensionless value is entered though the Text box into variable , at that the comment (mm) placed to the right of the Text box indicates that the variable becomes dimensional after execution of the second operator :=mm. Switches or Check boxes discussed below allows us to choose the units (Fig. 7.14 and 7.15).

Fig. 7.14. Entering dimensional quantity and choosing the unit (the area is expanded)

Fig. 7.14 shows the argument in switches (UnitP). It could be and should be hidden as shown in Fig. 7.15. For that we call the corresponding command from pop-up menu.

Fig. 7.15. Entering dimensional quantity and choosing the unit (the area is collapsed)

In ch. 6 we used the method of choosing the unit from the list (see Fig. 6.9) th show work of operator and function if.

The units are often used as comments in worksheets but not as multipliers that simplify and check computing. That is connected with following:

r    Many of the built-in functions cannot operate with dimensional arguments (see the article considering this problem at

r    Mathcad arrays (matrixes and vectors) operate only with dimensionless values or with quantities of the same dimension length, pressure etc.

r    Worksheets include so-called empirical formulae where the variables depend on the specific units but not on quantities that was discussed in sec. 1.4.

If a unit (for example, ) is used as a comment rather then a variable it is recommended inserting it into the calculation as a coefficient equal to one that completes evaluation operator := 1  C=25   . In that case the unit becomes floating, it moves and remains in the end of the value if the number of decimal places has changed (see Fig. 7.16 showing the problem from a Chekhovs story at

Fig. 7.16. A floating unit equal to one

Fig. 7.17-7.20 show dialog boxes to create and format Web Controls listed in Fig. 7.2: Text box, Check box, List box/combo box and Radio button group. Submit button was discussed previously (see sec. 1.7).

If there is only a few variants of entering information the value should be selected from a preset list (by a mouse) rather than typed through a text box (from the keyboard). We did it asking the user to choose one of three units, m, mm, and cm, but not type from the keyboard. If a list contain only two choices (yes or no, the alternative question) we can use a check box (entering the Boolean value), for three or more choices radio button group or/and list box. List box differs from Radio button only that it can hide a part of choices and display it by scrolling. If it is necessary to select not one but several values we may substitute a set of check boxes for that. Basically, a check box is more universal tool than a radio button, although it requires more complicated adjustment. A radio button always has an activated value thus it may prompt a user the solution that might be false. The check boxes may be empty that gives free choice to a user without any prompts, right or false. Besides, any distance is possible between the check boxes, they can be situated in any order in the worksheet but not only upright as radio buttons. Additionally, it is possible to set rearrangement of the check boxes in every call of the document. That also excludes preferences in choice. There may be few choices in the set of check boxes that conforms the developer idea of computing or checking technique.

Comparing a group of check boxes and radio buttons evokes memory of an old story. During the iron curtain the Author listened to Voice of America and other western radio stations pushing two frequency range buttons, SW1 and SW2, of the radio set Latvia simultaneously. The point is that the ruse shifted the frequency range from 25 and higher meters (that was jammed by security services) to 18 and higher meters (clear range). Thus, we can choose few buttons among real, not computer radio buttons.

Speaking of radio buttons and check box set we shall pose a problem similar to those discussed in ch. 6 about while and until loops: which is more important? A set of check boxes is more important than radio buttons because, first, a check box set allows us to choose none button or several buttons right up to all of them.

The dialog box shown in Fig. 7.17 and the similar (see Fig. 7.18 and 7.19) are displayed after pushing the button Next> in the right bottom corner of Fig. 7.2.

Fig. 7.17. The dialog box for formatting Text Box

Through the dialog box shown in Fig. 7.17 a user can change width a text box (it is equal to 18 in Fig. 7.17) or/and the maximum length of entered text (255 symbols). At that, it is noted that pressing <Enter> is a signal to transfer the changed data on MAS. I that case the button shown in Fig. 7.5 becomes unnecessary. But in that case it would not be excess to insert the corresponding comment. Otherwise a user may not see the result: a globe in the top right corner of a browser will not whirl.

There is own check box in the Check Box Properties tab (Fig. 7.18) which being enabling by a developer of MAS application transfer the changes in Mathcad document into the MAS. There are the same check boxes in the Radio Button Group Properties tab (Fig. 7.19) and the List/Combo Box Properties (Fig. 7.20).

Fig. 7.18. The dialog box for formatting Check Box

The check box returns zero or one to its variable (variable check in Fig. 7.18) depending on the state of the Web Control.

Comparing Fig. 7.19 and 7.20 we can see a counter Display height (rows) that fixes the number of elements displayed in a list at any given time. If this number less than the number of elements in the list they are displayed as a scrolling list box. If we set this number to one the list will be shown as standard combo box (see Fig. 7.22 and 7.23).

We can see all the elements (buttons) in the Radio Button Group. This is the only difference between the List box and the Radio Button.

Fig. 7.19. The dialog box for formatting Radio Button Group

Fig. 7.19 and 7.20 shows two ways of setup Radio Button Group and List/Combo Box see the check box Values equal Names. In the first case (Fig. 7.19) the value connected with the Combo Box or with the List (our unitP) receives a text name keeping in the corresponding cell of the Name column; and in the second case (Fig. 7.20) the value (number or text) from the cell of the Value column. Unfortunately, a user cannot type there a built-in variable or an expression but only constants. In the non-Web analogues of the Radio button and the List box such a formatting was made through programming in one of the BASIC versions, in VBS (Visual Basic Script)  Fig. 7.21.

Fig. 7.20. The dialog box for formatting the List box


Assignment of the values returned by the radio button or the list box to the Names but not to the Value (compare Fig. 7.19 and 7.20) may result to errors if the names contain reserved characters, for example, degree sign (<Alt>+0176). Creating the WebSheet for temperature computing the Author was worried with this error ( until he understood that the degree sign was losing (was used up) while transferring the data on the Web.

Fig. 7.21. An example of the program maintaining the List box

As was noted above, presence of the programs (macros) inserted into Mathcad worksheet causes us to refuse the Controls and replace them with the Web Controls. For that reason, the Web Control List does not contain such a convenient interface element as Slider. The Slider is convenient because it allow us to set with a mouse the required value within defined range and with defined unit. Nevertheless, we can simulate a slider (Fig. 7.22) formatting a list box accordingly, if we keep only one element in the box which we assign required number of the discrete values in the formatting table (in the columns Name and Value), for example, 0.1, 0.11, 0.12, ..., 0.2 as in Fog. 7.22.

Fig. 7.22. Simulation of a slider through the list box

Ideally, it is possible to design such interface of a MAS user that the user will not push a keyboard: he will work only with a mouse.

As we noted before, WebSheet may have not the Submit button. On the other hand, we may insert some of such buttons into designed document if it is bulky and the source data are entered in the different places. In that case it is advisable to fix these places with the Submit button. It is a good solution to divide the document into several parts and fix the end of each one with Submit button. Computing of the following parts will be enabled until the user enters required source data in the previous: check the solution and push next Submit button.

Those who designed a user interface in Visual C, Visual Basic, Delphi etc note that the MAS interface is rather scanty. We noted above that it has not the Combo box combining the text box and the list box.

Fig. 7.23 shows a way to combine the Text box and the List box and obtain the Combo box.

The trick in Fig. 7.23 is that the value in the text box is assigned to one variable and the value from the list box to another, hidden variable. The first or the second value may be assigned to the resulting variable depending on a user choice. A sign that it was chosen from the list box but not the text box -- there are no symbols in the text box. Such a box combining the text box and the list box is used in a document at A user is enabled to choose the filter diameter from the list (1.0, 1.5, 2.0, 2.6, 3.0 or 3.4 m) or type his own value. A reader understands that the solution shown in Fig. 7.23 cannot be considered as a complete one. Thus, we still need the Combo box.

Fig. 7.23. Simulation of a Combo box through the list box and the text box

There are other requirements. For example, MAS does not enable us to suppress some interface elements if a variable possess definite value. Partial solution of that problem is shown at and in Fig. 7.24.

Fig. 7.24. Suppressing of the text boxes

Fig. 7.24 shows the problem of converting the concentration of a solution from mass percent to titre or molarity. We use two formulae with the different sets of source data that requires or, otherwise, not require entering of them through the text box. In Fig. 7.24 we suppress the text box covering its text variable with operator  = with varying length, highlighted in black. Here we use such Mathcad feature as overlapping regions (see sec. 1.6).The check boxes of the titre (the concentration of solution expressed in mg/l) and molarity (the concentration of solution expressed in mole/l) are set thus their changes are transformed on the server right away that results in opening or closing corresponding text boxes of density entrance or/and mass of the solute. Fig. 7.24 shows three computing situations: the upper part is the WebSheet state after it being open on the Web; the middle part is computing of the titre; and the bottom part is computing of the molarity. There is also the fourth state: a user enables two check boxes accidentally or intentionally that correspond to initial state of computing.

Discussing limitations of Web Controls we should note that Controls were not created by Mathsoft but are standard tools for data transfer on the Internet, rather weak for the present time. They are half-finished products that require to be worked out. We can do that through programming only, through a script which see above. There is a magic circle and the problem is where we can tear it!

7.4. Comments in the Web Sheets

As was noted above we should to be lazy creating a Web Sheet and insert enough comments, text and graphic. They do not affect computing but help viewers and even the developer to understand it (see sec. 1.3).

Converting a worksheet for Web distribution we should examine this rule. The point is that a bulky document is decelerated on the Web and loads a server with superfluous nonspecialized work. For this reason it is worthwhile to place the main comments, the creation history, the detailed description, instructions etc, into a separate non-Mathcad file, for example, html-file created in Word or FrontPage. The Mathcad document itself should contain short comments and references to the bulky, additional comments that are opened in a new browser window. For the same reason it is not recommended inserting too much complicated plots. It is better to freeze static plots that do not change with the source data varying and insert them as pictures.

Publishing a document on the Internet we should think of making it polylingual. For that, we may duplicate all comments in some languages, in Russian, in English etc. Another way is to allow a user to choose the language (Fig. 7.25).

Fig. 7.25. Polylingual Mathcad document

The solution shown in Fig. 7.25 is the following: we entered the comments into the vectors and their elements are displayed depending on the chosen language (the first language corresponds to the first elements of vectors, the second language -- to the second elements etc). Also there is the third solution that allows a user to open some variants of a document (several files) with variables and comments written in different languages, for example Vinput and V. The Web Sheets at and were created in this way.


It is possible to make that the server application will feel what browser, Russian or English, touches it and open the Russian or English variant of the Web Sheet accordingly.

There is another solution shown in Fig. 7.26. Information representing also a part of Mathcad worksheet could be turned into the graphic files with different names (in Fig. 7.26 their names are Counter_Flow.gif and Direct_Flow.gif). Such pictures we can read from a disk and insert in any part of a worksheet following the calculation logic. The reader will find a virtual laboratory work concerning heat mass exchange at in which the student choice the heat exchanger (direct flow or counter flow) open a proper apparatus scheme.

Fig. 7.26. Interactive information change in the Web Sheet

And finally, a word about letters. Opening MAS applications on the Internet we can face the problem of Cyrillic character representing both in operators and in text comments. These problems are widespread representing of characters in wrong coding (abracadabra): the characters are not placed in a visible region but fall down behind the following operator (the problem common for the browser sets not only for Cyrillic characters). The abracadabra problem can be solved partly by addition of such notice inserted as a picture at the top: If coding of the Cyrillic characters is wrong change it pushing Encoding from the View menu. It is recommended that a user substitutes variable names (pictures) for text comments in which reserved characters are inserted after pushing <Ctrl>+<Shift>+<j>. We should remember that their number must be minimal, and it is better to type some blanks before and after such comment. We should debug a ready-made Web Sheet in computers which monitors differ in size and settings and in different browsers (Netscape, Mozilla etc., not only in Internet Explorer)

7.5. Inserting other applications

It is known that we can insert some fragments of other applications, Excel, MATLAB, LabView, into a Mathcad document and exchange data with these programs. The fragment of Excel is often inserted for easy entering and representing of the tables (vectors and matrixes, see Fig. 1.19) or for bringing its feature sets.

The list of such applications depends on the programs installed on the computer (worksheets) or on the server (WebSheets, Fig. 7.27 shows the dialog tab of inserting components into the Mathcad document).

Fig. 7.27. Dialog tab of inserting Windows applications into the Mathcad document

But we may publish the Mathcad documents containing such components on the MAS only if we have solved license problems with developers of corresponding applications. The programs were bought for using on a work station not for installing on the server and publishing on the Internet.

7.6. Names of variables and functions

Preparing a Mathcad document for the Web publication we can pose a problem that the name of a function or a variable working in the worksheet has failed while we open the document on the Internet. Usually that situation occurs if we use Russian characters in the names. It is not advisable to use Cyrillic characters in the working names of variables, functions, files and even in comments (see sec. 7.4). Nevertheless we have to use them, basically in special calculations in which one or another object has got customary Russian name. Some of them have their Latin analogues others have not. If we need Russian characters it is a good idea to smooth away the Russianness of these variables as was noted in Ch. 1. The Author noted that variables (hour), - (milligram-equivalents) etc fail while he open a Mathcad document on the Web: they became red and clicking on them displays the error message is displaying This variable or function is undefined. We can cure such variables starting their names from blank. They will have the same look (but will be shifted slightly to the right) and the document will work again. It is possible to cure such variable by changing its name via Edit | Replace clicking Find in Math Region.

We should remember that Mathcad really supports only Greek and Latin letters. Our ruses to heal reddening variable names that contain reserved characters (blanks) are non-documented. Therefore this technique may not work in next Mathcad versions. If we cannot do without Russian letters it is recommended that a user covers Latin names with the pictures of Russian characters, and MAS allows us to remove any restriction from the variable names. Thus, Fig. 7.28 shows computation of a temperature difference in which the variables contains tops, - and ~, subscripts, in and out, superscripts, 2 and x, located one over another without horizontal shift.

Fig. 7.28. Optional variable names on the MAS

The secret in Fig. 7.28 is that the real names of t1 and t2 are hidden and a user view pictures of the variables and the formulae. Such trick does not work in a Worksheet but is applicable to a WebSheet. As mentioned in sec. 1.22 the document requires minimum comments if the variable names are conventional for the specialists: it is quite enough to title the document and make reference to the description in HTML. Perhaps, it is superfluous because the variable names speak for themselves and for the document.

7.7. Problem of extensional source data

Working with Mathcad document opened on the MAS or on the application itself we can face with the problem of entering an extensional changing array of source data (see the example at in which a user should view and change values in dozens of text boxes before pushing the Recalculate button). Entry of such data via Web Controls is time-consuming and inconvenient. Working in individual computer (not on the Network) we can solve this problem saving the data to disk and reading it into the arrays via the READPRN function and others. This technique is difficult for work on the MAS and we can suggest another one. Before working on the MAS a user, for example prepares new source data in electronic tables (Fig. 7.29).

Fig. 7.29. Source data table for the MAS (small part is shown)

After preparing the data (for example, changing data of the previous connection with MAS which saved in the user archive) we can copy them (pushing <Ctrl>+<Insert>followed by <Shift>+<Insert>) to the long text box of the Mathcad document opened on the Network, one text box or several of them if the length of the file exceeds 255 symbols. After that we push the Submit button and the calculation operates with new source data. If the result is also extensional we recommend representing it as a table not as scalar values. The table can be easily copied from the WebSheet to transfer it to the user Mathcad document for analysis and redesign. At that, we should remember that scrolling of extensional arrays does not work on the Network. Besides, we cannot display nested arrays there. Such data should be prepared for display beforehand: insert some tables, expand nested arrays etc.

Suggested solution for archiving and entering extensional data in a WebSheet should be built in MAS. Many non-network Windows applications for calculation have the special commands New [Project], Open [Project] and Save [Project] in the File menu that allow us to work with an archive of source data, see Fig. 7.30 showing these commands (the menu and dialog windows of a Window application which save data concerning separate projects to a disk in files Sample1.rod, Sample2.rod, ... Sample8.rod).

Fig. 7.30. Menu and dialog window for opening calculation projects

Converting a worksheet to function as Web document we should choose start values of the source data. As a rule, WebSheet developer follows tradition of Mathcad with its basic interface operator := and creates it in such a way that the document contains common initial data that could be changed, edited by a user. On the one hand it is convenient: we can view a document right away and do not change anything there or change just some initial data. On the other hand it may result to errors if a user have not change required data and obtains wrong solution. Therefore it is recommended that the developer put a dash (-) into a text box but does not type standard value. That will disable calculation and thus demand that a user enters required data. For the same reason it is advisable to use check boxes instead of the list box or the radio button in creating data choice. As mentioned above we cannot choose none of the elements in a check box (clean page for calculation).

7.8 Knowledge checking via MAS

The problems represented on the MAS are aimed basically to practical problems. They are created in such a way that suggest a user to enter initial data via Web Controls, push the Recalculate button and obtain a result. But it is possible to set it for knowledge checking if we turn it inside out, such document shown in Fig. 7.12. It is acceptable to generate initial data and ask a user (a trainee) to enter required formulae. The result of calculation by these formulae is compared with the true one. We can check knowledge of corresponding process, equipment or technology on the base of the comparison. It could be used in education and for practical training and also as self-control. At that it is necessary to give the theoretical footing and references prompting a user to the right answer in the document itself or in the referenced worksheets. You can see the example of such WebSheet at which asks to define height and volume of the right circular cone by given geometry (Fig. 7.31).

Fig. 7.31. Knowledge checking via MAS: choice of the variant and entering an expression (mas)

In Fig. 7.31 point one suggests traditional choice the right solution from the list containing also some wrong solutions. This technique is obsolete. Point two asks to enter solution but not choose. At that, we can enter both variables (D, H, and i) and numerical constants.

Fig. 7.32. Knowledge checking via MAS: working out and solving an equation (mas)

The WebSheet at shown in Fig. 7.32 asks a student to solve a chemical problem on computer not by entering numerical constants as shown in Fig. 7.31 but by composing the required equation. At that, Mathcad with its procedures of finding a solution allows us to change method in one or another branch. Thus, similar problems are solved via proportions in schools. Having the method of finding a solution we can forget about primitive proportions and turn to the problem essence, to solve equation for conservation of substance.

We should solve the following problems in such documents (Fig. 7.31 and 7.32):

r    It is necessary to generate data within the reasonable range.

r    The initial data should be chosen from quite extensional table or created via true or pseudo random number generator excluding wrong data (such generator shown in Fig. 6.17).

r    Initial data may have different units that encourages a student to study some sections of metrology.

r    A trainee can choose a formula from the list (height of the cone, Fig. 7.31) or enter it in a text box (volume of the cone). These methods have their advantages and limitations. Choice of solution implies wrong variants. It is controversial point in methodology: a student may remember a wrong result from the list but not the right one. Entrance of a formula in the text box is rather inconvenient: we should enter the formula in the text mode basing on computer but not mathematical way of operator notation. There are some advantages in this method: a user studies some techniques of work with computer and special science at the same time. It is possible to enter numerical constants and the variables which keep them.

r    Comparing numerical answers of the user including those entered via formulae with true results we should take into consideration accuracy of mathematical operations. For example, the user may enter p equal to 3.14 that differ from the real value of this fundamental mathematical constant. A solution of this problem is to display not the message of the kind Right/Wrong but two values, users result and true result analyzed by a person.

7.9 Access to calculations via password

The problem of access to the MAS documents could be solved with traditional technologies used on the Internet: registration, password etc. These technologies could be applied to whole site or to separate calculations. For example, Fig. 7.33 shows calculation of the temperature in the condenser of a turbine which created in such a way that result is displayed only with proper initial data: at Pv=0.95 bar and =750 torr (mm Hg) the result will be Pc=4.99 kPa tc=32.8º etc, but the calculation is disabled with other data The user may view the WebSheet but not calculate. To make calculations the user with name Login should get the password from the developer and enter it in the corresponding text box.

Fig. 7.33. The document that requires password entering (mas)

Entered registration name and the password are compared with (operators or functions if) that keeping in the program and if they agree the calculation is enabled.

Thus, what should we do to make a Mathcad document accessible on the Internet:

1.        Edit Mathcad document in Mathcad 11.2 Enterprise Edition or Mathcad 12 (all versions): insert Web Controls instead of assignment operators, exclude or change superfluous comments, exclude formatting of some results etc. If the developer has no such versions he(she) may, for example, highlight these operators and ask MAS administrator make required changes (se Fig. 7.1 and 7.5)

  1. Send this document to MAS administrator, for example, to the Author of this book. It is better to place this WebSheet on two MAS, for example, also in Mathsoft library ( Beth Porter is the administrator of this site ( Thus, you can see the word double many a time at That means the corresponding calculation is duplicated on the mirror server. Of course, it is possible to acquire MAS for individual use. (See information concerning SoftLine, the distributor of Mathsoft, in the end of the book)
  2. After installing the WebSheet on the MAS check it and work it out to some iterations (correspondence with the server administrator).

The Mathcad documents converted in this way can also work in individual computers that have installed Mathcad. It is possible to protect the documents (see Fig. 1.23). Thus we stick a kind of protective film with openings in the Web Controls that protect document from intentional or unintentional damage and from curious look to the collapsed areas.

The only difference between such WebSheet and a WorkSheet is recalculation begins after we have change the Web Controls but not after pushing the Submit button (see Fig.1.74). In that case we can switch to manual mode and ask to press F9, not the Submit button. Fig. .3 from Foreword shows section from the Authors MAS  with general mathematical problems. Besides, this server contains the problems connected with power engineering, the Authors professional activity (also see Readers can add interesting WebSheets to favorites list via the Favorites menu of their Internet Explorer browsers as shown in Fig. 7.34.

Fig. 7.34. An example of formatting list of favorite calculation pages on the Internet

The Author hopes that readers will expand the list of problems shown in Fig. 7.34. MAS can also be used for creating the Internet versions of reference books and encyclopedias, inserting calculations in their Internet copies.

As mentioned above, Mathcad have reference tables, see Fig. 7.35. Here is another cast from Mathcad reference tables containing information on thermal conductivity of metals

Fig. 7.35. The page from Mathcad reference tables with data on thermal conductivity of metals

Many of the properties of metals (and non-metals) including thermal conductivity are known to depend on temperature. Fig. 7.36 shows the WebSheet containing detailed information on thermal conductivity of metals.

Fig. 7.36. The site concerning thermal conductivity of metals (mas)

This WebSheet has three features that give additional information:

1.     A user can choose both metal and temperature.

2.     The result is displayed numerically and on the plot that allow us to view changing of thermal conductivity with temperature

3.     The site shows values of coefficients of the polynomial which smoothes the data given in the table. A user can define exponent of the polynomial and transfer the interpolation formula obtained not only to Mathcad but also to other application.

Besides tables the formulae for calculations are considered as reference information (for example, see Fig. 3.1). The MAS technology allows us to animate such formulae. Fig. 7.37 shows the WebSheet enabling us both to compute the temperature inside of the wall and view temperature distribution in the wall depending on changing conditions of heat exchange.

Fig. 7.37. The site on thermal conductivity formulae on the Internet (mas)

The list of sites animated by the MAS technology is extending. Students help the Author in that converting reference books into the Internet sites. Thus they combine usefulness (studying basis of informatics on examples of power engineering) and pleasure (to see own work on the Internet). With that useful and pleasure note we are finishing the book.