Mathcad lets you use almost any expression as a variable or function name. Names in Mathcad can contain any of the following characters:
• Uppercase and lowercase letters.
• The digits 0 through 9.
• The underscore (_).
• a prime symbol ( , ). Note that this is not the same as an apostrophe. You’ll find the prime symbol on the same key as the tilde (-).
• percent (%).
• Greek letters. To insert a Greek letter, type the equivalent roman letter and press [Ctrl]G. The section “How to type Greek letters” on page 155 contains a table of equivalent roman letters.
• The infinity symbol 00, generated by typing [Ctrl]Z.
• Any other character provided you type [Ctrl][Shift]P before typing that character. This is discussed further in the section “Using an operator symbol in a name.”
• ~ny math expression appearing between the brackets generated by typing [Ctr 1][Shi f t ]0. This is discussed further in the section “Chemistry notation” on page 157. The following restrictions apply to variable names:
• A name cannot start with one of the digits 0 through 9. Mathcad interprets anything beginning with a number as either an imaginary number (2i or 3j), an octal or hexadecimal number (50 or 7h), or as a number times a variable ( 3 . x ).
• The infinity symbol, 00, can only appear as the first character in a name.
• Any characters you type after a period (.) will appear as a subscript. This is discussed in the section “Literal subscripts” on page 156.
• All characters in a name must be in the same font, have the same point size, and be in the same style (italic, bold, etc.). Greek letters can, however, appear in any variable name.
• Mathcad does not distinguish between variable names and function names. Thus, if you definef(x), and later on you define the variablej, you will find that you cannot use fix) anywhere below the definition for f
• Certain names are already used by Mathcad for built-in constants, functions, and unit. (For a list of constants and functions, see Appendix A, “Reference.” For a list of units, see Appendix B, “Unit Tables.”) Although you can redefme these mimes, keep in mind that their built-in meanings will no longer exist after the defmition. For example, if you define a variable mean, Mathcad’s built-in function mean(v) can no longer be used. Mathcad distinguishes between uppercase and lowercase letters. For example, diam is a different variable from DIAM. Mathcad also distinguishes between names in different fonts, as discussed in Chapter 6, “Equation and Result Formatting.” Thus, Diam is also a different variable from Diam. The following are examples of valid names: alpha.
How to type Greek letters
There are two ways to type a Greek variable name in Mathcad:
• Type the roman equivalent from the table below. Then press [Ctrl]G.
• Click on the appropriate letter on Greek Symbol Palette. To see this palette, click on the button labeled “ap” on the Math Palette. Note that although many of the uppercase Greek letters look like ordinary capital letters, they are not the same. Mathcad distinguishes between Greek and roman letters. If you use a Greek letter in place of the corresponding roman letter in a variable or function name, Mathcad will not recognize the two as equivalent. Note: Because it is used so frequently, the Greek letter 1t can also be typed by pressing [Ctr:t.] The following table lists all the Greek letters and their roman equivalents. These are the same roman equivalents used in the Symbol font. To insert an uppercase Greek
letter, use the uppercase roman equivalent. To insert a lowercase Greek letter, use the lowercase roman equivalent.
If you include a period in a variable name, Mathcad displays whatever follows the period as a subscript. You can use these literal subscripts to create variables with names like velinit and uair’ To create a literal subscript, follow these steps:
• Type the portion of the name that appears before the subscript. I~
• Type a period, followed by the portion of the name that is to become the subscript. Do not confuse literal subscripts with array subscripts. Although they appear sirnilara literal subscript appears below the line, like an array subscript, but with a slight space before the subscript-they behave quite differently in computations. A literal subscript, created by typing a period, is really just part of a variable name. An array subscript represents a reference to an array element. Array subscripts are generated with the left bracket key ( D. See Chapter 10, “Vectors and Matrices,” for a description of how to use subscripts with arrays.
Using an operator symbol in a name
When you’re in a math region, certain keystrokes insert math operators rather than the characters you see imprinted on the keys. For example, when you type “$” in a math region, Mathcad displays a summation symbol with placeholders, not a dollar sign. Although this feature makes it easier to type math expressions, it also excludes certain characters from use in variable names. To circumvent this problem, Mathcad lets you temporarily enter text mode while you’re still in a math expression. When you’re in text mode, all the keys lose their mathematical meaning. This lets you type exactly what you see imprinted on the keys on your keyboard. For example, here’s how you define the variable a$ to be equal to • Type a. Do not type $ yet since, at this , point, the “$” key will insert a summation sign.
• Type [Ctrl][Shift]P to enter a “text” 1 mode.
• Now go ahead and type $. The insertion 1 point turns red to show that you’re in text mode.
• Type [Ctrl][Shift]P again to return to 1 math mode.
• Type : 1 to complete the definition. Since I you’re now back in math mode, the “:” key 1 a$ .- 111 has recovered its mathematical meaning.