Arithmetic

On a previous page, you learned the Shwa numerals and signs. On this page, we'll discuss the symbols needed to express basic arithmetic.

Addition

In English, we use + to separate numbers being added together, but when we enclose a total in a larger expression, we have to surround it with parentheses or brackets, as in [4+3]. In Shwa, we simply enclose the addends - numbers or larger formulas - to indicate that they should be added together, with spaces (dots) separating the expressions. The brackets for addition have slanted bottoms:

Subtraction

To indicate subtraction, we replace the space with a negative sign before the number(s) being subtracted. You can subtract individual numbers or expressions no matter where they are in the sequence, even first.

Multiplication

Multiplication works just like addition, except that the brackets have slanted tops, instead of slanted bottoms:

Division

Finally, division replaces the spaces in multiplication with the reciprocal sign. As with subtraction, you can divide individual numbers anywhere in the sequence.

Precedence

These four operations can be combined without fear of ambiguity (and without precedence rules).

The bottom line shows a version where the signs have all been connected beyond the line of digits to make the grouping very explicit.

Exponentiation

On the last page, you saw how to write integer powers like . But that's only the simplest type of exponentiation. The exponent might also be a real number (a logarithm), a variable, or a complicated expression. The base might also be a complicated expression. In those cases, the base won't be low, and the exponent high. But we still use the same notation: a Break separating the base on the left from the exponent on the right.

Here's a complicated example: the quadratic formula. I've used the letters p t k to represent the coefficients of the quadratic px² + tx + k = 0, whose roots are the solutions to the formula. The second example is in connected form, which you may find easier to read.

-t + √(t² - 4pk)
2p

(It's not correct to use ± before the root, since both square roots are added - one of them just happens to be negative.)

Names of Constants, Variables and Functions

As in English, Shwa uses words within expressions to spell the names of constants, variables and functions. Placeholder variables, as above, are usually written with a single consonant, and can be used as if they were digits. But a longer sequence with consonants is a word, not a number, and should be separated from numbers with spaces. Unlike most computer languages, Shwa doesn't include digits in names, since they'd be read as vowels.

Here are some examples of well-known constants:

Units of measurement are always written before numbers, separated by a space (which implies multiplication). For example, kg 1°81 is how we write 81 kilograms.

Compound unit names may include the reciprocal sign or a power, preceded by a space:

Measurements usually use magnitude notation: they're real numbers, not integers. Note the relationship between the Shwa exponent and the metric prefix:  could be rewritten .

Functions

Functions not only have names; they also have arguments, parameters being passed to the function. For example, the famous trigonometric functions sin(α) cos(α) tan(α) all require an angle α. In Shwa, we use simple spaces to separate the arguments from the function name and from each other.

By the way, angles are expressed in Shwa as fractions of a full circle, not as radians or degrees. One full circle is called 1 Torit, abbreviated To. For example, an angle of π radians or 180° would simply be a Shwa angle of ½ Torit, written . The arguments to the trig functions are in Torits, so they already have the 2π built in. Instead of writing cos(π/3) = 1/2, we would write cos(1/6) = 1/2.

Very technical note: Shwa function notation is an example of currying, reducing all functions to one argument. For example, consider the common function log(b, n) that returns the logarithm of the number n in base b: it has two arguments. But the common function ln(n), which returns the natural logarithm of n (with base e) only has one argument. Reinterpreting the two-argument function log(e, n) as the one-argument function ln(n) is an example of currying: it's as if we wrote log(e)(n).

Positive Arithmetic

In positive arithmetic, there are only positive numbers (including zero). The operators all use a doubled negative sign. As a unary prefix, it indicates the absolute value of a number (the number without the sign):

When it replaces the subtraction sign between two numbers, it indicates the difference between them, which is always positive. For example, we say that New York is the same distance from San Francisco as San Francisco is from New York, not its negative.

Modular Division

The two Modulo functions - quotient and modulus - are a variant of division. The main use of these functions is to perform conversions of numbers from one form into another: into integers, real numbers, or multiples of a modulus. In the expression a ÷ b, a is called the dividend and b is called the divisor. The result of quot is called the quotient, and the result of mod is called the remainder.

If the dividend and divisor are both natural numbers (positive integers, including zero), then the quotient and remainder are also both natural numbers, and the following three properties hold:

For example, consider 7÷4. Using normal (real) division, the result is 1.75, and if you multiply the divisor by the quotient, you get the dividend: 7 = 4 × 1.75. But using modular division, the quotient would be 1 with a remainder of 3, and 7 = 4 × 1 + 3.

When the dividend and divisor aren't both natural numbers, the results are more complicated, but the same three properties always hold. When the divisor is negative, so is the remainder. When the dividend or divisor is real, so is the remainder. When the divisor is 1, the remainder is the fractional part of the number: 0 ≤ r < 1. When the divisor is zero, so is the quotient but not the remainder (and the division is valid)!

The two operations are used more often than you might think, for example for dates and times, or to separate numbers into integer+fraction, or real+imaginary, or larger+smaller than an arbitrary size. For instance, if you want to know how many 8-packs of hot dog buns you'll need for five 6-packs of hot dogs, it's (5×6) quot -8 (the divisor is negative so the remainder is negative: leftover buns).

Equalities

Shwa offers symbols for nine equalities, all written between spaces.

The equals sign looks the same in Shwa as it does in English:

If the first number is greater than the second, we write:

Likewise, if the first number is less than the second, we write:

These three signs combine to form symbols for greater than or equal to and less than or equal to:

A "greater or lesser" sign is used to symbolize unequal, that is, not equal:

There is also a sign for approximate equality, which is sometimes used as a general symbol for ambiguity. The lower line starts near on the left, then diverges, as if to say "they kinda seem alike, but when you look closer, they're not".

There is a different sign for equivalence, which means "not identical, but equivalent in some quality". For example, this is the relationship between the two square roots of negative 1. It might be used outside of arithmetic to match corresponding items, e.g. English cat ↔ French chat. The lower line starts far on the left then converges, as if to say "they kinda seem different, but when you look closer, they're not".

Finally, there is a sign for assignment or definition, which means "the value of the expression on the left is being assigned to the item on the right", or "the item on the right is being defined by the value on the left", or they're equal by definition, always. Note that the arrow formed by the two accents points to the right, and the value precedes the assignment, the opposite of our usual notation.

Recap of Symbols

To recap, here are all the symbols in the Shwa script :

That's all you need to write numbers and formulas in Shwa!

If you're interested, the link at right below leads to a set of pages describing another number system, the balanced dozenal or Janus numbers, and a metric system based on them. They are an example of a very different numeric "language" that the Shwa script enables. But you don't have to learn them to use Shwa, any more than you need to learn Zulu or Inuktitut to write English in Shwa.


< Numerals Janus Numbers >


© 2002-2018 Shwa shwa@shwa.org 07jan18