summaryrefslogtreecommitdiffstats
path: root/doc/kmplot/using.docbook
blob: f96e9af351bf23e7cdb3653e1109309d32f11599 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
<chapter id="using-kmplot">
<title>Using &kmplot;</title>

<para>&kmplot; deals with named functions, which can be specified in
terms of Cartesian coordinates (called <quote>explicit
functions</quote>), polar coordinates or as parametric functions. To
enter a function, choose
<menuchoice><guimenu>Plot</guimenu><guimenuitem>Edit
Plots...</guimenuitem> </menuchoice>. You can also enter new functions
in the <guilabel>Function equation</guilabel> text box in the main
&kmplot; window. The text box can handle explicit and polar
functions. Each function you enter must have a unique name (&ie;, a
name that is not taken by any of the existing functions displayed in
the list box). A function name will be automatically generated if you
do not specify one.</para>

<para>For more information on &kmplot; functions, see <xref
linkend="reference"/>.
</para>

<screenshot>
<screeninfo>Here is a screenshot of the &kmplot; welcome window</screeninfo>
	<mediaobject>
	  <imageobject>
	    <imagedata fileref="main.png" format="PNG"/>
	  </imageobject>
	  <textobject>
	    <phrase>Screenshot</phrase>
	  </textobject>
	</mediaobject>
</screenshot>

<sect1 id="function-types">
<title>Function Types</title>

<sect2 id="explicit-functions">
<title>Explicit Functions</title>
<para>To enter an explicit function (&ie;, a function in the form y=f(x)) into &kmplot;, just enter it in the
following form:
<screen>
<userinput><replaceable>f</replaceable>(<replaceable>x</replaceable>)=<replaceable>expression</replaceable></userinput>
</screen>
Where:
<itemizedlist>
<listitem><para>
 <replaceable>f</replaceable> is the name of the function, and can be any
string of letters and numbers you like, provided it does not start with any of
the letters x, y or r (since these are used for parametric and polar
functions).</para>
</listitem>

<listitem><para>
<replaceable>x</replaceable> is the x-coordinate, to be used in the expression
following the equals sign. It is in fact a dummy variable, so you can use any
variable name you like, but the effect will be the same.</para>
</listitem>

<listitem>
<para><replaceable>expression</replaceable> is the expression to be plotted,
given in appropriate syntax for &kmplot;. See <xref linkend="math-syntax"/>.
</para>
</listitem>

</itemizedlist>
</para>
<para>As an example, to draw the graph of y=x<superscript>2</superscript>+2x,
enter the following into the functions dialog of &kmplot;:
<screen>
f(x)=x^2+2x
</screen>
</para>
</sect2>

<sect2 id="parametric-functions">
<title>Parametric Functions</title>
<para>Parametric functions are those in which the x and y coordinates are
defined by separate functions of another variable, often called t. To enter a
parametric function in &kmplot;, follow the procedure as for an explicit
function, but prefix the name of the function describing the x-coordinate with
the letter x, and the function describing the y-coordinate with the letter
y. As with explicit functions, you may use any variable name you wish for the
parameter. To draw a parametric function, you must go to <guimenu>Plot</guimenu><guimenuitem>New Parametric Plot...</guimenuitem>. A function name will be created automatic if you do not specify one.</para>
<para>As an example, suppose you want to draw a circle, which has parametric
equations x=sin(t), y=cos(t). In the &kmplot; functions dialog, do the
following:
<orderedlist>
<listitem><para>Open the parametric plot dialog with
<menuchoice><guimenu>Plot</guimenu><guimenuitem>New Parametric Plot...</guimenuitem>
</menuchoice>.</para>
</listitem>
<listitem><para>Enter a name for the function, say,
<userinput>circle</userinput>, in the <guilabel>Name</guilabel>
box. The names of the x and y functions change to match this name: the
x function becomes <guilabel>xcircle(t)</guilabel> and the y function
becomes <guilabel>ycircle(t)</guilabel>.</para>
</listitem>
<listitem>
<para>In the x and y boxes, enter the appropriate equations, &ie;,
<guilabel>xcircle(t)=</guilabel><userinput>sin(t)</userinput> and
<guilabel>ycircle(t)=</guilabel><userinput>cos(t)</userinput>.</para>
</listitem>
</orderedlist>
Click on <guibutton>OK</guibutton> and the function will be drawn.
</para>
<para>You can set some further options for the plot in this dialog:
<variablelist>

<varlistentry>
<term><guilabel>Hide</guilabel></term>
<listitem>
<para>If this option is selected, the plot is not drawn, but &kmplot;
remembers the function definition, so you can use it to define other
functions.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Custom plot minimum-range</guilabel></term>
<term><guilabel>Custom plot maximum-range</guilabel></term>
<listitem>
<para>If this options are selected, you can change the maximum and
minimum values of the parameter t for which the function is plotted
using the <guilabel>Min:</guilabel> and <guilabel>Max:</guilabel>
boxes.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Line width:</guilabel></term>
<listitem>
<para>With this option you can set the width of the line drawn on the
plot area, in units of 0.1mm.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><guilabel>Color:</guilabel></term>
<listitem>
<para>Click on the color box and pick a color in the dialog that
appears. The line on the plot will be drawn in this color.</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</sect2>

