ClariCalc User’s Manual
Introduction
ClariCalc™ gives you the ability to perform high quality, readable calculations using standard math notation.
It works within Microsoft Word, so you can format and illustrate your work with all the power and flexibility of a full featured word processor.
ClariCalc helps you avoid the errors that infest spreadsheet calculations. When you read ClariCalc's written output, you are looking at the actual formula that was used to perform the calculation. ClariCalc also writes the numerical value of every variable used in a calculation. Compared to spreadsheets, ClariCalc calculations are easy to check.
ClariCalc is released under the MIT License. So you can use it for free.
System Minimums: ClariCalc requires Windows 7 or higher and Word 2007 or higher. It does not work in web-based versions of Word.
Note: In several places this manual invites the reader to type an example. Some of those invitations include a command-key combination. For example, c means hold down the Alt key, and while doing so, press c
.
The Basics
Get a copy of ClariCalc by clicking on the Download button in the left sidebar. Then install ClariCalc by double-clicking on the down-loaded file and following the directions. The next time you open Microsoft Word, it will contain ClariCalc.
You can set some preferences by clicking the button at Add-Ins | Edit | and selecting your preferences in the resulting dialog box. Or you can wait to set preferences later and get right to calculations with the default preferences.
The productivity starts with the first calculation. Your steps are to (1) write an equation, (2) put the selection point where you want the result to appear, and (3) give the command for a calculation. Like this:
Type these examples: | The results will be: |
1+1 = c | 1+1 =· 2 |
(18+7)/6 = c | \(\frac{18+7}{6}\) =· 4.17 |
15^2 = c | 15² =· 225 |
You can write explanatory notes into your work. ClariCalc will compute the expression written just before the c, and that leaves places available for your narrative.
x = Write a note here = 2+2 = c Another note here.
Writing Math
Microsoft Word now has Math Zones to help you generate math notation. Word creates a Math Zone when you type = or invoke the command Insert | Equation.
The power of a Math Zone is best appreciated when you see it in action, as in the videos located here and here. Or, you can try your own demonstration, such as the following equation. First, type =, then, inside the math zone, type:
a_b + 20^3 + y\bar + (1+5)/2 + \theta + \sqrt 15
As you type, the math objects will build up and the result will be:
\(a_b +{20}^3+\bar y +\frac{1+5}2 +\theta +\sqrt{15}\)
ClariCalc will add to Word’s math formatting with some equation format adjustments of its own. When ClariCalc performs a calculation, it will…
- create a Math Zone for any expression that includes a fraction or a radical.
- set variables to italic and set other words (functions, unit names, logic words) to non-italic.
- convert * characters to × or to an (a)(b) multiplication format. (Except when the expression contains an array.)
- set some fractions as:
- case fractions, for small factors, as in: \(\small{\tfrac{1}{2}}\normalsize x\)
- special fractions, for mixed fractions, as in: 1½
- inline (shilling) fractions, for exponents, as in: \(e^{a/b}\)
If you wish ClariCalc to perform its formatting without doing a calculation, place the insertion point after the expression and type m or invoke the ribbon command: Add-Ins | Edit | Format.
For tips on how to write math quicker, see the sections on Keyboard Shortcuts and Quick Parts, below.
Syntax
ClariCalc performs calculations on expressions written in standard math notation. That is a broad statement, so the following section covers some nuances.
Notation
Decimal symbol
Some countries use a dot for their decimal symbol. Others use a comma. ClariCalc can do either. It chooses the symbol per the settings in the Windows control panel. [Warning: comma decimal is only lightly tested.]
Multiplication
For multiplication of two numbers, ClariCalc recognizes several operator symbols. So if a = 2 and b = 3, then all of the expressions below will give the same result:
2 × 3 = 2 · 3 = 2 * 3 = (2)(3) = a b = 2 b = a × b = a · b
Between variables, a space is taken to be a multiplication operator, as in e = m c².
For the product of two arrays (unlike plain numbers), the type of multiplication varies with the operator symbol, as explained here.
Function argument separator
ClariCalc uses the semi-colon, not the comma, to separate function arguments, as in: x = max(a; b; c)
Variable names
Variable names may be multiple characters long. They must begin with a letter from the Latin or Greek alphabet. The rest of the characters may be letters or numerals (0123456789). An under-score within a name is allowed and will be interpreted to mean the start of a subscript. Primes at the end are ok, e.g., fc′. So are accents, e.g., \(\bar{y}\), \(\hat{\theta}\), etc.
Superscripts
ClariCalc will read a superscript as an exponent.
Special Fractions
A special
fraction is a small, slanted fraction like ½ or ⅞. They can be part of a mixed fraction such as 1½. ClariCalc can read either decimal fractions like 0.375 or special fractions like ⅜. ClariCalc normally writes calculation results in decimal fractions but if you prefer your results to be written as special fractions, then use the keyboard combination shift c or k.
Example:
1.5 + 1⅞ = 3⅜
Number Names and Bases
ClariCalc recognizes numbers such as 10 thousand, that is, an Arabic numeral followed by an alphabetic name of a number. The numeric extensions recognized are: hundred, thousand, lakh, crore, million, billion, milliard, trillion, googol, percent, procent, permille, promille, ppm, ppb, dozen, gross, score, karat, pair, pairs, wan, and yi. Billion is taken to mean 1,000,000,000.
ClariCalc also recognizes numbers such as 0F hex, that is, a numeral followed by a base label. The bases recognized are: decimal, hex, hexadecimal, octal, binary, and roman. Any number without a base label is assumed to be decimal.
z*
ClariCalc will find the complex conjugate of a variable noted z^*
When you run a calculation, ClariCalc will set variables to italic. It will set function names (e.g. sin), units (e.g. meters), and logic words (if and or not xor else otherwise) to non-italic.
Operators
Operator | Keyboard Shortcut | Example | Comment |
---|---|---|---|
= | x = 15 | Assign a value to a variable. Assignment statements must begin at the start of a paragraph or just after a tab. |
|
+ | 2 + 2 | Addition | |
– | 5 – 3 | Subtraction | |
- | -4 | Unary minus | |
* | 2 * 4 | Multiplication of numbers. Memberwise product of arrays. |
|
× | \times | 2 × 4 | Multiplication of numbers. Cross product of vectors. |
· | . | a · b | Multiplication of numbers. Dot product of matrices, or vectors. |
(2)(4) | Multiplication | ||
2 a | Multiplication. [▼]ClariCalc checks each blank space in an expression and inserts a multiplication where appropriate. | ||
2a | Multiplication | ||
a2 | Not a multiplication. ClariCalc reads a2as a variable name. |
||
a(2) | Either a function a(2) or a multiplication a×2. [▼]If a valid function name exists, it will take precedence over multiplication in this syntax. Using this syntax for multiplication is legal, but i do not recommend it. If you type a space between a factor and a following paren, as in a (2), you will make it easier for a reader to tell the difference between a multiplication and a function. |
||
/ | \(\frac{8}{2}\) | Division | |
÷ | \div | 8 ÷ 2 | Division |
∕ | \ldiv | 8 ∕ 2 | Division with inline format. |
^ | 32 | Exponent | |
√ | \sqrt or \r | \(\sqrt{4}\) | Square root |
\(\sqrt[n]a\) | \r(n&a) | \(\sqrt[3]{27}\) | nth-root |
% | 10% | Percent | |
‰ | 10‰ | Per thousand | |
| | | |-4| | Absolute value of a scalar, determinant of a matrix, or magnitude of a vector. | |
\(\lVert\,\,\,\rVert\) | \Vert | \(\lVert x \rVert\) | \(\sqrt{x_1^2+\cdots +x_n^2}\) if the argument is a vector of reals |
\(\sqrt{|z_1|^2+\cdots +|z_n|^2}\) if the argument is a complex vector | |||
\(\sqrt{\sum_i\sum_j A_{i;j}^2}\) if the argument is a matrix | |||
⌊ ⌋ | \lfloor \rfloor |
⌊4.5⌋ | Floor. Always rounds down. |
⌈ ⌉ | \lceil \rceil |
⌈4.5⌉ | Ceiling. Always rounds up. |
! | 5! | Factorial | |
‼ | !! | 5‼ | Double Factorial |
¡ | 0161 | 5¡ | Subfactorial, n¡ = \(\left\lfloor{\frac{n!}{e}+\frac{1}{2}}\right\rfloor \) |
\(\binom{n}{k}\) | (n\atop k) | \(\binom{5}{3}\) | Binomial coefficient. \(\binom{n}{k}=\frac{n!}{k!(n-k)!}\) |
^* | z* | Complex conjugate | |
∠ | \angle | r∠θ | Polar notation separator |
\ | a \ b F \ S | Integer division on numbers a and b = ⌊a ÷ b⌋ Matrix direct solution if F and S are matrices and S is square. [▼]Matrices can be used to express a sytem of linear equations, such as S×D = F. One can solve such a system by matrix inversion, D = S⁻¹ × F, but the direct solution, F \ S, has a faster algorithm. |
|
< | Comparison Operators. For If Expressions, such as: x = a if (n < 2) else b |
||
> | |||
≤ | <= | ||
≥ | >= | ||
== | |||
≠ | =/ | ||
≅ | ~= | Comparison operators that return True for magnitudes that are equal ± 0.1%. Useful when dealing with floating point error in engineering calculations. | |
≲ | <~ | ||
≳ | >~ | ||
≉ | ~/ | Returns True for comparisons that are more than 0.1% apart. | |
and | Logical operators. For If Expressions, such as: x = a if (n < 2 and c == 2) else b notand ¬are unary operators, as in: x = a if (not n == 2) else b |
||
or | |||
not | |||
xor | |||
¬ | \neg | ||
∧ | \wedge | ||
∨ | \vee | ||
: | 2:3 | Integer range separator. The term V[2:5] will return an vector containing elements 2 through 5 of vector V. The term table[1].range[4; 2:5] will return an array that contains the contents of table 1, row 4, columns 2 through 5. The comprehension [2 i for i in start:end] will return a vector after it executes the expression “2 i ” several times, with variable i taking on each integer value in the range from start to end. |
Functions
ClariCalc treats a word as a function name if it (1) matches a word in the ClariCalc function list[▼]abs acos acosd acosecd acosh acot acotd acoth acsch angle asec asecd asech asin asind asinh atan atan2 atand atanh cis combin cos cosd cosh cot cotd coth count csc csc cscd csch doc erf exp gcd gud haversin haversind hypot imag ln log log! log10 logΓ max mean median mht min permut product random range real remainder rib rms root round sec secd sech sign sin sind sinh sqr sqrt stddev sum table tan tand tanh trace trunc variance Γ Σ Φ, and (2) is placed directly before an open parenthesis. So a term like sinh(x)
is a function. [▼]If the word is not on the function list, then ClariCalc will search for a variable, so terms like a(b)
are equivalent to a × b
. For four functions (cos sin tan log), the parentheses are optional.
ClariCalc uses the semi-colon, not the comma, to separate function arguments, as in: x = max(a; b; c)
ClariCalc’s built-in functions are described below. Unless noted otherwise, they can operate on any complex number.
cos θ, sin θ, tan θ, sec(θ ), csc(θ ), cot(θ ), haversin(θ )
Trigonometry functions.
The trig functions listed above will assume that the argument is in radians, unless you tell it otherwise. You can tell it otherwise by just writing in a unit, as in: tan(45°).
A superscript after a trig function name will return the function result raised to a power. So that: sin2 θ = (sin θ )2.
Exception: A superscript -1 indicates an inverse function. In other words, cos-1(x) = acos(x).
ClariCalc’s trig functions will operate on angles and on complex numbers.
cosd(θ ), sind(θ ), tand(θ ), secd(θ ), cscd(θ ), cotd(θ )
The trigonometry functions listed just above will assume that the argument is in degrees.
acos(x), asin(x), atan(x), asec(x), acsc(x), acot(x)
Inverse trigonometry functions. One can also call an inverse trigonometry function with a superscript, as in cos-1(x).
atan2(x; y)
An atan function that returns an angle in the proper quadrant. Given a point defined by real coordinates x and y, atan2 returns the angle between that point and the positive x-axis of a plane.
cosh(x), sinh(x), tanh(x), sech(x), csch(x), coth(x)
Hyperbolic functions. Notation for inverse functions is similar to trigonometry.
doc(filename)
Assigns a Word document to an object. See remote bookmarks.
exp(x)
ex
log x, ln(x)
Natural (base e) logarithm of x.
log10(x)
Base 10 logarithm. ClariCalc will subscript the numerals for you.
log(b; x)
Base b logarithm.
Γ(z)
Gamma function. For positive integers, Γ(n) = (n – 1)!
Unlike a factorial, however, the Gamma function is extended to operate on all complex numbers.
logΓ(x), log!(n)
Natural log of, respectively, the Gamma function and the factorial. The log!() function can operate only on integers ≥ 0. [▼]These functions are useful when doing combinatorial calculations. That is because 170! is the largest factorial that fits into 64 bit floating memory. To avoid overflow from a factorial, one can substitute an equivalent expression that uses logarithms. For instance:
\(\frac{n!}{k!(n-k)!}=\) exp(log!(n) – (log!(k) + log!(n – k)))
abs(z)
Absolute value of a real number
Magnitude of a complex number
min(a; b; c; …) max(a; b; c; …)
Minimum or maximum of a list or array. Real numbers only.
combin(n; k)
Number of combinations of n items taken k ways = \(\frac{n!}{k!(n-k)!}\)
permut(n; k)
Number of permutations of n items taken k ways = \(\frac{n!}{(n-k)!}\)
hypot(a; b), rms(a; b)
\(\sqrt{a^2+b^2}\)
random()
Pseudo-random number between 0 and 1
rib(a; b)
Random integer bounded by a and b
remainder(m; n)
Remainder after n is divided by m. Integer inputs only. Always returns a positive number.
round(x; n)
Round a real number x to n places after the decimal.
Omit the n to round to an integer.
angle(z), real(z), imag(z), cis(θ )
Functions useful when working with complex numbers.
sum(a; b; c; …), product(a; b; c; …), count(a; b; c; …), range(a; b; c; …), mean(a; b; c; …), variance(a; b; c; …), stddev(a; b; c; …)
Functions on lists or arrays.
erf(x), Φ(x)
Functions useful for normal probability.
gcd(m; n)
gcd(LAT1; LONG1; LAT2; LONG2)
gcd on two integers returns the greatest common divisor.
gcd on four arguments returns an approximate great circle distance between two points on the surface of the Earth, given their latitude and longitude.
sign(x)
Returns 1 if x > 0, -1 if x is < 0, else 0
trace(M)
The sum of the elements of a square matrix.
Constants
π
ClariCalc uses a value of 3.141592653589793238462643383 for π.
e z
ClariCalc will treat e
just like any other variable most of the time. But if e
is the base of an exponent, for example: e x or e (3 a), then ClariCalc will perform the function exp(z).
Operator Precedence
What is the result of the expression 3 + 4 × 2
?
It depends on whether one does the addition first or the multiplication first. So the answer could be (3+4)(2) = 14 or 3+(4×2) = 11.
To resolve this ambiguity, ClariCalc performs operations with the following precedence:
! ‼ ¡ % ‰ | Factorials and percents are done first. |
^ ^* | Then exponents, from right to left. |
√ | Roots |
- | Unary minus, for example: -4 x |
∠ | To write a complex number in r∠θ notation. |
× · / ÷ | Multiplication or division, from left to right. |
+ – | Addition or subtraction, from left to right. |
< > ≤ ≥ | Comparisons (for If Expressions) |
not and or | Logical operators (ditto) |
: | Separator for a range of integers, as in V[2:3]. |
; @ & ¦ | Argument separators for functions, matrices, or Cases expressions. |
( ) [ ] | All conventions are over-ridden by parentheses. |
Now let’s return to the question that opened this section. We now know that multiplication has a higher precedence than addition, so the result of our question above is:
3 + 4 × 2 = 3 + (4 × 2) = 11
If Expressions
ClariCalc has two kinds of if expressions.
Inline If Expression
expression_1 if condition else expression_2
Example:
x = 2a if a < b else a² =
I recommend that you surround the condition with parentheses. They make the statement easier to read.
x = 2a if (a < b) else a² =
Cases Expression
Example:
β1 = \(\begin{cases}0.85 &\text{if }f_c^\prime\leq 4000 \\0.65 &\text{if }f_c^\prime\geq 8000 \\0.85-\frac{f_c^\prime -4000}{20{,}000}&\text{otherwise}\end{cases}\)
You can initiate a cases expression by clicking the ribbon button Add-Ins | Insert | \(\tiny{\begin{cases}\square \\ \square\end{cases}}\)
In a cases expression, ClariCalc will automatically align the logic words if
and otherwise
. You needn’t take any action to make that happen.
Conditions may contain logical operators: and or not xor
x = 2a if (a < b and b == 5) else a²
Chained comparisons are okay.
x = 1.0 if (a < b < 5 < d) else 1.3
In an inline expression, the equals comparison operator must be ==
. In a cases expression, you can use either =
or ==
.
x = 1.0 if (a == 12) else 1.3
Rounding
ClariCalc will round off the result of a calculation. You can specify the type of rounding via the button on the Add-Ins ribbon tab. The following rounding options are available:
Show All
…shows all digits, as in: sin(45°) = 0.707106781186548
##0
…rounds off to the nearest integer, as in: sin(45°) = 1
##0.00
…rounds to two digits after the decimal, as in: sin(45°) = 0.71
Scientific
…shows the result in 0.00E+00 format and displays the number of significant digits that is specified in Preferences. So, three significant digits returns: sin(45°) = 7.07E-01
Significant
…rounds the result to the number of significant digits that is specified in Preferences. So, three significant digits returns: sin(45°) = 0.707 and 10×sin(45°) = 7.07
##0 or Significant, whichever is longer
…rounds to the specified number of digits, unless an integer is more precise. [▼]To an engineer or scientist, it makes perfect sense to round off a result from 10,322.6 lbs to 10,300 lbs. From that perspective, this rounding spec promotes spurious precision. So why is this rounding spec here? Well, some ClariCalc users want to avoid freaking out their clients.
Variables
If you write variables into your equations, ClariCalc will search your document for values to plug in. Here's an example.
a = 7 b = 11.2 c = -4 ← separated by tabs
x = a+b/c = c
Result:
x = \(a+\frac{b}{c}\)a+b/c = \(\color{#3333CC}{7+\frac{11.2}{-4}}\) = 4.2
When an expression contains variables, ClariCalc will:
- Search for the variable assignments.
a. First in bookmarks and ParentFiles.
b. Then upwards in the document for variable assignments. - Write an echo of the expression, with the values plugged in.
- Do the calculation and write the result.
To assign a value to a variable, just write
variableName = value at the start of a paragraph, or after a tab.
More examples:
L = 14 | ← Write assignments at the start of a paragraph. | |
w = 0.12 | P = 2.3 | ← or after a tab. |
M = \(\frac{w\,L^2}{8}+\frac{P\,L}{4}\) = \(\color{#3333CC}{\frac{(0.12)(14^2)}{8}+\frac{(2.3)(14)}{4}}\) = 10.99
A ClariCalc search for a variable goes in the upward direction. So if you have defined d
more than once, ClariCalc will find the place that is (1) above the calculation line, and. (2) closest to the calculation line.
A variable search is case-sensitive. A search for E
will not find e
.
Variable names may be multiple characters. They must start with a letter, not a number. Other characters may be letters or numbers. Subscripts are ok. Primes at the end are ok, e.g., fc′. So are accents, e.g., \(\bar{y}\), \(\hat{\theta}\), etc.
To assign a text string, put the text inside quotes, e.g., s = a string
Note that ClariCalc writes an echo of the expression that displays the values used for each variable. This echo allows one to check ClariCalc’s work. The echo is typically colored blue to set it apart from other text.
When a value is sourced from a Bookmark, a Parent File, or from LookupTable.txt, then the value is written in green. This gives a checker a better audit trail for the values.
If you want to suppress the echo (often a bad idea), you can write an ellipsis where the echo would normally go.
Example: t = c - a = … = 5
Speed Tip
ClariCalc may slow down a little in a long document. To regain some speed, you can choose in the Settings to Search for variable assignments ONLY within the current section and in bookmarks
.
To insert a section break, use the ribbon button: Layout | Breaks | Section Break (Next Page) or the keyboard shortcut
Bookmarks
In a really long document, ClariCalc can slow down a little if it has to search a long way back to find a variable. To keep things speedy, ClariCalc has an alternate search method. It uses a Microsoft Word feature called bookmarks that you may not have used before. In Word, a bookmark is a place in the document that has a name. Word keeps track of this place and can find it quickly.
When ClariCalc searches for a variable, it will first look in the list of bookmarks. If ClariCalc finds the variable name in the list of bookmarks, it will use the bookmark, even if the variable name is defined again later in the document. That last sentence is an exception to the usual upward search. Bookmarks are trumps. That's why they're fast.
You can set a lot of bookmarks at once with ClariCalc. For example:
Fy = 36 ksi | E = 29000 ksi | G = 12000 ksi |
fc′ = 4500 psi | fc″ = 4500 psi² | fyr = 60000 psi |
Select the whole block of text and choose the menu command:
Add-Ins | Insert | Miscellaneous | Bookmark(s).
Word only allows alphanumeric characters in bookmark names. That interferes with certain variable names, so the ClariCalc bookmarking utility examines each proposed name and will make a substitution for the last character in four cases:
fc′ | → | fcPrime |
fc″ | → | fcPPrime |
\(\bar y \) | → | yBar |
\(\hat{\theta}\) | → | θHat |
Remote Bookmarks
A ClariCalc expression can call in a value from a bookmark, even if the bookmark is in a different Word document. To do this, first use the doc() function to assign a particular Word document to an object. The bookmarks of that other document can then be called as attributes of the object. Here’s an example:
stds = doc(Section A.docx) |
← | assigns a document to an object named stds |
A = stds.L × stds.W F = A × stds.p |
← | Two equations that call bookmarks. |
You can skip the first step, as in the equation below.
p = doc(Section A.docx
).p
You can also call table elements from the other document, as in:
n = stds.table[1].cell[2; 3]
File path
The syntax above ask you to assign a filename. You can choose to write an entire file path as your document definition, like this:
stds = doc(S:\Clients\John Doe\jobname\Section A.docx
)
Or, you can omit the path and just write the file name:
stds = doc(Section A.docx
)
If you omit the path, ClariCalc will first look for the external document in the same folder as the current document. If the desired document is not there, ClariCalc will then search the folder that contains the current folder, then the folder that contains it, all the way to the root subdirectory.
Parent Files
If you want to avoid the Object.Attribute notation, you can assign values in a ParentFile. Here's how:
- Use a text editor, say NotePad, to create a text file. Write your data into the file using a tab-delimited format like this example:
Name | Value | Unit |
---|---|---|
E | 29000 | ksi |
G | 12000 | ksi |
- Save the text file with UTF-8 encoding. It can now be used as a parent file.
Or, skip steps 1 and 2; select a range of assignments, then invoke Add-ins | Edit | Edit | Create Text ParenFile. - Place the parent file into the same folder as the descendent file(s), or in any folder that contains the descendent file(s).
- In each of the descendent files, type in the file name of the parent file, then select that file name and bookmark it with the name
ParentFile
.
Subsequent variable searches in the descendent files will inherit all the variable assignments in the parent file. Like this:
x = 2 G = (2)(12000) = 24000
A ParentFile has precedence over any variable assignment except a bookmark.
Variable Search of Data with a Lookup Key
If you have a big table of tab-delimited data in a separate text file, ClariCalc can search through it for a lookup value. To call for such a search, a document would contain text that looks something like this:
Section = “W8x31” | ← | This line sets a lookup key W8x31. |
2 d = (2)(8) =: 16 | ← | The value for dcomes from the entry for W8x31in LookupTable.txt. |
The data in LookupTable.txt can be anything you write. It’s format will look something like the structural steel table shown here:
W | wself | A | d | tw | bf | tf |
---|---|---|---|---|---|---|
Section | plf | in2 | in | in | in | in |
W14x74 | 74 | 21.8 | 14.17 | 0.45 | 10.07 | 0.785 |
W8x31 | 31 | 9.13 | 8 | 0.285 | 7.995 | 0.435 |
W8x28 | 28 | 8.25 | 8.06 | 0.285 | 6.535 | 0.465 |
W8x24 | 24 | 7.08 | 7.93 | 0.245 | 6.495 | 0.4 |
In order to search this table, first set a lookup key for say W14x74. In the rest of the document, ClariCalc variable searches will find values for:
wself, A, d, tw, bf, or tf
There are two ways to set a lookup key:
- Select from a list of keys in the menu command:
Add-Ins | Insert | Lookup Key… - Write the key into your document, then hit L. Example:
Type this: | W14x74 L |
Result: | Section = W14x74 |
You can have more than one lookup key active at one time, provided that they are of different types. For instance, one key (say Section = W14x74
) might deliver section properties like A and d. (area and depth for the W14x74 section.)
Another key (say SteelGrade = ASTM A36
) might then deliver properties, like Fy and Fu, of a steel grade.
The file with the data is named LookupTable.txt
. It must be located in C:\Users\userID\AppData\Roaming\Hilbert\
References to values inside a table
An expression located outside a table can refer to value(s) inside a table using any of the following syntaxes:
x = table(indicator).cell[row; col]
x = table(indicator).range[row; col]
x = table(indicator).find[string; col]
x = table(indicator).match[pattern; col]
x = table(indicator).interpolate[row; col]
The indicator term can be either an integer or a string of text, or a variable that returns an integer or string. An integer refers to a table by its position relative to the expression. A string refers to the nearest (upward) table that starts with that string. Examples:
table(-1) | ← refers to the previous table |
table(0) | ← refers to the table containing the expression |
table(2) | ← refers to the table after the next table |
table(“Fv”) | ← refers to the nearest table that starts with Fv |
The table’s method and property terms are:
[row; col] | ← | returns the contents of one cell. |
.cell[] | ← | returns the contents of one cell. |
.range[] | ← | returns an array with the contents of several cells. |
.find[] | ← | returns an array with the contents of cells from rows that match a string. |
.match[] | ← | returns an array with the contents of cells from rows that match a regular expression pattern. |
.interpolate[] | ← | returns a value interpolated between cell values. |
.find and.match work only on rows, not on columns.
The row and col terms can take several forms:
A positive integer points to a specific row or column.
A string refers to the row or column whose header is the string.
end
points to the bottom row or rightmost column.
A blank points to an entire row or column.
Colon-separated integers point to a range of cells.
Examples for row and col:
[3; 2] | ← returns the cell contents at row 3, column 2 |
[end; 4] | ← returns the bottom cell in column 4 |
[2:3; 4] | ← returns a 2x1 list |
[4;] | ← returns an array containing row 4 |
Dictionaries
A dictionary, like an array, contains data, but a dictionary is indexed by keys, not integers.
array[3] | ← Array calls use an integer. |
dictionary[k] |
← Dictionary calls use a key, which can be a string. |
The syntax that one uses to create a dictionary has pairs of a key and a value surrounded by braces.
decade = {50s: Elvis
; 60s: Beatles
; 70s: Eagles
}
base = {B:7.0; C:9.5; D:11.5}
Note that keys are separated from values by a colon. Each pair is separated from the others by a semi-colon. Keys need not be surrounded by quotation marks.
You can call a dictionary value in two steps, by assigning a dictionary to a variable and then making the call.
decade = {50s: Elvis
; 60s: Beatles
; 70s: Eagles
}
star = decade[50s
] = Elvis
Or you can call a dictionary value in one step by defining the dictionary and the index on the same line. The index can of course be a variable.
Cexp = C
α = {B:7.0; C:9.5; D:11.5}[Cexp] = 9.5
Dictionary values cannot be changed and they cannot be nested. They can contain a unit.
L = {court: 94 feet; field: 100 yards}
Units
If any operands are written with a unit, ClariCalc shifts into unit-aware mode. In this mode, ClariCalc will recognize units and handle unit conversions automatically. Like this:
Type these examples: | The results will be: |
2 m + 5 feet = mm c | (2 m) + (5 feet) = 3,524 mm |
\(\frac{10{,}000 \text{ m}}{100\text{ km/h}}\) = k minutes | \(\frac{10{,}000 \text{ m}}{100\text{ km/h}}\) = 6 minutes |
So long as the units for all operands, including the result, are compatible, ClariCalc can automatically handle unit conversions through most math operations and functions.
ClariCalc can read compound units. Examples:
multiplication: | lb·in or lb-in | |
division: | m/s or h/(N·m) | (Use only one solidus character “ / ” in any unit.) |
powers: | m/s2 or m·s-2 |
ClariCalc checks for incompatible units. If it finds a problem, it will shut down the calculation and give you an error message.
\(\frac{1500\text{ m}}{60\text{ mph}}\) = volts k | → | Error. The expression's units are incompatible with the result's units. |
4 ft + 6 sec = k | → | Error. You're adding incompatible units. |
Recognized unit formats include:
5 meters | Unit name or symbol written after the numeral. |
$10.25 | Currency symbol written before the numeral |
5′ 6″ | Feet and inches |
10° 15′ 7″ | Degrees, minutes, seconds |
95V∠80° | Unit symbol (e.g. V) embedded within a complex number written in polar coordinates. |
Currency exchange rates are not automatically updated. To update them, click on the button at: Add-Ins | Edit | Misc | Update Currency Exchange Rates. ClariCalc will then get a current set of exchange rates from Yahoo Finance.
Unit-Aware Variable Search
ClariCalc has two calculation commands: c and k.
Both of those commands will recognize units in your expressions and handle them automatically. Both will do this expression correctly:
10 m + 3 yards = c feet → 41.8 feet
10 m + 3 yards = k feet → 41.8 feet
The difference between the two commands occurs when ClariCalc does a variable search. For each variable, ClariCalc finds where a value is assigned, and then:
c → returns the scalar (number) assigned to a variable
k → returns both the scalar and the unit
Example:
a = 15 mm b = 5 m
a + b = c | → a + b = 15 + 5 = 20 |
a + b = mm k | → a + b = (15 mm) + (5 m) = 5015 mm |
Weight
ClariCalc’s default settings impose a strict treatment of mass and force. That is, ClariCalc will flag as an error any attempt to add mass to force or to convert mass to force.
But you can relax that setting via ClariCalc Preferences. Then ClariCalc will not flag a force + mass addition as an incompatible unit error. Instead, it will make a conversion under the assumption that the force is a weight imposed on the mass by earth gravity. [▼]This simulated compatibility will work though any number of additions and multiplications, but it may be fooled by a calculation involving an exponent. ClariCalc assumes that g = 9.80665 m/s².
If the relaxed treatment is a problem for your work, don’t use it. For example, people working in fluid dynamics should keep the strict treatment.
Traditional Units
Many traditional units have had more than one historical definition. ClariCalc currently has the following default treatment of certain traditional units:
- pound is treated as force. (lbf and lbm are un-ambiguous alternatives)
- ton is treated as a mass, and is the U.S. customary unit.
- gallon, fl oz, pint, quart, and bushel are the U.S. customary units.
- Weights are avoirdupois, unless specifically noted as a troy weight.
- point is the adobe point = ¹∕₇₂ inch. TeX point is also available.
- barrel and bbl are an oil barrel = 42 US gallons.
[▼]ClariCalc gets its conversion factors from a file named UnitFactors.txt
, which you can view and edit by invoking the ribbon button Add-Ins | Edit | Show | Unit Factors.
Currency Exchange Rates
To update the currency exchange rates in UnitFactors.txt, invoke the ribbon command Add-Ins | Edit | Misc | Update Currency Exchange Rates.
Recalculation
This section is for that moment when you want to change one number, then re-calculate a lot of results. No problem. Go ahead and edit your text. Then select the text that you want to re-calculate and hit the Re-Calc button or type r. ClariCalc will re-calculate everything in the selection.
You may have noticed that when you do a calculation, ClariCalc will add a small hidden symbol next to the last equals sign. That is a bread crumb left behind so that ClariCalc can know the type of re-calculation needed there. The bread crumb will not print out.
Beyond Real Numbers
One can add, multiply, etc., with many things besides real numbers. ClariCalc can help you do that. It operates on dates, arrays, matrices, vectors, comprehensions, and complex numbers.
Date Arithmetic
ClariCalc enables date addition and subtraction.
To assign a date to a variable, place a valid date string inside quotation marks. ClariCalc can recognize some dates even without quotation marks, such as today or now.
d1 = 12 January 2015
Then use the normal addition and subtraction operators to do date arithmetic. Examples:
d2 = d1 + (6 weeks) = (1/12/2016) + (6 weeks) = Friday, February 12, 2016
d3 = today + (10 weeks) = Sunday, September 6, 2015
d4 = d1 – d3 = (1/12/2016) - (9/6/2015) = 237 days
As you can see, the echo displays dates in the Short Date format chosen in your Windows Control Panel. ClariCalc writes results in Long Date format.
Arrays
A ClariCalc array is a collection of values stored in a one- or two-dimensional grid. They look like these examples:
\(\begin{pmatrix}1 & 0 & 0\\ 0 & 1 & 0\\ 0 & 0 & 1\end{pmatrix}\) \(\begin{bmatrix}4\\ 5.5\\ 0.9\end{bmatrix}\) [11 2.4 800]
One can call an individual value from an array with an index, as in: x = M[1] or y = M[1; 3].
Most ClariCalc operators and functions operate on arrays in an element-wise fashion. If you add a scalar to an array, or pass an array to most functions, ClariCalc will do an element-by-element calculation and return an array.
However, mathematicians have several ways to do multiplication on arrays. In ClariCalc, you choose the type of multiplication by your choice of multiplication symbol:
A B returns a matrix product, \((\mathit{\mathbf{A\,B}})_{ij}=\sum_{k=1}^m{A_{ik}B_{kj}}\).
A × B returns a cross product = |A| |B| sin(θ) n
A · B returns a dot product \(=\sum_{i=1}^n{A_i B_i}\)
A ∗ B returns a elementwise product, \((\mathbf A\mathrm{\ast }\mathbf B)_{ij}=A_{ij}B_{ij}\)
I want to draw your attention to the ∗ character in the previous line. In most expressions, ClariCalc will remove a * character and substitute a different multiplication syntax. But there is an exception: Any expression that contains an array will keep the ∗ character so that it can be used for an element-wise product.
Here are some other array operations:
AT returns a transposed array.
A-1 returns an inverted matrix, if A is square.
|A| returns a \(\begin{cases}\text{determinant }&\text{if }\mathbf A\text{ is square} \\\text{magnitude }&\text{otherwise}\end{cases}\)
abs(A) returns elementwise absolute values
F \ S returns a \(\begin{cases}\text{matrix direct solution }&\text{if }\mathbf S\text{ is square} \\\text{elementwise integer division }&\text{otherwise}\end{cases}\)
Functions min() and max() will work elementwise if you pass multiple arrays to the function. If you pass one array, they will find the minimum or maximum of the elements in the array.
There are three ways to write an array:
- If you click on the \(\tiny \begin{bmatrix}1 & 0 \\0 & 1\end{bmatrix}\) button on the Add-Ins menu, ClariCalc will show a dialog box to help you populate a matrix, such as:
M = \(\begin{pmatrix}10 & 4 \\0.5 & 103\end{pmatrix}\) - Between square brackets with spaces to separate elements and semi-colons to separate rows, as in: V = [10 4] or M = [10 4; 0.5 103]
- Comprehensions, see below.
To append a scalar onto one end of a vector, write the scalar name and the vector name into another array. Such that:
[a V] will prepend a to the beginning of vector V.
To concatenate two arrays, write the array names as elements in another array. So that:
[A B] will concatenate in a side-by-side manner.
\(\begin{bmatrix}\mathbf A \\\mathbf C\end{bmatrix}\) or [A; C] will concatenate C to the bottom of A.
Comprehensions
Comprehensions provide a concise way to create a column vector, using a syntax similar to set builder notation in mathematics.
Syntax:
[expression for variable in start:end]
where:
expression will be evaluated several times, with variable taking on all the integer values in the range from start to end
start and end are also expressions. They must result in integers.
Here are some examples
Input | Result |
---|---|
V = [2 i for i in 1:3] = c | \[\begin{bmatrix}2\\ 4\\ 6\end{bmatrix}\] |
n = 2 [3 + i for i in 1:n] = c |
\[\begin{bmatrix}4\\ 5\end{bmatrix}\] |
[2 + V[i] for i in 2:3] = c | \[\begin{bmatrix}6\\ 8\end{bmatrix}\] |
You can append a comprehension to a vector, like this:
\(\small\begin{bmatrix}2\\ \text{[7 + \textbf{V}[\textit{i}] for \textit{i} in 1:2]} \end{bmatrix}\) = \(\small\begin{bmatrix}2\\9\\11\end{bmatrix}\)
Or, you can get the same result this way:
[2; [2 + V[x] for x in 1:2]] = \(\small\begin{bmatrix}2\\9\\11\end{bmatrix}\)
In a comprehension, a call to index 0 returns 0. That is, A[0] = 0.
Matrices
A matrix is a two dimensional array of numbers, associated with certain matrix operations.
ClariCalc can: add matrices, subtract them, multiply them, invert them, and transpose them. It can find determinants of square matrices.
If you click on the \(\tiny \begin{bmatrix}1 & 0 \\0 & 1\end{bmatrix}\) button on the Add-Ins menu, ClariCalc will show a dialog box to help you populate a matrix.
You can work directly with matrices or you can work with variables to which you have assigned matrices. Here are some examples:
A = \(\begin{pmatrix}1 & 2 \\ 3 & 4\end{pmatrix}+\begin{pmatrix}7 & 1 \\ 8 & 3\end{pmatrix}\) = \(\begin{pmatrix}8 & 3 \\ 11 & 7\end{pmatrix}\)
B = \(\begin{pmatrix}10 \\ 15\end{pmatrix}\)
C = A B = \(\color{#3333CC}{\begin{pmatrix}8 & 3 \\ 11 & 7\end{pmatrix} \begin{pmatrix}10 \\ 15\end{pmatrix}}\) = \(\begin{pmatrix}125 \\ 215\end{pmatrix}\)
To append (or delete) rows or columns in an existing matrix, right click on an element and choose a command from the pop-up menu.
To invert a matrix, use this notation: x = A-1 = c
To transpose a matrix, use this notation: x = AT = c
To solve a system of linear equations, A x = B, use either:
The inverted matrix technique: x = A-1 B = c
Or a notation for direct solution: x = B \ A = c
Determinants
Use the |A| notation to find the determinant of a square matrix. As in:
A = \(\begin{pmatrix}1 & 2 \\ 3 & 4\end{pmatrix}\)
d = |A| = \(\color{#3333CC}{\begin{vmatrix}1 & 2 \\ 3 & 4\end{vmatrix}}\) = -2
Norms
Use the \(\small ||\mathit{\mathbf A}|| \) notation to find the Frobenius norm [▼]\(\small ||\mathit{\mathbf A}||=\sqrt{\sum_i\sum_j A_{i;j}^2}\) of a matrix.
\(\small n=||\mathit{\mathbf A}||=\color{#3333CC}{\begin{Vmatrix}1 & 2 \\ 3 & 4\end{Vmatrix}}=5.477\)
To retrieve one value from a matrix, use a bracket notation.
x = matrixName[rowIndex; columnIndex]
Example: x = A[2; 2] = 4
The trace function, trace(M), returns the sum of the elements on the diagonal of a square matrix.
Vectors
In ClariCalc, a vector [▼]The word vector can be taken to mean many different things. It makes no difference to ClariCalc how you interpret the meaning of a vector. It just does the operations. is a one dimensional array of numbers associated with certain vector operations. ClariCalc can: add vectors, subtract vectors, multiply them by a scalar, do dot products, find vector magnitudes, and find vector norms. ClariCalc can do cross products on 3-vectors.
Tip: you can use the \(\tiny \begin{bmatrix}1 & 0 \\0 & 1\end{bmatrix}\) button to get an array creation dialog box.
Vector Examples:
F1 = \(\begin{bmatrix}3 \\9\end{bmatrix}\)
F2 = \(\begin{bmatrix}0.7 \\0.6\end{bmatrix}\)
Use normal math notation to write addition, subtraction, or multiplication by a scalar.
F1 + F2 = \(\color{#3333CC}{\begin{bmatrix}3 \\9\end{bmatrix}} + \color{#3333CC}{\begin{bmatrix}0.7 \\0.6\end{bmatrix}}\) = \(\begin{bmatrix}3.7 \\9.6\end{bmatrix}\)
P = 2 F1 = (2) \(\color{#3333CC}{\begin{bmatrix}3 \\9\end{bmatrix}}\) = \(\begin{bmatrix}6 \\18\end{bmatrix}\)
Dot Products
Type . or \cdot
to create a dot product symbol.
c = F1 ∙ F2 = \(\color{#3333CC}{\begin{bmatrix}3 \\9\end{bmatrix}} \cdot \color{#3333CC}{\begin{bmatrix}0.7 \\0.6\end{bmatrix}}\) = 7.5
Magnitudes
Use the |a| notation to find the magnitude of a vector.
m = |F1| = \(\color{#3333CC}{\begin{vmatrix}3 \\9\end{vmatrix}}\) = 9.49
Norms
Use the \(\small \|\mathit{\mathbf x}\| \) notation to find the norm [▼]\(\small ||\mathit{\mathbf z}||=\begin{cases}\sqrt{x_1^2+\cdots +x_n^2}&\text{ if }\mathit{\mathbf x}\text{ is a vector of reals} \\ \sqrt{|z_1|^2+\cdots +|z_n|^2}&\text{ if }\mathit{\mathbf z}\text{ is a complex vector} \end{cases}\) of a vector.
\(n= \left\lVert\mathbf F\right\rVert=\color{#3333CC}{\begin{Vmatrix}3 \\9\end{Vmatrix}}=9.487\)
Cross Products
Write \times
to get the cross product symbol ×.
F1 = \(\begin{bmatrix}3\\9\\4\end{bmatrix}\)
F2 = \(\begin{bmatrix}0.7\\0.6\\26\end{bmatrix}\)
\(\mathbf{P} = \mathbf{F_1}\times\mathbf{F_2} = \color{#3333CC}{\begin{bmatrix}3\\9\\4\end{bmatrix}} \times \color{#3333CC}{\begin{bmatrix}0.7\\0.6\\26\end{bmatrix}} = \begin{bmatrix}232\\-75.2\\-4.5\end{bmatrix}\)
Complex Numbers
ClariCalc can perform calculations with complex numbers. Examples:
\(\sqrt{-9}\) = 0 + 3i
(2 + 3i ) + (8 – 2i ) = 10 + 2i
(4) (2 + 3i ) = 8 + 12i
\(\frac 3{2+i}\) = 1.2 – 0.6i
You can set ClariCalc to recognize either “ i ” or “ j ” for \(\sqrt{-1}\).
There are four options for output format:
a + bi a + jb r∠θ (rad) r∠θ °
Use the Add-Ins | Edit | button to set formats.
You can assign a unit to a complex number.
(2)(2 + j 3 volts) = 4 + j 6 volts
Electrical engineers may find the polar format to be useful. The following example sums two out-of-phase energy sources:
E1 = 100V∠45°
E2 = 80V∠90°
E1 + E2 = (100V∠45°) + (80V∠90°) = 166V ∠ 64.9°
Keyboard Shortcuts
Below are some keyboard shortcuts that I have found useful. There are many more at Word Options | Proofing | AutoCorrect Options… | Math AutoCorrect.
Some of these shortcuts will instantly convert to their target. Others take effect only when (1) a ClariCalc calculation is run, or (2) when you type m after your formula.
Desired | Input | Comment |
---|---|---|
Math Zone | = | Creates a Word Math Zone |
exponent | ^exponent | Works for any exponent or subscript. Builds up in a Math Zone, or during calculation, or when you type alt+m after your formula. |
subscript | _subscript | |
√ | \r | Radical |
\(\sqrt[b]x\) | \r(b&x) | |
δ | \delta | Works for many Greek letters. Shortened versions, e.g. \d, work for some Greek letters, but not the ones with short English names, like nu or rho. |
Δ | \Delta | |
· | \cdot | Middle dot, as in: N·m |
. | ||
× | \times | |
÷ | \div | |
∕ | \ldiv | Linear div: a ∕ b Works best in a Math Zone. |
′ | ' | Prime Hit ' twice to get a double prime, ″. |
″ | \pprime | Double prime |
° | \degree | Degree |
o | ||
≤ | <= | |
≥ | >= | |
≠ | =/ | |
≉ | ~/ | |
≅ | ~= | |
≲ | <~ | |
≳ | >~ | |
\(\bar y\) | y\bar | Accents work best in a Math Zone. |
\(\hat{\theta}\) | θ\hat | |
\(\dot{z}\) | z\dot | |
\(\vec F\) | F\vec | |
∠ | \angle | \an also works. |
ø | o// | o with stroke |
← | <– | |
→ | –> | |
⇒ | => | |
✓ | \checkmark | |
† | \dagger | |
€ | \euro | |
£ | \pound | |
¥ | \yen | |
fc′ | fc' | Starts out as f_c^′ Builds up to fc′ during calculation. |