BSD 3 development
[unix-history] / usr / doc / eqn / e4
Content-type: text/html git.subgeniuskitty.com - unix-history/.git/blame - usr/doc/eqn/e4


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 8) line 1, <$fd> line 396.
CommitLineData
8340f87c
BJ
1.NH
2The Language
3.PP
4We will not try to describe the language precisely here;
5interested readers may refer to the appendix for more details.
6Throughout this section, we will write expressions
7exactly
8as they are handed to the typesetting program (hereinafter called
9.UC ``EQN'' ),
10except that we won't show the delimiters
11that the user types to mark the beginning and end of the expression.
12The interface between
13.UC EQN
14and
15.UC TROFF
16is described at the end of this section.
17.PP
18As we said, typing x=y+z+1 should produce $x=y+z+1$,
19and indeed it does.
20Variables are made italic, operators and digits become roman,
21and normal spacings between letters and operators are altered slightly
22to give a more pleasing appearance.
23.PP
24Input is free-form.
25Spaces and new lines in the input are used by
26.UC EQN
27to separate pieces of the input;
28they are not used to create space in the output.
29Thus
30.P1
31x = y
32 + z + 1
33.P2
34also gives $x=y+z+1$.
35Free-form input is easier to type initially;
36subsequent editing is also easier,
37for an expression may be typed as many short lines.
38.PP
39Extra white space can be forced into the output by several
40characters of various sizes.
41A tilde ``\|~\|'' gives a space equal
42to the normal word spacing in text;
43a circumflex gives half this much,
44and a tab charcter spaces to the next tab stop.
45.PP
46Spaces (or tildes, etc.)
47also serve to delimit pieces of the input.
48For example, to get
49.EQ
50f(t) = 2 pi int sin ( omega t )dt
51.EN
52we write
53.P1
54f(t) = 2 pi int sin ( omega t )dt
55.P2
56Here spaces are
57.ul
58necessary
59in the input
60to indicate that
61.ul
62sin, pi, int,
63and
64.ul
65omega
66are special, and potentially worth special treatment.
67.UC EQN
68looks up each such string of characters
69in a table, and if appropriate gives it a translation.
70In this case,
71.ul
72pi
73and
74.ul
75omega
76become their greek equivalents,
77.ul
78int
79becomes the integral sign
80(which must be moved down and enlarged so it looks ``right''),
81and
82.ul
83sin
84is made roman, following conventional mathematical practice.
85Parentheses, digits and operators are automatically made roman
86wherever found.
87.PP
88Fractions are specified with the keyword
89.ul
90over:
91.P1
92a+b over c+d+e = 1
93.P2
94produces
95.EQ
96a+b over c+d+e = 1
97.EN
98.PP
99Similarly, subscripts and superscripts are introduced by the keywords
100.ul
101sub
102and
103.ul
104sup:
105.EQ
106x sup 2 + y sup 2 = z sup 2
107.EN
108is produced by
109.P1
110x sup 2 + y sup 2 = z sup 2
111.P2
112The spaces after the 2's are necessary to mark the end of
113the superscripts;
114similarly the keyword
115.ul
116sup
117has to be marked off by spaces or
118some equivalent delimiter.
119The return to the proper baseline is automatic.
120Multiple levels of subscripts or superscripts
121are of course allowed:
122``x\|\|sup\|\|y\|\|sup\|\|z'' is
123$x sup y sup z$.
124The construct
125``something
126.ul
127sub
128something
129.ul
130sup
131something''
132is recognized as a special case,
133so
134``x sub i sup 2''
135is
136$x sub i sup 2$ instead of ${x sub i} sup 2$.
137.PP
138More complicated expressions can now be formed with these
139primitives:
140.EQ
141{partial sup 2 f} over {partial x sup 2} =
142x sup 2 over a sup 2 + y sup 2 over b sup 2
143.EN
144is produced by
145.P1
146.ce 0
147 {partial sup 2 f} over {partial x sup 2} =
148 x sup 2 over a sup 2 + y sup 2 over b sup 2
149.P2
150Braces {} are used to group objects together;
151in this case they indicate unambiguously what goes over what
152on the left-hand side of the expression.
153The language defines the precedence of
154.ul
155sup
156to be higher than that of
157.ul
158over,
159so
160no braces are needed to get the correct association on the right side.
161Braces can always be used when in doubt
162about precedence.
163.PP
164The braces convention is an example of the power
165of using a recursive grammar
166to define the language.
167It is part of the language that if a construct can appear
168in some context,
169then
170.ul
171any expression
172in braces
173can also occur in that context.
174.PP
175There is a
176.ul
177sqrt
178operator for making square roots of the appropriate size:
179``sqrt a+b'' produces $sqrt a+b$,
180and
181.P1
182x = {-b +- sqrt{b sup 2 -4ac}} over 2a
183.P2
184is
185.EQ
186x={-b +- sqrt{b sup 2 -4ac}} over 2a
187.EN
188Since large radicals look poor on our typesetter,
189.ul
190sqrt
191is not useful for tall expressions.
192.PP
193