Bell 32V development
[unix-history] / usr / doc / eqn / g1
CommitLineData
755c0b0d
TL
1.if t .2C
2.SC Introduction
3.PP
4.UC EQN
5is a
6program for typesetting mathematics
7on the Graphics Systems phototypesetters on
8.UC UNIX
9and
10.UC GCOS .
11The
12.UC EQN
13language was designed to be easy to use
14by people who know neither mathematics
15nor typesetting.
16Thus
17.UC EQN
18knows relatively little about mathematics.
19In particular, mathematical symbols like
20+, \(mi, \(mu, parentheses, and so on have no special meanings.
21.UC EQN
22is quite happy to set garbage (but it will look good).
23.PP
24.UC EQN
25works as a preprocessor for the typesetter formatter,
26.UC TROFF [1],
27so the normal mode of operation is to prepare
28a document with both mathematics and ordinary text
29interspersed,
30and let
31.UC EQN
32set the mathematics while
33.UC TROFF
34does the body of the text.
35.PP
36On
37.UC UNIX ,
38.UC EQN
39will also produce mathematics on
40.UC DASI
41and
42.UC GSI
43terminals and on
44Model 37 teletypes.
45The input is identical, but you have to use the programs
46.UC NEQN
47and
48.UC NROFF
49instead of
50.UC EQN
51and
52.UC TROFF .
53Of course, some things won't look as good
54because terminals
55don't provide the variety of characters, sizes and fonts
56that a typesetter does,
57but the output is usually adequate for proofreading.
58.PP
59To use
60.UC EQN
61on
62.UC UNIX ,
63.P1
64eqn files | troff
65.P2
66.UC GCOS
67use is discussed in section 26.
68.SC Displayed Equations
69.PP
70To tell
71.UC EQN
72where a mathematical expression begins and ends,
73we mark it with lines beginning
74.UC .EQ
75and
76.UC .EN .
77Thus
78if you type the lines
79.P1
80^EQ
81x=y+z
82^EN
83.P2
84your output will look like
85.EQ
86x=y+z
87.EN
88The
89.UC .EQ
90and
91.UC .EN
92are copied through untouched;
93they
94are not otherwise processed
95by
96.UC EQN .
97This means that you have to take care
98of things like centering, numbering, and so on
99yourself.
100The most common way is to use the
101.UC TROFF
102and
103.UC NROFF
104macro package package `\(mims'
105developed by M. E. Lesk[3],
106which allows you to center, indent, left-justify and number equations.
107.PP
108With the `\(mims' package,
109equations are centered by default.
110To left-justify an equation, use
111.UC \&.EQ\ L
112instead of
113.UC .EQ .
114To indent it, use
115.UC .EQ\ I .
116Any of these can be followed by an arbitrary `equation number'
117which will be placed at the right margin.
118For example, the input
119.P1
120^EQ I (3.1a)
121x = f(y/2) + y/2
122^EN
123.P2
124produces the output
125.EQ I (3.1a)
126x = f(y/2) + y/2
127.EN
128.PP
129There is also a shorthand notation so
130in-line expressions
131like
132$pi sub i sup 2$
133can be entered without
134.UC .EQ
135and
136.UC .EN .
137We will talk about it in section 19.
138.SC Input spaces
139.PP
140Spaces and newlines within an expression are thrown away by
141.UC EQN .
142(Normal text is left absolutely alone.)
143Thus
144between
145.UC .EQ
146and
147.UC .EN ,
148.P1
149x=y+z
150.P2
151and
152.P1
153x = y + z
154.P2
155and
156.P1
157x = y
158 + z
159.P2
160and so on
161all produce the same
162output
163.EQ
164x=y+z
165.EN
166You should use spaces and newlines freely to make your input equations
167readable and easy to edit.
168In particular, very long lines are a bad idea,
169since they are often hard to fix if you make a mistake.
170.SC Output spaces
171.PP
172To force extra spaces into the
173.ul
174output,
175use a tilde ``\|~\|''
176for each space you want:
177.P1
178x~=~y~+~z
179.P2
180gives
181.EQ
182x~=~y~+~z
183.EN
184You can also use a circumflex ``^'',
185which gives a space half the width of a tilde.
186It is mainly useful for fine-tuning.
187Tabs may also be used to position pieces
188of an expression,
189but the tab stops must be set by
190.UC TROFF
191commands.
192.SC "Symbols, Special Names, Greek"
193.PP
194.UC EQN
195knows some mathematical symbols,
196some mathematical names, and the Greek alphabet.
197For example,
198.P1
199x=2 pi int sin ( omega t)dt
200.P2
201produces
202.EQ
203x = 2 pi int sin ( omega t)dt
204.EN
205Here the spaces in the input are
206.B
207necessary
208.R
209to tell
210.UC EQN
211that
212.ul
213int,
214.ul
215pi,
216.ul
217sin
218and
219.ul
220omega
221are separate entities that should get special treatment.
222The
223.ul
224sin,
225digit 2, and parentheses are set in roman type instead of italic;
226.ul
227pi
228and
229.ul
230omega
231are made Greek;
232and
233.ul
234int
235becomes the integral sign.
236.PP
237When in doubt, leave spaces around separate parts of the input.
238A
239.ul
240very
241common error is to type
242.ul
243f(pi)
244without leaving spaces on both sides of the
245.ul
246pi.
247As a result,
248.UC EQN
249does not recognize
250.ul
251pi
252as a special word, and it appears as
253$f(pi)$
254instead of
255$f( pi )$.
256.PP
257A complete list of
258.UC EQN
259names appears in section 23.
260Knowledgeable users can also use
261.UC TROFF
262four-character names
263for anything
264.UC EQN
265doesn't know about,
266like
267.ul
268\\(bs
269for the Bell System sign \(bs.
270.SC "Spaces, Again"
271.PP
272The only way
273.UC EQN
274can deduce that some sequence
275of letters might be special
276is if that sequence is separated from the letters
277on either side of it.
278This can be done by surrounding a special word by ordinary spaces
279(or tabs or newlines),
280as we did in the previous section.
281.PP
282.tr ~~
283You can also make special words stand out by surrounding them
284with tildes or circumflexes:
285.P1
286x~=~2~pi~int~sin~(~omega~t~)~dt
287.P2
288is much the same as the last example,
289except that the tildes
290not only
291separate the magic words
292like
293.ul
294sin,
295.ul
296omega,
297and so on,
298but also add extra spaces,
299one space per tilde:
300.EQ
301x~=~2~pi~int~sin~(~omega~t~)~dt
302.EN
303.PP
304Special words can also be separated by braces { }
305and double quotes "...",
306which have special meanings that we will
307see soon.
308.tr ~
309.SC "Subscripts and Superscripts"
310.PP
311Subscripts and superscripts are
312obtained with the words
313.ul
314sub
315and
316.ul
317sup.
318.P1
319x sup 2 + y sub k
320.P2
321gives
322.EQ
323x sup 2 + y sub k
324.EN
325.UC EQN
326takes care of all the size changes and vertical motions
327needed to make the output look right.
328The words
329.ul
330sub
331and
332.ul
333sup
334must be surrounded by spaces;
335.ul
336x sub2
337will give you
338$x sub2$ instead of $x sub 2$.
339Furthermore, don't forget to leave a space
340(or a tilde, etc.)
341to mark the end of a subscript or superscript.
342A common error is to say
343something like
344.P1
345y = (x sup 2)+1
346.P2
347which causes
348.EQ
349y = (x sup 2)+1
350.EN
351instead of
352the intended
353.EQ
354y = (x sup 2 )+1
355.EN
356.PP
357Subscripted subscripts and superscripted superscripts
358also work:
359.P1
360x sub i sub 1
361.P2
362is
363.EQ
364x sub i sub 1
365.EN
366A subscript and superscript on the same thing
367are printed one above the other
368if the subscript comes
369.ul
370first:
371.P1
372x sub i sup 2
373.P2
374is
375.EQ
376x sub i sup 2
377.EN
378.PP
379Other than this special case,
380.ul
381sub
382and
383.ul
384sup
385group to the right, so
386.ul
387x\ sup\ y\ sub\ z
388means
389$x sup {y sub z}$, not ${x sup y} sub z$.
390.SC "Braces for Grouping"
391.PP
392Normally, the end of a subscript or superscript is marked
393simply by a blank (or tab or tilde, etc.)
394What if the subscript or superscript is something that has to be typed
395with blanks in it?
396In that case, you can use the braces
397{ and } to mark the
398beginning and end of the subscript or superscript:
399.P1
400e sup {i omega t}
401.P2
402is
403.EQ
404e sup {i omega t}
405.EN
406.sp
407Rule: Braces can
408.ul
409always
410be used to force
411.UC EQN
412to treat something as a unit,
413or just to make your intent perfectly clear.
414Thus:
415.P1
416x sub {i sub 1} sup 2
417.P2
418is
419.EQ
420x sub {i sub 1} sup 2
421.EN
422with braces, but
423.P1
424x sub i sub 1 sup 2
425.P2
426is
427.EQ
428x sub i sub 1 sup 2
429.EN
430which is rather different.
431.PP
432Braces can occur within braces if necessary:
433.P1
434e sup {i pi sup {rho +1}}
435.P2
436is
437.EQ
438e sup {i pi sup {rho +1}}
439.EN
440The general rule is that anywhere you could use some single
441thing like
442.ul
443x,
444you can use an arbitrarily complicated thing if you enclose
445it in braces.
446.UC EQN
447will look after all the details of positioning it and making
448it the right size.
449.PP
450In all cases, make sure you have the
451right number of braces.
452Leaving one out or adding an extra will cause
453.UC EQN
454to complain bitterly.
455.PP
456Occasionally you will have to
457print braces.
458To do this,
459enclose them in double quotes,
460like "{".
461Quoting is discussed in more detail in section 14.
462.SC Fractions
463.PP
464To make a fraction,
465use the word
466.ul
467over:
468.P1
469a+b over 2c =1
470.P2
471gives
472.EQ
473a+b over 2c =1
474.EN
475The line is made the right length and positioned automatically.
476Braces can be used to make clear what goes over what:
477.P1
478{alpha + beta} over {sin (x)}
479.P2
480is
481.EQ
482{alpha + beta} over {sin (x)}
483.EN
484What happens when there is both an
485.ul
486over
487and a
488.ul
489sup
490in the same expression?
491In such an apparently ambiguous case,
492.UC EQN
493does the
494.ul
495sup
496before the
497.ul
498over,
499so
500.P1
501\(mib sup 2 over pi
502.P2
503is
504$-b sup 2 over pi$
505instead of
506$-b sup {2 over pi}$
507The rules
508which decide which operation is done first in cases like this
509are summarized in section 23.
510When in doubt, however,
511.ul
512use braces
513to make clear what goes with what.
514.SC "Square Roots"
515.PP
516To draw a square root, use
517.ul
518sqrt:
519.P1 2
520sqrt a+b + 1 over sqrt {ax sup 2 +bx+c}
521.P2
522is
523.EQ
524sqrt a+b + 1 over sqrt {ax sup 2 +bx+c}
525.EN
526Warning _ square roots of tall quantities look lousy,
527because a root-sign
528big enough to cover the quantity is
529too dark and heavy:
530.P1
531sqrt {a sup 2 over b sub 2}
532.P2
533is
534.EQ
535sqrt{a sup 2 over b sub 2}
536.EN
537Big square roots are generally better written as something
538to the power \(12:
539.EQ
540(a sup 2 /b sub 2 ) sup half
541.EN
542which is
543.P1
544(a sup 2 /b sub 2 ) sup half
545.P2
546.SC "Summation, Integral, Etc."
547.PP
548Summations, integrals, and similar constructions
549are easy:
550.P1
551sum from i=0 to {i= inf} x sup i
552.P2
553produces
554.EQ
555sum from i=0 to {i= inf} x sup i
556.EN
557Notice that we used
558braces to indicate where the upper
559part
560$i= inf$
561begins and ends.
562No braces were necessary for the lower part $i=0$,
563because it contained no blanks.
564The braces will never hurt,
565and if the
566.ul
567from
568and
569.ul
570to
571parts contain any blanks, you must use braces around them.
572.PP
573The
574.ul
575from
576and
577.ul
578to
579parts are both optional,
580but if both are used,
581they have to occur in that order.
582.PP
583Other useful characters can replace the
584.ul
585sum
586in our example:
587.P1
588int prod union inter
589.P2
590become, respectively,
591.EQ
592int ~~~~~~ prod ~~~~~~ union ~~~~~~ inter
593.EN
594Since the thing before the
595.ul
596from
597can be anything,
598even something in braces,
599.ul
600from-to
601can often be used in unexpected ways:
602.P1
603lim from {n \(mi> inf} x sub n =0
604.P2
605is
606.EQ
607lim from {n-> inf} x sub n =0
608.EN