xref: /original-bsd/old/eqn/USD.doc/eqnguide/g1 (revision deff14a8)
%sccs.include.proprietary.roff%

@(#)g1 8.2 (Berkeley) 05/20/94

.SC Introduction

C EQN is a program for typesetting mathematics on the Graphics Systems phototypesetters on the X operating system. The C EQN language was designed to be easy to use by people who know neither mathematics nor typesetting. Thus C EQN knows relatively little about mathematics. In particular, mathematical symbols like +, -, \(mu, parentheses, and so on have no special meanings. C EQN is quite happy to set garbage (but it will look good).

C EQN works as a preprocessor for the typesetter formatter, C TROFF [1], so the normal mode of operation is to prepare a document with both mathematics and ordinary text interspersed, and let C EQN set the mathematics while C TROFF does the body of the text.

On C UNIX , C EQN will also produce mathematics on C DASI and C GSI terminals and on Model 37 teletypes. The input is identical, but you have to use the programs C NEQN and C NROFF instead of C EQN and C TROFF . Of course, some things won't look as good because terminals don't provide the variety of characters, sizes and fonts that a typesetter does, but the output is usually adequate for proofreading.

To use C EQN on C UNIX ,

1 eqn files | troff

2 .SC Displayed Equations

To tell C EQN where a mathematical expression begins and ends, we mark it with lines beginning C .EQ and C .EN . Thus if you type the lines

1 ^EQ x=y+z ^EN

2 your output will look like x=y+z .EN The C .EQ and C .EN are copied through untouched; they are not otherwise processed by C EQN . This means that you have to take care of things like centering, numbering, and so on yourself. The most common way is to use the C TROFF and C NROFF macro package package `-ms' developed by M. E. Lesk[3], which allows you to center, indent, left-justify and number equations.

With the `-ms' package, equations are centered by default. To left-justify an equation, use C .EQ L instead of C .EQ . To indent it, use C .EQ I . Any of these can be followed by an arbitrary `equation number' which will be placed at the right margin. For example, the input

1 ^EQ I (3.1a) x = f(y/2) + y/2 ^EN

2 produces the output x = f(y/2) + y/2 .EN

There is also a shorthand notation so in-line expressions like $pi sub i sup 2$ can be entered without C .EQ and C .EN . We will talk about it in section 19. .SC Input spaces

Spaces and newlines within an expression are thrown away by C EQN . (Normal text is left absolutely alone.) Thus between C .EQ and C .EN ,

1 x=y+z

2 and

1 x = y + z

2 and

1 x = y + z

2 and so on all produce the same output x=y+z .EN You should use spaces and newlines freely to make your input equations readable and easy to edit. In particular, very long lines are a bad idea, since they are often hard to fix if you make a mistake. .SC Output spaces

To force extra spaces into the .ul output, use a tilde ``\|~\|'' for each space you want:

1 x~=~y~+~z

2 gives x~=~y~+~z .EN You can also use a circumflex ``^'', which gives a space half the width of a tilde. It is mainly useful for fine-tuning. Tabs may also be used to position pieces of an expression, but the tab stops must be set by C TROFF commands. .SC "Symbols, Special Names, Greek"

C EQN knows some mathematical symbols, some mathematical names, and the Greek alphabet. For example,

1 x=2 pi int sin ( omega t)dt

2 produces x = 2 pi int sin ( omega t)dt .EN Here the spaces in the input are necessary .R to tell C EQN that .ul int, .ul pi, .ul sin and .ul omega are separate entities that should get special treatment. The .ul sin, digit 2, and parentheses are set in roman type instead of italic; .ul pi and .ul omega are made Greek; and .ul int becomes the integral sign.

When in doubt, leave spaces around separate parts of the input. A .ul very common error is to type .ul f(pi) without leaving spaces on both sides of the .ul pi. As a result, C EQN does not recognize .ul pi as a special word, and it appears as $f(pi)$ instead of $f( pi )$.

A complete list of C EQN names appears in section 23. Knowledgeable users can also use C TROFF four-character names for anything C EQN doesn't know about. .SC "Spaces, Again"

The only way C EQN can deduce that some sequence of letters might be special is if that sequence is separated from the letters on either side of it. This can be done by surrounding a special word by ordinary spaces (or tabs or newlines), as we did in the previous section.

.tr ~~ You can also make special words stand out by surrounding them with tildes or circumflexes:

1 x~=~2~pi~int~sin~(~omega~t~)~dt

2 is much the same as the last example, except that the tildes not only separate the magic words like .ul sin, .ul omega, and so on, but also add extra spaces, one space per tilde: x~=~2~pi~int~sin~(~omega~t~)~dt .EN

Special words can also be separated by braces { } and double quotes "...", which have special meanings that we will see soon. .tr ~ .SC "Subscripts and Superscripts"

Subscripts and superscripts are obtained with the words .ul sub and .ul sup.

1 x sup 2 + y sub k

2 gives x sup 2 + y sub k .EN C EQN takes care of all the size changes and vertical motions needed to make the output look right. The words .ul sub and .ul sup must be surrounded by spaces; .ul x sub2 will give you $x sub2$ instead of $x sub 2$. Furthermore, don't forget to leave a space (or a tilde, etc.) to mark the end of a subscript or superscript. A common error is to say something like

1 y = (x sup 2)+1

2 which causes y = (x sup 2)+1 .EN instead of the intended y = (x sup 2 )+1 .EN

Subscripted subscripts and superscripted superscripts also work:

1 x sub i sub 1

2 is x sub i sub 1 .EN A subscript and superscript on the same thing are printed one above the other if the subscript comes .ul first:

1 x sub i sup 2

2 is x sub i sup 2 .EN

Other than this special case, .ul sub and .ul sup group to the right, so .ul x sup y sub z means $x sup {y sub z}$, not ${x sup y} sub z$. .SC "Braces for Grouping"

Normally, the end of a subscript or superscript is marked simply by a blank (or tab or tilde, etc.) What if the subscript or superscript is something that has to be typed with blanks in it? In that case, you can use the braces { and } to mark the beginning and end of the subscript or superscript:

1 e sup {i omega t}

2 is e sup {i omega t} .EN Rule: Braces can .ul always be used to force C EQN to treat something as a unit, or just to make your intent perfectly clear. Thus:

1 x sub {i sub 1} sup 2

2 is x sub {i sub 1} sup 2 .EN with braces, but

1 x sub i sub 1 sup 2

2 is x sub i sub 1 sup 2 .EN which is rather different.

Braces can occur within braces if necessary:

1 e sup {i pi sup {rho +1}}

2 is e sup {i pi sup {rho +1}} .EN The general rule is that anywhere you could use some single thing like .ul x, you can use an arbitrarily complicated thing if you enclose it in braces. C EQN will look after all the details of positioning it and making it the right size.

In all cases, make sure you have the right number of braces. Leaving one out or adding an extra will cause C EQN to complain bitterly.

Occasionally you will have to print braces. To do this, enclose them in double quotes, like "{". Quoting is discussed in more detail in section 14. .SC Fractions

To make a fraction, use the word .ul over:

1 a+b over 2c =1

2 gives a+b over 2c =1 .EN The line is made the right length and positioned automatically. Braces can be used to make clear what goes over what:

1 {alpha + beta} over {sin (x)}

2 is {alpha + beta} over {sin (x)} .EN What happens when there is both an .ul over and a .ul sup in the same expression? In such an apparently ambiguous case, C EQN does the .ul sup before the .ul over, so

1 -b sup 2 over pi

2 is $-b sup 2 over pi$ instead of $-b sup {2 over pi}$ The rules which decide which operation is done first in cases like this are summarized in section 23. When in doubt, however, .ul use braces to make clear what goes with what. .SC "Square Roots"

To draw a square root, use .ul sqrt:

1 2 sqrt a+b + 1 over sqrt {ax sup 2 +bx+c}

2 is sqrt a+b + 1 over sqrt {ax sup 2 +bx+c} .EN Warning _ square roots of tall quantities look lousy, because a root-sign big enough to cover the quantity is too dark and heavy:

1 sqrt {a sup 2 over b sub 2}

2 is sqrt{a sup 2 over b sub 2} .EN Big square roots are generally better written as something to the power \(12: (a sup 2 /b sub 2 ) sup half .EN which is

1 (a sup 2 /b sub 2 ) sup half

2 .SC "Summation, Integral, Etc."

Summations, integrals, and similar constructions are easy:

1 sum from i=0 to {i= inf} x sup i

2 produces sum from i=0 to {i= inf} x sup i .EN Notice that we used braces to indicate where the upper part $i= inf$ begins and ends. No braces were necessary for the lower part $i=0$, because it contained no blanks. The braces will never hurt, and if the .ul from and .ul to parts contain any blanks, you must use braces around them.

The .ul from and .ul to parts are both optional, but if both are used, they have to occur in that order.

Other useful characters can replace the .ul sum in our example:

1 int prod union inter

2 become, respectively, int ~~~~~~ prod ~~~~~~ union ~~~~~~ inter .EN Since the thing before the .ul from can be anything, even something in braces, .ul from-to can often be used in unexpected ways:

1 lim from {n -> inf} x sub n =0

2 is lim from {n-> inf} x sub n =0 .EN