<sect2 id="polar-functions">
<title>Entering Functions in Polar Coordinates</title>

<para>Polar coordinates represent a point by its distance from the origin
(usually called r), and the angle a line from the origin to the point makes
with the x-axis (usually represented by the Greek letter theta). To enter
functions in polar coordinates, use the menu entry
<menuchoice><guimenu>Plot</guimenu><guimenuitem>New Polar Plot...</guimenuitem>
</menuchoice>. In the box labeled <guilabel>r</guilabel>, complete the
function definition, including the name of the theta variable you want
to use, &eg;, to draw the Archimedes' spiral r=theta, enter:
<screen>
<userinput>
(theta)=theta
</userinput>
</screen>
so that the whole line reads <quote>r(theta)=theta</quote>. Note that
you can use any name for the theta variable, so
<quote>r(foo)=foo</quote> would have produced exactly the same output.
</para>

</sect2>

</sect1>

<sect1 id="combining-functions">
<title>Combining Functions</title>
<para>Functions can be combined to produce new ones. Simply enter the functions
after the equals sign in an expression as if the functions were variables. For
example, if you have defined functions f(x) and g(x), you can plot the sum of f
and g with:
<screen>
<userinput>
sum(x)=f(x)+g(x)
</userinput>
</screen>
</para>
<para>Note that you can only combine functions of the same type, &eg; an
explicit function cannot be combined with a polar function.</para>
</sect1>

<sect1 id="function-appearance">
<title>Changing the appearance of functions</title>

<para>To change the appearance of a function's graph on the main plot
window, select the function in the <guilabel>Edit Plots</guilabel>
dialog, and click on the <guibutton>Edit</guibutton> button. In the
dialog which appears, you can change the line width in the text box,
and the color of the function's graph by clicking on the color button
at the bottom. If you are editing an explicit function, you will see a
dialog with three tabs. In the first one you specify the equation of
the function. The <guilabel>Derivatives</guilabel> tab lets you draw
the first and second derivative to the function. With the
<guilabel>Integral</guilabel> tab you can draw the integral of the
function which is calculated using Euler's method. </para>
<para>Another way to edit a function is to right click on the
graph. In the popup menu that appears, choose
<guibutton>Edit</guibutton></para>

<para>For more information on the popup menu, see <xref
linkend="popupmenu"/>.
</para>
</sect1>

<sect1 id="popupmenu">
<title>Popup menu</title>

<para>When right-clicking on a plot function or a single-point parametric plot function a popup menu will appear.
In the menu there are five items available:</para>

<variablelist>
<varlistentry>
<term><menuchoice><guimenuitem>Hide</guimenuitem>
</menuchoice></term>
<listitem>
<para>Hides the selected graph. Other plots of the graph's function will still be shown.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><menuchoice><guimenuitem>Remove</guimenuitem>
</menuchoice></term>
<listitem>
<para>Removes the function. All its graphs will disappear.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><menuchoice><guimenuitem>Edit</guimenuitem>
</menuchoice></term>
<listitem>
<para>Shows the editor dialog for the selected function.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><menuchoice><guimenuitem>Copy</guimenuitem>
</menuchoice></term>
<listitem>
<para>Copies the graph to another running &kmplot; instance.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><menuchoice><guimenuitem>Move</guimenuitem>
</menuchoice></term>
<listitem>
<para>Moves the graph to another running &kmplot; instance.</para>
</listitem>
</varlistentry>
</variablelist>

<para>For plot functions the following four items are also available:</para>

<variablelist>
<varlistentry>
<term><menuchoice><guimenuitem>Get y-Value</guimenuitem>
</menuchoice></term>
<listitem>
<para>Opens a dialog in which you can find the y-value corresponding to
a specific x-value. The selected graph will be highlighted in the
dialog. Enter an x value in the <guilabel>X:</guilabel> box, and click
on <guibutton>Calculate</guibutton> (or press &Enter;). The corresponding y
value will be shown under <guilabel>Y:</guilabel>.
</para>
</listitem>
</varlistentry>

<varlistentry>
<term><menuchoice><guimenuitem>Search for Minimum Value</guimenuitem>
</menuchoice></term>
<listitem>
<para>Find the minimum value of the graph in a specified range. The
selected graph will be highlighted in the dialog that appears. Enter
the lower and upper boundaries of the region in which you want to
search for a minimum, and click <guibutton>Find</guibutton>. The x and
y values at the minimum will be shown.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><menuchoice><guimenuitem>Search for Maximum Value</guimenuitem>
</menuchoice></term>
<listitem>
<para>This is the same as <guimenuitem>Search for Minimum
Value</guimenuitem> above, but finds maximum values instead of minima. </para>
</listitem>
</varlistentry>

<varlistentry>
<term><menuchoice><guimenuitem>Calculate Integral</guimenuitem>
</menuchoice></term>
<listitem>
<para>Select the x-values for the graph in the new dialog that appears.
Calulates the integral and draws the area between the graph and the x-axis in the 
selected range in the color of the graph.</para>
</listitem>
</varlistentry>
</variablelist>


</sect1>


</chapter>