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