~ubuntu-branches/debian/squeeze/maxima/squeeze

« back to all changes in this revision

Viewing changes to doc/info/maxima.info-3

  • Committer: Bazaar Package Importer
  • Author(s): Camm Maguire
  • Date: 2006-10-18 14:52:42 UTC
  • mto: (1.1.5 upstream)
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: james.westby@ubuntu.com-20061018145242-vzyrm5hmxr8kiosf
ImportĀ upstreamĀ versionĀ 5.10.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
This is maxima.info, produced by makeinfo version 4.5 from maxima.texi.
 
1
This is maxima.info, produced by makeinfo version 4.7 from maxima.texi.
2
2
 
3
3
   This is a Texinfo Maxima Manual
4
4
 
9
9
END-INFO-DIR-ENTRY
10
10
 
11
11
 
12
 
File: maxima.info,  Node: Definitions for Expressions,  Prev: SYNTAX,  Up: Expressions
13
 
 
14
 
Definitions for Expressions
 
12
File: maxima.info,  Node: Definitions for Differential Equations,  Prev: Differential Equations,  Up: Differential Equations
 
13
 
 
14
22.1 Definitions for Differential Equations
 
15
===========================================
 
16
 
 
17
 -- Function: bc2 (<solution>, <xval1>, <yval1>, <xval2>, <yval2>)
 
18
     Solves boundary value problem for second order differential
 
19
     equation.  Here: <solution> is a general solution to the equation,
 
20
     as found by `ode2', <xval1> is an equation for the independent
 
21
     variable in the form `<x> = <x0>', and <yval1> is an equation for
 
22
     the dependent variable in the form `<y> = <y0>'.  The <xval2> and
 
23
     <yval2> are equations for these variables at another point.  See
 
24
     `ode2' for example of usage.
 
25
 
 
26
 
 
27
 -- Function: desolve (<eqn>, <x>)
 
28
 -- Function: desolve ([<eqn_1>, ..., <eqn_n>], [<x_1>, ..., <x_n>])
 
29
     The function `dsolve' solves systems of linear ordinary
 
30
     differential equations using Laplace transform.  Here the <eqn>'s
 
31
     are differential equations in the dependent variables <x_1>, ...,
 
32
     <x_n>.  The functional relationships must be explicitly indicated
 
33
     in both the equations and the variables. For example
 
34
 
 
35
          'diff(f,x,2)=sin(x)+'diff(g,x);
 
36
          'diff(f,x)+x^2-f=2*'diff(g,x,2);
 
37
 
 
38
     is not the proper format.  The correct way is:
 
39
 
 
40
          'diff(f(x),x,2)=sin(x)+'diff(g(x),x);
 
41
          'diff(f(x),x)+x^2-f=2*'diff(g(x),x,2);
 
42
 
 
43
     The call is then `desolve([%o3,%o4],[f(x),g(x)]);' .
 
44
 
 
45
     If initial conditions at 0 are known, they should be supplied
 
46
     before calling `desolve' by using `atvalue'.
 
47
 
 
48
          (%i1) 'diff(f(x),x)='diff(g(x),x)+sin(x);
 
49
                           d           d
 
50
          (%o1)            -- (f(x)) = -- (g(x)) + sin(x)
 
51
                           dx          dx
 
52
          (%i2) 'diff(g(x),x,2)='diff(f(x),x)-cos(x);
 
53
                            2
 
54
                           d            d
 
55
          (%o2)            --- (g(x)) = -- (f(x)) - cos(x)
 
56
                             2          dx
 
57
                           dx
 
58
          (%i3) atvalue('diff(g(x),x),x=0,a);
 
59
          (%o3)                           a
 
60
          (%i4) atvalue(f(x),x=0,1);
 
61
          (%o4)                           1
 
62
          (%i5) desolve([%o1,%o2],[f(x),g(x)]);
 
63
                            x
 
64
          (%o5) [f(x) = a %e  - a + 1, g(x) =
 
65
 
 
66
                                                          x
 
67
                                             cos(x) + a %e  - a + g(0) - 1]
 
68
          (%i6) [%o1,%o2],%o5,diff;
 
69
                       x       x      x                x
 
70
          (%o6)   [a %e  = a %e , a %e  - cos(x) = a %e  - cos(x)]
 
71
 
 
72
     If `desolve' cannot obtain a solution, it returns `false'.
 
73
 
 
74
 
 
75
 -- Function: ic1 (<solution>, <xval>, <yval>)
 
76
     Solves initial value problem for first order differential equation.
 
77
     Here: <solution> is a general solution to the equation, as found
 
78
     by `ode2', <xval> is an equation for the independent variable in
 
79
     the form `<x> = <x0>', and <yval> is an equation for the dependent
 
80
     variable in the form `<y> = <y0>'. See `ode2' for example of usage.
 
81
 
 
82
 
 
83
 -- Function: ic2 (<solution>, <xval>, <yval>, <dval>)
 
84
     Solves initial value problem for second order differential
 
85
     equation.  Here: <solution> is a general solution to the equation,
 
86
     as found by `ode2', <xval> is an equation for the independent
 
87
     variable in the form `<x> = <x0>', <yval> is an equation for the
 
88
     dependent variable in the form `<y> = <y0>', and <dval> is an
 
89
     equation for the derivative of the dependent variable with respect
 
90
     to independent variable evaluated at the point <xval>.  See `ode2'
 
91
     for example of usage.
 
92
 
 
93
 
 
94
 -- Function: ode2 (<eqn>, <dvar>, <ivar>)
 
95
     The function `ode2' solves ordinary differential equations of
 
96
     first or second order.  It takes three arguments: an ODE <eqn>,
 
97
     the dependent variable <dvar>, and the independent variable <ivar>.
 
98
     When successful, it returns either an explicit or implicit
 
99
     solution for the dependent variable.  `%c' is used to represent
 
100
     the constant in the case of first order equations, and `%k1' and
 
101
     `%k2' the constants for second order equations.  If `ode2' cannot
 
102
     obtain a solution for whatever reason, it returns `false', after
 
103
     perhaps printing out an error message.  The methods implemented
 
104
     for first order equations in the order in which they are tested
 
105
     are: linear, separable, exact - perhaps requiring an integrating
 
106
     factor, homogeneous, Bernoulli's equation, and a generalized
 
107
     homogeneous method.  For second order: constant coefficient,
 
108
     exact, linear homogeneous with non-constant coefficients which can
 
109
     be transformed to constant coefficient, the Euler or
 
110
     equidimensional equation, the method of variation of parameters,
 
111
     and equations which are free of either the independent or of the
 
112
     dependent variable so that they can be reduced to two first order
 
113
     linear equations to be solved sequentially.  In the course of
 
114
     solving ODEs, several variables are set purely for informational
 
115
     purposes: `method' denotes the method of solution used e.g.
 
116
     `linear', `intfactor' denotes any integrating factor used,
 
117
     `odeindex' denotes the index for Bernoulli's method or for the
 
118
     generalized homogeneous method, and `yp' denotes the particular
 
119
     solution for the variation of parameters technique.
 
120
 
 
121
     In order to solve initial value problems (IVPs) and boundary value
 
122
     problems (BVPs), the routine `ic1' is available for first order
 
123
     equations, and `ic2' and `bc2' for second order IVPs and BVPs,
 
124
     respectively.
 
125
 
 
126
     Example:
 
127
 
 
128
          (%i1) x^2*'diff(y,x) + 3*y*x = sin(x)/x;
 
129
                                2 dy           sin(x)
 
130
          (%o1)                x  -- + 3 x y = ------
 
131
                                  dx             x
 
132
          (%i2) ode2(%,y,x);
 
133
                                       %c - cos(x)
 
134
          (%o2)                    y = -----------
 
135
                                            3
 
136
                                           x
 
137
          (%i3) ic1(%o2,x=%pi,y=0);
 
138
                                        cos(x) + 1
 
139
          (%o3)                   y = - ----------
 
140
                                             3
 
141
                                            x
 
142
          (%i4) 'diff(y,x,2) + y*'diff(y,x)^3 = 0;
 
143
                                   2
 
144
                                  d y      dy 3
 
145
          (%o4)                   --- + y (--)  = 0
 
146
                                    2      dx
 
147
                                  dx
 
148
          (%i5) ode2(%,y,x);
 
149
                                3
 
150
                               y  + 6 %k1 y
 
151
          (%o5)                ------------ = x + %k2
 
152
                                    6
 
153
          (%i6) ratsimp(ic2(%o5,x=0,y=0,'diff(y,x)=2));
 
154
                                       3
 
155
                                    2 y  - 3 y
 
156
          (%o6)                   - ---------- = x
 
157
                                        6
 
158
          (%i7) bc2(%o5,x=0,y=1,x=1,y=3);
 
159
                                   3
 
160
                                  y  - 10 y       3
 
161
          (%o7)                   --------- = x - -
 
162
                                      6           2
 
163
 
 
164
 
 
165
 
 
166
File: maxima.info,  Node: Numerical,  Next: Statistics,  Prev: Differential Equations,  Up: Top
 
167
 
 
168
23 Numerical
 
169
************
 
170
 
 
171
* Menu:
 
172
 
 
173
* Introduction to Numerical::
 
174
* Fourier packages::
 
175
* Definitions for Numerical::
 
176
* Definitions for Fourier Series::
 
177
 
 
178
 
 
179
File: maxima.info,  Node: Introduction to Numerical,  Next: Fourier packages,  Prev: Numerical,  Up: Numerical
 
180
 
 
181
23.1 Introduction to Numerical
 
182
==============================
 
183
 
 
184
 
 
185
File: maxima.info,  Node: Fourier packages,  Next: Definitions for Numerical,  Prev: Introduction to Numerical,  Up: Numerical
 
186
 
 
187
23.2 Fourier packages
 
188
=====================
 
189
 
 
190
The `fft' package comprises functions for the numerical (not symbolic)
 
191
computation of the fast Fourier transform.  `load ("fft")' loads this
 
192
package.  See `fft'.
 
193
 
 
194
   The `fourie' package comprises functions for the symbolic computation
 
195
of Fourier series.  `load ("fourie")' loads this package.  There are
 
196
functions in the `fourie' package to calculate Fourier integral
 
197
coefficients and some functions for manipulation of expressions.  See
 
198
`Definitions for Fourier Series'.
 
199
 
 
200
 
 
201
File: maxima.info,  Node: Definitions for Numerical,  Next: Definitions for Fourier Series,  Prev: Fourier packages,  Up: Numerical
 
202
 
 
203
23.3 Definitions for Numerical
 
204
==============================
 
205
 
 
206
 -- Function: polartorect (<magnitude_array>, <phase_array>)
 
207
     Translates complex values of the form `r %e^(%i t)' to the form `a
 
208
     + b %i'.  `load ("fft")' loads this function into Maxima. See also
 
209
     `fft'.
 
210
 
 
211
     The magnitude and phase, `r' and `t', are taken from
 
212
     <magnitude_array> and <phase_array>, respectively. The original
 
213
     values of the input arrays are replaced by the real and imaginary
 
214
     parts, `a' and `b', on return. The outputs are calculated as
 
215
 
 
216
          a: r cos (t)
 
217
          b: r sin (t)
 
218
 
 
219
     The input arrays must be the same size and 1-dimensional.  The
 
220
     array size need not be a power of 2.
 
221
 
 
222
     `polartorect' is the inverse function of `recttopolar'.
 
223
 
 
224
 
 
225
 -- Function: recttopolar (<real_array>, <imaginary_array>)
 
226
     Translates complex values of the form `a + b %i' to the form `r
 
227
     %e^(%i t)'.  `load ("fft")' loads this function into Maxima. See
 
228
     also `fft'.
 
229
 
 
230
     The real and imaginary parts, `a' and `b', are taken from
 
231
     <real_array> and <imaginary_array>, respectively. The original
 
232
     values of the input arrays are replaced by the magnitude and
 
233
     angle, `r' and `t', on return. The outputs are calculated as
 
234
 
 
235
          r: sqrt (a^2 + b^2)
 
236
          t: atan2 (b, a)
 
237
 
 
238
     The computed angle is in the range `-%pi' to `%pi'.
 
239
 
 
240
     The input arrays must be the same size and 1-dimensional.  The
 
241
     array size need not be a power of 2.
 
242
 
 
243
     `recttopolar' is the inverse function of `polartorect'.
 
244
 
 
245
 
 
246
 -- Function: ift (<real_array>, <imaginary_array>)
 
247
     Fast inverse discrete Fourier transform. `load ("fft")' loads this
 
248
     function into Maxima.
 
249
 
 
250
     `ift' carries out the inverse complex fast Fourier transform on
 
251
     1-dimensional floating point arrays. The inverse transform is
 
252
     defined as
 
253
 
 
254
          x[j]: sum (y[j] exp (+2 %i %pi j k / n), k, 0, n-1)
 
255
 
 
256
     See `fft' for more details.
 
257
 
 
258
 
 
259
 -- Function: fft (<real_array>, <imaginary_array>)
 
260
 -- Function: ift (<real_array>, <imaginary_array>)
 
261
 -- Function: recttopolar (<real_array>, <imaginary_array>)
 
262
 -- Function: polartorect (<magnitude_array>, <phase_array>)
 
263
     Fast Fourier transform and related functions. `load ("fft")' loads
 
264
     these functions into Maxima.
 
265
 
 
266
     `fft' and `ift' carry out the complex fast Fourier transform and
 
267
     inverse transform, respectively, on 1-dimensional floating point
 
268
     arrays. The size of <imaginary_array> must equal the size of
 
269
     <real_array>.
 
270
 
 
271
     `fft' and `ift' operate in-place. That is, on return from `fft' or
 
272
     `ift', the original content of the input arrays is replaced by the
 
273
     output.  The `fillarray' function can make a copy of an array,
 
274
     should it be necessary.
 
275
 
 
276
     The discrete Fourier transform and inverse transform are defined
 
277
     as follows. Let `x' be the original data, with
 
278
 
 
279
          x[i]: real_array[i] + %i imaginary_array[i]
 
280
 
 
281
     Let `y' be the transformed data. The forward and inverse
 
282
     transforms are
 
283
 
 
284
          y[k]: (1/n) sum (x[j] exp (-2 %i %pi j k / n), j, 0, n-1)
 
285
 
 
286
          x[j]:       sum (y[j] exp (+2 %i %pi j k / n), k, 0, n-1)
 
287
 
 
288
     Suitable arrays can be allocated by the `array' function. For
 
289
     example:
 
290
 
 
291
          array (my_array, float, n-1)$
 
292
 
 
293
     declares a 1-dimensional array with n elements, indexed from 0
 
294
     through n-1 inclusive. The number of elements n must be equal to
 
295
     2^m for some m.
 
296
 
 
297
     `fft' can be applied to real data (imaginary array all zeros) to
 
298
     obtain sine and cosine coefficients. After calling `fft', the sine
 
299
     and cosine coefficients, say `a' and `b', can be calculated as
 
300
 
 
301
          a[0]: real_array[0]
 
302
          b[0]: 0
 
303
 
 
304
     and
 
305
 
 
306
          a[j]: real_array[j] + real_array[n-j]
 
307
          b[j]: imaginary_array[j] - imaginary_array[n-j]
 
308
 
 
309
     for j equal to 1 through n/2-1, and
 
310
 
 
311
          a[n/2]: real_array[n/2]
 
312
          b[n/2]: 0
 
313
 
 
314
     `recttopolar' translates complex values of the form `a + b %i' to
 
315
     the form `r %e^(%i t)'. See `recttopolar'.
 
316
 
 
317
     `polartorect' translates complex values of the form `r %e^(%i t)'
 
318
     to the form `a + b %i'. See `polartorect'.
 
319
 
 
320
     `demo ("fft")' displays a demonstration of the `fft' package.
 
321
 
 
322
 
 
323
 -- Option variable: fortindent
 
324
     Default value: 0
 
325
 
 
326
     `fortindent' controls the left margin indentation of expressions
 
327
     printed out by the `fortran' command.  0 gives normal printout
 
328
     (i.e., 6 spaces), and positive values will causes the expressions
 
329
     to be printed farther to the right.
 
330
 
 
331
 
 
332
 -- Function: fortran (<expr>)
 
333
     Prints <expr> as a Fortran statement.  The output line is indented
 
334
     with spaces.  If the line is too long, `fortran' prints
 
335
     continuation lines.  `fortran' prints the exponentiation operator
 
336
     `^' as `**', and prints a complex number `a + b %i' in the form
 
337
     `(a,b)'.
 
338
 
 
339
     <expr> may be an equation. If so, `fortran' prints an assignment
 
340
     statement, assigning the right-hand side of the equation to the
 
341
     left-hand side.  In particular, if the right-hand side of <expr>
 
342
     is the name of a matrix, then `fortran' prints an assignment
 
343
     statement for each element of the matrix.
 
344
 
 
345
     If <expr> is not something recognized by `fortran', the expression
 
346
     is printed in `grind' format without complaint.  `fortran' does
 
347
     not know about lists, arrays, or functions.
 
348
 
 
349
     `fortindent' controls the left margin of the printed lines.  0 is
 
350
     the normal margin (i.e., indented 6 spaces). Increasing
 
351
     `fortindent' causes expressions to be printed further to the right.
 
352
 
 
353
     When `fortspaces' is `true', `fortran' fills out each printed line
 
354
     with spaces to 80 columns.
 
355
 
 
356
     `fortran' evaluates its arguments; quoting an argument defeats
 
357
     evaluation.  `fortran' always returns `done'.
 
358
 
 
359
     Examples:
 
360
 
 
361
          (%i1) expr: (a + b)^12$
 
362
          (%i2) fortran (expr);
 
363
                (b+a)**12
 
364
          (%o2)                         done
 
365
          (%i3) fortran ('x=expr);
 
366
                x = (b+a)**12
 
367
          (%o3)                         done
 
368
          (%i4) fortran ('x=expand (expr));
 
369
                x = b**12+12*a*b**11+66*a**2*b**10+220*a**3*b**9+495*a**4*b**8+792
 
370
               1   *a**5*b**7+924*a**6*b**6+792*a**7*b**5+495*a**8*b**4+220*a**9*b
 
371
               2   **3+66*a**10*b**2+12*a**11*b+a**12
 
372
          (%o4)                         done
 
373
          (%i5) fortran ('x=7+5*%i);
 
374
                x = (7,5)
 
375
          (%o5)                         done
 
376
          (%i6) fortran ('x=[1,2,3,4]);
 
377
                x = [1,2,3,4]
 
378
          (%o6)                         done
 
379
          (%i7) f(x) := x^2$
 
380
          (%i8) fortran (f);
 
381
                f
 
382
          (%o8)                         done
 
383
 
 
384
 
 
385
 -- Option variable: fortspaces
 
386
     Default value: `false'
 
387
 
 
388
     When `fortspaces' is `true', `fortran' fills out each printed line
 
389
     with spaces to 80 columns.
 
390
 
 
391
 
 
392
 -- Function: horner (<expr>, <x>)
 
393
 -- Function: horner (<expr>)
 
394
     Returns a rearranged representation of <expr> as in Horner's rule,
 
395
     using <x> as the main variable if it is specified.  `x' may be
 
396
     omitted in which case the main variable of the canonical rational
 
397
     expression form of <expr> is used.
 
398
 
 
399
     `horner' sometimes improves stability if `expr' is to be
 
400
     numerically evaluated.  It is also useful if Maxima is used to
 
401
     generate programs to be run in Fortran. See also `stringout'.
 
402
 
 
403
          (%i1) expr: 1e-155*x^2 - 5.5*x + 5.2e155;
 
404
                                     2
 
405
          (%o1)            1.0E-155 x  - 5.5 x + 5.2E+155
 
406
          (%i2) expr2: horner (%, x), keepfloat: true;
 
407
          (%o2)            (1.0E-155 x - 5.5) x + 5.2E+155
 
408
          (%i3) ev (expr, x=1e155);
 
409
          Maxima encountered a Lisp error:
 
410
 
 
411
           floating point overflow
 
412
 
 
413
          Automatically continuing.
 
414
          To reenable the Lisp debugger set *debugger-hook* to nil.
 
415
          (%i4) ev (expr2, x=1e155);
 
416
          (%o4)                       7.0E+154
 
417
 
 
418
 
 
419
 -- Function: find_root (<f>(<x>), <x>, <a>, <b>)
 
420
 -- Function: find_root (<f>, <a>, <b>)
 
421
     Finds the zero of function <f> as variable <x> varies over the
 
422
     range `[<a>, <b>]'.  The function must have a different sign at
 
423
     each endpoint.  If this condition is not met, the action of the
 
424
     function is governed by `find_root_error'.  If `find_root_error'
 
425
     is `true' then an error occurs, otherwise the value of
 
426
     `find_root_error' is returned (thus for plotting `find_root_error'
 
427
     might be set to 0.0).  Otherwise (given that Maxima can evaluate
 
428
     the first argument in the specified range, and that it is
 
429
     continuous) `find_root' is guaranteed to come up with the zero (or
 
430
     one of them if there is more than one zero).  The accuracy of
 
431
     `find_root' is governed by `find_root_abs' and `find_root_rel'
 
432
     which must be non-negative floating point numbers.  `find_root'
 
433
     will stop when the first arg evaluates to something less than or
 
434
     equal to `find_root_abs' or if successive approximants to the root
 
435
     differ by no more than `find_root_rel * <one of the approximants>'.
 
436
     The default values of `find_root_abs' and `find_root_rel' are 0.0
 
437
     so `find_root' gets as good an answer as is possible with the
 
438
     single precision arithmetic we have.  The first arg may be an
 
439
     equation.  The order of the last two args is irrelevant.  Thus
 
440
 
 
441
          find_root (sin(x) = x/2, x, %pi, 0.1);
 
442
 
 
443
     is equivalent to
 
444
 
 
445
          find_root (sin(x) = x/2, x, 0.1, %pi);
 
446
 
 
447
     The method used is a binary search in the range specified by the
 
448
     last two args.  When it thinks the function is close enough to
 
449
     being linear, it starts using linear interpolation.
 
450
 
 
451
     Examples:
 
452
 
 
453
          (%i1) f(x) := sin(x) - x/2;
 
454
                                                  x
 
455
          (%o1)                  f(x) := sin(x) - -
 
456
                                                  2
 
457
          (%i2) find_root (sin(x) - x/2, x, 0.1, %pi);
 
458
          (%o2)                   1.895494267033981
 
459
          (%i3) find_root (sin(x) = x/2, x, 0.1, %pi);
 
460
          (%o3)                   1.895494267033981
 
461
          (%i4) find_root (f(x), x, 0.1, %pi);
 
462
          (%o4)                   1.895494267033981
 
463
          (%i5) find_root (f, 0.1, %pi);
 
464
          (%o5)                   1.895494267033981
 
465
 
 
466
 
 
467
 -- Option variable: find_root_abs
 
468
     Default value: 0.0
 
469
 
 
470
     `find_root_abs' is the accuracy of the `find_root' command is
 
471
     governed by `find_root_abs' and `find_root_rel' which must be
 
472
     non-negative floating point numbers.  `find_root' will stop when
 
473
     the first arg evaluates to something less than or equal to
 
474
     `find_root_abs' or if successive approximants to the root differ
 
475
     by no more than `find_root_rel * <one of the approximants>'.  The
 
476
     default values of `find_root_abs' and `find_root_rel' are 0.0 so
 
477
     `find_root' gets as good an answer as is possible with the single
 
478
     precision arithmetic we have.
 
479
 
 
480
 
 
481
 -- Option variable: find_root_error
 
482
     Default value: `true'
 
483
 
 
484
     `find_root_error' governs the behavior of `find_root'.  When
 
485
     `find_root' is called, it determines whether or not the function
 
486
     to be solved satisfies the condition that the values of the
 
487
     function at the endpoints of the interpolation interval are
 
488
     opposite in sign.  If they are of opposite sign, the interpolation
 
489
     proceeds.  If they are of like sign, and `find_root_error' is
 
490
     `true', then an error is signaled.  If they are of like sign and
 
491
     `find_root_error' is not `true', the value of `find_root_error' is
 
492
     returned.  Thus for plotting, `find_root_error' might be set to
 
493
     0.0.
 
494
 
 
495
 
 
496
 -- Option variable: find_root_rel
 
497
     Default value: 0.0
 
498
 
 
499
     `find_root_rel' is the accuracy of the `find_root' command is
 
500
     governed by `find_root_abs' and `find_root_rel' which must be
 
501
     non-negative floating point numbers.  `find_root' will stop when
 
502
     the first arg evaluates to something less than or equal to
 
503
     `find_root_abs' or if successive approximants to the root differ
 
504
     by no more than `find_root_rel * <one of the approximants>'.  The
 
505
     default values of `find_root_abs' and `find_root_rel' are 0.0 so
 
506
     `find_root' gets as good an answer as is possible with the single
 
507
     precision arithmetic we have.
 
508
 
 
509
 
 
510
 
 
511
File: maxima.info,  Node: Definitions for Fourier Series,  Prev: Definitions for Numerical,  Up: Numerical
 
512
 
 
513
23.4 Definitions for Fourier Series
 
514
===================================
 
515
 
 
516
 -- Function: equalp (<x>, <y>)
 
517
     Returns `true' if `equal (<x>, <y>)' otherwise `false' (doesn't
 
518
     give an error message like `equal (x, y)' would do in this case).
 
519
 
 
520
 
 
521
 -- Function: remfun (<f>, <expr>)
 
522
 -- Function: remfun (<f>, <expr>, <x>)
 
523
     `remfun (<f>, <expr>)' replaces all occurrences of `<f> (<arg>)'
 
524
     by <arg> in <expr>.
 
525
 
 
526
     `remfun (<f>, <expr>, <x>)' replaces all occurrences of `<f>
 
527
     (<arg>)' by <arg> in <expr> only if <arg> contains the variable
 
528
     <x>.
 
529
 
 
530
 
 
531
 -- Function: funp (<f>, <expr>)
 
532
 -- Function: funp (<f>, <expr>, <x>)
 
533
     `funp (<f>, <expr>)' returns `true' if <expr> contains the
 
534
     function <f>.
 
535
 
 
536
     `funp (<f>, <expr>, <x>)' returns `true' if <expr> contains the
 
537
     function <f> and the variable <x> is somewhere in the argument of
 
538
     one of the instances of <f>.
 
539
 
 
540
 
 
541
 -- Function: absint (<f>, <x>, <halfplane>)
 
542
 -- Function: absint (<f>, <x>)
 
543
 -- Function: absint (<f>, <x>, <a>, <b>)
 
544
     `absint (<f>, <x>, <halfplane>)' returns the indefinite integral
 
545
     of <f> with respect to <x> in the given halfplane (`pos', `neg',
 
546
     or `both').  <f> may contain expressions of the form `abs (x)',
 
547
     `abs (sin (x))', `abs (a) * exp (-abs (b) * abs (x))'.
 
548
 
 
549
     `absint (<f>, <x>)' is equivalent to `absint (<f>, <x>, pos)'.
 
550
 
 
551
     `absint (<f>, <x>, <a>, <b>)' returns the definite integral of <f>
 
552
     with respect to <x> from <a> to <b>.  <f> may include absolute
 
553
     values.
 
554
 
 
555
 
 
556
 -- Function: fourier (<f>, <x>, <p>)
 
557
     Returns a list of the Fourier coefficients of `<f>(<x>)' defined
 
558
     on the interval `[-%pi, %pi]'.
 
559
 
 
560
 
 
561
 -- Function: foursimp (<l>)
 
562
     Simplifies `sin (n %pi)' to 0 if `sinnpiflag' is `true' and `cos
 
563
     (n %pi)' to `(-1)^n' if `cosnpiflag' is `true'.
 
564
 
 
565
 
 
566
 -- Option variable: sinnpiflag
 
567
     Default value: `true'
 
568
 
 
569
     See `foursimp'.
 
570
 
 
571
 
 
572
 -- Option variable: cosnpiflag
 
573
     Default value: `true'
 
574
 
 
575
     See `foursimp'.
 
576
 
 
577
 
 
578
 -- Function: fourexpand (<l>, <x>, <p>, <limit>)
 
579
     Constructs and returns the Fourier series from the list of Fourier
 
580
     coefficients <l> up through <limit> terms (<limit> may be `inf').
 
581
     <x> and <p> have same meaning as in `fourier'.
 
582
 
 
583
 
 
584
 -- Function: fourcos (<f>, <x>, <p>)
 
585
     Returns the Fourier cosine coefficients for `<f>(<x>)' defined on
 
586
     `[0, %pi]'.
 
587
 
 
588
 
 
589
 -- Function: foursin (<f>, <x>, <p>)
 
590
     Returns the Fourier sine coefficients for `<f>(<x>)' defined on
 
591
     `[0, %pi]'.
 
592
 
 
593
 
 
594
 -- Function: totalfourier (<f>, <x>, <p>)
 
595
     Returns `fourexpand (foursimp (fourier (<f>, <x>, <p>)), <x>, <p>,
 
596
     'inf)'.
 
597
 
 
598
 
 
599
 -- Function: fourint (<f>, <x>)
 
600
     Constructs and returns a list of the Fourier integral coefficients
 
601
     of `<f>(<x>)' defined on `[minf, inf]'.
 
602
 
 
603
 
 
604
 -- Function: fourintcos (<f>, <x>)
 
605
     Returns the Fourier cosine integral coefficients for `<f>(<x>)' on
 
606
     `[0, inf]'.
 
607
 
 
608
 
 
609
 -- Function: fourintsin (<f>, <x>)
 
610
     Returns the Fourier sine integral coefficients for `<f>(<x>)' on
 
611
     `[0, inf]'.
 
612
 
 
613
 
 
614
 
 
615
File: maxima.info,  Node: Statistics,  Next: Arrays,  Prev: Numerical,  Up: Top
 
616
 
 
617
24 Statistics
 
618
*************
 
619
 
 
620
* Menu:
 
621
 
 
622
* Definitions for Statistics::
 
623
 
 
624
 
 
625
File: maxima.info,  Node: Definitions for Statistics,  Prev: Statistics,  Up: Statistics
 
626
 
 
627
24.1 Definitions for Statistics
 
628
===============================
 
629
 
 
630
 -- Function: gauss (<mean>, <sd>)
 
631
     Returns a random floating point number from a normal distribution
 
632
     with mean <mean> and standard deviation <sd>.
 
633
 
 
634
 
 
635
 
 
636
File: maxima.info,  Node: Arrays,  Next: Matrices and Linear Algebra,  Prev: Statistics,  Up: Top
 
637
 
 
638
25 Arrays
 
639
*********
 
640
 
 
641
* Menu:
 
642
 
 
643
* Definitions for Arrays::
 
644
 
 
645
 
 
646
File: maxima.info,  Node: Definitions for Arrays,  Prev: Arrays,  Up: Arrays
 
647
 
 
648
25.1 Definitions for Arrays
15
649
===========================
16
650
 
17
 
 - Function: AT (exp, list)
18
 
     will evaluate exp (which may be any expression) with the variables
19
 
     assuming the values as specified for them in the list of equations
20
 
     or the single equation similar to that given to the ATVALUE
21
 
     function.  If a subexpression depends on any of the variables in
22
 
     list but it hasn't had an atvalue specified and it can't be
23
 
     evaluated then a noun form of the AT will be returned which will
24
 
     display in a two-dimensional form.  Do EXAMPLE(AT); for an example.
25
 
 
26
 
 
27
 
 - Function: BOX (expr)
28
 
     returns expr enclosed in a box.  The box is actually part of the
 
651
 -- Function: array (<name>, <dim_1>, ..., <dim_n>)
 
652
 -- Function: array (<name>, <type>, <dim_1>, ..., <dim_n>)
 
653
 -- Function: array ([<name_1>, ..., <name_m>], <dim_1>, ..., <dim_n>)
 
654
     Creates an n-dimensional array.  n may be less than or equal to 5.
 
655
     The subscripts for the i'th dimension are the integers running
 
656
     from 0 to <dim_i>.
 
657
 
 
658
     `array (<name>, <dim_1>, ..., <dim_n>)' creates a general array.
 
659
 
 
660
     `array (<name>, <type>, <dim_1>, ..., <dim_n>)' creates an array,
 
661
     with elements of a specified type.  <type> can be `fixnum' for
 
662
     integers of limited size or `flonum' for floating-point numbers.
 
663
 
 
664
     `array ([<name_1>, ..., <name_m>], <dim_1>, ..., <dim_n>)' creates
 
665
     m arrays, all of the same dimensions.
 
666
 
 
667
     If the user assigns to a subscripted variable before declaring the
 
668
     corresponding array, an undeclared array is created.  Undeclared
 
669
     arrays, otherwise known as hashed arrays (because hash coding is
 
670
     done on the subscripts), are more general than declared arrays.
 
671
     The user does not declare their maximum size, and they grow
 
672
     dynamically by hashing as more elements are assigned values.  The
 
673
     subscripts of undeclared arrays need not even be numbers.  However,
 
674
     unless an array is rather sparse, it is probably more efficient to
 
675
     declare it when possible than to leave it undeclared.  The `array'
 
676
     function can be used to transform an undeclared array into a
 
677
     declared array.
 
678
 
 
679
 
 
680
 -- Function: arrayapply (<A>, [<i_1>, ..., <i_n>])
 
681
     Evaluates `<A> [<i_1>, ..., <i_n>]', where <A> is an array and
 
682
     <i_1>, ..., <i_n> are integers.
 
683
 
 
684
     This is reminiscent of `apply', except the first argument is an
 
685
     array instead of a function.
 
686
 
 
687
 
 
688
 -- Function: arrayinfo (<A>)
 
689
     Returns information about the array <A>.  The argument <A> may be
 
690
     a declared array, an undeclared (hashed) array, an array function,
 
691
     or a subscripted function.
 
692
 
 
693
     For declared arrays, `arrayinfo' returns a list comprising the
 
694
     atom `declared', the number of dimensions, and the size of each
 
695
     dimension.  The elements of the array, both bound and unbound, are
 
696
     returned by `listarray'.
 
697
 
 
698
     For undeclared arrays (hashed arrays), `arrayinfo' returns a list
 
699
     comprising the atom `hashed', the number of subscripts, and the
 
700
     subscripts of every element which has a value.  The values are
 
701
     returned by `listarray'.
 
702
 
 
703
     For array functions, `arrayinfo' returns a list comprising the
 
704
     atom `hashed', the number of subscripts, and any subscript values
 
705
     for which there are stored function values.  The stored function
 
706
     values are returned by `listarray'.
 
707
 
 
708
     For subscripted functions, `arrayinfo' returns a list comprising
 
709
     the atom `hashed', the number of subscripts, and any subscript
 
710
     values for which there are lambda expressions.  The lambda
 
711
     expressions are returned by `listarray'.
 
712
 
 
713
     Examples:
 
714
 
 
715
     `arrayinfo' and `listarray' applied to a declared array.
 
716
 
 
717
          (%i1) array (aa, 2, 3);
 
718
          (%o1)                          aa
 
719
          (%i2) aa [2, 3] : %pi;
 
720
          (%o2)                          %pi
 
721
          (%i3) aa [1, 2] : %e;
 
722
          (%o3)                          %e
 
723
          (%i4) arrayinfo (aa);
 
724
          (%o4)                 [declared, 2, [2, 3]]
 
725
          (%i5) listarray (aa);
 
726
          (%o5) [#####, #####, #####, #####, #####, #####, %e, #####,
 
727
                                                  #####, #####, #####, %pi]
 
728
 
 
729
     `arrayinfo' and `listarray' applied to an undeclared (hashed)
 
730
     array.
 
731
 
 
732
          (%i1) bb [FOO] : (a + b)^2;
 
733
                                             2
 
734
          (%o1)                       (b + a)
 
735
          (%i2) bb [BAR] : (c - d)^3;
 
736
                                             3
 
737
          (%o2)                       (c - d)
 
738
          (%i3) arrayinfo (bb);
 
739
          (%o3)               [hashed, 1, [BAR], [FOO]]
 
740
          (%i4) listarray (bb);
 
741
                                        3         2
 
742
          (%o4)                 [(c - d) , (b + a) ]
 
743
 
 
744
     `arrayinfo' and `listarray' applied to an array function.
 
745
 
 
746
          (%i1) cc [x, y] := y / x;
 
747
                                               y
 
748
          (%o1)                      cc     := -
 
749
                                       x, y    x
 
750
          (%i2) cc [u, v];
 
751
                                          v
 
752
          (%o2)                           -
 
753
                                          u
 
754
          (%i3) cc [4, z];
 
755
                                          z
 
756
          (%o3)                           -
 
757
                                          4
 
758
          (%i4) arrayinfo (cc);
 
759
          (%o4)              [hashed, 2, [4, z], [u, v]]
 
760
          (%i5) listarray (cc);
 
761
                                        z  v
 
762
          (%o5)                        [-, -]
 
763
                                        4  u
 
764
 
 
765
     `arrayinfo' and `listarray' applied to a subscripted function.
 
766
 
 
767
          (%i1) dd [x] (y) := y ^ x;
 
768
                                               x
 
769
          (%o1)                     dd (y) := y
 
770
                                      x
 
771
          (%i2) dd [a + b];
 
772
                                              b + a
 
773
          (%o2)                  lambda([y], y     )
 
774
          (%i3) dd [v - u];
 
775
                                              v - u
 
776
          (%o3)                  lambda([y], y     )
 
777
          (%i4) arrayinfo (dd);
 
778
          (%o4)             [hashed, 1, [b + a], [v - u]]
 
779
          (%i5) listarray (dd);
 
780
                                   b + a                v - u
 
781
          (%o5)      [lambda([y], y     ), lambda([y], y     )]
 
782
 
 
783
 
 
784
 -- Function: arraymake (<name>, [<i_1>, ..., <i_n>])
 
785
     Returns the expression `<name> [<i_1>, ..., <i_n>]'.
 
786
 
 
787
     This is reminiscent of `funmake', except the return value is an
 
788
     unevaluated array reference instead of an unevaluated function
 
789
     call.
 
790
 
 
791
 
 
792
 -- System variable: arrays
 
793
     Default value: `[]'
 
794
 
 
795
     `arrays' is a list of arrays that have been allocated.  These
 
796
     comprise arrays declared by `array', hashed arrays constructed by
 
797
     implicit definition (assigning something to an array element), and
 
798
     array functions defined by `:=' and `define'.  Arrays defined by
 
799
     `make_array' are not included.
 
800
 
 
801
     See also `array', `arrayapply', `arrayinfo', `arraymake',
 
802
     `fillarray', `listarray', and `rearray'.
 
803
 
 
804
     Examples:
 
805
 
 
806
          (%i1) array (aa, 5, 7);
 
807
          (%o1)                          aa
 
808
          (%i2) bb [FOO] : (a + b)^2;
 
809
                                             2
 
810
          (%o2)                       (b + a)
 
811
          (%i3) cc [x] := x/100;
 
812
                                             x
 
813
          (%o3)                      cc  := ---
 
814
                                       x    100
 
815
          (%i4) dd : make_array ('any, 7);
 
816
          (%o4)       {Array:  #(NIL NIL NIL NIL NIL NIL NIL)}
 
817
          (%i5) arrays;
 
818
          (%o5)                     [aa, bb, cc]
 
819
 
 
820
 
 
821
 -- Function: bashindices (<expr>)
 
822
     Transforms the expression <expr> by giving each summation and
 
823
     product a unique index. This gives `changevar' greater precision
 
824
     when it is working with summations or products.  The form of the
 
825
     unique index is `j<number>'. The quantity <number> is determined by
 
826
     referring to `gensumnum', which can be changed by the user.  For
 
827
     example, `gensumnum:0$' resets it.
 
828
 
 
829
 
 
830
 -- Function: fillarray (<A>, <B>)
 
831
     Fills array <A> from <B>, which is a list or an array.
 
832
 
 
833
     If <A> is a floating-point (integer) array then <B> should be
 
834
     either a list of floating-point (integer) numbers or another
 
835
     floating-point (integer) array.
 
836
 
 
837
     If the dimensions of the arrays are different <A> is filled in
 
838
     row-major order.  If there are not enough elements in <B> the last
 
839
     element is used to fill out the rest of <A>.  If there are too
 
840
     many the remaining ones are thrown away.
 
841
 
 
842
     `fillarray' returns its first argument.
 
843
 
 
844
 
 
845
 -- Function: listarray (<A>)
 
846
     Returns a list of the elements of the array <A>.  The argument <A>
 
847
     may be a declared array, an undeclared (hashed) array, an array
 
848
     function, or a subscripted function.
 
849
 
 
850
     Elements are listed in row-major order.  That is, elements are
 
851
     sorted according to the first index, then according to the second
 
852
     index, and so on.  The sorting order of index values is the same
 
853
     as the order established by `orderless'.
 
854
 
 
855
     For undeclared arrays, array functions, and subscripted functions,
 
856
     the elements correspond to the index values returned by
 
857
     `arrayinfo'.
 
858
 
 
859
     Unbound elements of declared general arrays (that is, not `fixnum'
 
860
     and not `flonum') are returned as `#####'.  Unbound elements of
 
861
     declared `fixnum' or `flonum' arrays are returned as 0 or 0.0,
 
862
     respectively.  Unbound elements of undeclared arrays, array
 
863
     functions, and subscripted functions are not returned.
 
864
 
 
865
     Examples:
 
866
 
 
867
     `listarray' and `arrayinfo' applied to a declared array.
 
868
 
 
869
          (%i1) array (aa, 2, 3);
 
870
          (%o1)                          aa
 
871
          (%i2) aa [2, 3] : %pi;
 
872
          (%o2)                          %pi
 
873
          (%i3) aa [1, 2] : %e;
 
874
          (%o3)                          %e
 
875
          (%i4) listarray (aa);
 
876
          (%o4) [#####, #####, #####, #####, #####, #####, %e, #####,
 
877
                                                  #####, #####, #####, %pi]
 
878
          (%i5) arrayinfo (aa);
 
879
          (%o5)                 [declared, 2, [2, 3]]
 
880
 
 
881
     `listarray' and `arrayinfo' applied to an undeclared (hashed)
 
882
     array.
 
883
 
 
884
          (%i1) bb [FOO] : (a + b)^2;
 
885
                                             2
 
886
          (%o1)                       (b + a)
 
887
          (%i2) bb [BAR] : (c - d)^3;
 
888
                                             3
 
889
          (%o2)                       (c - d)
 
890
          (%i3) listarray (bb);
 
891
                                        3         2
 
892
          (%o3)                 [(c - d) , (b + a) ]
 
893
          (%i4) arrayinfo (bb);
 
894
          (%o4)               [hashed, 1, [BAR], [FOO]]
 
895
 
 
896
     `listarray' and `arrayinfo' applied to an array function.
 
897
 
 
898
          (%i1) cc [x, y] := y / x;
 
899
                                               y
 
900
          (%o1)                      cc     := -
 
901
                                       x, y    x
 
902
          (%i2) cc [u, v];
 
903
                                          v
 
904
          (%o2)                           -
 
905
                                          u
 
906
          (%i3) cc [4, z];
 
907
                                          z
 
908
          (%o3)                           -
 
909
                                          4
 
910
          (%i4) listarray (cc);
 
911
                                        z  v
 
912
          (%o4)                        [-, -]
 
913
                                        4  u
 
914
          (%i5) arrayinfo (cc);
 
915
          (%o5)              [hashed, 2, [4, z], [u, v]]
 
916
 
 
917
     `listarray' and `arrayinfo' applied to a subscripted function.
 
918
 
 
919
          (%i1) dd [x] (y) := y ^ x;
 
920
                                               x
 
921
          (%o1)                     dd (y) := y
 
922
                                      x
 
923
          (%i2) dd [a + b];
 
924
                                              b + a
 
925
          (%o2)                  lambda([y], y     )
 
926
          (%i3) dd [v - u];
 
927
                                              v - u
 
928
          (%o3)                  lambda([y], y     )
 
929
          (%i4) listarray (dd);
 
930
                                   b + a                v - u
 
931
          (%o4)      [lambda([y], y     ), lambda([y], y     )]
 
932
          (%i5) arrayinfo (dd);
 
933
          (%o5)             [hashed, 1, [b + a], [v - u]]
 
934
 
 
935
 
 
936
 -- Function: make_array (<type>, <dim_1>, ..., <dim_n>)
 
937
     Creates and returns a Lisp array.  <type> may be `any', `flonum',
 
938
     `fixnum', `hashed' or `functional'.  There are n indices, and the
 
939
     i'th index runs from 0 to <dim_i> - 1.
 
940
 
 
941
     The advantage of `make_array' over `array' is that the return
 
942
     value doesn't have a name, and once a pointer to it goes away, it
 
943
     will also go away.  For example, if `y: make_array (...)' then `y'
 
944
     points to an object which takes up space, but after `y: false',
 
945
     `y' no longer points to that object, so the object can be garbage
 
946
     collected.
 
947
 
 
948
 
 
949
 -- Function: rearray (<A>, <dim_1>, ..., <dim_n>)
 
950
     Changes the dimensions of an array.  The new array will be filled
 
951
     with the elements of the old one in row-major order.  If the old
 
952
     array was too small, the remaining elements are filled with
 
953
     `false', `0.0' or `0', depending on the type of the array.  The
 
954
     type of the array cannot be changed.
 
955
 
 
956
 
 
957
 -- Function: remarray (<A_1>, ..., <A_n>)
 
958
 -- Function: remarray (all)
 
959
     Removes arrays and array associated functions and frees the
 
960
     storage occupied.  The arguments may be declared arrays,
 
961
     undeclared (hashed) arrays, array functions, and subscripted
 
962
     functions.
 
963
 
 
964
     `remarray (all)' removes all items in the global list `arrays'.
 
965
 
 
966
     It may be necessary to use this function if it is desired to
 
967
     redefine the values in a hashed array.
 
968
 
 
969
     `remarray' returns the list of arrays removed.
 
970
 
 
971
 
 
972
 -- Function: subvar (<x>, <i>)
 
973
     Evaluates the subscripted expression `<x>[<i>]'.
 
974
 
 
975
     `subvar' evaluates its arguments.
 
976
 
 
977
     `arraymake (<x>, [<i>]' constructs the expression `<x>[<i>]', but
 
978
     does not evaluate it.
 
979
 
 
980
     Examples:
 
981
 
 
982
          (%i1) x : foo $
 
983
 
 
984
          (%i2) i : 3 $
 
985
 
 
986
          (%i3) subvar (x, i);
 
987
          (%o3)                         foo
 
988
                                           3
 
989
          (%i4) foo : [aa, bb, cc, dd, ee]$
 
990
 
 
991
          (%i5) subvar (x, i);
 
992
          (%o5)                          cc
 
993
          (%i6) arraymake (x, [i]);
 
994
          (%o6)                         foo
 
995
                                           3
 
996
          (%i7) ''%;
 
997
          (%o7)                          cc
 
998
 
 
999
 
 
1000
 -- Option variable: use_fast_arrays
 
1001
     - if `true' then only two types of arrays are recognized.
 
1002
 
 
1003
     1) The art-q array (t in Common Lisp) which may have several
 
1004
     dimensions indexed by integers, and may hold any Lisp or Maxima
 
1005
     object as an entry.  To construct such an array, enter
 
1006
     `a:make_array(any,3,4);' then `a' will have as value, an array
 
1007
     with twelve slots, and the indexing is zero based.
 
1008
 
 
1009
     2) The Hash_table array which is the default type of array created
 
1010
     if one does `b[x+1]:y^2' (and `b' is not already an array, a list,
 
1011
     or a matrix - if it were one of these an error would be caused
 
1012
     since `x+1' would not be a valid subscript for an art-q array, a
 
1013
     list or a matrix). Its indices (also known as keys) may be any
 
1014
     object.  It only takes one key at a time (`b[x+1,u]:y' would
 
1015
     ignore the `u').  Referencing is done by `b[x+1] ==> y^2'.  Of
 
1016
     course the key may be a list, e.g. `b[[x+1,u]]:y' would be valid.
 
1017
     This is incompatible with the old Maxima hash arrays, but saves
 
1018
     consing.
 
1019
 
 
1020
     An advantage of storing the arrays as values of the symbol is that
 
1021
     the usual conventions about local variables of a function apply to
 
1022
     arrays as well.  The Hash_table type also uses less consing and is
 
1023
     more efficient than the old type of Maxima hashar.  To obtain
 
1024
     consistent behaviour in translated and compiled code set
 
1025
     `translate_fast_arrays' to be `true'.
 
1026
 
 
1027
 
 
1028
 
 
1029
File: maxima.info,  Node: Matrices and Linear Algebra,  Next: Affine,  Prev: Arrays,  Up: Top
 
1030
 
 
1031
26 Matrices and Linear Algebra
 
1032
******************************
 
1033
 
 
1034
* Menu:
 
1035
 
 
1036
* Introduction to Matrices and Linear Algebra::
 
1037
* Definitions for Matrices and Linear Algebra::
 
1038
 
 
1039
 
 
1040
File: maxima.info,  Node: Introduction to Matrices and Linear Algebra,  Next: Definitions for Matrices and Linear Algebra,  Prev: Matrices and Linear Algebra,  Up: Matrices and Linear Algebra
 
1041
 
 
1042
26.1 Introduction to Matrices and Linear Algebra
 
1043
================================================
 
1044
 
 
1045
* Menu:
 
1046
 
 
1047
* Dot::
 
1048
* Vectors::
 
1049
* eigen::
 
1050
 
 
1051
 
 
1052
File: maxima.info,  Node: Dot,  Next: Vectors,  Prev: Introduction to Matrices and Linear Algebra,  Up: Introduction to Matrices and Linear Algebra
 
1053
 
 
1054
26.1.1 Dot
 
1055
----------
 
1056
 
 
1057
The operator `.' represents noncommutative multiplication and scalar
 
1058
product.  When the operands are 1-column or 1-row matrices `a' and `b',
 
1059
the expression `a.b' is equivalent to `sum (a[i]*b[i], i, 1,
 
1060
length(a))'.  If `a' and `b' are not complex, this is the scalar
 
1061
product, also called the inner product or dot product, of `a' and `b'.
 
1062
The scalar product is defined as `conjugate(a).b' when `a' and `b' are
 
1063
complex; `innerproduct' in the `eigen' package provides the complex
 
1064
scalar product.
 
1065
 
 
1066
   When the operands are more general matrices, the product is the
 
1067
matrix product `a' and `b'.  The number of rows of `b' must equal the
 
1068
number of columns of `a', and the result has number of rows equal to
 
1069
the number of rows of `a' and number of columns equal to the number of
 
1070
columns of `b'.
 
1071
 
 
1072
   To distinguish `.' as an arithmetic operator from the decimal point
 
1073
in a floating point number, it may be necessary to leave spaces on
 
1074
either side.  For example, `5.e3' is `5000.0' but `5 . e3' is `5' times
 
1075
`e3'.
 
1076
 
 
1077
   There are several flags which govern the simplification of
 
1078
expressions involving `.', namely `dot', `dot0nscsimp', `dot0simp',
 
1079
`dot1simp', `dotassoc', `dotconstrules', `dotdistrib', `dotexptsimp',
 
1080
`dotident', and `dotscrules'.
 
1081
 
 
1082
 
 
1083
File: maxima.info,  Node: Vectors,  Next: eigen,  Prev: Dot,  Up: Introduction to Matrices and Linear Algebra
 
1084
 
 
1085
26.1.2 Vectors
 
1086
--------------
 
1087
 
 
1088
`vect' is a package of functions for vector analysis.  `load ("vect")'
 
1089
loads this package, and `demo ("vect")' displays a demonstration.
 
1090
 
 
1091
   The vector analysis package can combine and simplify symbolic
 
1092
expressions including dot products and cross products, together with
 
1093
the gradient, divergence, curl, and Laplacian operators.  The
 
1094
distribution of these operators over sums or products is governed by
 
1095
several flags, as are various other expansions, including expansion
 
1096
into components in any specific orthogonal coordinate systems.  There
 
1097
are also functions for deriving the scalar or vector potential of a
 
1098
field.
 
1099
 
 
1100
   The `vect' package contains these functions: `vectorsimp',
 
1101
`scalefactors', `express', `potential', and `vectorpotential'.
 
1102
 
 
1103
   Warning: the `vect' package declares the dot operator `.' to be a
 
1104
commutative operator.
 
1105
 
 
1106
 
 
1107
File: maxima.info,  Node: eigen,  Prev: Vectors,  Up: Introduction to Matrices and Linear Algebra
 
1108
 
 
1109
26.1.3 eigen
 
1110
------------
 
1111
 
 
1112
The package `eigen' contains several functions devoted to the symbolic
 
1113
computation of eigenvalues and eigenvectors.  Maxima loads the package
 
1114
automatically if one of the functions `eigenvalues' or `eigenvectors'
 
1115
is invoked.  The package may be loaded explicitly as `load ("eigen")'.
 
1116
 
 
1117
   `demo ("eigen")' displays a demonstration of the capabilities of
 
1118
this package.  `batch ("eigen")' executes the same demonstration, but
 
1119
without the user prompt between successive computations.
 
1120
 
 
1121
   The functions in the `eigen' package are `innerproduct',
 
1122
`unitvector', `columnvector', `gramschmidt', `eigenvalues',
 
1123
`eigenvectors', `uniteigenvectors', and `similaritytransform'.
 
1124
 
 
1125
 
 
1126
File: maxima.info,  Node: Definitions for Matrices and Linear Algebra,  Prev: Introduction to Matrices and Linear Algebra,  Up: Matrices and Linear Algebra
 
1127
 
 
1128
26.2 Definitions for Matrices and Linear Algebra
 
1129
================================================
 
1130
 
 
1131
 -- Function: addcol (<M>, <list_1>, ..., <list_n>)
 
1132
     Appends the column(s) given by the one or more lists (or matrices)
 
1133
     onto the matrix <M>.
 
1134
 
 
1135
 
 
1136
 -- Function: addrow (<M>, <list_1>, ..., <list_n>)
 
1137
     Appends the row(s) given by the one or more lists (or matrices)
 
1138
     onto the matrix <M>.
 
1139
 
 
1140
 
 
1141
 -- Function: adjoint (<M>)
 
1142
     Returns the adjoint of the matrix <M>.  The adjoint matrix is the
 
1143
     transpose of the matrix of cofactors of <M>.
 
1144
 
 
1145
 
 
1146
 -- Function: augcoefmatrix ([<eqn_1>, ..., <eqn_m>], [<x_1>, ...,
 
1147
          <x_n>])
 
1148
     Returns the augmented coefficient matrix for the variables <x_1>,
 
1149
     ..., <x_n> of the system of linear equations <eqn_1>, ...,
 
1150
     <eqn_m>.  This is the coefficient matrix with a column adjoined for
 
1151
     the constant terms in each equation (i.e., those terms not
 
1152
     dependent upon <x_1>, ..., <x_n>).
 
1153
 
 
1154
          (%i1) m: [2*x - (a - 1)*y = 5*b, c + b*y + a*x = 0]$
 
1155
          (%i2) augcoefmatrix (m, [x, y]);
 
1156
                                 [ 2  1 - a  - 5 b ]
 
1157
          (%o2)                  [                 ]
 
1158
                                 [ a    b      c   ]
 
1159
 
 
1160
 
 
1161
 -- Function: charpoly (<M>, <x>)
 
1162
     Returns the characteristic polynomial for the matrix <M> with
 
1163
     respect to variable <x>.  That is, `determinant (<M> - diagmatrix
 
1164
     (length (<M>), <x>))'.
 
1165
 
 
1166
          (%i1) a: matrix ([3, 1], [2, 4]);
 
1167
                                      [ 3  1 ]
 
1168
          (%o1)                       [      ]
 
1169
                                      [ 2  4 ]
 
1170
          (%i2) expand (charpoly (a, lambda));
 
1171
                                     2
 
1172
          (%o2)                lambda  - 7 lambda + 10
 
1173
          (%i3) (programmode: true, solve (%));
 
1174
          (%o3)               [lambda = 5, lambda = 2]
 
1175
          (%i4) matrix ([x1], [x2]);
 
1176
                                       [ x1 ]
 
1177
          (%o4)                        [    ]
 
1178
                                       [ x2 ]
 
1179
          (%i5) ev (a . % - lambda*%, %th(2)[1]);
 
1180
                                    [ x2 - 2 x1 ]
 
1181
          (%o5)                     [           ]
 
1182
                                    [ 2 x1 - x2 ]
 
1183
          (%i6) %[1, 1] = 0;
 
1184
          (%o6)                     x2 - 2 x1 = 0
 
1185
          (%i7) x2^2 + x1^2 = 1;
 
1186
                                      2     2
 
1187
          (%o7)                     x2  + x1  = 1
 
1188
          (%i8) solve ([%th(2), %], [x1, x2]);
 
1189
                            1               2
 
1190
          (%o8) [[x1 = - -------, x2 = - -------],
 
1191
                         sqrt(5)         sqrt(5)
 
1192
 
 
1193
                                                       1             2
 
1194
                                              [x1 = -------, x2 = -------]]
 
1195
                                                    sqrt(5)       sqrt(5)
 
1196
 
 
1197
 
 
1198
 -- Function: coefmatrix ([<eqn_1>, ..., <eqn_m>], [<x_1>, ..., <x_n>])
 
1199
     Returns the coefficient matrix for the variables <x_1>, ..., <x_n>
 
1200
     of the system of linear equations <eqn_1>, ..., <eqn_m>.
 
1201
 
 
1202
          (%i1) coefmatrix([2*x-(a-1)*y+5*b = 0, b*y+a*x = 3], [x,y]);
 
1203
                                           [ 2  1 - a ]
 
1204
          (%o1)                            [          ]
 
1205
                                           [ a    b   ]
 
1206
 
 
1207
 
 
1208
 -- Function: col (<M>, <i>)
 
1209
     Returns the <i>'th column of the matrix <M>.  The return value is
 
1210
     a matrix.
 
1211
 
 
1212
 
 
1213
 -- Function: columnvector (<L>)
 
1214
 -- Function: covect (<L>)
 
1215
     Returns a matrix of one column and `length (<L>)' rows, containing
 
1216
     the elements of the list <L>.
 
1217
 
 
1218
     `covect' is a synonym for `columnvector'.
 
1219
 
 
1220
     `load ("eigen")' loads this function.
 
1221
 
 
1222
     This is useful if you want to use parts of the outputs of the
 
1223
     functions in this package in matrix calculations.
 
1224
 
 
1225
     Example:
 
1226
 
 
1227
          (%i1) load ("eigen")$
 
1228
          Warning - you are redefining the Macsyma function eigenvalues
 
1229
          Warning - you are redefining the Macsyma function eigenvectors
 
1230
          (%i2) columnvector ([aa, bb, cc, dd]);
 
1231
                                       [ aa ]
 
1232
                                       [    ]
 
1233
                                       [ bb ]
 
1234
          (%o2)                        [    ]
 
1235
                                       [ cc ]
 
1236
                                       [    ]
 
1237
                                       [ dd ]
 
1238
 
 
1239
 
 
1240
 -- Function: conjugate (<x>)
 
1241
     Returns the complex conjugate of <x>.
 
1242
 
 
1243
          (%i1) declare ([aa, bb], real, cc, complex, ii, imaginary);
 
1244
 
 
1245
          (%o1)                         done
 
1246
          (%i2) conjugate (aa + bb*%i);
 
1247
 
 
1248
          (%o2)                      aa - %i bb
 
1249
          (%i3) conjugate (cc);
 
1250
 
 
1251
          (%o3)                     conjugate(cc)
 
1252
          (%i4) conjugate (ii);
 
1253
 
 
1254
          (%o4)                         - ii
 
1255
          (%i5) conjugate (xx + yy);
 
1256
 
 
1257
          (%o5)             conjugate(yy) + conjugate(xx)
 
1258
 
 
1259
 
 
1260
 -- Function: copymatrix (<M>)
 
1261
     Returns a copy of the matrix <M>.  This is the only way to make a
 
1262
     copy aside from copying <M> element by element.
 
1263
 
 
1264
     Note that an assignment of one matrix to another, as in `m2: m1',
 
1265
     does not copy `m1'.  An assignment `m2 [i,j]: x' or `setelmx (x,
 
1266
     i, j, m2' also modifies `m1 [i,j]'.  Creating a copy with
 
1267
     `copymatrix' and then using assignment creates a separate,
 
1268
     modified copy.
 
1269
 
 
1270
 
 
1271
 -- Function: determinant (<M>)
 
1272
     Computes the determinant of <M> by a method similar to Gaussian
 
1273
     elimination.
 
1274
 
 
1275
     The form of the result depends upon the setting of the switch
 
1276
     `ratmx'.
 
1277
 
 
1278
     There is a special routine for computing sparse determinants which
 
1279
     is called when the switches `ratmx' and `sparse' are both `true'.
 
1280
 
 
1281
 
 
1282
 -- Option variable: detout
 
1283
     Default value: `false'
 
1284
 
 
1285
     When `detout' is `true', the determinant of a matrix whose inverse
 
1286
     is computed is factored out of the inverse.
 
1287
 
 
1288
     For this switch to have an effect `doallmxops' and `doscmxops'
 
1289
     should be `false' (see their descriptions).  Alternatively this
 
1290
     switch can be given to `ev' which causes the other two to be set
 
1291
     correctly.
 
1292
 
 
1293
     Example:
 
1294
 
 
1295
          (%i1) m: matrix ([a, b], [c, d]);
 
1296
                                      [ a  b ]
 
1297
          (%o1)                       [      ]
 
1298
                                      [ c  d ]
 
1299
          (%i2) detout: true$
 
1300
          (%i3) doallmxops: false$
 
1301
          (%i4) doscmxops: false$
 
1302
          (%i5) invert (m);
 
1303
                                    [  d   - b ]
 
1304
                                    [          ]
 
1305
                                    [ - c   a  ]
 
1306
          (%o5)                     ------------
 
1307
                                     a d - b c
 
1308
 
 
1309
 
 
1310
 -- Function: diagmatrix (<n>, <x>)
 
1311
     Returns a diagonal matrix of size <n> by <n> with the diagonal
 
1312
     elements all equal to <x>.  `diagmatrix (<n>, 1)' returns an
 
1313
     identity matrix (same as `ident (<n>)').
 
1314
 
 
1315
     <n> must evaluate to an integer, otherwise `diagmatrix' complains
 
1316
     with an error message.
 
1317
 
 
1318
     <x> can be any kind of expression, including another matrix.  If
 
1319
     <x> is a matrix, it is not copied; all diagonal elements refer to
 
1320
     the same instance, <x>.
 
1321
 
 
1322
 
 
1323
 -- Option variable: doallmxops
 
1324
     Default value: `true'
 
1325
 
 
1326
     When `doallmxops' is `true', all operations relating to matrices
 
1327
     are carried out.  When it is `false' then the setting of the
 
1328
     individual `dot' switches govern which operations are performed.
 
1329
 
 
1330
 
 
1331
 -- Option variable: domxexpt
 
1332
     Default value: `true'
 
1333
 
 
1334
     When `domxexpt' is `true', a matrix exponential, `exp (<M>)' where
 
1335
     <M> is a matrix, is interpreted as a matrix with element `[i,j'
 
1336
     equal to `exp (m[i,j])'.  Otherwise `exp (<M>)' evaluates to `exp
 
1337
     (<ev(M)>'.
 
1338
 
 
1339
     `domxexpt' affects all expressions of the form `<base>^<power>'
 
1340
     where <base> is an expression assumed scalar or constant, and
 
1341
     <power> is a list or matrix.
 
1342
 
 
1343
     Example:
 
1344
 
 
1345
          (%i1) m: matrix ([1, %i], [a+b, %pi]);
 
1346
                                   [   1    %i  ]
 
1347
          (%o1)                    [            ]
 
1348
                                   [ b + a  %pi ]
 
1349
          (%i2) domxexpt: false$
 
1350
          (%i3) (1 - c)^m;
 
1351
                                       [   1    %i  ]
 
1352
                                       [            ]
 
1353
                                       [ b + a  %pi ]
 
1354
          (%o3)                 (1 - c)
 
1355
          (%i4) domxexpt: true$
 
1356
          (%i5) (1 - c)^m;
 
1357
                            [                      %i  ]
 
1358
                            [    1 - c      (1 - c)    ]
 
1359
          (%o5)             [                          ]
 
1360
                            [        b + a         %pi ]
 
1361
                            [ (1 - c)       (1 - c)    ]
 
1362
 
 
1363
 
 
1364
 -- Option variable: domxmxops
 
1365
     Default value: `true'
 
1366
 
 
1367
     When `domxmxops' is `true', all matrix-matrix or matrix-list
 
1368
     operations are carried out (but not scalar-matrix operations); if
 
1369
     this switch is `false' such operations are not carried out.
 
1370
 
 
1371
 
 
1372
 -- Option variable: domxnctimes
 
1373
     Default value: `false'
 
1374
 
 
1375
     When `domxnctimes' is `true', non-commutative products of matrices
 
1376
     are carried out.
 
1377
 
 
1378
 
 
1379
 -- Option variable: dontfactor
 
1380
     Default value: `[]'
 
1381
 
 
1382
     `dontfactor' may be set to a list of variables with respect to
 
1383
     which factoring is not to occur.  (The list is initially empty.)
 
1384
     Factoring also will not take place with respect to any variables
 
1385
     which are less important, according the variable ordering assumed
 
1386
     for canonical rational expression (CRE) form, than those on the
 
1387
     `dontfactor' list.
 
1388
 
 
1389
 
 
1390
 -- Option variable: doscmxops
 
1391
     Default value: `false'
 
1392
 
 
1393
     When `doscmxops' is `true', scalar-matrix operations are carried
 
1394
     out.
 
1395
 
 
1396
 
 
1397
 -- Option variable: doscmxplus
 
1398
     Default value: `false'
 
1399
 
 
1400
     When `doscmxplus' is `true', scalar-matrix operations yield a
 
1401
     matrix result.  This switch is not subsumed under `doallmxops'.
 
1402
 
 
1403
 
 
1404
 -- Option variable: dot0nscsimp
 
1405
     Default value: `true'
 
1406
 
 
1407
     When `dot0nscsimp' is `true', a non-commutative product of zero
 
1408
     and a nonscalar term is simplified to a commutative product.
 
1409
 
 
1410
 
 
1411
 -- Option variable: dot0simp
 
1412
     Default value: `true'
 
1413
 
 
1414
     When `dot0simp' is `true', a non-commutative product of zero and a
 
1415
     scalar term is simplified to a commutative product.
 
1416
 
 
1417
 
 
1418
 -- Option variable: dot1simp
 
1419
     Default value: `true'
 
1420
 
 
1421
     When `dot1simp' is `true', a non-commutative product of one and
 
1422
     another term is simplified to a commutative product.
 
1423
 
 
1424
 
 
1425
 -- Option variable: dotassoc
 
1426
     Default value: `true'
 
1427
 
 
1428
     When `dotassoc' is `true', an expression `(A.B).C' simplifies to
 
1429
     `A.(B.C)'.
 
1430
 
 
1431
 
 
1432
 -- Option variable: dotconstrules
 
1433
     Default value: `true'
 
1434
 
 
1435
     When `dotconstrules' is `true', a non-commutative product of a
 
1436
     constant and another term is simplified to a commutative product.
 
1437
     Turning on this flag effectively turns on `dot0simp',
 
1438
     `dot0nscsimp', and `dot1simp' as well.
 
1439
 
 
1440
 
 
1441
 -- Option variable: dotdistrib
 
1442
     Default value: `false'
 
1443
 
 
1444
     When `dotdistrib' is `true', an expression `A.(B + C)' simplifies
 
1445
     to `A.B + A.C'.
 
1446
 
 
1447
 
 
1448
 -- Option variable: dotexptsimp
 
1449
     Default value: `true'
 
1450
 
 
1451
     When `dotexptsimp' is `true', an expression `A.A' simplifies to
 
1452
     `A^^2'.
 
1453
 
 
1454
 
 
1455
 -- Option variable: dotident
 
1456
     Default value: 1
 
1457
 
 
1458
     `dotident' is the value returned by `X^^0'.
 
1459
 
 
1460
 
 
1461
 -- Option variable: dotscrules
 
1462
     Default value: `false'
 
1463
 
 
1464
     When `dotscrules' is `true', an expression `A.SC' or `SC.A'
 
1465
     simplifies to `SC*A' and `A.(SC*B)' simplifies to `SC*(A.B)'.
 
1466
 
 
1467
 
 
1468
 -- Function: echelon (<M>)
 
1469
     Returns the echelon form of the matrix <M>, as produced by
 
1470
     Gaussian elimination.  The echelon form is computed from <M> by
 
1471
     elementary row operations such that the first non-zero element in
 
1472
     each row in the resulting matrix is one and the column elements
 
1473
     under the first one in each row are all zero.
 
1474
 
 
1475
     `triangularize' also carries out Gaussian elimination, but it does
 
1476
     not normalize the leading non-zero element in each row.
 
1477
 
 
1478
     `lu_factor' and `cholesky' are other functions which yield
 
1479
     triangularized matrices.
 
1480
 
 
1481
          (%i1) M: matrix ([3, 7, aa, bb], [-1, 8, 5, 2], [9, 2, 11, 4]);
 
1482
                                 [  3   7  aa  bb ]
 
1483
                                 [                ]
 
1484
          (%o1)                  [ - 1  8  5   2  ]
 
1485
                                 [                ]
 
1486
                                 [  9   2  11  4  ]
 
1487
          (%i2) echelon (M);
 
1488
                            [ 1  - 8  - 5      - 2     ]
 
1489
                            [                          ]
 
1490
                            [         28       11      ]
 
1491
                            [ 0   1   --       --      ]
 
1492
          (%o2)             [         37       37      ]
 
1493
                            [                          ]
 
1494
                            [              37 bb - 119 ]
 
1495
                            [ 0   0    1   ----------- ]
 
1496
                            [              37 aa - 313 ]
 
1497
 
 
1498
 
 
1499
 -- Function: eigenvalues (<M>)
 
1500
 -- Function: eivals (<M>)
 
1501
     Returns a list of two lists containing the eigenvalues of the
 
1502
     matrix <M>.  The first sublist of the return value is the list of
 
1503
     eigenvalues of the matrix, and the second sublist is the list of
 
1504
     the multiplicities of the eigenvalues in the corresponding order.
 
1505
 
 
1506
     `eivals' is a synonym for `eigenvalues'.
 
1507
 
 
1508
     `eigenvalues' calls the function `solve' to find the roots of the
 
1509
     characteristic polynomial of the matrix.  Sometimes `solve' may
 
1510
     not be able to find the roots of the polynomial; in that case some
 
1511
     other functions in this package (except `innerproduct',
 
1512
     `unitvector', `columnvector' and `gramschmidt') will not work.
 
1513
 
 
1514
     In some cases the eigenvalues found by `solve' may be complicated
 
1515
     expressions.  (This may happen when `solve' returns a
 
1516
     not-so-obviously real expression for an eigenvalue which is known
 
1517
     to be real.)  It may be possible to simplify the eigenvalues using
 
1518
     some other functions.
 
1519
 
 
1520
     The package `eigen.mac' is loaded automatically when `eigenvalues'
 
1521
     or `eigenvectors' is referenced.  If `eigen.mac' is not already
 
1522
     loaded, `load ("eigen")' loads it.  After loading, all functions
 
1523
     and variables in the package are available.
 
1524
 
 
1525
 
 
1526
 -- Function: eigenvectors (<M>)
 
1527
 -- Function: eivects (<M>)
 
1528
     takes a matrix <M> as its argument and returns a list of lists the
 
1529
     first sublist of which is the output of `eigenvalues' and the
 
1530
     other sublists of which are the eigenvectors of the matrix
 
1531
     corresponding to those eigenvalues respectively.  The calculated
 
1532
     eigenvectors and the unit eigenvectors of the matrix are the right
 
1533
     eigenvectors and the right unit eigenvectors respectively.
 
1534
 
 
1535
     `eivects' is a synonym for `eigenvectors'.
 
1536
 
 
1537
     The package `eigen.mac' is loaded automatically when `eigenvalues'
 
1538
     or `eigenvectors' is referenced.  If `eigen.mac' is not already
 
1539
     loaded, `load ("eigen")' loads it.  After loading, all functions
 
1540
     and variables in the package are available.
 
1541
 
 
1542
     The flags that affect this function are:
 
1543
 
 
1544
     `nondiagonalizable' is set to `true' or `false' depending on
 
1545
     whether the matrix is nondiagonalizable or diagonalizable after
 
1546
     `eigenvectors' returns.
 
1547
 
 
1548
     `hermitianmatrix' when `true', causes the degenerate eigenvectors
 
1549
     of the Hermitian matrix to be orthogonalized using the
 
1550
     Gram-Schmidt algorithm.
 
1551
 
 
1552
     `knowneigvals' when `true' causes the `eigen' package to assume the
 
1553
     eigenvalues of the matrix are known to the user and stored under
 
1554
     the global name `listeigvals'.  `listeigvals' should be set to a
 
1555
     list similar to the output `eigenvalues'.
 
1556
 
 
1557
     The function `algsys' is used here to solve for the eigenvectors.
 
1558
     Sometimes if the eigenvalues are messy, `algsys' may not be able
 
1559
     to find a solution.  In some cases, it may be possible to simplify
 
1560
     the eigenvalues by first finding them using `eigenvalues' command
 
1561
     and then using other functions to reduce them to something simpler.
 
1562
     Following simplification, `eigenvectors' can be called again with
 
1563
     the `knowneigvals' flag set to `true'.
 
1564
 
 
1565
 
 
1566
 -- Function: ematrix (<m>, <n>, <x>, <i>, <j>)
 
1567
     Returns an <m> by <n> matrix, all elements of which are zero
 
1568
     except for the `[<i>, <j>]' element which is <x>.
 
1569
 
 
1570
 
 
1571
 -- Function: entermatrix (<m>, <n>)
 
1572
     Returns an <m> by <n> matrix, reading the elements interactively.
 
1573
 
 
1574
     If <n> is equal to <m>, Maxima prompts for the type of the matrix
 
1575
     (diagonal, symmetric, antisymmetric, or general) and for each
 
1576
     element.  Each response is terminated by a semicolon `;' or dollar
 
1577
     sign `$'.
 
1578
 
 
1579
     If <n> is not equal to <m>, Maxima prompts for each element.
 
1580
 
 
1581
     The elements may be any expressions, which are evaluated.
 
1582
     `entermatrix' evaluates its arguments.
 
1583
 
 
1584
          (%i1) n: 3$
 
1585
          (%i2) m: entermatrix (n, n)$
 
1586
 
 
1587
          Is the matrix  1. Diagonal  2. Symmetric  3. Antisymmetric  4. General
 
1588
          Answer 1, 2, 3 or 4 :
 
1589
          1$
 
1590
          Row 1 Column 1:
 
1591
          (a+b)^n$
 
1592
          Row 2 Column 2:
 
1593
          (a+b)^(n+1)$
 
1594
          Row 3 Column 3:
 
1595
          (a+b)^(n+2)$
 
1596
 
 
1597
          Matrix entered.
 
1598
          (%i3) m;
 
1599
                          [        3                     ]
 
1600
                          [ (b + a)      0         0     ]
 
1601
                          [                              ]
 
1602
          (%o3)           [                  4           ]
 
1603
                          [    0      (b + a)      0     ]
 
1604
                          [                              ]
 
1605
                          [                            5 ]
 
1606
                          [    0         0      (b + a)  ]
 
1607
 
 
1608
 
 
1609
 -- Function: genmatrix (<a>, <i_2>, <j_2>, <i_1>, <j_1>)
 
1610
 -- Function: genmatrix (<a>, <i_2>, <j_2>, <i_1>)
 
1611
 -- Function: genmatrix (<a>, <i_2>, <j_2>)
 
1612
     Returns a matrix generated from <a>, taking element
 
1613
     `<a>[<i_1>,<j_1>]' as the upper-left element and `<a>[<i_2>,<j_2>]'
 
1614
     as the lower-right element of the matrix.  Here <a> is a declared
 
1615
     array (created by `array' but not by `make_array') or an
 
1616
     undeclared array, or an array function, or a lambda expression of
 
1617
     two arguments.  (An array function is created like other functions
 
1618
     with `:=' or `define', but arguments are enclosed in square
 
1619
     brackets instead of parentheses.)
 
1620
 
 
1621
     If <j_1> is omitted, it is assumed equal to <i_1>.  If both <j_1>
 
1622
     and <i_1> are omitted, both are assumed equal to 1.
 
1623
 
 
1624
     If a selected element `i,j' of the array is undefined, the matrix
 
1625
     will contain a symbolic element `<a>[i,j]'.
 
1626
 
 
1627
     Examples:
 
1628
 
 
1629
          (%i1) h [i, j] := 1 / (i + j - 1);
 
1630
                                              1
 
1631
          (%o1)                  h     := ---------
 
1632
                                  i, j    i + j - 1
 
1633
          (%i2) genmatrix (h, 3, 3);
 
1634
                                     [    1  1 ]
 
1635
                                     [ 1  -  - ]
 
1636
                                     [    2  3 ]
 
1637
                                     [         ]
 
1638
                                     [ 1  1  1 ]
 
1639
          (%o2)                      [ -  -  - ]
 
1640
                                     [ 2  3  4 ]
 
1641
                                     [         ]
 
1642
                                     [ 1  1  1 ]
 
1643
                                     [ -  -  - ]
 
1644
                                     [ 3  4  5 ]
 
1645
          (%i3) array (a, fixnum, 2, 2);
 
1646
          (%o3)                           a
 
1647
          (%i4) a [1, 1] : %e;
 
1648
          (%o4)                          %e
 
1649
          (%i5) a [2, 2] : %pi;
 
1650
          (%o5)                          %pi
 
1651
          (%i6) genmatrix (a, 2, 2);
 
1652
                                     [ %e   0  ]
 
1653
          (%o6)                      [         ]
 
1654
                                     [ 0   %pi ]
 
1655
          (%i7) genmatrix (lambda ([i, j], j - i), 3, 3);
 
1656
                                   [  0    1   2 ]
 
1657
                                   [             ]
 
1658
          (%o7)                    [ - 1   0   1 ]
 
1659
                                   [             ]
 
1660
                                   [ - 2  - 1  0 ]
 
1661
          (%i8) genmatrix (B, 2, 2);
 
1662
                                  [ B      B     ]
 
1663
                                  [  1, 1   1, 2 ]
 
1664
          (%o8)                   [              ]
 
1665
                                  [ B      B     ]
 
1666
                                  [  2, 1   2, 2 ]
 
1667
 
 
1668
 
 
1669
 -- Function: gramschmidt (<x>)
 
1670
 -- Function: gschmit (<x>)
 
1671
     Carries out the Gram-Schmidt orthogonalization algorithm on <x>,
 
1672
     which is either a matrix or a list of lists.  <x> is not modified
 
1673
     by `gramschmidt'.
 
1674
 
 
1675
     If <x> is a matrix, the algorithm is applied to the rows of <x>.
 
1676
     If <x> is a list of lists, the algorithm is applied to the
 
1677
     sublists, which must have equal numbers of elements.  In either
 
1678
     case, the return value is a list of lists, the sublists of which
 
1679
     are orthogonal and span the same space as <x>.  If the dimension
 
1680
     of the span of <x> is less than the number of rows or sublists,
 
1681
     some sublists of the return value are zero.
 
1682
 
 
1683
     `factor' is called at each stage of the algorithm to simplify
 
1684
     intermediate results.  As a consequence, the return value may
 
1685
     contain factored integers.
 
1686
 
 
1687
     `gschmit' (note spelling) is a synonym for `gramschmidt'.
 
1688
 
 
1689
     `load ("eigen")' loads this function.
 
1690
 
 
1691
     Example:
 
1692
 
 
1693
          (%i1) load ("eigen")$
 
1694
          Warning - you are redefining the Macsyma function eigenvalues
 
1695
          Warning - you are redefining the Macsyma function eigenvectors
 
1696
          (%i2) x: matrix ([1, 2, 3], [9, 18, 30], [12, 48, 60]);
 
1697
                                   [ 1   2   3  ]
 
1698
                                   [            ]
 
1699
          (%o2)                    [ 9   18  30 ]
 
1700
                                   [            ]
 
1701
                                   [ 12  48  60 ]
 
1702
          (%i3) y: gramschmidt (x);
 
1703
                                 2      2            4     3
 
1704
                                3      3   3 5      2  3  2  3
 
1705
          (%o3)  [[1, 2, 3], [- ---, - --, ---], [- ----, ----, 0]]
 
1706
                                2 7    7   2 7       5     5
 
1707
          (%i4) i: innerproduct$
 
1708
          (%i5) [i (y[1], y[2]), i (y[2], y[3]), i (y[3], y[1])];
 
1709
          (%o5)                       [0, 0, 0]
 
1710
 
 
1711
 
 
1712
 -- Function: hach (<a>, <b>, <m>, <n>, <l>)
 
1713
     `hach' is an implementation of Hacijan's linear programming
 
1714
     algorithm.
 
1715
 
 
1716
     `load ("kach")' loads this function.  `demo ("kach")' executes a
 
1717
     demonstration of this function.
 
1718
 
 
1719
 
 
1720
 -- Function: ident (<n>)
 
1721
     Returns an <n> by <n> identity matrix.
 
1722
 
 
1723
 
 
1724
 -- Function: innerproduct (<x>, <y>)
 
1725
 -- Function: inprod (<x>, <y>)
 
1726
     Returns the inner product (also called the scalar product or dot
 
1727
     product) of <x> and <y>, which are lists of equal length, or both
 
1728
     1-column or 1-row matrices of equal length.  The return value is
 
1729
     `conjugate (x) . y', where `.' is the noncommutative
 
1730
     multiplication operator.
 
1731
 
 
1732
     `load ("eigen")' loads this function.
 
1733
 
 
1734
     `inprod' is a synonym for `innerproduct'.
 
1735
 
 
1736
 
 
1737
 -- Function: invert (<M>)
 
1738
     Returns the inverse of the matrix <M>.  The inverse is computed by
 
1739
     the adjoint method.
 
1740
 
 
1741
     This allows a user to compute the inverse of a matrix with bfloat
 
1742
     entries or polynomials with floating pt. coefficients without
 
1743
     converting to cre-form.
 
1744
 
 
1745
     Cofactors are computed by the `determinant' function, so if
 
1746
     `ratmx' is `false' the inverse is computed without changing the
 
1747
     representation of the elements.
 
1748
 
 
1749
     The current implementation is inefficient for matrices of high
 
1750
     order.
 
1751
 
 
1752
     When `detout' is `true', the determinant is factored out of the
 
1753
     inverse.
 
1754
 
 
1755
     The elements of the inverse are not automatically expanded.  If
 
1756
     <M> has polynomial elements, better appearing output can be
 
1757
     generated by `expand (invert (m)), detout'.  If it is desirable to
 
1758
     then divide through by the determinant this can be accomplished by
 
1759
     `xthru (%)' or alternatively from scratch by
 
1760
 
 
1761
          expand (adjoint (m)) / expand (determinant (m))
 
1762
          invert (m) := adjoint (m) / determinant (m)
 
1763
 
 
1764
     See `^^' (noncommutative exponent) for another method of inverting
 
1765
     a matrix.
 
1766
 
 
1767
 
 
1768
 -- Option variable: lmxchar
 
1769
     Default value: `['
 
1770
 
 
1771
     `lmxchar' is the character displayed as the left delimiter of a
 
1772
     matrix.  See also `rmxchar'.
 
1773
 
 
1774
     Example:
 
1775
 
 
1776
          (%i1) lmxchar: "|"$
 
1777
          (%i2) matrix ([a, b, c], [d, e, f], [g, h, i]);
 
1778
                                     | a  b  c ]
 
1779
                                     |         ]
 
1780
          (%o2)                      | d  e  f ]
 
1781
                                     |         ]
 
1782
                                     | g  h  i ]
 
1783
 
 
1784
 
 
1785
 -- Function: matrix (<row_1>, ..., <row_n>)
 
1786
     Returns a rectangular matrix which has the rows <row_1>, ...,
 
1787
     <row_n>.  Each row is a list of expressions.  All rows must be the
 
1788
     same length.
 
1789
 
 
1790
     The operations `+' (addition), `-' (subtraction), `*'
 
1791
     (multiplication), and `/' (division), are carried out element by
 
1792
     element when the operands are two matrices, a scalar and a matrix,
 
1793
     or a matrix and a scalar.  The operation `^' (exponentiation,
 
1794
     equivalently `**') is carried out element by element if the
 
1795
     operands are a scalar and a matrix or a matrix and a scalar, but
 
1796
     not if the operands are two matrices.  All operations are normally
 
1797
     carried out in full, including `.' (noncommutative multiplication).
 
1798
 
 
1799
     Matrix multiplication is represented by the noncommutative
 
1800
     multiplication operator `.'.  The corresponding noncommutative
 
1801
     exponentiation operator is `^^'.  For a matrix `<A>', `<A>.<A> =
 
1802
     <A>^^2' and `<A>^^-1' is the inverse of <A>, if it exists.
 
1803
 
 
1804
     There are switches for controlling simplification of expressions
 
1805
     involving dot and matrix-list operations.  These are `doallmxops',
 
1806
     `domxexpt' `domxmxops', `doscmxops', and `doscmxplus'.
 
1807
 
 
1808
     There are additional options which are related to matrices. These
 
1809
     are: `lmxchar', `rmxchar', `ratmx', `listarith', `detout',
 
1810
     `scalarmatrix', and `sparse'.
 
1811
 
 
1812
     There are a number of functions which take matrices as arguments
 
1813
     or yield matrices as return values.  See `eigenvalues',
 
1814
     `eigenvectors', `determinant', `charpoly', `genmatrix', `addcol',
 
1815
     `addrow', `copymatrix', `transpose', `echelon', and `rank'.
 
1816
 
 
1817
     Examples:
 
1818
 
 
1819
        * Construction of matrices from lists.
 
1820
 
 
1821
          (%i1) x: matrix ([17, 3], [-8, 11]);
 
1822
                                     [ 17   3  ]
 
1823
          (%o1)                      [         ]
 
1824
                                     [ - 8  11 ]
 
1825
          (%i2) y: matrix ([%pi, %e], [a, b]);
 
1826
                                     [ %pi  %e ]
 
1827
          (%o2)                      [         ]
 
1828
                                     [  a   b  ]
 
1829
 
 
1830
        * Addition, element by element.
 
1831
 
 
1832
          (%i3) x + y;
 
1833
                                [ %pi + 17  %e + 3 ]
 
1834
          (%o3)                 [                  ]
 
1835
                                [  a - 8    b + 11 ]
 
1836
 
 
1837
        * Subtraction, element by element.
 
1838
 
 
1839
          (%i4) x - y;
 
1840
                                [ 17 - %pi  3 - %e ]
 
1841
          (%o4)                 [                  ]
 
1842
                                [ - a - 8   11 - b ]
 
1843
 
 
1844
        * Multiplication, element by element.
 
1845
 
 
1846
          (%i5) x * y;
 
1847
                                  [ 17 %pi  3 %e ]
 
1848
          (%o5)                   [              ]
 
1849
                                  [ - 8 a   11 b ]
 
1850
 
 
1851
        * Division, element by element.
 
1852
 
 
1853
          (%i6) x / y;
 
1854
                                  [ 17       - 1 ]
 
1855
                                  [ ---  3 %e    ]
 
1856
                                  [ %pi          ]
 
1857
          (%o6)                   [              ]
 
1858
                                  [   8    11    ]
 
1859
                                  [ - -    --    ]
 
1860
                                  [   a    b     ]
 
1861
 
 
1862
        * Matrix to a scalar exponent, element by element.
 
1863
 
 
1864
          (%i7) x ^ 3;
 
1865
                                   [ 4913    27  ]
 
1866
          (%o7)                    [             ]
 
1867
                                   [ - 512  1331 ]
 
1868
 
 
1869
        * Scalar base to a matrix exponent, element by element.
 
1870
 
 
1871
          (%i8) exp(y);
 
1872
                                   [   %pi    %e ]
 
1873
                                   [ %e     %e   ]
 
1874
          (%o8)                    [             ]
 
1875
                                   [    a     b  ]
 
1876
                                   [  %e    %e   ]
 
1877
 
 
1878
        * Matrix base to a matrix exponent. This is not carried out
 
1879
          element by element.
 
1880
 
 
1881
          (%i9) x ^ y;
 
1882
                                          [ %pi  %e ]
 
1883
                                          [         ]
 
1884
                                          [  a   b  ]
 
1885
                               [ 17   3  ]
 
1886
          (%o9)                [         ]
 
1887
                               [ - 8  11 ]
 
1888
 
 
1889
        * Noncommutative matrix multiplication.
 
1890
 
 
1891
          (%i10) x . y;
 
1892
                            [ 3 a + 17 %pi  3 b + 17 %e ]
 
1893
          (%o10)            [                           ]
 
1894
                            [ 11 a - 8 %pi  11 b - 8 %e ]
 
1895
          (%i11) y . x;
 
1896
                          [ 17 %pi - 8 %e  3 %pi + 11 %e ]
 
1897
          (%o11)          [                              ]
 
1898
                          [  17 a - 8 b     11 b + 3 a   ]
 
1899
 
 
1900
        * Noncommutative matrix exponentiation.  A scalar base <b> to a
 
1901
          matrix power <M> is carried out element by element and so
 
1902
          `b^^m' is the same as `b^m'.
 
1903
 
 
1904
          (%i12) x ^^ 3;
 
1905
                                  [  3833   1719 ]
 
1906
          (%o12)                  [              ]
 
1907
                                  [ - 4584  395  ]
 
1908
          (%i13) %e ^^ y;
 
1909
                                   [   %pi    %e ]
 
1910
                                   [ %e     %e   ]
 
1911
          (%o13)                   [             ]
 
1912
                                   [    a     b  ]
 
1913
                                   [  %e    %e   ]
 
1914
 
 
1915
        * A matrix raised to a -1 exponent with noncommutative
 
1916
          exponentiation is the matrix inverse, if it exists.
 
1917
 
 
1918
          (%i14) x ^^ -1;
 
1919
                                   [ 11      3  ]
 
1920
                                   [ ---  - --- ]
 
1921
                                   [ 211    211 ]
 
1922
          (%o14)                   [            ]
 
1923
                                   [  8    17   ]
 
1924
                                   [ ---   ---  ]
 
1925
                                   [ 211   211  ]
 
1926
          (%i15) x . (x ^^ -1);
 
1927
                                      [ 1  0 ]
 
1928
          (%o15)                      [      ]
 
1929
                                      [ 0  1 ]
 
1930
 
 
1931
 
 
1932
 -- Function: matrixmap (<f>, <M>)
 
1933
     Returns a matrix with element `i,j' equal to `<f>(<M>[i,j])'.
 
1934
 
 
1935
     See also `map', `fullmap', `fullmapl', and `apply'.
 
1936
 
 
1937
 
 
1938
 -- Function: matrixp (<expr>)
 
1939
     Returns `true' if <expr> is a matrix, otherwise `false'.
 
1940
 
 
1941
 
 
1942
 -- Option variable: matrix_element_add
 
1943
     Default value: `+'
 
1944
 
 
1945
     `matrix_element_add' is the operation invoked in place of addition
 
1946
     in a matrix multiplication.  `matrix_element_add' can be assigned
 
1947
     any n-ary operator (that is, a function which handles any number
 
1948
     of arguments).  The assigned value may be the name of an operator
 
1949
     enclosed in quote marks, the name of a function, or a lambda
29
1950
     expression.
30
 
          BOX(expr,label)
31
 
     encloses expr in a labelled box.  label is a name which will be
32
 
     truncated in display if it is too long.      BOXCHAR["] - is the
33
 
     character used to draw the box in this and in the DPART and LPART
34
 
     functions.
35
 
 
36
 
 
37
 
 - Variable: BOXCHAR
38
 
     default: ["] is the character used to draw the box in the BOX and
39
 
     in the DPART and LPART functions.
40
 
 
41
 
 
42
 
 - special operator: CONSTANT
43
 
     - makes ai a constant as is %PI.
44
 
 
45
 
 
46
 
 - Function: CONSTANTP (exp)
47
 
     is TRUE if exp is a constant (i.e.  composed of numbers and %PI,
48
 
     %E, %I or any variables bound to a constant or DECLAREd constant)
49
 
     else FALSE.  Any function whose arguments are constant is also
50
 
     considered to be a constant.
51
 
 
52
 
 
53
 
 - Function: CONTRACT (exp)
54
 
     carries out all possible contractions in exp, which may be any
55
 
     well-formed combination of sums and products.  This function uses
56
 
     the information given to the DEFCON function.  Since all tensors
57
 
     are considered to be symmetric in all indices, the indices are
58
 
     sorted into alphabetical order.  Also all dummy indices are
59
 
     renamed using the symbols !1,!2,... to permit the expression to be
60
 
     simplified as much as possible by reducing equivalent terms to a
61
 
     canonical form.  For best results exp should be fully expanded.
62
 
     RATEXPAND is the fastest way to expand products and powers of sums
63
 
     if there are no variables in the denominators of the terms.  The
64
 
     GCD switch should be FALSE if gcd cancellations are unnecessary.
65
 
 
66
 
 
67
 
 - Function: DECLARE (a1, f1, a2, f2, ...)
68
 
     gives the atom ai the flag fi.  The ai's and fi's may also be
69
 
     lists of atoms and flags respectively in which case each of the
70
 
     atoms gets all of the properties.  The possible flags and their
71
 
     meanings are:
72
 
 
73
 
     CONSTANT - makes ai a constant as is %PI.
74
 
 
75
 
     MAINVAR - makes ai a MAINVAR.  The ordering scale for atoms:
76
 
     numbers < constants (e.g. %E,%PI) < scalars < other variables <
77
 
     mainvars.
78
 
 
79
 
     SCALAR - makes ai a scalar.
80
 
 
81
 
     NONSCALAR - makes ai behave as does a list or matrix with respect
82
 
     to the dot operator.
83
 
 
84
 
     NOUN - makes the function ai a noun so that it won't be evaluated
85
 
     automatically.
86
 
 
87
 
     EVFUN - makes ai known to the EV function so that it will get
88
 
     applied if its name is mentioned.  Initial evfuns are
89
 
          FACTOR, TRIGEXPAND,
90
 
          TRIGREDUCE, BFLOAT, RATSIMP, RATEXPAND, and RADCAN
91
 
 
92
 
     EVFLAG - makes ai known to the EV function so that it will be
93
 
     bound to TRUE during the execution of EV if it is mentioned.
94
 
     Initial evflags are
95
 
          FLOAT, PRED, SIMP, NUMER, DETOUT, EXPONENTIALIZE, DEMOIVRE,
96
 
          KEEPFLOAT, LISTARITH, TRIGEXPAND, SIMPSUM, ALGEBRAIC,
97
 
          RATALGDENOM, FACTORFLAG, %EMODE, LOGARC, LOGNUMER,
98
 
          RADEXPAND, RATSIMPEXPONS, RATMX, RATFAC, INFEVAL, %ENUMER,
99
 
          PROGRAMMODE, LOGNEGINT, LOGABS, LETRAT, HALFANGLES,
100
 
          EXPTISOLATE, ISOLATE_WRT_TIMES, SUMEXPAND, CAUCHYSUM,
101
 
          NUMER_PBRANCH, M1PBRANCH, DOTSCRULES, and LOGEXPAND
102
 
 
103
 
     BINDTEST - causes ai to signal an error if it ever is used in a
104
 
     computation unbound.  DECLARE([var1, var2, ...], BINDTEST) causes
105
 
     MACSYMA to give an error message whenever any of the vari occur
106
 
     unbound in a computation.  MACSYMA currently recognizes and uses
107
 
     the following features of objects:
108
 
          EVEN, ODD, INTEGER, RATIONAL, IRRATIONAL, REAL, IMAGINARY,
109
 
          and COMPLEX
110
 
     he useful features of functions include:
111
 
           INCREASING,
112
 
          DECREASING, ODDFUN (odd function), EVENFUN (even function),
113
 
          COMMUTATIVE (or SYMMETRIC), ANTISYMMETRIC, LASSOCIATIVE and
114
 
          RASSOCIATIVE
115
 
     DECLARE(F,INCREASING) is in all respects equivalent to
116
 
 
117
 
          ASSUME(KIND(F,INCREASING))
118
 
     The ai and fi may also be lists of objects or features.  The
119
 
     command
120
 
          FEATUREP(object,feature)
121
 
     may be used to determine if an object has been DECLAREd to have
122
 
     "feature".  See DESCRIBE(FEATURES); .
123
 
 
124
 
 
125
 
 - Function: DISOLATE (exp, var1, var2, ..., varN)
126
 
     is similar to ISOLATE(exp, var) (Do DESCRIBE(ISOLATE);) except
127
 
     that it enables the user to isolate more than one variable
128
 
     simultaneously.  This might be useful, for example, if one were
129
 
     attempting to change variables in a multiple integration, and that
130
 
     variable change involved two or more of the integration variables.
131
 
     This function is autoloaded from `simplification/disol.mac'.  A
132
 
     demo is available by `demo("disol")$'.
133
 
 
134
 
 
135
 
 - Function: DISPFORM (exp)
136
 
     returns the external representation of exp (wrt its main
137
 
     operator).  This should be useful in conjunction with PART which
138
 
     also deals with the external representation.  Suppose EXP is -A .
139
 
     Then the internal representation of EXP is "*"(-1,A), while the
140
 
     external representation is "-"(A). DISPFORM(exp,ALL) converts the
141
 
     entire expression (not just the top-level) to external format.  For
142
 
     example, if EXP:SIN(SQRT(X)), then FREEOF(SQRT,EXP) and
143
 
     FREEOF(SQRT,DISPFORM(EXP)) give TRUE, while
144
 
     FREEOF(SQRT,DISPFORM(EXP,ALL)) gives FALSE.
145
 
 
146
 
 
147
 
 - Function: DISTRIB (exp)
148
 
     distributes sums over products.  It differs from EXPAND in that it
149
 
     works at only the top level of an expression, i.e. it doesn't
150
 
     recurse and it is faster than EXPAND.  It differs from MULTTHRU in
151
 
     that it expands all sums at that level. For example,
152
 
     DISTRIB((A+B)*(C+D)) -> A C + A D + B C + B D MULTTHRU
153
 
     ((A+B)*(C+D)) -> (A + B) C + (A + B) D DISTRIB (1/((A+B)*(C+D)))
154
 
     ->  1/ ((A+B) *(C+D)) EXPAND(1/((A+B)*(C+D)),1,0) -> 1/(A C + A D
155
 
     + B C + B D)
156
 
 
157
 
 
158
 
 - Function: DPART (exp, n1, ..., nk)
159
 
     selects the same subexpression as PART, but instead of just
160
 
     returning that subexpression as its value, it returns the whole
161
 
     expression with the selected subexpression displayed inside a box.
162
 
     The box is actually part of the expression.
163
 
          (%i1) DPART(X+Y/Z**2,1,2,1);
164
 
                                 Y
165
 
          (%o1)                  ---- + X
166
 
                                   2
167
 
                               *****
168
 
                               * Z *
169
 
                               *****
170
 
 
171
 
 - Function: EXP (X)
172
 
     the exponential function.  It is represented internally as %E^X.
173
 
     DEMOIVRE[FALSE] - if TRUE will cause %E^(A+B*%I) to become
174
 
     %E^A*(COS(B)+%I*SIN(B)) if B is free of %I.  A and B are not
175
 
     expanded.    %EMODE[TRUE] - when TRUE %E^(%PI*%I*X) will be
176
 
     simplified as follows: it will become COS(%PI*X)+%I*SIN(%PI*X) if
177
 
     X is an integer or a multiple of 1/2, 1/3, 1/4, or 1/6 and thus
178
 
     will simplify further.  For other numerical X it will become
179
 
     %E^(%PI*%I*Y) where Y is X-2*k for some integer k such that
180
 
     ABS(Y)<1.  If %EMODE is FALSE no simplification of %E^(%PI*%I*X)
181
 
     will take place.    %ENUMER[FALSE] - when TRUE will cause %E to be
182
 
     converted into 2.718...  whenever NUMER is TRUE.  The default is
183
 
     that this conversion will take place only if the exponent in %E^X
184
 
     evaluates to a number.
185
 
 
186
 
 
187
 
 - Variable: EXPTISOLATE
188
 
     default: [FALSE] if TRUE will cause ISOLATE(expr,var); to examine
189
 
     exponents of atoms (like %E) which contain var.
190
 
 
191
 
 
192
 
 - Variable: EXPTSUBST
193
 
     default: [FALSE] if TRUE permits substitutions such as Y for %E**X
194
 
     in %E**(A*X) to take place.
195
 
 
196
 
 
197
 
 - Function: FREEOF (x1, x2, ..., exp)
198
 
     yields TRUE if the xi do not occur in exp and FALSE otherwise.
199
 
     The xi are atoms or they may be subscripted names, functions (e.g.
200
 
     SIN(X) ), or operators enclosed in "s.  If 'var' is a "dummy
201
 
     variable" of 'exp', then FREEOF(var,exp); will return TRUE.
202
 
     "Dummy variables" are mathematical things like the index of a sum
203
 
     or product, the limit variable, and the definite integration
204
 
     variable.  Example: FREEOF(I,'SUM(F(I),I,0,N)); returns TRUE.  Do
205
 
     EXAMPLE(FREEOF); for more examples.
206
 
 
207
 
 
208
 
 - Function: GENFACT (X, Y, Z)
209
 
     is the generalized factorial of X which is:
210
 
     X*(X-Z)*(X-2*Z)*...*(X-(Y-1)*Z).  Thus, for integral X,
211
 
     GENFACT(X,X,1)=X!  and GENFACT(X,X/2,2)=X!!
212
 
 
213
 
 
214
 
 - Function: IMAGPART (exp)
215
 
     returns the imaginary part of the expression exp.
216
 
 
217
 
 
218
 
 - Function: INDICES (exp)
219
 
     returns a list of two elements.  The first is a list of the free
220
 
     indices in exp (those that occur only once); the second is the
221
 
     list of dummy indices in exp (those that occur exactly twice).
222
 
 
223
 
 
224
 
 - Function: INFIX (op)
225
 
     - INFIX operators are used to denote functions of two arguments,
226
 
     one given before the operator and one after, e.g. A^2 .  The
227
 
     INFIX("x") function is a syntax extention function to declare x to
228
 
     be an INFIX operator.  Do DESCRIBE(SYNTAX); for more details.
229
 
 
230
 
 
231
 
 - Variable: INFLAG
232
 
     default: [FALSE] if set to TRUE, the functions for part extraction
233
 
     will look at the internal form of exp.  Note that the simplifier
234
 
     re-orders expressions.  Thus FIRST(X+Y) will be X if INFLAG is
235
 
     TRUE and Y if INFLAG is FALSE.  (FIRST(Y+X) gives the same
236
 
     results).  Also, setting INFLAG to TRUE and calling PART/SUBSTPART
237
 
     is the same as calling INPART/SUBSTINPART.  Functions affected by
238
 
     the setting of INFLAG are: PART, SUBSTPART, FIRST, REST, LAST,
239
 
     LENGTH, the FOR ... IN construct, MAP, FULLMAP, MAPLIST, REVEAL
240
 
     and PICKAPART.
241
 
 
242
 
 
243
 
 - Function: INPART (exp, n1, ..., nk)
244
 
     is similar to PART but works on the internal representation of the
245
 
     expression rather than the displayed form and thus may be faster
246
 
     since no formatting is done.  Care should be taken with respect to
247
 
     the order of subexpressions in sums and products (since the order
248
 
     of variables in the internal form is often different from that in
249
 
     the displayed form) and in dealing with unary minus, subtraction,
250
 
     and division (since these operators are removed from the
251
 
     expression). PART(X+Y,0) or INPART(X+Y,0) yield +, though in order
252
 
     to refer to the operator it must be enclosed in "s.  For example
253
 
     ...IF INPART(%o9,0)="+" THEN ...
254
 
          (%i1)  X+Y+W*Z;
255
 
          (%o1)                  W Z + Y + X
256
 
          (%i2)  INPART(%o1,3,2);
257
 
          (%o2)                  Z
258
 
          (%i3)  PART(%o1,1,2);
259
 
          (%o3)                  Z
260
 
          (%i4) 'LIMIT(F(X)**G(X+1),X,0,MINUS);
261
 
                                                G(X + 1)
262
 
          (%o4)                      LIMIT   F(X)
263
 
                                    X ->0-
264
 
          (%i5) INPART(%,1,2);
265
 
          (%o5)                            G(X + 1)
266
 
 
267
 
 - Function: ISOLATE (exp, var)
268
 
     returns exp with subexpressions which are sums and which do not
269
 
     contain var replaced by intermediate expression labels (these
270
 
     being atomic symbols like %t1, %t2, ...).  This is often useful to
271
 
     avoid unnecessary expansion of subexpressions which don't contain
272
 
     the variable of interest.  Since the intermediate labels are bound
273
 
     to the subexpressions they can all be substituted back by
274
 
     evaluating the expression in which they occur.  EXPTISOLATE[FALSE]
275
 
     if TRUE will cause ISOLATE to examine exponents of atoms (like %E)
276
 
     which contain var.  ISOLATE_WRT_TIMES[FALSE] if TRUE, then ISOLATE
277
 
     will also isolate wrt products.  E.g. compare both settings of the
278
 
     switch on ISOLATE(EXPAND((A+B+C)^2),C); .  Do EXAMPLE(ISOLATE);
279
 
     for examples.
280
 
 
281
 
 
282
 
 - Variable: ISOLATE_WRT_TIMES
283
 
     default: [FALSE] - if set to TRUE, then ISOLATE will also isolate
284
 
     wrt products.  E.g. compare both settings of the switch on
285
 
     ISOLATE(EXPAND((A+B+C)^2),C); .
286
 
 
287
 
 
288
 
 - Variable: LISTCONSTVARS
289
 
     default: [FALSE] - if TRUE will cause LISTOFVARS to include %E,
290
 
     %PI, %I, and any variables declared constant in the list it
291
 
     returns if they appear in the expression LISTOFVARS is called on.
292
 
     The default is to omit these.
293
 
 
294
 
 
295
 
 - Variable: LISTDUMMYVARS
296
 
     default: [TRUE] - if FALSE, "dummy variables" in the expression
297
 
     will not be included in the list returned by LISTOFVARS.  (The
298
 
     meaning of "dummy variables" is as given in DESCRIBE(FREEOF):
299
 
     "Dummy variables" are mathematical things like the index of a sum
300
 
     or product, the limit variable, and the definite integration
301
 
     variable.)  Example: LISTOFVARS('SUM(F(I),I,0,N)); gives [I,N] if
302
 
     LISTDUMMYVARS is TRUE, and [N] if LISTDUMMYVARS is FALSE.
303
 
 
304
 
 
305
 
 - Function: LISTOFVARS (exp)
306
 
     yields a list of the variables in exp.  LISTCONSTVARS[FALSE] if
307
 
     TRUE will cause LISTOFVARS to include %E, %PI, %I, and any
308
 
     variables declared constant in the list it returns if they appear
309
 
     in exp.  The default is to omit these.
310
 
          (%i1) LISTOFVARS(F(X[1]+Y)/G**(2+A));
311
 
          (%o1)                            [X[1], Y, A, G]
312
 
 
313
 
 - Function: LFREEOF (list, exp)
314
 
     For each member m of list, calls FREEOF(m,exp).  It returns false
315
 
     if any call to FREEOF does and true otherwise.
316
 
 
317
 
 - Function: LOPOW (exp, v)
318
 
     the lowest exponent of v which explicitly appears in exp.  Thus
319
 
 
320
 
          LOPOW((X+Y)**2+(X+Y)**A,X+Y) ==> MIN(A,2)
321
 
     .
322
 
 
323
 
 
324
 
 - Function: LPART (label, expr, n1, ..., nk)
325
 
     is similar to DPART but uses a labelled box. A labelled box is
326
 
     similar to the one produced by DPART but it has a name in the top
327
 
     line.
328
 
 
329
 
 
330
 
 - Function: MULTTHRU (exp)
331
 
     multiplies a factor (which should be a sum) of exp by the other
332
 
     factors of exp.  That is exp is f1*f2*...*fn where at least one
333
 
     factor, say fi, is a sum of terms.  Each term in that sum is
334
 
     multiplied by the other factors in the product.  (Namely all the
335
 
     factors except fi).  MULTTHRU does not expand exponentiated sums.
336
 
     This function is the fastest way to distribute products
337
 
     (commutative or noncommutative) over sums.  Since quotients are
338
 
     represented as products MULTTHRU can be used to divide sums by
339
 
     products as well.  MULTTHRU(exp1, exp2) multiplies each term in
340
 
     exp2 (which should be a sum or an equation) by exp1.  If exp1 is
341
 
     not itself a sum then this form is equivalent to
342
 
     MULTTHRU(exp1*exp2).
343
 
          (%i1) X/(X-Y)**2-1/(X-Y)-F(X)/(X-Y)**3;
344
 
                         1        X         F(X)
345
 
          (%o1)       - ----- + -------- - --------
346
 
                       X - Y          2          3
347
 
                               (X - Y)    (X - Y)
348
 
          (%i2) MULTTHRU((X-Y)**3,%);
349
 
                              2
350
 
          (%o2)       - (X - Y)  + X (X - Y) - F(X)
351
 
          (%i3) RATEXPAND(%o2);
352
 
                                     2
353
 
          (%o3)                    - Y  + X Y - F(X)
354
 
          (%i4) ((A+B)**10*S**2+2*A*B*S+(A*B)**2)/(A*B*S**2);
355
 
                                   10  2              2  2
356
 
                          (B  + A )   S  + 2 A B S + A  B
357
 
          (%o4)            --------------------------------
358
 
                                             2
359
 
                                        A B S
360
 
          (%i5) MULTTHRU(%);
361
 
                                                    10
362
 
                                  2   A B   (B  + A)
363
 
          (%o5)                    - + --- + -------
364
 
                                  S    2      A B
365
 
                                      S
366
 
          (notice that (B+A)**10 is not expanded)
367
 
          (%i6) MULTTHRU(A.(B+C.(D+E)+F));
368
 
          (%o6)                A . F + A . (C . (E + D)) + A . B
369
 
          (compare with similar example under EXPAND)
370
 
 
371
 
 - Function: NOUNIFY (f)
372
 
     returns the noun form of the function name f.  This is needed if
373
 
     one wishes to refer to the name of a verb function as if it were a
374
 
     noun.  Note that some verb functions will return their noun forms
375
 
     if they can't be evaluated for certain arguments.  This is also
376
 
     the form returned if a function call is preceded by a quote.
377
 
 
378
 
 
379
 
 - Function: NTERMS (exp)
380
 
     gives the number of terms that exp would have if it were fully
381
 
     expanded out and no cancellations or combination of terms
382
 
     occurred. Note that expressions like SIN(E), SQRT(E), EXP(E), etc.
383
 
     count as just one term regardless of how many terms E has (if it
384
 
     is a sum).
385
 
 
386
 
 
387
 
 - Function: OP (exp)
388
 
     Returns the operator of the expression, and functions the same way
389
 
     as PART(exp,0).  It observes the setting of the INPART flag.  It
390
 
     may not return the same value as the commercial Macsyma.
391
 
 
392
 
 
393
 
 - Function: OPERATORP (exp, ool)
394
 
     Uses OP to get the operator of the expression and either compares
395
 
     it to ool, if it is a operator, or checks if it is a member of ool
396
 
     if it is a list.
397
 
 
398
 
 
399
 
 - Function: OPTIMIZE (exp)
400
 
     returns an expression that produces the same value and side
401
 
     effects as exp but does so more efficiently by avoiding the
402
 
     recomputation of common subexpressions.  OPTIMIZE also has the side
403
 
     effect of "collapsing" its argument so that all common
404
 
     subexpressions are shared.  Do EXAMPLE(OPTIMIZE); for examples.
405
 
 
406
 
 
407
 
 - Variable: OPTIMPREFIX
408
 
     default: [%] - The prefix used for generated symbols by the
409
 
     OPTIMIZE command.
410
 
 
411
 
 
412
 
 - Function: ORDERGREAT (V1, ..., Vn)
413
 
     sets up aliases for the variables V1, ..., Vn such that V1 > V2 >
414
 
     ...  > Vn > any other variable not mentioned as an argument.  See
415
 
     also ORDERLESS.  Caveat:  do EXAMPLE(ORDERGREAT); for some
416
 
     specifics.
417
 
 
418
 
 
419
 
 - Function: ORDERGREATP (exp1,exp2)
420
 
     returns TRUE if exp2 precedes exp1 in the ordering set up with the
421
 
     ORDERGREAT function (see DESCRIBE(ORDERGREAT);).
422
 
 
423
 
 
424
 
 - Function: ORDERLESS (V1, ..., Vn)
425
 
     sets up aliases for the variables V1, ..., Vn such that V1 < V2 <
426
 
     ...  < Vn < any other variable not mentioned as an argument.  Thus
427
 
     the complete ordering scale is: numerical constants < declared
428
 
     constants < declared scalars < first argument to ORDERLESS < ...
429
 
     < last argument to ORDERLESS < variables which begin with A < ...
430
 
     < variables which begin with Z < last argument to ORDERGREAT <
431
 
     ... < first argument to ORDERGREAT < declared MAINVARs.  Caveat: do
432
 
     EXAMPLE(ORDERLESS); for some specifics.  For another ordering
433
 
     scheme, see DESCRIBE(MAINVAR);.
434
 
 
435
 
 
436
 
 - Function: ORDERLESSP (exp1,exp2)
437
 
     returns TRUE if exp1 precedes exp2 in the ordering set up by the
438
 
     ORDERLESS command (see DESCRIBE(ORDERLESS);).
439
 
 
440
 
 
441
 
 - Function: PART (exp, n1, ..., nk)
442
 
     deals with the displayed form of exp. It obtains the part of exp
443
 
     as specified by the indices n1,...,nk.  First part n1 of exp is
444
 
     obtained, then part n2 of that, etc.  The result is part nk of ...
445
 
     part n2 of part n1 of exp.  Thus PART(Z+2*Y,2,1) yields 2.  PART
446
 
     can be used to obtain an element of a list, a row of a matrix, etc.
447
 
     If the last argument to a Part function is a list of indices then
448
 
     several subexpressions are picked out, each one corresponding to an
449
 
     index of the list.  Thus PART(X+Y+Z,[1,3]) is Z+X.  PIECE holds
450
 
     the last expression selected when using the Part functions.  It is
451
 
     set during the execution of the function and thus may be referred
452
 
     to in the function itself as shown below.  If PARTSWITCH[FALSE] is
453
 
     set to TRUE then END is returned when a selected part of an
454
 
     expression doesn't exist, otherwise an error message is given.
455
 
     For examples, do EXAMPLE(PART);
456
 
 
457
 
 
458
 
 - Function: PARTITION (exp, var)
459
 
     returns a list of two expressions.  They are (1) the factors of
460
 
     exp (if it is a product), the terms of exp (if it is a sum), or
461
 
     the list (if it is a list) which don't contain var and, (2) the
462
 
     factors, terms, or list which do.
463
 
          (%i1) PARTITION(2*A*X*F(X),X);
464
 
          (%o1)                 [ 2 A , X F(X) ]
465
 
          (%i2) PARTITION(A+B,X);
466
 
          (%o2)                 [ A + B , 0 ]
467
 
          (%i3) PARTITION([A,B,F(A),C],A);
468
 
          (%o3)                [[B,C],[A,F(A)]]
469
 
 
470
 
 - Variable: PARTSWITCH
471
 
     default: [FALSE] - if set to TRUE then END is returned when a
472
 
     selected part of an expression doesn't exist, otherwise an error
473
 
     message is given.
474
 
 
475
 
 
476
 
 - Function: PICKAPART (exp,depth)
477
 
     will assign E labels to all subexpressions of exp down to the
478
 
     specified integer depth.  This is useful for dealing with large
479
 
     expressions and for automatically assigning parts of an expression
480
 
     to a variable without having to use the part functions.
481
 
          (%i1) EXP:(A+B)/2+SIN(X^2)/3-LOG(1+SQRT(X+1));
482
 
                                                           2
483
 
                                                      SIN(X )   B + A
484
 
          (%o1)               - LOG(SQRT(X + 1) + 1) + ------- + -----
485
 
                                                         3        2
486
 
          (%i2) PICKAPART(%,1);
487
 
          (%t2)                    - LOG(SQRT(X + 1) + 1)
488
 
                                              2
489
 
                                         SIN(X )
490
 
          (%t3)                           -------
491
 
                                            3
492
 
                                          B + A
493
 
          (%t4)                            -----
 
1951
 
 
1952
     See also `matrix_element_mult' and `matrix_element_transpose'.
 
1953
 
 
1954
     Example:
 
1955
 
 
1956
          (%i1) matrix_element_add: "*"$
 
1957
          (%i2) matrix_element_mult: "^"$
 
1958
          (%i3) aa: matrix ([a, b, c], [d, e, f]);
 
1959
                                     [ a  b  c ]
 
1960
          (%o3)                      [         ]
 
1961
                                     [ d  e  f ]
 
1962
          (%i4) bb: matrix ([u, v, w], [x, y, z]);
 
1963
                                     [ u  v  w ]
 
1964
          (%o4)                      [         ]
 
1965
                                     [ x  y  z ]
 
1966
          (%i5) aa . transpose (bb);
 
1967
                               [  u  v  w   x  y  z ]
 
1968
                               [ a  b  c   a  b  c  ]
 
1969
          (%o5)                [                    ]
 
1970
                               [  u  v  w   x  y  z ]
 
1971
                               [ d  e  f   d  e  f  ]
 
1972
 
 
1973
 
 
1974
 -- Option variable: matrix_element_mult
 
1975
     Default value: `*'
 
1976
 
 
1977
     `matrix_element_mult' is the operation invoked in place of
 
1978
     multiplication in a matrix multiplication.  `matrix_element_mult'
 
1979
     can be assigned any binary operator.  The assigned value may be
 
1980
     the name of an operator enclosed in quote marks, the name of a
 
1981
     function, or a lambda expression.
 
1982
 
 
1983
     The dot operator `.' is a useful choice in some contexts.
 
1984
 
 
1985
     See also `matrix_element_add' and `matrix_element_transpose'.
 
1986
 
 
1987
     Example:
 
1988
 
 
1989
          (%i1) matrix_element_add: lambda ([[x]], sqrt (apply ("+", x)))$
 
1990
          (%i2) matrix_element_mult: lambda ([x, y], (x - y)^2)$
 
1991
          (%i3) [a, b, c] . [x, y, z];
 
1992
                                    2          2          2
 
1993
          (%o3)         sqrt((c - z)  + (b - y)  + (a - x) )
 
1994
          (%i4) aa: matrix ([a, b, c], [d, e, f]);
 
1995
                                     [ a  b  c ]
 
1996
          (%o4)                      [         ]
 
1997
                                     [ d  e  f ]
 
1998
          (%i5) bb: matrix ([u, v, w], [x, y, z]);
 
1999
                                     [ u  v  w ]
 
2000
          (%o5)                      [         ]
 
2001
                                     [ x  y  z ]
 
2002
          (%i6) aa . transpose (bb);
 
2003
                         [             2          2          2  ]
 
2004
                         [ sqrt((c - w)  + (b - v)  + (a - u) ) ]
 
2005
          (%o6)  Col 1 = [                                      ]
 
2006
                         [             2          2          2  ]
 
2007
                         [ sqrt((f - w)  + (e - v)  + (d - u) ) ]
 
2008
 
 
2009
                                   [             2          2          2  ]
 
2010
                                   [ sqrt((c - z)  + (b - y)  + (a - x) ) ]
 
2011
                           Col 2 = [                                      ]
 
2012
                                   [             2          2          2  ]
 
2013
                                   [ sqrt((f - z)  + (e - y)  + (d - x) ) ]
 
2014
 
 
2015
 
 
2016
 -- Option variable: matrix_element_transpose
 
2017
     Default value: `false'
 
2018
 
 
2019
     `matrix_element_transpose' is the operation applied to each
 
2020
     element of a matrix when it is transposed.  `matrix_element_mult'
 
2021
     can be assigned any unary operator.  The assigned value may be the
 
2022
     name of an operator enclosed in quote marks, the name of a
 
2023
     function, or a lambda expression.
 
2024
 
 
2025
     When `matrix_element_transpose' equals `transpose', the
 
2026
     `transpose' function is applied to every element.  When
 
2027
     `matrix_element_transpose' equals `nonscalars', the `transpose'
 
2028
     function is applied to every nonscalar element.  If some element
 
2029
     is an atom, the `nonscalars' option applies `transpose' only if
 
2030
     the atom is declared nonscalar, while the `transpose' option
 
2031
     always applies `transpose'.
 
2032
 
 
2033
     The default value, `false', means no operation is applied.
 
2034
 
 
2035
     See also `matrix_element_add' and `matrix_element_mult'.
 
2036
 
 
2037
     Examples:
 
2038
 
 
2039
          (%i1) declare (a, nonscalar)$
 
2040
          (%i2) transpose ([a, b]);
 
2041
                                  [ transpose(a) ]
 
2042
          (%o2)                   [              ]
 
2043
                                  [      b       ]
 
2044
          (%i3) matrix_element_transpose: nonscalars$
 
2045
          (%i4) transpose ([a, b]);
 
2046
                                  [ transpose(a) ]
 
2047
          (%o4)                   [              ]
 
2048
                                  [      b       ]
 
2049
          (%i5) matrix_element_transpose: transpose$
 
2050
          (%i6) transpose ([a, b]);
 
2051
                                  [ transpose(a) ]
 
2052
          (%o6)                   [              ]
 
2053
                                  [ transpose(b) ]
 
2054
          (%i7) matrix_element_transpose: lambda ([x], realpart(x) - %i*imagpart(x))$
 
2055
          (%i8) m: matrix ([1 + 5*%i, 3 - 2*%i], [7*%i, 11]);
 
2056
                               [ 5 %i + 1  3 - 2 %i ]
 
2057
          (%o8)                [                    ]
 
2058
                               [   7 %i       11    ]
 
2059
          (%i9) transpose (m);
 
2060
                                [ 1 - 5 %i  - 7 %i ]
 
2061
          (%o9)                 [                  ]
 
2062
                                [ 2 %i + 3    11   ]
 
2063
 
 
2064
 
 
2065
 -- Function: mattrace (<M>)
 
2066
     Returns the trace (that is, the sum of the elements on the main
 
2067
     diagonal) of the square matrix <M>.
 
2068
 
 
2069
     `mattrace' is called by `ncharpoly', an alternative to Maxima's
 
2070
     `charpoly'.
 
2071
 
 
2072
     `load ("nchrpl")' loads this function.
 
2073
 
 
2074
 
 
2075
 -- Function: minor (<M>, <i>, <j>)
 
2076
     Returns the <i>, <j> minor of the matrix <M>.  That is, <M> with
 
2077
     row <i> and column <j> removed.
 
2078
 
 
2079
 
 
2080
 -- Function: ncexpt (<a>, <b>)
 
2081
     If a non-commutative exponential expression is too wide to be
 
2082
     displayed as `<a>^^<b>' it appears as `ncexpt (<a>,<b>)'.
 
2083
 
 
2084
     `ncexpt' is not the name of a function or operator; the name only
 
2085
     appears in output, and is not recognized in input.
 
2086
 
 
2087
 
 
2088
 -- Function: ncharpoly (<M>, <x>)
 
2089
     Returns the characteristic polynomial of the matrix <M> with
 
2090
     respect to <x>.  This is an alternative to Maxima's `charpoly'.
 
2091
 
 
2092
     `ncharpoly' works by computing traces of powers of the given
 
2093
     matrix, which are known to be equal to sums of powers of the roots
 
2094
     of the characteristic polynomial.  From these quantities the
 
2095
     symmetric functions of the roots can be calculated, which are
 
2096
     nothing more than the coefficients of the characteristic
 
2097
     polynomial.  `charpoly' works by forming the determinant of `<x> *
 
2098
     ident [n] - a'.  Thus `ncharpoly' wins, for example, in the case
 
2099
     of large dense matrices filled with integers, since it avoids
 
2100
     polynomial arithmetic altogether.
 
2101
 
 
2102
     `load ("nchrpl")' loads this file.
 
2103
 
 
2104
 
 
2105
 -- Function: newdet (<M>, <n>)
 
2106
     Computes the determinant of the matrix or array <M> by the
 
2107
     Johnson-Gentleman tree minor algorithm.  The argument <n> is the
 
2108
     order; it is optional if <M> is a matrix.
 
2109
 
 
2110
 
 
2111
 -- Declaration: nonscalar
 
2112
     Makes atoms behave as does a list or matrix with respect to the
 
2113
     dot operator.
 
2114
 
 
2115
 
 
2116
 -- Function: nonscalarp (<expr>)
 
2117
     Returns `true' if <expr> is a non-scalar, i.e., it contains atoms
 
2118
     declared as non-scalars, lists, or matrices.
 
2119
 
 
2120
 
 
2121
 -- Function: permanent (<M>, <n>)
 
2122
     Computes the permanent of the matrix <M>.  A permanent is like a
 
2123
     determinant but with no sign changes.
 
2124
 
 
2125
 
 
2126
 -- Function: rank (<M>)
 
2127
     Computes the rank of the matrix <M>.  That is, the order of the
 
2128
     largest non-singular subdeterminant of <M>.
 
2129
 
 
2130
     <rank> may return the wrong answer if it cannot determine that a
 
2131
     matrix element that is equivalent to zero is indeed so.
 
2132
 
 
2133
 
 
2134
 -- Option variable: ratmx
 
2135
     Default value: `false'
 
2136
 
 
2137
     When `ratmx' is `false', determinant and matrix addition,
 
2138
     subtraction, and multiplication are performed in the
 
2139
     representation of the matrix elements and cause the result of
 
2140
     matrix inversion to be left in general representation.
 
2141
 
 
2142
     When `ratmx' is `true', the 4 operations mentioned above are
 
2143
     performed in CRE form and the result of matrix inverse is in CRE
 
2144
     form.  Note that this may cause the elements to be expanded
 
2145
     (depending on the setting of `ratfac') which might not always be
 
2146
     desired.
 
2147
 
 
2148
 
 
2149
 -- Function: row (<M>, <i>)
 
2150
     Returns the <i>'th row of the matrix <M>.  The return value is a
 
2151
     matrix.
 
2152
 
 
2153
 
 
2154
 -- Option variable: scalarmatrixp
 
2155
     Default value: `true'
 
2156
 
 
2157
     When `scalarmatrixp' is `true', then whenever a 1 x 1 matrix is
 
2158
     produced as a result of computing the dot product of matrices it
 
2159
     is simplified to a scalar, namely the sole element of the matrix.
 
2160
 
 
2161
     When `scalarmatrixp' is `all', then all 1 x 1 matrices are
 
2162
     simplified to scalars.
 
2163
 
 
2164
     When `scalarmatrixp' is `false', 1 x 1 matrices are not simplified
 
2165
     to scalars.
 
2166
 
 
2167
 
 
2168
 -- Function: scalefactors (<coordinatetransform>)
 
2169
     Here coordinatetransform evaluates to the form [[expression1,
 
2170
     expression2, ...], indeterminate1, indeterminat2, ...], where
 
2171
     indeterminate1, indeterminate2, etc. are the curvilinear
 
2172
     coordinate variables and where a set of rectangular Cartesian
 
2173
     components is given in terms of the curvilinear coordinates by
 
2174
     [expression1, expression2, ...].  `coordinates' is set to the
 
2175
     vector [indeterminate1, indeterminate2,...], and `dimension' is
 
2176
     set to the length of this vector.  SF[1], SF[2], ...,
 
2177
     SF[DIMENSION] are set to the coordinate scale factors, and `sfprod'
 
2178
     is set to the product of these scale factors.  Initially,
 
2179
     `coordinates' is [X, Y, Z], `dimension' is 3, and
 
2180
     SF[1]=SF[2]=SF[3]=SFPROD=1, corresponding to 3-dimensional
 
2181
     rectangular Cartesian coordinates.  To expand an expression into
 
2182
     physical components in the current coordinate system, there is a
 
2183
     function with usage of the form
 
2184
 
 
2185
 
 
2186
 -- Function: setelmx (<x>, <i>, <j>, <M>)
 
2187
     Assigns <x> to the (<i>, <j>)'th element of the matrix <M>, and
 
2188
     returns the altered matrix.
 
2189
 
 
2190
     `<M> [<i>, <j>]: <x>' has the same effect, but returns <x> instead
 
2191
     of <M>.
 
2192
 
 
2193
 
 
2194
 -- Function: similaritytransform (<M>)
 
2195
 -- Function: simtran (<M>)
 
2196
     `similaritytransform' computes a similarity transform of the
 
2197
     matrix `M'.  It returns a list which is the output of the
 
2198
     `uniteigenvectors' command.  In addition if the flag
 
2199
     `nondiagonalizable' is `false' two global matrices `leftmatrix'
 
2200
     and `rightmatrix' are computed.  These matrices have the property
 
2201
     that `leftmatrix . <M> . rightmatrix' is a diagonal matrix with
 
2202
     the eigenvalues of <M> on the diagonal.  If `nondiagonalizable' is
 
2203
     `true' the left and right matrices are not computed.
 
2204
 
 
2205
     If the flag `hermitianmatrix' is `true' then `leftmatrix' is the
 
2206
     complex conjugate of the transpose of `rightmatrix'.  Otherwise
 
2207
     `leftmatrix' is the inverse of `rightmatrix'.
 
2208
 
 
2209
     `rightmatrix' is the matrix the columns of which are the unit
 
2210
     eigenvectors of <M>.  The other flags (see `eigenvalues' and
 
2211
     `eigenvectors') have the same effects since `similaritytransform'
 
2212
     calls the other functions in the package in order to be able to
 
2213
     form `rightmatrix'.
 
2214
 
 
2215
     `load ("eigen")' loads this function.
 
2216
 
 
2217
     `simtran' is a synonym for `similaritytransform'.
 
2218
 
 
2219
 
 
2220
 -- Option variable: sparse
 
2221
     Default value: `false'
 
2222
 
 
2223
     When `sparse' is `true', and if `ratmx' is `true', then
 
2224
     `determinant' will use special routines for computing sparse
 
2225
     determinants.
 
2226
 
 
2227
 
 
2228
 -- Function: submatrix (<i_1>, ..., <i_m>, <M>, <j_1>, ..., <j_n>)
 
2229
 -- Function: submatrix (<i_1>, ..., <i_m>, <M>)
 
2230
 -- Function: submatrix (<M>, <j_1>, ..., <j_n>)
 
2231
     Returns a new matrix composed of the matrix <M> with rows <i_1>,
 
2232
     ..., <i_m> deleted, and columns <j_1>, ..., <j_n> deleted.
 
2233
 
 
2234
 
 
2235
 -- Function: transpose (<M>)
 
2236
     Returns the transpose of <M>.
 
2237
 
 
2238
     If <M> is a matrix, the return value is another matrix <N> such
 
2239
     that `N[i,j] = M[j,i]'.
 
2240
 
 
2241
     Otherwise <M> is a list, and the return value is a matrix <N> of
 
2242
     `length (m)' rows and 1 column, such that `N[i,1] = M[i]'.
 
2243
 
 
2244
 
 
2245
 -- Function: triangularize (<M>)
 
2246
     Returns the upper triangular form of the matrix `M', as produced
 
2247
     by Gaussian elimination.  The return value is the same as
 
2248
     `echelon', except that the leading nonzero coefficient in each row
 
2249
     is not normalized to 1.
 
2250
 
 
2251
     `lu_factor' and `cholesky' are other functions which yield
 
2252
     triangularized matrices.
 
2253
 
 
2254
          (%i1) M: matrix ([3, 7, aa, bb], [-1, 8, 5, 2], [9, 2, 11, 4]);
 
2255
                                 [  3   7  aa  bb ]
 
2256
                                 [                ]
 
2257
          (%o1)                  [ - 1  8  5   2  ]
 
2258
                                 [                ]
 
2259
                                 [  9   2  11  4  ]
 
2260
          (%i2) triangularize (M);
 
2261
                       [ - 1   8         5            2      ]
 
2262
                       [                                     ]
 
2263
          (%o2)        [  0   - 74     - 56         - 22     ]
 
2264
                       [                                     ]
 
2265
                       [  0    0    626 - 74 aa  238 - 74 bb ]
 
2266
 
 
2267
 
 
2268
 -- Function: uniteigenvectors (<M>)
 
2269
 -- Function: ueivects (<M>)
 
2270
     Computes unit eigenvectors of the matrix <M>.  The return value is
 
2271
     a list of lists, the first sublist of which is the output of the
 
2272
     `eigenvalues' command, and the other sublists of which are the
 
2273
     unit eigenvectors of the matrix corresponding to those eigenvalues
 
2274
     respectively.
 
2275
 
 
2276
     The flags mentioned in the description of the `eigenvectors'
 
2277
     command have the same effects in this one as well.
 
2278
 
 
2279
     When `knowneigvects' is `true', the `eigen' package assumes that
 
2280
     the eigenvectors of the matrix are known to the user and are
 
2281
     stored under the global name `listeigvects'.  `listeigvects'
 
2282
     should be set to a list similar to the output of the
 
2283
     `eigenvectors' command.
 
2284
 
 
2285
     If `knowneigvects' is set to `true' and the list of eigenvectors
 
2286
     is given the setting of the flag `nondiagonalizable' may not be
 
2287
     correct.  If that is the case please set it to the correct value.
 
2288
     The author assumes that the user knows what he is doing and will
 
2289
     not try to diagonalize a matrix the eigenvectors of which do not
 
2290
     span the vector space of the appropriate dimension.
 
2291
 
 
2292
     `load ("eigen")' loads this function.
 
2293
 
 
2294
     `ueivects' is a synonym for `uniteigenvectors'.
 
2295
 
 
2296
 
 
2297
 -- Function: unitvector (<x>)
 
2298
 -- Function: uvect (<x>)
 
2299
     Returns <x>/norm(<x>); this is a unit vector in the same direction
 
2300
     as <x>.
 
2301
 
 
2302
     `load ("eigen")' loads this function.
 
2303
 
 
2304
     `uvect' is a synonym for `unitvector'.
 
2305
 
 
2306
 
 
2307
 -- Function: vectorsimp (<expr>)
 
2308
     Applies simplifications and expansions according to the following
 
2309
     global flags:
 
2310
 
 
2311
     `expandall', `expanddot', `expanddotplus', `expandcross',
 
2312
     `expandcrossplus', `expandcrosscross', `expandgrad',
 
2313
     `expandgradplus', `expandgradprod', `expanddiv', `expanddivplus',
 
2314
     `expanddivprod', `expandcurl', `expandcurlplus', `expandcurlcurl',
 
2315
     `expandlaplacian', `expandlaplacianplus', and
 
2316
     `expandlaplacianprod'.
 
2317
 
 
2318
     All these flags have default value `false'. The `plus' suffix
 
2319
     refers to employing additivity or distributivity.  The `prod'
 
2320
     suffix refers to the expansion for an operand that is any kind of
 
2321
     product.
 
2322
 
 
2323
    `expandcrosscross'
 
2324
          Simplifies p ~ (q ~ r) to (p . r)*q - (p . q)*r.
 
2325
 
 
2326
    `expandcurlcurl'
 
2327
          Simplifies curl curl p to grad div p + div grad p.
 
2328
 
 
2329
    `expandlaplaciantodivgrad'
 
2330
          Simplifies laplacian p to div grad p.
 
2331
 
 
2332
    `expandcross'
 
2333
          Enables `expandcrossplus' and `expandcrosscross'.
 
2334
 
 
2335
    `expandplus'
 
2336
          Enables `expanddotplus', `expandcrossplus', `expandgradplus',
 
2337
          `expanddivplus', `expandcurlplus', and `expandlaplacianplus'.
 
2338
 
 
2339
    `expandprod'
 
2340
          Enables `expandgradprod', `expanddivprod', and
 
2341
          `expandlaplacianprod'.
 
2342
 
 
2343
     These flags have all been declared `evflag'.
 
2344
 
 
2345
 
 
2346
 -- Option variable: vect_cross
 
2347
     Default value: `false'
 
2348
 
 
2349
     When `vect_cross' is `true', it allows DIFF(X~Y,T) to work where ~
 
2350
     is defined in SHARE;VECT (where VECT_CROSS is set to `true',
 
2351
     anyway.)
 
2352
 
 
2353
 
 
2354
 -- Function: zeromatrix (<m>, <n>)
 
2355
     Returns an <m> by <n> matrix, all elements of which are zero.
 
2356
 
 
2357
 
 
2358
 -- Special symbol: [
 
2359
 -- Special symbol: ]
 
2360
     `[' and `]' mark the beginning and end, respectively, of a list.
 
2361
 
 
2362
     `[' and `]' also enclose the subscripts of a list, array, hash
 
2363
     array, or array function.
 
2364
 
 
2365
     Examples:
 
2366
 
 
2367
          (%i1) x: [a, b, c];
 
2368
          (%o1)                       [a, b, c]
 
2369
          (%i2) x[3];
 
2370
          (%o2)                           c
 
2371
          (%i3) array (y, fixnum, 3);
 
2372
          (%o3)                           y
 
2373
          (%i4) y[2]: %pi;
 
2374
          (%o4)                          %pi
 
2375
          (%i5) y[2];
 
2376
          (%o5)                          %pi
 
2377
          (%i6) z['foo]: 'bar;
 
2378
          (%o6)                          bar
 
2379
          (%i7) z['foo];
 
2380
          (%o7)                          bar
 
2381
          (%i8) g[k] := 1/(k^2+1);
 
2382
                                            1
 
2383
          (%o8)                     g  := ------
 
2384
                                     k     2
 
2385
                                          k  + 1
 
2386
          (%i9) g[10];
 
2387
                                          1
 
2388
          (%o9)                          ---
 
2389
                                         101
 
2390
 
 
2391
 
 
2392
 
 
2393
File: maxima.info,  Node: Affine,  Next: itensor,  Prev: Matrices and Linear Algebra,  Up: Top
 
2394
 
 
2395
27 Affine
 
2396
*********
 
2397
 
 
2398
* Menu:
 
2399
 
 
2400
* Definitions for Affine::
 
2401
 
 
2402
 
 
2403
File: maxima.info,  Node: Definitions for Affine,  Prev: Affine,  Up: Affine
 
2404
 
 
2405
27.1 Definitions for Affine
 
2406
===========================
 
2407
 
 
2408
 -- Function: fast_linsolve ([<expr_1>, ..., <expr_m>], [<x_1>, ...,
 
2409
          <x_n>])
 
2410
     Solves the simultaneous linear equations <expr_1>, ..., <expr_m>
 
2411
     for the variables <x_1>, ..., <x_n>.  Each <expr_i> may be an
 
2412
     equation or a general expression; if given as a general
 
2413
     expression, it is treated as an equation of the form `<expr_i> =
 
2414
     0'.
 
2415
 
 
2416
     The return value is a list of equations of the form `[<x_1> =
 
2417
     <a_1>, ..., <x_n> = <a_n>]' where <a_1>, ..., <a_n> are all free
 
2418
     of <x_1>, ..., <x_n>.
 
2419
 
 
2420
     `fast_linsolve' is faster than `linsolve' for system of equations
 
2421
     which are sparse.
 
2422
 
 
2423
 
 
2424
 -- Function: grobner_basis ([<expr_1>, ..., <expr_m>])
 
2425
     Returns a Groebner basis for the equations <expr_1>, ..., <expr_m>.
 
2426
     The function `polysimp' can then be used to simplify other
 
2427
     functions relative to the equations.
 
2428
 
 
2429
          grobner_basis ([3*x^2+1, y*x])$
 
2430
 
 
2431
          polysimp (y^2*x + x^3*9 + 2) ==> -3*x + 2
 
2432
 
 
2433
     `polysimp(f)' yields 0 if and only if <f> is in the ideal
 
2434
     generated by <expr_1>, ..., <expr_m>, that is, if and only if <f>
 
2435
     is a polynomial combination of the elements of <expr_1>, ...,
 
2436
     <expr_m>.
 
2437
 
 
2438
 
 
2439
 -- Function: set_up_dot_simplifications (<eqns>,
 
2440
          <check_through_degree>)
 
2441
 -- Function: set_up_dot_simplifications (<eqns>)
 
2442
     The <eqns> are polynomial equations in non commutative variables.
 
2443
     The value of `current_variables' is the list of variables used for
 
2444
     computing degrees.  The equations must be homogeneous, in order
 
2445
     for the procedure to terminate.
 
2446
 
 
2447
     If you have checked overlapping simplifications in
 
2448
     `dot_simplifications' above the degree of <f>, then the following
 
2449
     is true: `dotsimp (<f>)' yields 0 if and only if <f> is in the
 
2450
     ideal generated by the equations, i.e., if and only if <f> is a
 
2451
     polynomial combination of the elements of the equations.
 
2452
 
 
2453
     The degree is that returned by `nc_degree'.   This in turn is
 
2454
     influenced by the weights of individual variables.
 
2455
 
 
2456
 
 
2457
 -- Function: declare_weight (<x_1>, <w_1>, ..., <x_n>, <w_n>)
 
2458
     Assigns weights <w_1>, ..., <w_n> to <x_1>, ..., <x_n>,
 
2459
     respectively.  These are the weights used in computing `nc_degree'.
 
2460
 
 
2461
 
 
2462
 -- Function: nc_degree (<p>)
 
2463
     Returns the degree of a noncommutative polynomial <p>.  See
 
2464
     `declare_weights'.
 
2465
 
 
2466
 
 
2467
 -- Function: dotsimp (<f>)
 
2468
     Returns 0 if and only if <f> is in the ideal generated by the
 
2469
     equations, i.e., if and only if <f> is a polynomial combination of
 
2470
     the elements of the equations.
 
2471
 
 
2472
 
 
2473
 -- Function: fast_central_elements ([<x_1>, ..., <x_n>], <n>)
 
2474
     If `set_up_dot_simplifications' has been previously done, finds
 
2475
     the central polynomials in the variables <x_1>, ..., <x_n> in the
 
2476
     given degree, <n>.
 
2477
 
 
2478
     For example:
 
2479
          set_up_dot_simplifications ([y.x + x.y], 3);
 
2480
          fast_central_elements ([x, y], 2);
 
2481
          [y.y, x.x];
 
2482
 
 
2483
 
 
2484
 -- Function: check_overlaps (<n>, <add_to_simps>)
 
2485
     Checks the overlaps thru degree <n>, making sure that you have
 
2486
     sufficient simplification rules in each degree, for `dotsimp' to
 
2487
     work correctly.  This process can be speeded up if you know before
 
2488
     hand what the dimension of the space of monomials is.  If it is of
 
2489
     finite global dimension, then `hilbert' should be used.  If you
 
2490
     don't know the monomial dimensions, do not specify a
 
2491
     `rank_function'.  An optional third argument `reset', `false' says
 
2492
     don't bother to query about resetting things.
 
2493
 
 
2494
 
 
2495
 -- Function: mono ([<x_1>, ..., <x_n>], <n>)
 
2496
     Returns the list of independent monomials relative to the current
 
2497
     dot simplifications of degree <n> in the variables <x_1>, ...,
 
2498
     <x_n>.
 
2499
 
 
2500
 
 
2501
 -- Function: monomial_dimensions (<n>)
 
2502
     Compute the Hilbert series through degree <n> for the current
 
2503
     algebra.
 
2504
 
 
2505
 
 
2506
 -- Function: extract_linear_equations ([<p_1>, ..., <p_n>], [<m_1>,
 
2507
          ..., <m_n>])
 
2508
     Makes a list of the coefficients of the noncommutative polynomials
 
2509
     <p_1>, ..., <p_n> of the noncommutative monomials <m_1>, ...,
 
2510
     <m_n>.  The coefficients should be scalars.   Use
 
2511
     `list_nc_monomials' to build the list of monomials.
 
2512
 
 
2513
 
 
2514
 -- Function: list_nc_monomials ([<p_1>, ..., <p_n>])
 
2515
 -- Function: list_nc_monomials (<p>)
 
2516
     Returns a list of the non commutative monomials occurring in a
 
2517
     polynomial <p> or a list of polynomials <p_1>, ..., <p_n>.
 
2518
 
 
2519
 
 
2520
 -- Option variable: all_dotsimp_denoms
 
2521
     Default value: `false'
 
2522
 
 
2523
     When `all_dotsimp_denoms' is a list, the denominators encountered
 
2524
     by `dotsimp' are appended to the list.  `all_dotsimp_denoms' may
 
2525
     be initialized to an empty list `[]' before calling `dotsimp'.
 
2526
 
 
2527
     By default, denominators are not collected by `dotsimp'.
 
2528
 
 
2529
 
 
2530
 
 
2531
File: maxima.info,  Node: itensor,  Next: ctensor,  Prev: Affine,  Up: Top
 
2532
 
 
2533
28 itensor
 
2534
**********
 
2535
 
 
2536
* Menu:
 
2537
 
 
2538
* Introduction to itensor::
 
2539
* Definitions for itensor::
 
2540
 
 
2541
 
 
2542
File: maxima.info,  Node: Introduction to itensor,  Next: Definitions for itensor,  Prev: itensor,  Up: itensor
 
2543
 
 
2544
28.1 Introduction to itensor
 
2545
============================
 
2546
 
 
2547
Maxima implements symbolic tensor manipulation of two distinct types:
 
2548
component tensor manipulation (`ctensor' package) and indicial tensor
 
2549
manipulation (`itensor' package).
 
2550
 
 
2551
   Nota bene: Please see the note on 'new tensor notation' below.
 
2552
 
 
2553
   Component tensor manipulation means that geometrical tensor objects
 
2554
are represented as arrays or matrices. Tensor operations such as
 
2555
contraction or covariant differentiation are carried out by actually
 
2556
summing over repeated (dummy) indices with `do' statements.  That is,
 
2557
one explicitly performs operations on the appropriate tensor components
 
2558
stored in an array or matrix.
 
2559
 
 
2560
   Indicial tensor manipulation is implemented by representing tensors
 
2561
as functions of their covariant, contravariant and derivative indices.
 
2562
Tensor operations such as contraction or covariant differentiation are
 
2563
performed by manipulating the indices themselves rather than the
 
2564
components to which they correspond.
 
2565
 
 
2566
   These two approaches to the treatment of differential, algebraic and
 
2567
analytic processes in the context of Riemannian geometry have various
 
2568
advantages and disadvantages which reveal themselves only through the
 
2569
particular nature and difficulty of the user's problem.  However, one
 
2570
should keep in mind the following characteristics of the two
 
2571
implementations:
 
2572
 
 
2573
   The representation of tensors and tensor operations explicitly in
 
2574
terms of their components makes `ctensor' easy to use. Specification of
 
2575
the metric and the computation of the induced tensors and invariants is
 
2576
straightforward. Although all of Maxima's powerful simplification
 
2577
capacity is at hand, a complex metric with intricate functional and
 
2578
coordinate dependencies can easily lead to expressions whose size is
 
2579
excessive and whose structure is hidden. In addition, many calculations
 
2580
involve intermediate expressions which swell causing programs to
 
2581
terminate before completion. Through experience, a user can avoid many
 
2582
of these difficulties.
 
2583
 
 
2584
   Because of the special way in which tensors and tensor operations
 
2585
are represented in terms of symbolic operations on their indices,
 
2586
expressions which in the component representation would be unmanageable
 
2587
can sometimes be greatly simplified by using the special routines for
 
2588
symmetrical objects in `itensor'. In this way the structure of a large
 
2589
expression may be more transparent. On the other hand, because of the
 
2590
the special indicial representation in `itensor', in some cases the
 
2591
user may find difficulty with the specification of the metric, function
 
2592
definition, and the evaluation of differentiated "indexed" objects.
 
2593
 
 
2594
28.1.1 New tensor notation
 
2595
--------------------------
 
2596
 
 
2597
Until now, the `itensor' package in Maxima has used a notation that
 
2598
sometimes led to incorrect index ordering. Consider the following, for
 
2599
instance:
 
2600
 
 
2601
     (%i2) imetric(g);
 
2602
     (%o2)                                done
 
2603
     (%i3) ishow(g([],[j,k])*g([],[i,l])*a([i,j],[]))$
 
2604
                                      i l  j k
 
2605
     (%t3)                           g    g    a
 
2606
                                                i j
 
2607
     (%i4) ishow(contract(%))$
 
2608
                                           k l
 
2609
     (%t4)                                a
 
2610
 
 
2611
   This result is incorrect unless `a' happens to be a symmetric tensor.
 
2612
The reason why this happens is that although `itensor' correctly
 
2613
maintains the order within the set of covariant and contravariant
 
2614
indices, once an index is raised or lowered, its position relative to
 
2615
the other set of indices is lost.
 
2616
 
 
2617
   To avoid this problem, a new notation has been developed that
 
2618
remains fully compatible with the existing notation and can be used
 
2619
interchangeably. In this notation, contravariant indices are inserted
 
2620
in the appropriate positions in the covariant index list, but with a
 
2621
minus sign prepended.  Functions like `contract' and `ishow' are now
 
2622
aware of this new index notation and can process tensors appropriately.
 
2623
 
 
2624
   In this new notation, the previous example yields a correct result:
 
2625
 
 
2626
     (%i5) ishow(g([-j,-k],[])*g([-i,-l],[])*a([i,j],[]))$
 
2627
                                      i l       j k
 
2628
     (%t5)                           g    a    g
 
2629
                                           i j
 
2630
     (%i6) ishow(contract(%))$
 
2631
                                           l k
 
2632
     (%t6)                                a
 
2633
 
 
2634
   Presently, the only code that makes use of this notation is the
 
2635
`lc2kdt' function. Through this notation, it achieves consistent
 
2636
results as it applies the metric tensor to resolve Levi-Civita symbols
 
2637
without resorting to numeric indices.
 
2638
 
 
2639
   Since this code is brand new, it probably contains bugs. While it
 
2640
has been tested to make sure that it doesn't break anything using the
 
2641
"old" tensor notation, there is a considerable chance that "new"
 
2642
tensors will fail to interoperate with certain functions or features.
 
2643
These bugs will be fixed as they are encountered... until then, caveat
 
2644
emptor!
 
2645
 
 
2646
28.1.2 Indicial tensor manipulation
 
2647
-----------------------------------
 
2648
 
 
2649
The indicial tensor manipulation package may be loaded by
 
2650
`load(itensor)'. Demos are also available: try `demo(tensor)'.
 
2651
 
 
2652
   In `itensor' a tensor is represented as an "indexed object" .  This
 
2653
is a function of 3 groups of indices which represent the covariant,
 
2654
contravariant and derivative indices.  The covariant indices are
 
2655
specified by a list as the first argument to the indexed object, and
 
2656
the contravariant indices by a list as the second argument. If the
 
2657
indexed object lacks either of these groups of indices then the empty
 
2658
list `[]' is given as the corresponding argument.  Thus, `g([a,b],[c])'
 
2659
represents an indexed object called `g' which has two covariant indices
 
2660
`(a,b)', one contravariant index (`c') and no derivative indices.
 
2661
 
 
2662
   The derivative indices, if they are present, are appended as
 
2663
additional arguments to the symbolic function representing the tensor.
 
2664
They can be explicitly specified by the user or be created in the
 
2665
process of differentiation with respect to some coordinate variable.
 
2666
Since ordinary differentiation is commutative, the derivative indices
 
2667
are sorted alphanumerically, unless `iframe_flag' is set to `true',
 
2668
indicating that a frame metric is being used. This canonical ordering
 
2669
makes it possible for Maxima to recognize that, for example,
 
2670
`t([a],[b],i,j)' is the same as `t([a],[b],j,i)'.  Differentiation of
 
2671
an indexed object with respect to some coordinate whose index does not
 
2672
appear as an argument to the indexed object would normally yield zero.
 
2673
This is because Maxima would not know that the tensor represented by
 
2674
the indexed object might depend implicitly on the corresponding
 
2675
coordinate.  By modifying the existing Maxima function `diff' in
 
2676
`itensor', Maxima now assumes that all indexed objects depend on any
 
2677
variable of differentiation unless otherwise stated.  This makes it
 
2678
possible for the summation convention to be extended to derivative
 
2679
indices. It should be noted that `itensor' does not possess the
 
2680
capabilities of raising derivative indices, and so they are always
 
2681
treated as covariant.
 
2682
 
 
2683
   The following functions are available in the tensor package for
 
2684
manipulating indexed objects.  At present, with respect to the
 
2685
simplification routines, it is assumed that indexed objects do not by
 
2686
default possess symmetry properties. This can be overridden by setting
 
2687
the variable `allsym[false]' to `true', which will result in treating
 
2688
all indexed objects completely symmetric in their lists of covariant
 
2689
indices and symmetric in their lists of contravariant indices.
 
2690
 
 
2691
   The `itensor' package generally treats tensors as opaque objects.
 
2692
Tensorial equations are manipulated based on algebraic rules,
 
2693
specifically symmetry and contraction rules. In addition, the `itensor'
 
2694
package understands covariant differentiation, curvature, and torsion.
 
2695
Calculations can be performed relative to a metric of moving frame,
 
2696
depending on the setting of the `iframe_flag' variable.
 
2697
 
 
2698
   A sample session below demonstrates how to load the `itensor'
 
2699
package, specify the name of the metric, and perform some simple
 
2700
calculations.
 
2701
 
 
2702
     (%i1) load(itensor);
 
2703
     (%o1)      /share/tensor/itensor.lisp
 
2704
     (%i2) imetric(g);
 
2705
     (%o2)                                done
 
2706
     (%i3) components(g([i,j],[]),p([i,j],[])*e([],[]))$
 
2707
     (%i4) ishow(g([k,l],[]))$
 
2708
     (%t4)                               e p
 
2709
                                            k l
 
2710
     (%i5) ishow(diff(v([i],[]),t))$
 
2711
     (%t5)                                  0
 
2712
     (%i6) depends(v,t);
 
2713
     (%o6)                               [v(t)]
 
2714
     (%i7) ishow(diff(v([i],[]),t))$
 
2715
                                         d
 
2716
     (%t7)                               -- (v )
 
2717
                                         dt   i
 
2718
     (%i8) ishow(idiff(v([i],[]),j))$
 
2719
     (%t8)                                v
 
2720
                                           i,j
 
2721
     (%i9) ishow(extdiff(v([i],[]),j))$
 
2722
     (%t9)                             v    - v
 
2723
                                        j,i    i,j
 
2724
                                       -----------
494
2725
                                            2
495
 
          (%o4)                         %t4 + %t3 + %t2
496
 
 
497
 
 - Variable: PIECE
498
 
     - holds the last expression selected when using the Part
499
 
     functions.  It is set during the execution of the function and thus
500
 
     may be referred to in the function itself.
501
 
 
502
 
 
503
 
 - Function: POWERS (expr, var)
504
 
     gives the powers of var occuring in expr.  To use it, do
505
 
     LOAD(POWERS);.  For details on usage, do PRINTFILE("powers.usg");.
506
 
 
507
 
 
508
 
 - Function: PRODUCT (exp, ind, lo, hi)
509
 
     gives the product of the values of exp as the index ind varies
510
 
     from lo to hi.  The evaluation is similar to that of SUM.  No
511
 
     simplification of products is available at this time.  If hi is
512
 
     one less than lo, we have an "empty product" and PRODUCT returns 1
513
 
     rather than erring out.  Also see DESCRIBE(PRODHACK).
514
 
          (%i1)  PRODUCT(X+I*(I+1)/2,I,1,4);
515
 
          (%o1)             (X + 1) (X + 3) (X + 6) (X + 10)
516
 
 
517
 
 - Function: REALPART (exp)
518
 
     gives the real part of exp. REALPART and IMAGPART will work on
519
 
     expressions involving trigonometic and hyperbolic functions, as
520
 
     well as SQRT, LOG, and exponentiation.
521
 
 
522
 
 
523
 
 - Function: RECTFORM (exp)
524
 
     returns an expression of the form A + B*%I, where A and B are
525
 
     purely real.
526
 
 
527
 
 
528
 
 - Function: REMBOX (expr, arg)
529
 
     removes boxes from expr according to arg.  If arg is UNLABELED
530
 
     then all unlabelled boxes are removed.  If arg is the name of some
531
 
     label then only boxes with that label are removed.  If arg is
532
 
     omitted then all boxes labelled and unlabelled are removed.
533
 
 
534
 
 
535
 
 - Function: SUM (exp, ind, lo, hi)
536
 
     performs a summation of the values of exp as the index ind varies
537
 
     from lo to hi.  If the upper and lower limits differ by an integer
538
 
     then each term in the sum is evaluated and added together.
539
 
     Otherwise, if the SIMPSUM [FALSE] is TRUE the result is
540
 
     simplified.  This simplification may sometimes be able to produce a
541
 
     closed form.  If SIMPSUM is FALSE or if 'SUM is used, the value is
542
 
     a sum noun form which is a representation of the sigma notation
543
 
     used in mathematics.  If hi is one less than lo, we have an "empty
544
 
     sum" and SUM returns 0 rather than erring out.  Sums may be
545
 
     differentiated, added, subtracted, or multiplied with some
546
 
     automatic simplification being performed.  Also see
547
 
     DESCRIBE(SUMHACK).  CAUCHYSUM[FALSE] when TRUE causes the Cauchy
548
 
     product to be used when multiplying sums together rather than the
549
 
     usual product.  In the Cauchy product the index of the inner
550
 
     summation is a function of the index of the outer one rather than
551
 
     varying independently.  GENINDEX[I] is the alphabetic prefix used
552
 
     to generate the next variable of summation.  GENSUMNUM[0] is the
553
 
     numeric suffix used to generate the next variable of summation.
554
 
     If it is set to FALSE then the index will consist only of GENINDEX
555
 
     with no numeric suffix.  Do EXAMPLE(SUM); for examples.  See also
556
 
     SUMCONTRACT, INTOSUM, BASHINDICES, and NICEINDICES.
557
 
 
558
 
 
559
 
 - Function: LSUM (exp, ind, list)
560
 
     performs the sum of EXP for each element IND of the LIST.
561
 
          (%i10) lsum(x^i,i,[1,2,7]);
562
 
          
563
 
                                      7    2
564
 
          (%o10)                      x  + x  + x
565
 
     If the last element LIST argument does not evaluate, or does not
566
 
     evaluate to a Maxima list then the answer is left in noun form
567
 
          (%i13) lsum(i^2,i,rootsof(x^3-1));
568
 
          
569
 
                               ====
570
 
                               \      2
571
 
          (%o13)                 >    i
572
 
                               /
573
 
                               ====
574
 
                                             3
575
 
                               i in ROOTSOF(x  - 1)
576
 
 
577
 
 
578
 
 - special symbol: VERB
579
 
     - the opposite of "noun", i.e. a function form which "does
580
 
     something" ("action" - for most functions the usual case).  E.g.
581
 
     INTEGRATE integrates a function, unless it is DECLAREd to be a
582
 
     "noun", in which case it represents the INTEGRAL of the function.
583
 
     See NOUN, NOUNIFY, and VERBIFY.
584
 
 
585
 
 
586
 
 - Function: VERBIFY (f)
587
 
     returns the function name f in its verb form (See also VERB, NOUN,
588
 
     and NOUNIFY).
589
 
 
590
 
 
591
 
 
592
 
File: maxima.info,  Node: Simplification,  Next: Plotting,  Prev: Expressions,  Up: Top
593
 
 
594
 
Simplification
595
 
**************
596
 
 
597
 
* Menu:
598
 
 
599
 
* Definitions for Simplification::
600
 
 
601
 
 
602
 
File: maxima.info,  Node: Definitions for Simplification,  Prev: Simplification,  Up: Simplification
603
 
 
604
 
Definitions for Simplification
605
 
==============================
606
 
 
607
 
* Menu:
608
 
 
609
 
 - Function: APPLY_NOUNS (exp)
610
 
     causes the application of noun forms in an expression.  E.g.
611
 
     EXP:'DIFF(X^2/2,X); APPLY_NOUNS(EXP); gives X.  This gives the
612
 
     same result as EV(EXP,NOUNS); except that it can be faster and use
613
 
     less storage.  It also can be used in translated code, where EV
614
 
     may cause problems.  Note that it is called APPLY_NOUNS, not
615
 
     EV_NOUNS, because what it does is to APPLY the rules corresponding
616
 
     to the noun-form operators, which is not evaluation.
617
 
 
618
 
 
619
 
 - Variable: ASKEXP
620
 
     default: [] contains the expression upon which ASKSIGN is called.
621
 
     A user may enter a MACSYMA break with ^A and inspect this
622
 
     expression in order to answer questions asked by ASKSIGN.
623
 
 
624
 
 - Function: ASKINTEGER (exp,<optional-arg>)
625
 
     exp is any valid macsyma expression and optional-arg is
626
 
     EVEN,ODD,INTEGER and defaults to INTEGER if not given.  This
627
 
     function attempts to determine from the data-base whether exp is
628
 
     EVEN, ODD or just an INTEGER.  It will ask the user if it cannot
629
 
     tell otherwise and attempt to install the information in the
630
 
     data-base if possible.
631
 
 
632
 
 
633
 
 - Function: ASKSIGN (exp)
634
 
     first attempts to determine whether the specified expression is
635
 
     positive, negative, or zero.  If it cannot, it asks the user the
636
 
     necessary questions to complete its deduction.  The user's answer
637
 
     is recorded in the data base for the duration of the current
638
 
     computation (one "C-line"). The value of ASKSIGN is one of POS,
639
 
     NEG, or ZERO.
640
 
 
641
 
 
642
 
 - Variable: DEMOIVRE
643
 
     default: [FALSE] if TRUE will cause
644
 
          %E^(A+B*%I) ==> %E^A*(COS(B)+%I*SIN(B))
645
 
     if B is free of %I.  A and B are not expanded.  DEMOIVRE:TRUE; is
646
 
     the way to reverse the effect of EXPONENTIALIZE:TRUE;
647
 
 
648
 
     DEMOIVRE(exp) will cause the conversion without setting the switch
649
 
     or having to re-evaluate the expression with EV.
650
 
 
651
 
 
652
 
 - Variable: DOMAIN
653
 
     default: [REAL] - if set to COMPLEX, SQRT(X^2) will remain
654
 
     SQRT(X^2) instead of returning ABS(X).  The notion of a "domain" of
655
 
     simplification is still in its infancy, and controls little more
656
 
     than this at the moment.
657
 
 
658
 
 
659
 
 - Function: EXPAND (exp)
660
 
     will cause products of sums and exponentiated sums to be
661
 
     multiplied out, numerators of rational expressions which are sums
662
 
     to be split into their respective terms, and multiplication
663
 
     (commutative and non-commutative) to be distributed over addition
664
 
     at all levels of exp.  For polynomials one should usually use
665
 
     RATEXPAND which uses a more efficient algorithm (see
666
 
     DESCRIBE(RATEXPAND);).  MAXNEGEX[1000] and MAXPOSEX[1000] control
667
 
     the maximum negative and positive exponents, respectively, which
668
 
     will expand.  EXPAND(exp,p,n) expands exp, using p for MAXPOSEX
669
 
     and n for MAXNEGEX.  This is useful in order to expand part but
670
 
     not all of an expression.  EXPON[0] - the exponent of the largest
671
 
     negative power which is automatically expanded (independent of
672
 
     calls to EXPAND).  For example if EXPON is 4 then (X+1)^(-5) will
673
 
     not be automatically expanded.  EXPOP[0] - the highest positive
674
 
     exponent which is automatically expanded.  Thus (X+1)^3, when
675
 
     typed, will be automatically expanded only if EXPOP is greater
676
 
     than or equal to 3.  If it is desired to have (X+1)^N expanded
677
 
     where N is greater than EXPOP then executing EXPAND((X+1)^N) will
678
 
     work only if MAXPOSEX is not less than N.  The EXPAND flag used
679
 
     with EV (see EV) causes expansion.
680
 
 
681
 
     The file `simplification/facexp.mac' contains several related
682
 
     functions (in particular FACSUM, FACTORFACSUM and COLLECTTERMS,
683
 
     which are autoloaded) and variables (NEXTLAYERFACTOR and
684
 
     FACSUM_COMBINE) that provide the user with the ability to structure
685
 
     expressions by controlled expansion.  Brief function descriptions
686
 
     are available in `simplification/facexp.usg'.  A demo is available
687
 
     by doing `demo("facexp")$'.
688
 
 
689
 
 
690
 
 - Function: EXPANDWRT (exp,var1,var2,...)
691
 
     expands exp with respect to the vari.  All products involving the
692
 
     vari appear explicitly.  The form returned will be free of
693
 
     products of sums of expressions that are not free of the vari.
694
 
     The vari may be variables, operators, or expressions.  By default,
695
 
     denominators are not expanded, but this can be controlled by means
696
 
     of the switch EXPANDWRT_DENOM.  This function is autoloaded from
697
 
     `simplification/stopex.mac'.
698
 
 
699
 
 
700
 
 - Variable: EXPANDWRT_DENOM
701
 
     default:[FALSE] controls the treatment of rational expressions by
702
 
     EXPANDWRT.  If TRUE, then both the numerator and denominator of
703
 
     the expression will be expanded according to the arguments of
704
 
     EXPANDWRT, but if EXPANDWRT_DENOM is FALSE, then only the
705
 
     numerator will be expanded in that way.
706
 
 
707
 
 
708
 
 - Function: EXPANDWRT_FACTORED (exp, var1, var2, ..., varN)
709
 
     is similar to EXPANDWRT, but treats expressions that are products
710
 
     somewhat differently.  EXPANDWRT_FACTORED will perform the
711
 
     required expansion only on those factors of exp that contain the
712
 
     variables in its argument list argument list.  This function is
713
 
     autoloaded from `simplification/stopex.mac'.
714
 
 
715
 
 
716
 
 - Variable: EXPON
717
 
     default: [0] - the exponent of the largest negative power which is
718
 
     automatically expanded (independent of calls to EXPAND).  For
719
 
     example if EXPON is 4 then (X+1)^(-5) will not be automatically
720
 
     expanded.
721
 
 
722
 
 
723
 
 - Variable: EXPONENTIALIZE
724
 
     default: [FALSE] if TRUE will cause all circular and hyperbolic
725
 
     functions to be converted to exponential form.  (Setting
726
 
     DEMOIVRE:TRUE; will reverse the effect.)  EXPONENTIALIZE(exp) will
727
 
     cause the conversion to exponential form of an expression without
728
 
     setting the switch or having to re-evaluate the expression with EV.
729
 
 
730
 
 
731
 
 - Variable: EXPOP
732
 
     default: [0] - the highest positive exponent which is
733
 
     automatically expanded.  Thus (X+1)^3, when typed, will be
734
 
     automatically expanded only if EXPOP is greater than or equal to 3.
735
 
     If it is desired to have (X+1)^n expanded where n is greater than
736
 
     EXPOP then executing EXPAND((X+1)^n) will work only if MAXPOSEX is
737
 
     not less than n.
738
 
 
739
 
 
740
 
 - Variable: FACTLIM
741
 
     default: [-1] gives the highest factorial which is automatically
742
 
     expanded.  If it is -1 then all integers are expanded.
743
 
 
744
 
 
745
 
 - Function: INTOSUM (expr)
746
 
     will take all things that a summation is multiplied by, and put
747
 
     them inside the summation. If the index is used in the outside
748
 
     expression, then the function tries to find a reasonable index,
749
 
     the same as it does for SUMCONTRACT.  This is essentially the
750
 
     reverse idea of the OUTATIVE property of summations, but note that
751
 
     it does not remove this property, it only bypasses it.  In some
752
 
     cases, a SCANMAP(MULTTHRU,expr) may be necessary before the
753
 
     INTOSUM.
754
 
 
755
 
 
756
 
 - declaration: LASSOCIATIVE
757
 
     - If DECLARE(G,LASSOCIATIVE); is done, this tells the simplifier
758
 
     that G is left-associative.  E.g.  G(G(A,B),G(C,D)) will simplify
759
 
     to G(G(G(A,B),C),D).
760
 
 
761
 
 
762
 
 - declaration: LINEAR
763
 
     - One of MACSYMA's OPPROPERTIES.  For univariate f so declared,
764
 
     "expansion" F(X+Y) -> F(X)+F(Y), F(A*X) -> A*F(X) takes place
765
 
     where A is a "constant".  For functions F of >=2 args, "linearity"
766
 
     is defined to be as in the case of 'SUM or 'INTEGRATE, i.e.
767
 
     F(A*X+B,X) -> A*F(X,X)+B*F(1,X) for A,B FREEOF X.  (LINEAR is just
768
 
     ADDITIVE + OUTATIVE.)
769
 
 
770
 
 
771
 
 - declaration: MAINVAR
772
 
     - You may DECLARE variables to be MAINVAR.  The ordering scale for
773
 
     atoms is essentially: numbers < constants (e.g. %E,%PI) < scalars
774
 
     < other variables < mainvars.  E.g. compare EXPAND((X+Y)^4); with
775
 
     (DECLARE(X,MAINVAR), EXPAND((X+Y)^4)); .  (Note: Care should be
776
 
     taken if you elect to use the above feature.  E.g. if you subtract
777
 
     an expression in which X is a MAINVAR from one in which X isn't a
778
 
     MAINVAR, resimplification e.g. with EV(expression,SIMP) may be
779
 
     necessary if cancellation is to occur.  Also, if you SAVE an
780
 
     expression in which X is a MAINVAR, you probably should also SAVE
781
 
     X.)
782
 
 
783
 
 
784
 
 - Variable: MAXAPPLYDEPTH
785
 
     default: [10000] - the maximum depth to which APPLY1 and APPLY2
786
 
     will delve.
787
 
 
788
 
 
789
 
 - Variable: MAXAPPLYHEIGHT
790
 
     default: [10000] - the maximum height to which APPLYB1 will reach
791
 
     before giving up.
792
 
 
793
 
 
794
 
 - Variable: MAXNEGEX
795
 
     default: [1000] - the largest negative exponent which will be
796
 
     expanded by the EXPAND command (see also MAXPOSEX).
797
 
 
798
 
 
799
 
 - Variable: MAXPOSEX
800
 
     default: [1000] - the largest exponent which will be expanded with
801
 
     the EXPAND command (see also MAXNEGEX).
802
 
 
803
 
 
804
 
 - declaration: MULTIPLICATIVE
805
 
     - If DECLARE(F,MULTIPLICATIVE) has been executed, then: (1) If F
806
 
     is univariate, whenever the simplifier encounters F applied to a
807
 
     product, F will be distributed over that product.  I.e. F(X*Y);
808
 
     will simplify to F(X)*F(Y).  (2) If F is a function of 2 or more
809
 
     arguments, multiplicativity is defined as multiplicativity in the
810
 
     first argument to F, i.e.  F(G(X)*H(X),X); will simplify to
811
 
     F(G(X),X)*F(H(X),X).  This simplification does not occur when F is
812
 
     applied to expressions of the form
813
 
     PRODUCT(X[I],I,lower-limit,upper-limit).
814
 
 
815
 
 
816
 
 - Variable: NEGDISTRIB
817
 
     default: [TRUE] - when TRUE allows -1 to be distributed over an
818
 
     expression.  E.g. -(X+Y) becomes -Y-X.  Setting it to FALSE will
819
 
     allow -(X+Y) to be displayed like that.  This is sometimes useful
820
 
     but be very careful: like the SIMP flag, this is one flag you do
821
 
     not want to set to FALSE as a matter of course or necessarily for
822
 
     other than local use in your MACSYMA.
823
 
 
824
 
 
825
 
 - Variable: NEGSUMDISPFLAG
826
 
     default: [TRUE] - when TRUE, X-Y displays as X-Y instead of as
827
 
     -Y+X.  Setting it to FALSE causes the special check in display for
828
 
     the difference of two expressions to not be done.  One application
829
 
     is that thus A+%I*B and A-%I*B may both be displayed the same way.
830
 
 
831
 
 
832
 
 - special symbol: NOEVAL
833
 
     - suppresses the evaluation phase of EV.  This is useful in
834
 
     conjunction with other switches and in causing expressions to be
835
 
     resimplified without being reevaluated.
836
 
 
837
 
 
838
 
 - declaration: NOUN
839
 
     - One of the options of the DECLARE command.  It makes a function
840
 
     so DECLAREd a "noun", meaning that it won't be evaluated
841
 
     automatically.
842
 
 
843
 
 
844
 
 - Variable: NOUNDISP
845
 
     default: [FALSE] - if TRUE will cause NOUNs to display with a
846
 
     single quote.  This switch is always TRUE when displaying function
847
 
     definitions.
848
 
 
849
 
 
850
 
 - special symbol: NOUNS
851
 
     (EVFLAG) when used as an option to the EV command, converts all
852
 
     "noun" forms occurring in the expression being EV'd to "verbs",
853
 
     i.e.  evaluates them.  See also NOUN, NOUNIFY, VERB, and VERBIFY.
854
 
 
855
 
 
856
 
 - special symbol: NUMER
857
 
     causes some mathematical functions (including exponentiation) with
858
 
     numerical arguments to be evaluated in floating point. It causes
859
 
     variables in exp which have been given numervals to be replaced by
860
 
     their values.  It also sets the FLOAT switch on.
861
 
 
862
 
 
863
 
 - Function: NUMERVAL (var1, exp1, var2, exp2, ...)
864
 
     declares vari to have a numerval of expi which is evaluated and
865
 
     substituted for the variable in any expressions in which the
866
 
     variable occurs if the NUMER flag is TRUE. (see the EV function).
867
 
 
868
 
 
869
 
 - Variable: OPPROPERTIES
870
 
     - the list of the special operator-properties handled by the
871
 
     MACSYMA simplifier: LINEAR, ADDITIVE, MULTIPLICATIVE, OUTATIVE,
872
 
     EVENFUN, ODDFUN, COMMUTATIVE, SYMMETRIC, ANTISYMMETRIC, NARY,
873
 
     LASSOCIATIVE, and RASSOCIATIVE.
874
 
 
875
 
 
876
 
 - Variable: OPSUBST
877
 
     default:[TRUE] - if FALSE, SUBST will not attempt to substitute
878
 
     into the operator of an expression.  E.g. (OPSUBST:FALSE,
879
 
     SUBST(X^2,R,R+R[0])); will work.
880
 
 
881
 
 
882
 
 - declaration: OUTATIVE
883
 
     - If DECLARE(F,OUTATIVE) has been executed, then: (1) If F is
884
 
     univariate, whenever the simplifier encounters F applied to a
885
 
     product, that product will be partitioned into factors that are
886
 
     constant and factors that are not and the constant factors will be
887
 
     pulled out.  I.e. F(A*X); will simplify to A*F(X) where A is a
888
 
     constant.  Non-atomic constant factors will not be pulled out.
889
 
     (2) If F is a function of 2 or more arguments, outativity is
890
 
     defined as in the case of 'SUM or 'INTEGRATE, i.e. F(A*G(X),X);
891
 
     will simplify to A*F(G(X),X) for A free-of X.  Initially, 'SUM,
892
 
     'INTEGRATE, and 'LIMIT are declared to be OUTATIVE.
893
 
 
894
 
 
895
 
 - declaration: POSFUN
896
 
     - POSitive FUNction, e.g. DECLARE(F,POSFUN); IS(F(X)>0); -> TRUE.
897
 
 
898
 
 
899
 
 - Variable: PRODHACK
900
 
     default: [FALSE] - if set to TRUE then PRODUCT(F(I),I,3,1); will
901
 
     yield 1/F(2), by the identity PRODUCT(F(I),I,A,B) =
902
 
     1/PRODUCT(F(I),I,B+1,A-1) when A>B.
903
 
 
904
 
 
905
 
 - Function: RADCAN (exp)
906
 
     simplifies exp, which can contain logs, exponentials, and
907
 
     radicals, by converting it into a form which is canonical over a
908
 
     large class of expressions and a given ordering of variables; that
909
 
     is, all functionally equivalent forms are mapped into a unique
910
 
     form.  For a somewhat larger class of expressions, RADCAN produces
911
 
     a regular form.  Two equivalent expressions in this class will not
912
 
     necessarily have the same appearance, but their difference will be
913
 
     simplified by RADCAN to zero.  For some expressions RADCAN can be
914
 
     quite time consuming.  This is the cost of exploring certain
915
 
     relationships among the components of the expression for
916
 
     simplifications based on factoring and partial-fraction expansions
917
 
     of exponents.  %E_TO_NUMLOG (default: [FALSE]) - when set to TRUE,
918
 
     for "r" some rational number, and "x" some expression,
919
 
     %E^(r*LOG(x)) will be simplified into x^r .  RADEXPAND[TRUE] when
920
 
     set to FALSE will inhibit certain transformations:
921
 
     RADCAN(SQRT(1-X)) will remain SQRT(1-X) and will not become %I
922
 
     SQRT(X-1).  RADCAN(SQRT(X^2-2*X+1)) will remain SQRT(X^2-2*X + 1)
923
 
     and will not be transformed to X- 1.  Do EXAMPLE(RADCAN); for
924
 
     examples.
925
 
 
926
 
 
927
 
 - Variable: RADEXPAND
928
 
     default: [TRUE] - if set to ALL will cause nth roots of factors of
929
 
     a product which are powers of n to be pulled outside of the
930
 
     radical.  E.g. if RADEXPAND is ALL, SQRT(16*X^2) will become 4*X .
931
 
     More particularly, consider SQRT(X^2).  (a) If RADEXPAND is ALL or
932
 
     ASSUME(X>0) has been done, SQRT(X^2) will become X.  (b) If
933
 
     RADEXPAND is TRUE and DOMAIN is REAL (its default), SQRT(X^2) will
934
 
     become ABS(X).  (c) If RADEXPAND is FALSE, or RADEXPAND is TRUE
935
 
     and DOMAIN is COMPLEX, SQRT(X^2) will be returned.  (The notion of
936
 
     DOMAIN with settings of REAL or COMPLEX is still in its infancy.
937
 
     Note that its setting here only matters when RADEXPAND is TRUE.)
938
 
 
939
 
 
940
 
 - Variable: RADPRODEXPAND
941
 
     - this switch has been renamed RADEXPAND.
942
 
 
943
 
 
944
 
 - Variable: RADSUBSTFLAG
945
 
     default: [FALSE] - if TRUE permits RATSUBST to make substitutions
946
 
     such as U for SQRT(X) in X.
947
 
 
948
 
 
949
 
 - declaration: RASSOCIATIVE
950
 
     - If DECLARE(G,RASSOCIATIVE); is done, this tells the simplifier
951
 
     that G is right-associative.  E.g.  G(G(A,B),G(C,D)) will simplify
952
 
     to G(A,G(B,G(C,D))).
953
 
 
954
 
 
955
 
 - Function: SCSIMP (exp,rule1, rule2,...,rulen)
956
 
     Sequential Comparative Simplification [Stoute]) takes an
957
 
     expression (its first argument) and a set of identities, or rules
958
 
     (its other arguments) and tries simplifying.  If a smaller
959
 
     expression is obtained, the process repeats.  Otherwise after all
960
 
     simplifications are tried, it returns the original answer.  For
961
 
     examples, try EXAMPLE(SCSIMP); .
962
 
 
963
 
 
964
 
 - Function: SIMP
965
 
     causes exp to be simplified regardless of the setting of the
966
 
     switch SIMP which inhibits simplification if FALSE.
967
 
 
968
 
 
969
 
 - Variable: SIMPSUM
970
 
     default: [FALSE] - if TRUE, the result of a SUM is simplified.
971
 
     This simplification may sometimes be able to produce a closed
972
 
     form.  If SIMPSUM is FALSE or if 'SUM is used, the value is a sum
973
 
     noun form which is a representation of the sigma notation used in
974
 
     mathematics.
975
 
 
976
 
 
977
 
 - Function: SUMCONTRACT (expr)
978
 
     will combine all sums of an addition that have upper and lower
979
 
     bounds that differ by constants. The result will be an expression
980
 
     containing one summation for each set of such summations added to
981
 
     all appropriate extra terms that had to be extracted to form this
982
 
     sum.  SUMCONTRACT will combine all compatible sums and use one of
983
 
     the indices from one of the sums if it can, and then try to form a
984
 
     reasonable index if it cannot use any supplied.  It may be
985
 
     necessary to do an INTOSUM(expr) before the SUMCONTRACT.
986
 
 
987
 
 
988
 
 - Variable: SUMEXPAND
989
 
     default: [FALSE] if TRUE, products of sums and exponentiated sums
990
 
     are converted into nested sums. For example:
991
 
                  SUMEXPAND:TRUE$
992
 
                  SUM(F(I),I,0,M)*SUM(G(J),J,0,N); ->
993
 
                                  'SUM('SUM(F(I1)*G(I2),I2,0,N),I1,0,M)
994
 
                  SUM(F(I),I,0,M)^2; -> 'SUM('SUM(F(I3)*F(I4),I4,0,M),I3,0,M)
995
 
 
996
 
     If FALSE, they are left alone.  See also CAUCHYSUM.
997
 
 
998
 
 
999
 
 - Variable: SUMHACK
1000
 
     default: [FALSE] - if set to TRUE then SUM(F(I),I,3,1); will yield
1001
 
     -F(2), by the identity SUM(F(I),I,A,B) = - SUM(F(I),I,B+1,A-1)
1002
 
     when A>B.
1003
 
 
1004
 
 
1005
 
 - Variable: SUMSPLITFACT
1006
 
     default: [TRUE] - if set to FALSE will cause MINFACTORIAL to be
1007
 
     applied after a FACTCOMB.
1008
 
 
1009
 
 
1010
 
 - declaration: SYMMETRIC
1011
 
     - If DECLARE(H,SYMMETRIC); is done, this tells the simplifier that
1012
 
     H is a symmetric function.  E.g. H(X,Z,Y) will simplify to H(X, Y,
1013
 
     Z).  This is the same as COMMUTATIVE.
1014
 
 
1015
 
 
1016
 
 - Function: UNKNOWN (exp)
1017
 
     returns TRUE iff exp contains an operator or function not known to
1018
 
     the built-in simplifier.
1019
 
 
1020
 
 
1021
 
 
1022
 
File: maxima.info,  Node: Plotting,  Next: Input and Output,  Prev: Simplification,  Up: Top
1023
 
 
1024
 
Plotting
1025
 
********
1026
 
 
1027
 
* Menu:
1028
 
 
1029
 
* Definitions for Plotting::
 
2726
     (%i10) ishow(liediff(v,w([i],[])))$
 
2727
                                    %3          %3
 
2728
     (%t10)                        v   w     + v   w
 
2729
                                        i,%3    ,i  %3
 
2730
     (%i11) ishow(covdiff(v([i],[]),j))$
 
2731
                                                   %4
 
2732
     (%t11)                        v    - v   ichr2
 
2733
                                    i,j    %4      i j
 
2734
     (%i12) ishow(ev(%,ichr2))$
 
2735
                    %4 %5
 
2736
     (%t12) v    - g      v   (e p       + e   p     - e p       - e    p
 
2737
             i,j           %4     j %5,i    ,i  j %5      i j,%5    ,%5  i j
 
2738
 
 
2739
                                                     + e p       + e   p    )/2
 
2740
                                                          i %5,j    ,j  i %5
 
2741
     (%i13) iframe_flag:true;
 
2742
     (%o13)                               true
 
2743
     (%i14) ishow(covdiff(v([i],[]),j))$
 
2744
                                                  %6
 
2745
     (%t14)                        v    - v   icc2
 
2746
                                    i,j    %6     i j
 
2747
     (%i15) ishow(ev(%,icc2))$
 
2748
                                                  %6
 
2749
     (%t15)                        v    - v   ifc2
 
2750
                                    i,j    %6     i j
 
2751
     (%i16) ishow(radcan(ev(%,ifc2,ifc1)))$
 
2752
                  %6 %8                    %6 %8
 
2753
     (%t16) - (ifg      v   ifb       + ifg      v   ifb       - 2 v
 
2754
                         %6    j %8 i             %6    i j %8      i,j
 
2755
 
 
2756
                                                         %6 %8
 
2757
                                                    - ifg      v   ifb      )/2
 
2758
                                                                %6    %8 i j
 
2759
     (%i17) ishow(canform(s([i,j],[])-s([j,i])))$
 
2760
     (%t17)                            s    - s
 
2761
                                        i j    j i
 
2762
     (%i18) decsym(s,2,0,[sym(all)],[]);
 
2763
     (%o18)                               done
 
2764
     (%i19) ishow(canform(s([i,j],[])-s([j,i])))$
 
2765
     (%t19)                                 0
 
2766
     (%i20) ishow(canform(a([i,j],[])+a([j,i])))$
 
2767
     (%t20)                            a    + a
 
2768
                                        j i    i j
 
2769
     (%i21) decsym(a,2,0,[anti(all)],[]);
 
2770
     (%o21)                               done
 
2771
     (%i22) ishow(canform(a([i,j],[])+a([j,i])))$
 
2772
     (%t22)                                 0
 
2773
 
 
2774
 
 
2775
File: maxima.info,  Node: Definitions for itensor,  Prev: Introduction to itensor,  Up: itensor
 
2776
 
 
2777
28.2 Definitions for itensor
 
2778
============================
 
2779
 
 
2780
28.2.1 Managing indexed objects
 
2781
-------------------------------
 
2782
 
 
2783
 -- Function: entertensor (<name>)
 
2784
     is a function which, by prompting, allows one to create an indexed
 
2785
     object called <name> with any number of tensorial and derivative
 
2786
     indices. Either a single index or a list of indices (which may be
 
2787
     null) is acceptable input (see the example under `covdiff').
 
2788
 
 
2789
 
 
2790
 -- Function: changename (<old>, <new>, <expr>)
 
2791
     will change the name of all indexed objects called <old> to <new>
 
2792
     in <expr>. <old> may be either a symbol or a list of the form
 
2793
     `[<name>, <m>, <n>]' in which case only those indexed objects
 
2794
     called <name> with <m> covariant and <n> contravariant indices
 
2795
     will be renamed to <new>.
 
2796
 
 
2797
 
 
2798
 -- Function: listoftens
 
2799
     Lists all tensors in a tensorial expression, complete with their
 
2800
     indices. E.g.,
 
2801
 
 
2802
 
 
2803
          (%i6) ishow(a([i,j],[k])*b([u],[],v)+c([x,y],[])*d([],[])*e)$
 
2804
                                                   k
 
2805
          (%t6)                        d e c    + a    b
 
2806
                                            x y    i j  u,v
 
2807
          (%i7) ishow(listoftens(%))$
 
2808
                                         k
 
2809
          (%t7)                        [a   , b   , c   , d]
 
2810
                                         i j   u,v   x y
 
2811
 
 
2812
 
 
2813
 -- Function: ishow (<expr>)
 
2814
     displays <expr> with the indexed objects in it shown having their
 
2815
     covariant indices as subscripts and contravariant indices as
 
2816
     superscripts. The derivative indices are displayed as subscripts,
 
2817
     separated from the covariant indices by a comma (see the examples
 
2818
     throughout this document).
 
2819
 
 
2820
 
 
2821
 -- Function: indices (<expr>)
 
2822
     Returns a list of two elements.  The first is a list of the free
 
2823
     indices in <expr> (those that occur only once). The second is the
 
2824
     list of the dummy indices in <expr> (those that occur exactly
 
2825
     twice) as the following example demonstrates.
 
2826
 
 
2827
 
 
2828
          (%i1) load(itensor);
 
2829
          (%o1)      /share/tensor/itensor.lisp
 
2830
          (%i2) ishow(a([i,j],[k,l],m,n)*b([k,o],[j,m,p],q,r))$
 
2831
                                          k l      j m p
 
2832
          (%t2)                          a        b
 
2833
                                          i j,m n  k o,q r
 
2834
          (%i3) indices(%);
 
2835
          (%o3)                 [[l, p, i, n, o, q, r], [k, j, m]]
 
2836
 
 
2837
     A tensor product containing the same index more than twice is
 
2838
     syntactically illegal. `indices' attempts to deal with these
 
2839
     expressions in a reasonable manner; however, when it is called to
 
2840
     operate upon such an illegal expression, its behavior should be
 
2841
     considered undefined.
 
2842
 
 
2843
 
 
2844
 -- Function: rename (<expr>)
 
2845
 -- Function: rename (<expr>, <count>)
 
2846
     Returns an expression equivalent to <expr> but with the dummy
 
2847
     indices in each term chosen from the set `[%1, %2,...]', if the
 
2848
     optional second argument is omitted. Otherwise, the dummy indices
 
2849
     are indexed beginning at the value of <count>.  Each dummy index
 
2850
     in a product will be different. For a sum, `rename' will operate
 
2851
     upon each term in the sum resetting the counter with each term. In
 
2852
     this way `rename' can serve as a tensorial simplifier. In
 
2853
     addition, the indices will be sorted alphanumerically (if `allsym'
 
2854
     is `true') with respect to covariant or contravariant indices
 
2855
     depending upon the value of `flipflag'.  If `flipflag' is `false'
 
2856
     then the indices will be renamed according to the order of the
 
2857
     contravariant indices. If `flipflag' is `true' the renaming will
 
2858
     occur according to the order of the covariant indices. It often
 
2859
     happens that the combined effect of the two renamings will reduce
 
2860
     an expression more than either one by itself.
 
2861
 
 
2862
 
 
2863
          (%i1) load(itensor);
 
2864
          (%o1)      /share/tensor/itensor.lisp
 
2865
          (%i2) allsym:true;
 
2866
          (%o2)                                true
 
2867
          (%i3) g([],[%4,%5])*g([],[%6,%7])*ichr2([%1,%4],[%3])*
 
2868
          ichr2([%2,%3],[u])*ichr2([%5,%6],[%1])*ichr2([%7,r],[%2])-
 
2869
          g([],[%4,%5])*g([],[%6,%7])*ichr2([%1,%2],[u])*
 
2870
          ichr2([%3,%5],[%1])*ichr2([%4,%6],[%3])*ichr2([%7,r],[%2]),noeval$
 
2871
          (%i4) expr:ishow(%)$
 
2872
 
 
2873
                 %4 %5  %6 %7      %3         u          %1         %2
 
2874
          (%t4) g      g      ichr2      ichr2      ichr2      ichr2
 
2875
                                   %1 %4      %2 %3      %5 %6      %7 r
 
2876
 
 
2877
                        %4 %5  %6 %7      u          %1         %3         %2
 
2878
                     - g      g      ichr2      ichr2      ichr2      ichr2
 
2879
                                          %1 %2      %3 %5      %4 %6      %7 r
 
2880
          (%i5) flipflag:true;
 
2881
          (%o5)                                true
 
2882
          (%i6) ishow(rename(expr))$
 
2883
                 %2 %5  %6 %7      %4         u          %1         %3
 
2884
          (%t6) g      g      ichr2      ichr2      ichr2      ichr2
 
2885
                                   %1 %2      %3 %4      %5 %6      %7 r
 
2886
 
 
2887
                        %4 %5  %6 %7      u          %1         %3         %2
 
2888
                     - g      g      ichr2      ichr2      ichr2      ichr2
 
2889
                                          %1 %2      %3 %4      %5 %6      %7 r
 
2890
          (%i7) flipflag:false;
 
2891
          (%o7)                                false
 
2892
          (%i8) rename(%th(2));
 
2893
          (%o8)                                  0
 
2894
          (%i9) ishow(rename(expr))$
 
2895
                 %1 %2  %3 %4      %5         %6         %7        u
 
2896
          (%t9) g      g      ichr2      ichr2      ichr2     ichr2
 
2897
                                   %1 %6      %2 %3      %4 r      %5 %7
 
2898
 
 
2899
                        %1 %2  %3 %4      %6         %5         %7        u
 
2900
                     - g      g      ichr2      ichr2      ichr2     ichr2
 
2901
                                          %1 %3      %2 %6      %4 r      %5 %7
 
2902
 
 
2903
 
 
2904
 -- Option variable: flipflag
 
2905
     Default: `false'. If `false' then the indices will be renamed
 
2906
     according to the order of the contravariant indices, otherwise
 
2907
     according to the order of the covariant indices.
 
2908
 
 
2909
     If `flipflag' is `false' then `rename' forms a list of the
 
2910
     contravariant indices as they are encountered from left to right
 
2911
     (if `true' then of the covariant indices). The first dummy index
 
2912
     in the list is renamed to `%1', the next to `%2', etc.  Then
 
2913
     sorting occurs after the `rename'-ing (see the example under
 
2914
     `rename').
 
2915
 
 
2916
 
 
2917
 -- Function: defcon (<tensor_1>)
 
2918
 -- Function: defcon (<tensor_1>, <tensor_2>, <tensor_3>)
 
2919
     gives <tensor_1> the property that the contraction of a product of
 
2920
     <tensor_1> and <tensor_2> results in <tensor_3> with the
 
2921
     appropriate indices.  If only one argument, <tensor_1>, is given,
 
2922
     then the contraction of the product of <tensor_1> with any indexed
 
2923
     object having the appropriate indices (say `my_tensor') will yield
 
2924
     an indexed object with that name, i.e. `my_tensor', and with a new
 
2925
     set of indices reflecting the contractions performed.      For
 
2926
     example, if `imetric:g', then `defcon(g)' will implement the
 
2927
     raising and lowering of indices through contraction with the metric
 
2928
     tensor.      More than one `defcon' can be given for the same
 
2929
     indexed object; the latest one given which applies in a particular
 
2930
     contraction will be used.  `contractions' is a list of those
 
2931
     indexed objects which have been given contraction properties with
 
2932
     `defcon'.
 
2933
 
 
2934
 
 
2935
 -- Function: remcon (<tensor_1>, ..., <tensor_n>)
 
2936
 -- Function: remcon (all)
 
2937
     removes all the contraction properties from the <tensor_1>, ...,
 
2938
     <tensor_n>). `remcon(all)' removes all contraction properties from
 
2939
     all indexed objects.
 
2940
 
 
2941
 
 
2942
 -- Function: contract (<expr>)
 
2943
     Carries out the tensorial contractions in <expr> which may be any
 
2944
     combination of sums and products. This function uses the
 
2945
     information given to the `defcon' function. For best results,
 
2946
     `expr' should be fully expanded. `ratexpand' is the fastest way to
 
2947
     expand products and powers of sums if there are no variables in
 
2948
     the denominators of the terms. The `gcd' switch should be `false'
 
2949
     if GCD cancellations are unnecessary.
 
2950
 
 
2951
 
 
2952
 -- Function: indexed_tensor (<tensor>)
 
2953
     Must be executed before assigning components to a <tensor> for
 
2954
     which a built in value already exists as with `ichr1', `ichr2',
 
2955
     `icurvature'. See the example under `icurvature'.
 
2956
 
 
2957
 
 
2958
 -- Function: components (<tensor>, <expr>)
 
2959
     permits one to assign an indicial value to an expression <expr>
 
2960
     giving the values of the components of <tensor>. These are
 
2961
     automatically substituted for the tensor whenever it occurs with
 
2962
     all of its indices. The tensor must be of the form `t([...],[...])'
 
2963
     where either list may be empty. <expr> can be any indexed
 
2964
     expression involving other objects with the same free indices as
 
2965
     <tensor>. When used to assign values to the metric tensor wherein
 
2966
     the components contain dummy indices one must be careful to define
 
2967
     these indices to avoid the generation of multiple dummy indices.
 
2968
     Removal of this assignment is given to the function `remcomps'.
 
2969
 
 
2970
     It is important to keep in mind that `components' cares only about
 
2971
     the valence of a tensor, not about any particular index ordering.
 
2972
     Thus assigning components to, say, `x([i,-j],[])', `x([-j,i],[])',
 
2973
     or `x([i],[j])' all produce the same result, namely components
 
2974
     being assigned to a tensor named `x' with valence `(1,1)'.
 
2975
 
 
2976
     Components can be assigned to an indexed expression in four ways,
 
2977
     two of which involve the use of the `components' command:
 
2978
 
 
2979
     1) As an indexed expression. For instance:
 
2980
 
 
2981
 
 
2982
          (%i2) components(g([],[i,j]),e([],[i])*p([],[j]))$
 
2983
          (%i3) ishow(g([],[i,j]))$
 
2984
                                                i  j
 
2985
          (%t3)                                e  p
 
2986
 
 
2987
     2) As a matrix:
 
2988
 
 
2989
 
 
2990
          (%i6) components(g([i,j],[]),lg);
 
2991
          (%o6)                                done
 
2992
          (%i7) ishow(g([i,j],[]))$
 
2993
          (%t7)                                g
 
2994
                                                i j
 
2995
          (%i8) g([3,3],[]);
 
2996
          (%o8)                                  1
 
2997
          (%i9) g([4,4],[]);
 
2998
          (%o9)                                 - 1
 
2999
 
 
3000
     3) As a function. You can use a Maxima function to specify the
 
3001
     components of a tensor based on its indices. For instance, the
 
3002
     following code assigns `kdelta' to `h' if `h' has the same number
 
3003
     of covariant and contravariant indices and no derivative indices,
 
3004
     and `g' otherwise:
 
3005
 
 
3006
 
 
3007
          (%i4) h(l1,l2,[l3]):=if length(l1)=length(l2) and length(l3)=0
 
3008
            then kdelta(l1,l2) else apply(g,append([l1,l2], l3))$
 
3009
          (%i5) ishow(h([i],[j]))$
 
3010
                                                    j
 
3011
          (%t5)                               kdelta
 
3012
                                                    i
 
3013
          (%i6) ishow(h([i,j],[k],l))$
 
3014
                                               k
 
3015
          (%t6)                               g
 
3016
                                               i j,l
 
3017
 
 
3018
     4) Using Maxima's pattern matching capabilities, specifically the
 
3019
     `defrule' and `applyb1' commands:
 
3020
 
 
3021
 
 
3022
          (%i1) load(itensor);
 
3023
          (%o1)      /share/tensor/itensor.lisp
 
3024
          (%i2) matchdeclare(l1,listp);
 
3025
          (%o2)                                done
 
3026
          (%i3) defrule(r1,m(l1,[]),(i1:idummy(),
 
3027
                g([l1[1],l1[2]],[])*q([i1],[])*e([],[i1])))$
 
3028
 
 
3029
          (%i4) defrule(r2,m([],l1),(i1:idummy(),
 
3030
                w([],[l1[1],l1[2]])*e([i1],[])*q([],[i1])))$
 
3031
 
 
3032
          (%i5) ishow(m([i,n],[])*m([],[i,m]))$
 
3033
                                              i m
 
3034
          (%t5)                              m    m
 
3035
                                                   i n
 
3036
          (%i6) ishow(rename(applyb1(%,r1,r2)))$
 
3037
                                     %1  %2  %3 m
 
3038
          (%t6)                     e   q   w     q   e   g
 
3039
                                                   %1  %2  %3 n
 
3040
 
 
3041
 
 
3042
 -- Function: remcomps (<tensor>)
 
3043
     Unbinds all values from <tensor> which were assigned with the
 
3044
     `components' function.
 
3045
 
 
3046
 
 
3047
 -- Function: showcomps (<tensor>)
 
3048
     Shows component assignments of a tensor, as made using the
 
3049
     `components' command. This function can be particularly useful
 
3050
     when a matrix is assigned to an indicial tensor using
 
3051
     `components', as demonstrated by the following example:
 
3052
 
 
3053
 
 
3054
          (%i1) load(ctensor);
 
3055
          (%o1)       /share/tensor/ctensor.mac
 
3056
          (%i2) load(itensor);
 
3057
          (%o2)      /share/tensor/itensor.lisp
 
3058
          (%i3) lg:matrix([sqrt(r/(r-2*m)),0,0,0],[0,r,0,0],
 
3059
                          [0,0,sin(theta)*r,0],[0,0,0,sqrt((r-2*m)/r)]);
 
3060
                         [         r                                     ]
 
3061
                         [ sqrt(-------)  0       0              0       ]
 
3062
                         [      r - 2 m                                  ]
 
3063
                         [                                               ]
 
3064
                         [       0        r       0              0       ]
 
3065
          (%o3)          [                                               ]
 
3066
                         [       0        0  r sin(theta)        0       ]
 
3067
                         [                                               ]
 
3068
                         [                                      r - 2 m  ]
 
3069
                         [       0        0       0        sqrt(-------) ]
 
3070
                         [                                         r     ]
 
3071
          (%i4) components(g([i,j],[]),lg);
 
3072
          (%o4)                                done
 
3073
          (%i5) showcomps(g([i,j],[]));
 
3074
                            [         r                                     ]
 
3075
                            [ sqrt(-------)  0       0              0       ]
 
3076
                            [      r - 2 m                                  ]
 
3077
                            [                                               ]
 
3078
                            [       0        r       0              0       ]
 
3079
          (%t5)      g    = [                                               ]
 
3080
                      i j   [       0        0  r sin(theta)        0       ]
 
3081
                            [                                               ]
 
3082
                            [                                      r - 2 m  ]
 
3083
                            [       0        0       0        sqrt(-------) ]
 
3084
                            [                                         r     ]
 
3085
          (%o5)                                false
 
3086
 
 
3087
     The `showcomps' command can also display components of a tensor of
 
3088
     rank higher than 2.
 
3089
 
 
3090
 
 
3091
 -- Function: idummy ()
 
3092
     Increments `icounter' and returns as its value an index of the form
 
3093
     `%n' where n is a positive integer.  This guarantees that dummy
 
3094
     indices which are needed in forming expressions will not conflict
 
3095
     with indices already in use (see the example under `indices').
 
3096
 
 
3097
 
 
3098
 -- Option variable: idummyx
 
3099
     Default value: `%'
 
3100
 
 
3101
     Is the prefix for dummy indices (see the example under `indices').
 
3102
 
 
3103
 
 
3104
 -- Option variable: icounter
 
3105
     Default value: `1'
 
3106
 
 
3107
     Determines the numerical suffix to be used in generating the next
 
3108
     dummy index in the tensor package.  The prefix is determined by
 
3109
     the option `idummy' (default: `%').
 
3110
 
 
3111
 -- Function: kdelta (<L1>, <L2>)
 
3112
     is the generalized Kronecker delta function defined in the
 
3113
     `itensor' package with <L1> the list of covariant indices and <L2>
 
3114
     the list of contravariant indices.  `kdelta([i],[j])' returns the
 
3115
     ordinary Kronecker delta.  The command `ev(<expr>,kdelta)' causes
 
3116
     the evaluation of an expression containing `kdelta([],[])' to the
 
3117
     dimension of the manifold.
 
3118
 
 
3119
     In what amounts to an abuse of this notation, `itensor' also allows
 
3120
     `kdelta' to have 2 covariant and no contravariant, or 2
 
3121
     contravariant and no covariant indices, in effect providing a
 
3122
     co(ntra)variant "unit matrix" capability. This is strictly
 
3123
     considered a programming aid and not meant to imply that
 
3124
     `kdelta([i,j],[])' is a valid tensorial object.
 
3125
 
 
3126
 
 
3127
 -- Function: kdels (<L1>, <L2>)
 
3128
     Symmetricized Kronecker delta, used in some calculations. For
 
3129
     instance:
 
3130
 
 
3131
 
 
3132
          (%i1) load(itensor);
 
3133
          (%o1)      /share/tensor/itensor.lisp
 
3134
          (%i2) kdelta([1,2],[2,1]);
 
3135
          (%o2)                                 - 1
 
3136
          (%i3) kdels([1,2],[2,1]);
 
3137
          (%o3)                                  1
 
3138
          (%i4) ishow(kdelta([a,b],[c,d]))$
 
3139
                                       c       d         d       c
 
3140
          (%t4)                  kdelta  kdelta  - kdelta  kdelta
 
3141
                                       a       b         a       b
 
3142
          (%i4) ishow(kdels([a,b],[c,d]))$
 
3143
                                       c       d         d       c
 
3144
          (%t4)                  kdelta  kdelta  + kdelta  kdelta
 
3145
                                       a       b         a       b
 
3146
 
 
3147
 
 
3148
 -- Function: levi_civita (<L>)
 
3149
     is the permutation (or Levi-Civita) tensor which yields 1 if the
 
3150
     list <L> consists of an even permutation of integers, -1 if it
 
3151
     consists of an odd permutation, and 0 if some indices in <L> are
 
3152
     repeated.
 
3153
 
 
3154
 
 
3155
 -- Function: lc2kdt (<expr>)
 
3156
     Simplifies expressions containing the Levi-Civita symbol,
 
3157
     converting these to Kronecker-delta expressions when possible. The
 
3158
     main difference between this function and simply evaluating the
 
3159
     Levi-Civita symbol is that direct evaluation often results in
 
3160
     Kronecker expressions containing numerical indices. This is often
 
3161
     undesirable as it prevents further simplification.  The `lc2kdt'
 
3162
     function avoids this problem, yielding expressions that are more
 
3163
     easily simplified with `rename' or `contract'.
 
3164
 
 
3165
 
 
3166
          (%i1) load(itensor);
 
3167
          (%o1)      /share/tensor/itensor.lisp
 
3168
          (%i2) expr:ishow('levi_civita([],[i,j])*'levi_civita([k,l],[])*a([j],[k]))$
 
3169
                                            i j  k
 
3170
          (%t2)                  levi_civita    a  levi_civita
 
3171
                                                 j            k l
 
3172
          (%i3) ishow(ev(expr,levi_civita))$
 
3173
                                            i j  k       1 2
 
3174
          (%t3)                       kdelta    a  kdelta
 
3175
                                            1 2  j       k l
 
3176
          (%i4) ishow(ev(%,kdelta))$
 
3177
                       i       j         j       i   k
 
3178
          (%t4) (kdelta  kdelta  - kdelta  kdelta ) a
 
3179
                       1       2         1       2   j
 
3180
 
 
3181
                                         1       2         2       1
 
3182
                                  (kdelta  kdelta  - kdelta  kdelta )
 
3183
                                         k       l         k       l
 
3184
          (%i5) ishow(lc2kdt(expr))$
 
3185
                               k       i       j    k       j       i
 
3186
          (%t5)               a  kdelta  kdelta  - a  kdelta  kdelta
 
3187
                               j       k       l    j       k       l
 
3188
          (%i6) ishow(contract(expand(%)))$
 
3189
                                           i           i
 
3190
          (%t6)                           a  - a kdelta
 
3191
                                           l           l
 
3192
 
 
3193
     The `lc2kdt' function sometimes makes use of the metric tensor.
 
3194
     If the metric tensor was not defined previously with `imetric',
 
3195
     this results in an error.
 
3196
 
 
3197
 
 
3198
          (%i7) expr:ishow('levi_civita([],[i,j])*'levi_civita([],[k,l])*a([j,k],[]))$
 
3199
                                           i j            k l
 
3200
          (%t7)                 levi_civita    levi_civita    a
 
3201
                                                               j k
 
3202
          (%i8) ishow(lc2kdt(expr))$
 
3203
          Maxima encountered a Lisp error:
 
3204
 
 
3205
           Error in $IMETRIC [or a callee]:
 
3206
           $IMETRIC [or a callee] requires less than two arguments.
 
3207
 
 
3208
          Automatically continuing.
 
3209
          To reenable the Lisp debugger set *debugger-hook* to nil.
 
3210
          (%i9) imetric(g);
 
3211
          (%o9)                                done
 
3212
          (%i10) ishow(lc2kdt(expr))$
 
3213
                   %3 i       k   %4 j       l     %3 i       l   %4 j       k
 
3214
          (%t10) (g     kdelta   g     kdelta   - g     kdelta   g     kdelta  ) a
 
3215
                              %3             %4               %3             %4   j k
 
3216
          (%i11) ishow(contract(expand(%)))$
 
3217
                                            l i      l i
 
3218
          (%t11)                           a    - a g
 
3219
 
 
3220
 
 
3221
 -- Function: lc_l
 
3222
     Simplification rule used for expressions containing the
 
3223
     unevaluated Levi-Civita symbol (`levi_civita'). Along with `lc_u',
 
3224
     it can be used to simplify many expressions more efficiently than
 
3225
     the evaluation of `levi_civita'.  For example:
 
3226
 
 
3227
 
 
3228
          (%i1) load(itensor);
 
3229
          (%o1)      /share/tensor/itensor.lisp
 
3230
          (%i2)  el1:ishow('levi_civita([i,j,k],[])*a([],[i])*a([],[j]))$
 
3231
                                       i  j
 
3232
          (%t2)                       a  a  levi_civita
 
3233
                                                       i j k
 
3234
          (%i3) el2:ishow('levi_civita([],[i,j,k])*a([i])*a([j]))$
 
3235
                                                 i j k
 
3236
          (%t3)                       levi_civita      a  a
 
3237
                                                        i  j
 
3238
          (%i4) ishow(canform(contract(expand(applyb1(el1,lc_l,lc_u)))))$
 
3239
          (%t4)                                  0
 
3240
          (%i5) ishow(canform(contract(expand(applyb1(el2,lc_l,lc_u)))))$
 
3241
          (%t5)                                  0
 
3242
 
 
3243
 
 
3244
 -- Function: lc_u
 
3245
     Simplification rule used for expressions containing the
 
3246
     unevaluated Levi-Civita symbol (`levi_civita'). Along with `lc_u',
 
3247
     it can be used to simplify many expressions more efficiently than
 
3248
     the evaluation of `levi_civita'.  For details, see `lc_l'.
 
3249
 
 
3250
 
 
3251
 -- Function: canten (<expr>)
 
3252
     Simplifies <expr> by renaming (see `rename') and permuting dummy
 
3253
     indices. `rename' is restricted to sums of tensor products in
 
3254
     which no derivatives are present. As such it is limited and should
 
3255
     only be used if `canform' is not capable of carrying out the
 
3256
     required simplification.
 
3257
 
 
3258
     The `canten' function returns a mathematically correct result only
 
3259
     if its argument is an expression that is fully symmetric in its
 
3260
     indices.  For this reason, `canten' returns an error if `allsym'
 
3261
     is not set to `true'.
 
3262
 
 
3263
 
 
3264
 -- Function: concan (<expr>)
 
3265
     Similar to `canten' but also performs index contraction.
 
3266
 
 
3267
 
 
3268
28.2.2 Tensor symmetries
 
3269
------------------------
 
3270
 
 
3271
 -- Option variable: allsym
 
3272
     Default: `false'. if `true' then all indexed objects are assumed
 
3273
     symmetric in all of their covariant and contravariant indices. If
 
3274
     `false' then no symmetries of any kind are assumed in these
 
3275
     indices. Derivative indices are always taken to be symmetric
 
3276
     unless `iframe_flag' is set to `true'.
 
3277
 
 
3278
 
 
3279
 -- Function: decsym (<tensor>, <m>, <n>, [<cov_1>, <cov_2>, ...],
 
3280
          [<contr_1>, <contr_2>, ...])
 
3281
     Declares symmetry properties for <tensor> of <m> covariant and <n>
 
3282
     contravariant indices. The <cov_i> and <contr_i> are
 
3283
     pseudofunctions expressing symmetry relations among the covariant
 
3284
     and contravariant indices respectively.  These are of the form
 
3285
     `symoper(<index_1>, <index_2>,...)' where `symoper' is one of
 
3286
     `sym', `anti' or `cyc' and the <index_i> are integers indicating
 
3287
     the position of the index in the <tensor>.  This will declare
 
3288
     <tensor> to be symmetric, antisymmetric or cyclic respectively in
 
3289
     the <index_i>. `symoper(all)' is also an allowable form which
 
3290
     indicates all indices obey the symmetry condition. For example,
 
3291
     given an object `b' with 5 covariant indices,
 
3292
     `decsym(b,5,3,[sym(1,2),anti(3,4)],[cyc(all)])' declares `b'
 
3293
     symmetric in its first and second and antisymmetric in its third
 
3294
     and fourth covariant indices, and cyclic in all of its
 
3295
     contravariant indices.  Either list of symmetry declarations may
 
3296
     be null.  The function which performs the simplifications is
 
3297
     `canform' as the example below illustrates.
 
3298
 
 
3299
 
 
3300
          (%i1) load(itensor);
 
3301
          (%o1)      /share/tensor/itensor.lisp
 
3302
          (%i2) expr:contract(expand(a([i1,j1,k1],[])*kdels([i,j,k],[i1,j1,k1])))$
 
3303
          (%i3) ishow(expr)$
 
3304
          (%t3)         a      + a      + a      + a      + a      + a
 
3305
                         k j i    k i j    j k i    j i k    i k j    i j k
 
3306
          (%i4) decsym(a,3,0,[sym(all)],[]);
 
3307
          (%o4)                                done
 
3308
          (%i5) ishow(canform(expr))$
 
3309
          (%t5)                              6 a
 
3310
                                                i j k
 
3311
          (%i6) remsym(a,3,0);
 
3312
          (%o6)                                done
 
3313
          (%i7) decsym(a,3,0,[anti(all)],[]);
 
3314
          (%o7)                                done
 
3315
          (%i8) ishow(canform(expr))$
 
3316
          (%t8)                                  0
 
3317
          (%i9) remsym(a,3,0);
 
3318
          (%o9)                                done
 
3319
          (%i10) decsym(a,3,0,[cyc(all)],[]);
 
3320
          (%o10)                               done
 
3321
          (%i11) ishow(canform(expr))$
 
3322
          (%t11)                        3 a      + 3 a
 
3323
                                           i k j      i j k
 
3324
          (%i12) dispsym(a,3,0);
 
3325
          (%o12)                     [[cyc, [[1, 2, 3]], []]]
 
3326
 
 
3327
 
 
3328
 -- Function: remsym (<tensor>, <m>, <n>)
 
3329
     Removes all symmetry properties from <tensor> which has <m>
 
3330
     covariant indices and <n> contravariant indices.
 
3331
 
 
3332
 -- Function: canform (<expr>)
 
3333
     Simplifies <expr> by renaming dummy indices and reordering all
 
3334
     indices as dictated by symmetry conditions imposed on them. If
 
3335
     `allsym' is `true' then all indices are assumed symmetric,
 
3336
     otherwise symmetry information provided by `decsym' declarations
 
3337
     will be used. The dummy indices are renamed in the same manner as
 
3338
     in the `rename' function. When `canform' is applied to a large
 
3339
     expression the calculation may take a considerable amount of time.
 
3340
     This time can be shortened by calling `rename' on the expression
 
3341
     first.  Also see the example under `decsym'. Note: `canform' may
 
3342
     not be able to reduce an expression completely to its simplest
 
3343
     form although it will always return a mathematically correct
 
3344
     result.
 
3345
 
 
3346
28.2.3 Indicial tensor calculus
 
3347
-------------------------------
 
3348
 
 
3349
 -- Function: diff (<expr>, <v_1>, [<n_1>, [<v_2>, <n_2>] ...])
 
3350
     is the usual Maxima differentiation function which has been
 
3351
     expanded in its abilities for `itensor'. It takes the derivative
 
3352
     of <expr> with respect to <v_1> <n_1> times, with respect to <v_2>
 
3353
     <n_2> times, etc. For the tensor package, the function has been
 
3354
     modified so that the <v_i> may be integers from 1 up to the value
 
3355
     of the variable `dim'.  This will cause the differentiation to be
 
3356
     carried out with respect to the <v_i>th member of the list
 
3357
     `vect_coords'.  If `vect_coords' is bound to an atomic variable,
 
3358
     then that variable subscripted by <v_i> will be used for the
 
3359
     variable of differentiation.  This permits an array of coordinate
 
3360
     names or subscripted names like `x[1]', `x[2]', ...  to be used.
 
3361
 
 
3362
 -- Function: idiff (<expr>, <v_1>, [<n_1>, [<v_2>, <n_2>] ...])
 
3363
     Indicial differentiation. Unlike `diff', which differentiates with
 
3364
     respect to an independent variable, `idiff)' can be used to
 
3365
     differentiate with respect to a coordinate. For an indexed object,
 
3366
     this amounts to appending the <v_i> as derivative indices.
 
3367
     Subsequently, derivative indices will be sorted, unless
 
3368
     `iframe_flag' is set to `true'.
 
3369
 
 
3370
     `idiff' can also differentiate the determinant of the metric
 
3371
     tensor. Thus, if `imetric' has been bound to `G' then
 
3372
     `idiff(determinant(g),k)' will return
 
3373
     `2*determinant(g)*ichr2([%i,k],[%i])' where the dummy index `%i'
 
3374
     is chosen appropriately.
 
3375
 
 
3376
 
 
3377
 -- Function: liediff (<v>, <ten>)
 
3378
     Computes the Lie-derivative of the tensorial expression <ten> with
 
3379
     respect to the vector field <v>. <ten> should be any indexed
 
3380
     tensor expression; <v> should be the name (without indices) of a
 
3381
     vector field. For example:
 
3382
 
 
3383
 
 
3384
          (%i1) load(itensor);
 
3385
          (%o1)      /share/tensor/itensor.lisp
 
3386
          (%i2) ishow(liediff(v,a([i,j],[])*b([],[k],l)))$
 
3387
                 k    %2            %2          %2
 
3388
          (%t2) b   (v   a       + v   a     + v   a    )
 
3389
                 ,l       i j,%2    ,j  i %2    ,i  %2 j
 
3390
 
 
3391
                                          %1  k        %1  k      %1  k
 
3392
                                      + (v   b      - b   v    + v   b   ) a
 
3393
                                              ,%1 l    ,l  ,%1    ,l  ,%1   i j
 
3394
 
 
3395
 
 
3396
 -- Function: rediff (<ten>)
 
3397
     Evaluates all occurrences of the `idiff' command in the tensorial
 
3398
     expression <ten>.
 
3399
 
 
3400
 
 
3401
 -- Function: undiff (<expr>)
 
3402
     Returns an expression equivalent to <expr> but with all derivatives
 
3403
     of indexed objects replaced by the noun form of the `idiff'
 
3404
     function. Its arguments would yield that indexed object if the
 
3405
     differentiation were carried out.  This is useful when it is
 
3406
     desired to replace a differentiated indexed object with some
 
3407
     function definition resulting in <expr> and then carry out the
 
3408
     differentiation by saying `ev(<expr>, idiff)'.
 
3409
 
 
3410
 
 
3411
 -- Function: evundiff (<expr>)
 
3412
     Equivalent to the execution of `undiff', followed by `ev' and
 
3413
     `rediff'.
 
3414
 
 
3415
     The point of this operation is to easily evalute expressions that
 
3416
     cannot be directly evaluated in derivative form. For instance, the
 
3417
     following causes an error:
 
3418
 
 
3419
          (%i1) load(itensor);
 
3420
          (%o1)      /share/tensor/itensor.lisp
 
3421
          (%i2) icurvature([i,j,k],[l],m);
 
3422
          Maxima encountered a Lisp error:
 
3423
 
 
3424
           Error in $ICURVATURE [or a callee]:
 
3425
           $ICURVATURE [or a callee] requires less than three arguments.
 
3426
 
 
3427
          Automatically continuing.
 
3428
          To reenable the Lisp debugger set *debugger-hook* to nil.
 
3429
 
 
3430
     However, if `icurvature' is entered in noun form, it can be
 
3431
     evaluated using `evundiff':
 
3432
 
 
3433
          (%i3) ishow('icurvature([i,j,k],[l],m))$
 
3434
                                                   l
 
3435
          (%t3)                          icurvature
 
3436
                                                   i j k,m
 
3437
          (%i4) ishow(evundiff(%))$
 
3438
                       l              l         %1           l           %1
 
3439
          (%t4) - ichr2        - ichr2     ichr2      - ichr2       ichr2
 
3440
                       i k,j m        %1 j      i k,m        %1 j,m      i k
 
3441
 
 
3442
                          l              l         %1           l           %1
 
3443
                   + ichr2        + ichr2     ichr2      + ichr2       ichr2
 
3444
                          i j,k m        %1 k      i j,m        %1 k,m      i j
 
3445
 
 
3446
     Note: In earlier versions of Maxima, derivative forms of the
 
3447
     Christoffel-symbols also could not be evaluated. This has been
 
3448
     fixed now, so `evundiff' is no longer necessary for expressions
 
3449
     like this:
 
3450
 
 
3451
          (%i5) imetric(g);
 
3452
          (%o5)                                done
 
3453
          (%i6) ishow(ichr2([i,j],[k],l))$
 
3454
                 k %3
 
3455
                g     (g         - g         + g        )
 
3456
                        j %3,i l    i j,%3 l    i %3,j l
 
3457
          (%t6) -----------------------------------------
 
3458
                                    2
 
3459
 
 
3460
                                   k %3
 
3461
                                  g     (g       - g       + g      )
 
3462
                                   ,l     j %3,i    i j,%3    i %3,j
 
3463
                                + -----------------------------------
 
3464
                                                   2
 
3465
 
 
3466
 
 
3467
 -- Function: flush (<expr>, <tensor_1>, <tensor_2>, ...)
 
3468
     Set to zero, in <expr>, all occurrences of the <tensor_i> that
 
3469
     have no derivative indices.
 
3470
 
 
3471
 
 
3472
 -- Function: flushd (<expr>, <tensor_1>, <tensor_2>, ...)
 
3473
     Set to zero, in <expr>, all occurrences of the <tensor_i> that
 
3474
     have derivative indices.
 
3475
 
 
3476
 
 
3477
 -- Function: flushnd (<expr>, <tensor>, <n>)
 
3478
     Set to zero, in <expr>, all occurrences of the differentiated
 
3479
     object <tensor> that have <n> or more derivative indices as the
 
3480
     following example demonstrates.
 
3481
 
 
3482
          (%i1) load(itensor);
 
3483
          (%o1)      /share/tensor/itensor.lisp
 
3484
          (%i2) ishow(a([i],[J,r],k,r)+a([i],[j,r,s],k,r,s))$
 
3485
                                          J r      j r s
 
3486
          (%t2)                          a      + a
 
3487
                                          i,k r    i,k r s
 
3488
          (%i3) ishow(flushnd(%,a,3))$
 
3489
                                               J r
 
3490
          (%t3)                               a
 
3491
                                               i,k r
 
3492
 
 
3493
 -- Function: coord (<tensor_1>, <tensor_2>, ...)
 
3494
     Gives <tensor_i> the coordinate differentiation property that the
 
3495
     derivative of contravariant vector whose name is one of the
 
3496
     <tensor_i> yields a Kronecker delta. For example, if `coord(x)' has
 
3497
     been done then `idiff(x([],[i]),j)' gives `kdelta([i],[j])'.
 
3498
     `coord' is a list of all indexed objects having this property.
 
3499
 
 
3500
 
 
3501
 -- Function: remcoord (<tensor_1>, <tensor_2>, ...)
 
3502
 -- Function: remcoord (all)
 
3503
     Removes the coordinate differentiation property from the `tensor_i'
 
3504
     that was established by the function `coord'.  `remcoord(all)'
 
3505
     removes this property from all indexed objects.
 
3506
 
 
3507
 
 
3508
 -- Function: makebox (<expr>)
 
3509
     Display <expr> in the same manner as `show'; however, any tensor
 
3510
     d'Alembertian occurring in <expr> will be indicated using the
 
3511
     symbol `[]'.  For example, `[]p([m],[n])' represents
 
3512
     `g([],[i,j])*p([m],[n],i,j)'.
 
3513
 
 
3514
 
 
3515
 -- Function: conmetderiv (<expr>, <tensor>)
 
3516
     Simplifies expressions containing ordinary derivatives of both
 
3517
     covariant and contravariant forms of the metric tensor (the
 
3518
     current restriction).  For example, `conmetderiv' can relate the
 
3519
     derivative of the contravariant metric tensor with the Christoffel
 
3520
     symbols as seen from the following:
 
3521
 
 
3522
 
 
3523
          (%i1) load(itensor);
 
3524
          (%o1)      /share/tensor/itensor.lisp
 
3525
          (%i2) ishow(g([],[a,b],c))$
 
3526
                                                a b
 
3527
          (%t2)                                g
 
3528
                                                ,c
 
3529
          (%i3) ishow(conmetderiv(%,g))$
 
3530
                                   %1 b      a       %1 a      b
 
3531
          (%t3)                 - g     ichr2     - g     ichr2
 
3532
                                             %1 c              %1 c
 
3533
 
 
3534
 -- Function: simpmetderiv (<expr>)
 
3535
 -- Function: simpmetderiv (<expr>[, <stop>])
 
3536
     Simplifies expressions containing products of the derivatives of
 
3537
     the metric tensor. Specifically, `simpmetderiv' recognizes two
 
3538
     identities:
 
3539
 
 
3540
 
 
3541
             ab        ab           ab                 a
 
3542
            g   g   + g   g     = (g   g  )   = (kdelta )   = 0
 
3543
             ,d  bc        bc,d         bc ,d          c ,d
 
3544
 
 
3545
     hence
 
3546
 
 
3547
 
 
3548
             ab          ab
 
3549
            g   g   = - g   g
 
3550
             ,d  bc          bc,d
 
3551
 
 
3552
     and
 
3553
 
 
3554
 
 
3555
            ab          ab
 
3556
           g   g     = g   g
 
3557
            ,j  ab,i    ,i  ab,j
 
3558
 
 
3559
     which follows from the symmetries of the Christoffel symbols.
 
3560
 
 
3561
     The `simpmetderiv' function takes one optional parameter which,
 
3562
     when present, causes the function to stop after the first
 
3563
     successful substitution in a product expression. The
 
3564
     `simpmetderiv' function also makes use of the global variable
 
3565
     <flipflag> which determines how to apply a "canonical" ordering to
 
3566
     the product indices.
 
3567
 
 
3568
     Put together, these capabilities can be used to achieve powerful
 
3569
     simplifications that are difficult or impossible to accomplish
 
3570
     otherwise.  This is demonstrated through the following example
 
3571
     that explicitly uses the partial simplification features of
 
3572
     `simpmetderiv' to obtain a contractible expression:
 
3573
 
 
3574
 
 
3575
          (%i1) load(itensor);
 
3576
          (%o1)      /share/tensor/itensor.lisp
 
3577
          (%i2) imetric(g);
 
3578
          (%o2)                                done
 
3579
          (%i3) ishow(g([],[a,b])*g([],[b,c])*g([a,b],[],d)*g([b,c],[],e))$
 
3580
                                       a b  b c
 
3581
          (%t3)                       g    g    g      g
 
3582
                                                 a b,d  b c,e
 
3583
          (%i4) ishow(canform(%))$
 
3584
 
 
3585
          errexp1 has improper indices
 
3586
           -- an error.  Quitting.  To debug this try debugmode(true);
 
3587
          (%i5) ishow(simpmetderiv(%))$
 
3588
                                       a b  b c
 
3589
          (%t5)                       g    g    g      g
 
3590
                                                 a b,d  b c,e
 
3591
          (%i6) flipflag:not flipflag;
 
3592
          (%o6)                                true
 
3593
          (%i7) ishow(simpmetderiv(%th(2)))$
 
3594
                                         a b  b c
 
3595
          (%t7)                         g    g    g    g
 
3596
                                         ,d   ,e   a b  b c
 
3597
          (%i8) flipflag:not flipflag;
 
3598
          (%o8)                                false
 
3599
          (%i9) ishow(simpmetderiv(%th(2),stop))$
 
3600
                                         a b  b c
 
3601
          (%t9)                       - g    g    g      g
 
3602
                                              ,e   a b,d  b c
 
3603
          (%i10) ishow(contract(%))$
 
3604
                                              b c
 
3605
          (%t10)                           - g    g
 
3606
                                              ,e   c b,d
 
3607
 
 
3608
     See also `weyl.dem' for an example that uses `simpmetderiv' and
 
3609
     `conmetderiv' together to simplify contractions of the Weyl tensor.
 
3610
 
 
3611
 
 
3612
 -- Function: flush1deriv (<expr>, <tensor>)
 
3613
     Set to zero, in `expr', all occurrences of `tensor' that have
 
3614
     exactly one derivative index.
 
3615
 
 
3616
 
 
3617
28.2.4 Tensors in curved spaces
 
3618
-------------------------------
 
3619
 
 
3620
 -- Function: imetric (<g>)
 
3621
 -- System variable: imetric
 
3622
     Specifies the metric by assigning the variable `imetric:<g>' in
 
3623
     addition, the contraction properties of the metric <g> are set up
 
3624
     by executing the commands `defcon(<g>),defcon(<g>,<g>,kdelta)'.
 
3625
     The variable `imetric' (unbound by default), is bound to the
 
3626
     metric, assigned by the `imetric(<g>)' command.
 
3627
 
 
3628
 
 
3629
 -- Function: idim (<n>)
 
3630
     Sets the dimensions of the metric. Also initializes the
 
3631
     antisymmetry properties of the Levi-Civita symbols for the given
 
3632
     dimension.
 
3633
 
 
3634
 
 
3635
 -- Function: ichr1 ([<i>, <j>, <k>])
 
3636
     Yields the Christoffel symbol of the first kind via the definition
 
3637
                 (g      + g      - g     )/2 .
 
3638
                   ik,j     jk,i     ij,k
 
3639
     To evaluate the Christoffel symbols for a particular metric, the
 
3640
     variable `imetric' must be assigned a name as in the example under
 
3641
     `chr2'.
 
3642
 
 
3643
 
 
3644
 -- Function: ichr2 ([<i>, <j>], [<k>])
 
3645
     Yields the Christoffel symbol of the second kind defined by the
 
3646
     relation
 
3647
                                 ks
 
3648
             ichr2([i,j],[k]) = g    (g      + g      - g     )/2
 
3649
                                       is,j     js,i     ij,s
 
3650
 
 
3651
 -- Function: icurvature ([<i>, <j>, <k>], [<h>])
 
3652
     Yields the Riemann curvature tensor in terms of the Christoffel
 
3653
     symbols of the second kind (`ichr2').  The following notation is
 
3654
     used:
 
3655
                         h             h            h         %1         h
 
3656
               icurvature     = - ichr2      - ichr2     ichr2    + ichr2
 
3657
                         i j k         i k,j        %1 j      i k        i j,k
 
3658
                                         h          %1
 
3659
                                  + ichr2      ichr2
 
3660
                                         %1 k       i j
 
3661
 
 
3662
 -- Function: covdiff (<expr>, <v_1>, <v_2>, ...)
 
3663
     Yields the covariant derivative of <expr> with respect to the
 
3664
     variables <v_i> in terms of the Christoffel symbols of the second
 
3665
     kind (`ichr2').  In order to evaluate these, one should use
 
3666
     `ev(<expr>,ichr2)'.
 
3667
 
 
3668
 
 
3669
          (%i1) load(itensor);
 
3670
          (%o1)      /share/tensor/itensor.lisp
 
3671
          (%i2) entertensor()$
 
3672
          Enter tensor name: a;
 
3673
          Enter a list of the covariant indices: [i,j];
 
3674
          Enter a list of the contravariant indices: [k];
 
3675
          Enter a list of the derivative indices: [];
 
3676
                                                k
 
3677
          (%t2)                                a
 
3678
                                                i j
 
3679
          (%i3) ishow(covdiff(%,s))$
 
3680
                       k         %1     k         %1     k            k     %1
 
3681
          (%t3)     - a     ichr2    - a     ichr2    + a      + ichr2     a
 
3682
                       i %1      j s    %1 j      i s    i j,s        %1 s  i j
 
3683
          (%i4) imetric:g;
 
3684
          (%o4)                                  g
 
3685
          (%i5) ishow(ev(%th(2),ichr2))$
 
3686
                   %1 %4  k
 
3687
                  g      a     (g       - g       + g      )
 
3688
                          i %1   s %4,j    j s,%4    j %4,s
 
3689
          (%t5) - ------------------------------------------
 
3690
                                      2
 
3691
              %1 %3  k
 
3692
             g      a     (g       - g       + g      )
 
3693
                     %1 j   s %3,i    i s,%3    i %3,s
 
3694
           - ------------------------------------------
 
3695
                                 2
 
3696
              k %2  %1
 
3697
             g     a    (g        - g        + g       )
 
3698
                    i j   s %2,%1    %1 s,%2    %1 %2,s     k
 
3699
           + ------------------------------------------- + a
 
3700
                                  2                         i j,s
 
3701
          (%i6)
 
3702
 
 
3703
 
 
3704
 -- Function: lorentz_gauge (<expr>)
 
3705
     Imposes the Lorentz condition by substituting 0 for all indexed
 
3706
     objects in <expr> that have a derivative index identical to a
 
3707
     contravariant index.
 
3708
 
 
3709
 
 
3710
 -- Function: igeodesic_coords (<expr>, <name>)
 
3711
     Causes undifferentiated Christoffel symbols and first derivatives
 
3712
     of the metric tensor vanish in <expr>. The <name> in the
 
3713
     `igeodesic_coords' function refers to the metric <name> (if it
 
3714
     appears in <expr>) while the connection coefficients must be
 
3715
     called with the names `ichr1' and/or `ichr2'. The following example
 
3716
     demonstrates the verification of the cyclic identity satisfied by
 
3717
     the Riemann curvature tensor using the `igeodesic_coords' function.
 
3718
 
 
3719
 
 
3720
          (%i1) load(itensor);
 
3721
          (%o1)      /share/tensor/itensor.lisp
 
3722
          (%i2) ishow(icurvature([r,s,t],[u]))$
 
3723
                       u            u         %1         u            u         %1
 
3724
          (%t2) - ichr2      - ichr2     ichr2    + ichr2      + ichr2     ichr2
 
3725
                       r t,s        %1 s      r t        r s,t        %1 t      r s
 
3726
          (%i3) ishow(igeodesic_coords(%,ichr2))$
 
3727
                                           u            u
 
3728
          (%t3)                       ichr2      - ichr2
 
3729
                                           r s,t        r t,s
 
3730
          (%i4) ishow(igeodesic_coords(icurvature([r,s,t],[u]),ichr2)+
 
3731
                      igeodesic_coords(icurvature([s,t,r],[u]),ichr2)+
 
3732
                      igeodesic_coords(icurvature([t,r,s],[u]),ichr2))$
 
3733
                       u            u            u            u            u
 
3734
          (%t4) - ichr2      + ichr2      + ichr2      - ichr2      - ichr2
 
3735
                       t s,r        t r,s        s t,r        s r,t        r t,s
 
3736
 
 
3737
                                                                            u
 
3738
                                                                     + ichr2
 
3739
                                                                            r s,t
 
3740
          (%i5) canform(%);
 
3741
          (%o5)                                  0
 
3742
 
 
3743
 
 
3744
28.2.5 Moving frames
 
3745
--------------------
 
3746
 
 
3747
Maxima now has the ability to perform calculations using moving frames.
 
3748
These can be orthonormal frames (tetrads, vielbeins) or an arbitrary
 
3749
frame.
 
3750
 
 
3751
   To use frames, you must first set `iframe_flag' to `true'. This
 
3752
causes the Christoffel-symbols, `ichr1' and `ichr2', to be replaced by
 
3753
the more general frame connection coefficients `icc1' and `icc2' in
 
3754
calculations. Speficially, the behavior of `covdiff' and `icurvature'
 
3755
is changed.
 
3756
 
 
3757
   The frame is defined by two tensors: the inverse frame field (`ifri',
 
3758
the dual basis tetrad), and the frame metric `ifg'. The frame metric is
 
3759
the identity matrix for orthonormal frames, or the Lorentz metric for
 
3760
orthonormal frames in Minkowski spacetime. The inverse frame field
 
3761
defines the frame base (unit vectors).  Contraction properties are
 
3762
defined for the frame field and the frame metric.
 
3763
 
 
3764
   When `iframe_flag' is true, many `itensor' expressions use the frame
 
3765
metric `ifg' instead of the metric defined by `imetric' for raising and
 
3766
lowerind indices.
 
3767
 
 
3768
   IMPORTANT: Setting the variable `iframe_flag' to `true' does NOT
 
3769
undefine the contraction properties of a metric defined by a call to
 
3770
`defcon' or `imetric'. If a frame field is used, it is best to define
 
3771
the metric by assigning its name to the variable `imetric' and NOT
 
3772
invoke the `imetric' function.
 
3773
 
 
3774
   Maxima uses these two tensors to define the frame coefficients
 
3775
(`ifc1' and `ifc2') which form part of the connection coefficients
 
3776
(`icc1' and `icc2'), as the following example demonstrates:
 
3777
 
 
3778
 
 
3779
     (%i1) load(itensor);
 
3780
     (%o1)      /share/tensor/itensor.lisp
 
3781
     (%i2) iframe_flag:true;
 
3782
     (%o2)                                true
 
3783
     (%i3) ishow(covdiff(v([],[i]),j))$
 
3784
                                    i        i     %1
 
3785
     (%t3)                         v   + icc2     v
 
3786
                                    ,j       %1 j
 
3787
     (%i4) ishow(ev(%,icc2))$
 
3788
                             %1      i           i        i
 
3789
     (%t4)                  v   (ifc2     + ichr2    ) + v
 
3790
                                     %1 j        %1 j     ,j
 
3791
     (%i5) ishow(ev(%,ifc2))$
 
3792
                 %1    i %2
 
3793
                v   ifg     (ifb        - ifb        + ifb       )
 
3794
                                j %2 %1      %2 %1 j      %1 j %2     i
 
3795
     (%t5)      -------------------------------------------------- + v
 
3796
                                        2                             ,j
 
3797
     (%i6) ishow(ifb([a,b,c]))$
 
3798
                            %5    %4
 
3799
     (%t6)               ifr   ifr   (ifri        - ifri       )
 
3800
                            a     b       c %4,%5       c %5,%4
 
3801
 
 
3802
   An alternate method is used to compute the frame bracket (`ifb') if
 
3803
the `iframe_bracket_form' flag is set to `false':
 
3804
 
 
3805
 
 
3806
     (%i8) block([iframe_bracket_form:false],ishow(ifb([a,b,c])))$
 
3807
                            %7    %6        %6      %7
 
3808
     (%t8)              (ifr   ifr     - ifr     ifr  ) ifri
 
3809
                            a     b,%7      a,%7    b       c %6
 
3810
 
 
3811
 -- Function: iframes ()
 
3812
     Since in this version of Maxima, contraction identities for `ifr'
 
3813
     and `ifri' are always defined, as is the frame bracket (`ifb'),
 
3814
     this function does nothing.
 
3815
 
 
3816
 
 
3817
 -- Variable: ifb
 
3818
     The frame bracket. The contribution of the frame metric to the
 
3819
     connection coefficients is expressed using the frame bracket:
 
3820
 
 
3821
 
 
3822
                    - ifb      + ifb      + ifb
 
3823
                         c a b      b c a      a b c
 
3824
          ifc1    = --------------------------------
 
3825
              abc                  2
 
3826
 
 
3827
     The frame bracket itself is defined in terms of the frame field
 
3828
     and frame metric. Two alternate methods of computation are used
 
3829
     depending on the value of `frame_bracket_form'. If true (the
 
3830
     default) or if the `itorsion_flag' is `true':
 
3831
 
 
3832
 
 
3833
                    d      e                                      f
 
3834
          ifb =  ifr    ifr   (ifri      - ifri      - ifri    itr   )
 
3835
             abc    b      c       a d,e       a e,d       a f    d e
 
3836
 
 
3837
     Otherwise:
 
3838
 
 
3839
 
 
3840
                       e      d        d      e
 
3841
          ifb    = (ifr    ifr    - ifr    ifr   ) ifri
 
3842
             abc       b      c,e      b,e    c        a d
 
3843
 
 
3844
 
 
3845
 -- Variable: icc1
 
3846
     Connection coefficients of the first kind. In `itensor', defined as
 
3847
 
 
3848
 
 
3849
          icc1    = ichr1    - ikt1    - inmc1
 
3850
              abc        abc       abc        abc
 
3851
 
 
3852
     In this expression, if `iframe_flag' is true, the
 
3853
     Christoffel-symbol `ichr1' is replaced with the frame connection
 
3854
     coefficient `ifc1'.  If `itorsion_flag' is `false', `ikt1' will be
 
3855
     omitted. It is also omitted if a frame base is used, as the
 
3856
     torsion is already calculated as part of the frame bracket.
 
3857
     Lastly, of `inonmet_flag' is `false', `inmc1' will not be present.
 
3858
 
 
3859
 
 
3860
 -- Variable: icc2
 
3861
     Connection coefficients of the second kind. In `itensor', defined
 
3862
     as
 
3863
 
 
3864
 
 
3865
              c         c        c         c
 
3866
          icc2   = ichr2   - ikt2   - inmc2
 
3867
              ab        ab       ab        ab
 
3868
 
 
3869
     In this expression, if `iframe_flag' is true, the
 
3870
     Christoffel-symbol `ichr2' is replaced with the frame connection
 
3871
     coefficient `ifc2'.  If `itorsion_flag' is `false', `ikt2' will be
 
3872
     omitted. It is also omitted if a frame base is used, as the
 
3873
     torsion is already calculated as part of the frame bracket.
 
3874
     Lastly, of `inonmet_flag' is `false', `inmc2' will not be present.
 
3875
 
 
3876
 
 
3877
 -- Variable: ifc1
 
3878
     Frame coefficient of the first kind (also known as Ricci-rotation
 
3879
     coefficients.) This tensor represents the contribution of the
 
3880
     frame metric to the connection coefficient of the first kind.
 
3881
     Defined as:
 
3882
 
 
3883
 
 
3884
                    - ifb      + ifb      + ifb
 
3885
                         c a b      b c a      a b c
 
3886
          ifc1    = --------------------------------
 
3887
              abc                   2
 
3888
 
 
3889
 
 
3890
 -- Variable: ifc2
 
3891
     Frame coefficient of the first kind. This tensor represents the
 
3892
     contribution of the frame metric to the connection coefficient of
 
3893
     the first kind. Defined as a permutation of the frame bracket
 
3894
     (`ifb') with the appropriate indices raised and lowered as
 
3895
     necessary:
 
3896
 
 
3897
 
 
3898
              c       cd
 
3899
          ifc2   = ifg   ifc1
 
3900
              ab             abd
 
3901
 
 
3902
 
 
3903
 -- Variable: ifr
 
3904
     The frame field. Contracts with the inverse frame field (`ifri') to
 
3905
     form the frame metric (`ifg').
 
3906
 
 
3907
 
 
3908
 -- Variable: ifri
 
3909
     The inverse frame field. Specifies the frame base (dual basis
 
3910
     vectors). Along with the frame metric, it forms the basis of all
 
3911
     calculations based on frames.
 
3912
 
 
3913
 
 
3914
 -- Variable: ifg
 
3915
     The frame metric. Defaults to `kdelta', but can be changed using
 
3916
     `components'.
 
3917
 
 
3918
 
 
3919
 -- Variable: ifgi
 
3920
     The inverse frame metric. Contracts with the frame metric (`ifg')
 
3921
     to `kdelta'.
 
3922
 
 
3923
 
 
3924
 -- Option variable: iframe_bracket_form
 
3925
     Default value: `true'
 
3926
 
 
3927
     Specifies how the frame bracket (`ifb') is computed.
 
3928
 
 
3929
 
 
3930
28.2.6 Torsion and nonmetricity
 
3931
-------------------------------
 
3932
 
 
3933
Maxima can now take into account torsion and nonmetricity. When the flag
 
3934
`itorsion_flag' is set to `true', the contribution of torsion is added
 
3935
to the connection coefficients. Similarly, when the flag `inonmet_flag'
 
3936
is true, nonmetricity components are included.
 
3937
 
 
3938
 -- Variable: inm
 
3939
     The nonmetricity vector. Conformal nonmetricity is defined through
 
3940
     the covariant derivative of the metric tensor. Normally zero, the
 
3941
     metric tensor's covariant derivative will evaluate to the
 
3942
     following when `inonmet_flag' is set to `true':
 
3943
 
 
3944
 
 
3945
          g     =- g  inm
 
3946
           ij;k     ij   k
 
3947
 
 
3948
 
 
3949
 -- Variable: inmc1
 
3950
     Covariant permutation of the nonmetricity vector components.
 
3951
     Defined as
 
3952
 
 
3953
 
 
3954
                     g   inm  - inm  g   - g   inm
 
3955
                      ab    c      a  bc    ac    b
 
3956
          inmc1    = ------------------------------
 
3957
               abc                 2
 
3958
 
 
3959
     (Substitute `ifg' in place of `g' if a frame metric is used.)
 
3960
 
 
3961
 
 
3962
 -- Variable: inmc2
 
3963
     Contravariant permutation of the nonmetricity vector components.
 
3964
     Used in the connection coefficients if `inonmet_flag' is `true'.
 
3965
     Defined as:
 
3966
 
 
3967
 
 
3968
                                c         c         cd
 
3969
                    -inm  kdelta  - kdelta  inm  + g   inm  g
 
3970
               c        a       b         a    b          d  ab
 
3971
          inmc2   = -------------------------------------------
 
3972
               ab                        2
 
3973
 
 
3974
     (Substitute `ifg' in place of `g' if a frame metric is used.)
 
3975
 
 
3976
 
 
3977
 -- Variable: ikt1
 
3978
     Covariant permutation of the torsion tensor (also known as
 
3979
     contorsion).  Defined as:
 
3980
 
 
3981
 
 
3982
                            d           d       d
 
3983
                    -g   itr  - g    itr   - itr   g
 
3984
                      ad    cb    bd    ca      ab  cd
 
3985
          ikt1    = ----------------------------------
 
3986
              abc                   2
 
3987
 
 
3988
     (Substitute `ifg' in place of `g' if a frame metric is used.)
 
3989
 
 
3990
 
 
3991
 -- Variable: ikt2
 
3992
     Contravariant permutation of the torsion tensor (also known as
 
3993
     contorsion).  Defined as:
 
3994
 
 
3995
 
 
3996
              c     cd
 
3997
          ikt2   = g   ikt1
 
3998
              ab           abd
 
3999
 
 
4000
     (Substitute `ifg' in place of `g' if a frame metric is used.)
 
4001
 
 
4002
 
 
4003
 -- Variable: itr
 
4004
     The torsion tensor. For a metric with torsion, repeated covariant
 
4005
     differentiation on a scalar function will not commute, as
 
4006
     demonstrated by the following example:
 
4007
 
 
4008
 
 
4009
          (%i1) load(itensor);
 
4010
          (%o1)      /share/tensor/itensor.lisp
 
4011
          (%i2) imetric:g;
 
4012
          (%o2)                                  g
 
4013
          (%i3) covdiff(covdiff(f([],[]),i),j)-covdiff(covdiff(f([],[]),j),i)$
 
4014
          (%i4) ishow(%)$
 
4015
                                             %4              %2
 
4016
          (%t4)                    f    ichr2    - f    ichr2
 
4017
                                    ,%4      j i    ,%2      i j
 
4018
          (%i5) canform(%);
 
4019
          (%o5)                                  0
 
4020
          (%i6) itorsion_flag:true;
 
4021
          (%o6)                                true
 
4022
          (%i7) covdiff(covdiff(f([],[]),i),j)-covdiff(covdiff(f([],[]),j),i)$
 
4023
          (%i8) ishow(%)$
 
4024
                                     %8             %6
 
4025
          (%t8)             f    icc2    - f    icc2    - f     + f
 
4026
                             ,%8     j i    ,%6     i j    ,j i    ,i j
 
4027
          (%i9) ishow(canform(%))$
 
4028
                                             %1             %1
 
4029
          (%t9)                     f    icc2    - f    icc2
 
4030
                                     ,%1     j i    ,%1     i j
 
4031
          (%i10) ishow(canform(ev(%,icc2)))$
 
4032
                                             %1             %1
 
4033
          (%t10)                    f    ikt2    - f    ikt2
 
4034
                                     ,%1     i j    ,%1     j i
 
4035
          (%i11) ishow(canform(ev(%,ikt2)))$
 
4036
                                %2 %1                    %2 %1
 
4037
          (%t11)          f    g      ikt1       - f    g      ikt1
 
4038
                           ,%2            i j %1    ,%2            j i %1
 
4039
          (%i12) ishow(factor(canform(rename(expand(ev(%,ikt1))))))$
 
4040
                                     %3 %2            %1       %1
 
4041
                               f    g      g      (itr    - itr   )
 
4042
                                ,%3         %2 %1     j i      i j
 
4043
          (%t12)               ------------------------------------
 
4044
                                                2
 
4045
          (%i13) decsym(itr,2,1,[anti(all)],[]);
 
4046
          (%o13)                               done
 
4047
          (%i14) defcon(g,g,kdelta);
 
4048
          (%o14)                               done
 
4049
          (%i15) subst(g,nounify(g),%th(3))$
 
4050
          (%i16) ishow(canform(contract(%)))$
 
4051
                                                     %1
 
4052
          (%t16)                           - f    itr
 
4053
                                              ,%1    i j
 
4054
 
 
4055
 
 
4056
28.2.7 Exterior algebra
 
4057
-----------------------
 
4058
 
 
4059
The `itensor' package can perform operations on totally antisymmetric
 
4060
covariant tensor fields. A totally antisymmetric tensor field of rank
 
4061
(0,L) corresponds with a differential L-form. On these objects, a
 
4062
multiplication operation known as the exterior product, or wedge
 
4063
product, is defined.
 
4064
 
 
4065
   Unfortunately, not all authors agree on the definition of the wedge
 
4066
product. Some authors prefer a definition that corresponds with the
 
4067
notion of antisymmetrization: in these works, the wedge product of two
 
4068
vector fields, for instance, would be defined as
 
4069
 
 
4070
                 a a  - a a
 
4071
                  i j    j i
 
4072
      a  /\ a  = -----------
 
4073
       i     j        2
 
4074
 
 
4075
   More generally, the product of a p-form and a q-form would be
 
4076
defined as
 
4077
 
 
4078
                            1     k1..kp l1..lq
 
4079
     A       /\ B       = ------ D              A       B
 
4080
      i1..ip     j1..jq   (p+q)!  i1..ip j1..jq  k1..kp  l1..lq
 
4081
 
 
4082
   where `D' stands for the Kronecker-delta.
 
4083
 
 
4084
   Other authors, however, prefer a "geometric" definition that
 
4085
corresponds with the notion of the volume element:
 
4086
 
 
4087
     a  /\ a  = a a  - a a
 
4088
      i     j    i j    j i
 
4089
 
 
4090
   and, in the general case
 
4091
 
 
4092
                            1    k1..kp l1..lq
 
4093
     A       /\ B       = ----- D              A       B
 
4094
      i1..ip     j1..jq   p! q!  i1..ip j1..jq  k1..kp  l1..lq
 
4095
 
 
4096
   Since `itensor' is a tensor algebra package, the first of these two
 
4097
definitions appears to be the more natural one. Many applications,
 
4098
however, utilize the second definition. To resolve this dilemma, a flag
 
4099
has been implemented that controls the behavior of the wedge product: if
 
4100
`igeowedge_flag' is `false' (the default), the first, "tensorial"
 
4101
definition is used, otherwise the second, "geometric" definition will
 
4102
be applied.
 
4103
 
 
4104
 -- Operator: ~
 
4105
     The wedge product operator is denoted by the tilde `~'. This is a
 
4106
     binary operator. Its arguments should be expressions involving
 
4107
     scalars, covariant tensors of rank one, or covariant tensors of
 
4108
     rank `l' that have been declared antisymmetric in all covariant
 
4109
     indices.
 
4110
 
 
4111
     The behavior of the wedge product operator is controlled by the
 
4112
     `igeowedge_flag' flag, as in the following example:
 
4113
 
 
4114
          (%i1) load(itensor);
 
4115
          (%o1)      /share/tensor/itensor.lisp
 
4116
          (%i2) ishow(a([i])~b([j]))$
 
4117
                                           a  b  - b  a
 
4118
                                            i  j    i  j
 
4119
          (%t2)                            -------------
 
4120
                                                 2
 
4121
          (%i3) decsym(a,2,0,[anti(all)],[]);
 
4122
          (%o3)                                done
 
4123
          (%i4) ishow(a([i,j])~b([k]))$
 
4124
                                    a    b  + b  a    - a    b
 
4125
                                     i j  k    i  j k    i k  j
 
4126
          (%t4)                     ---------------------------
 
4127
                                                 3
 
4128
          (%i5) igeowedge_flag:true;
 
4129
          (%o5)                                true
 
4130
          (%i6) ishow(a([i])~b([j]))$
 
4131
          (%t6)                            a  b  - b  a
 
4132
                                            i  j    i  j
 
4133
          (%i7) ishow(a([i,j])~b([k]))$
 
4134
          (%t7)                     a    b  + b  a    - a    b
 
4135
                                     i j  k    i  j k    i k  j
 
4136
 
 
4137
 
 
4138
 -- Operator: |
 
4139
     The vertical bar `|' denotes the "contraction with a vector" binary
 
4140
     operation. When a totally antisymmetric covariant tensor is
 
4141
     contracted with a contravariant vector, the result is the same
 
4142
     regardless which index was used for the contraction. Thus, it is
 
4143
     possible to define the contraction operation in an index-free
 
4144
     manner.
 
4145
 
 
4146
     In the `itensor' package, contraction with a vector is always
 
4147
     carried out with respect to the first index in the literal sorting
 
4148
     order. This ensures better simplification of expressions involving
 
4149
     the `|' operator. For instance:
 
4150
 
 
4151
          (%i1) load(itensor);
 
4152
          (%o1)      /share/tensor/itensor.lisp
 
4153
          (%i2) decsym(a,2,0,[anti(all)],[]);
 
4154
          (%o2)                                done
 
4155
          (%i3) ishow(a([i,j],[])|v)$
 
4156
                                              %1
 
4157
          (%t3)                              v   a
 
4158
                                                  %1 j
 
4159
          (%i4) ishow(a([j,i],[])|v)$
 
4160
                                               %1
 
4161
          (%t4)                             - v   a
 
4162
                                                   %1 j
 
4163
 
 
4164
     Note that it is essential that the tensors used with the `|'
 
4165
     operator be declared totally antisymmetric in their covariant
 
4166
     indices. Otherwise, the results will be incorrect.
 
4167
 
 
4168
 
 
4169
 -- Function: extdiff (<expr>, <i>)
 
4170
     Computes the exterior derivative of <expr> with respect to the
 
4171
     index <i>. The exterior derivative is formally defined as the wedge
 
4172
     product of the partial derivative operator and a differential
 
4173
     form. As such, this operation is also controlled by the setting of
 
4174
     `igeowedge_flag'.  For instance:
 
4175
 
 
4176
          (%i1) load(itensor);
 
4177
          (%o1)      /share/tensor/itensor.lisp
 
4178
          (%i2) ishow(extdiff(v([i]),j))$
 
4179
                                            v    - v
 
4180
                                             j,i    i,j
 
4181
          (%t2)                             -----------
 
4182
                                                 2
 
4183
          (%i3) decsym(a,2,0,[anti(all)],[]);
 
4184
          (%o3)                                done
 
4185
          (%i4) ishow(extdiff(a([i,j]),k))$
 
4186
                                     a      - a      + a
 
4187
                                      j k,i    i k,j    i j,k
 
4188
          (%t4)                      ------------------------
 
4189
                                                3
 
4190
          (%i5) igeowedge_flag:true;
 
4191
          (%o5)                                true
 
4192
          (%i6) ishow(extdiff(v([i]),j))$
 
4193
          (%t6)                             v    - v
 
4194
                                             j,i    i,j
 
4195
          (%i7) ishow(extdiff(a([i,j]),k))$
 
4196
          (%t7)                      a      - a      + a
 
4197
                                      j k,i    i k,j    i j,k
 
4198
 
 
4199
 
 
4200
 -- Function: hodge (<expr>)
 
4201
     Compute the Hodge-dual of <expr>. For instance:
 
4202
 
 
4203
 
 
4204
          (%i1) load(itensor);
 
4205
          (%o1)      /share/tensor/itensor.lisp
 
4206
          (%i2) imetric(g);
 
4207
          (%o2)                            done
 
4208
          (%i3) idim(4);
 
4209
          (%o3)                            done
 
4210
          (%i4) icounter:100;
 
4211
          (%o4)                             100
 
4212
          (%i5) decsym(A,3,0,[anti(all)],[])$
 
4213
 
 
4214
          (%i6) ishow(A([i,j,k],[]))$
 
4215
          (%t6)                           A
 
4216
                                           i j k
 
4217
          (%i7) ishow(canform(hodge(%)))$
 
4218
                                    %1 %2 %3 %4
 
4219
                         levi_civita            g        A
 
4220
                                                 %1 %102  %2 %3 %4
 
4221
          (%t7)          -----------------------------------------
 
4222
                                             6
 
4223
          (%i8) ishow(canform(hodge(%)))$
 
4224
                           %1 %2 %3 %8            %4 %5 %6 %7
 
4225
          (%t8) levi_civita            levi_civita            g        g
 
4226
                                                               %1 %106  %2 %107
 
4227
                                                      g        g      A        /6
 
4228
                                                       %3 %108  %4 %8  %5 %6 %7
 
4229
          (%i9) lc2kdt(%)$
 
4230
 
 
4231
          (%i10) %,kdelta$
 
4232
 
 
4233
          (%i11) ishow(canform(contract(expand(%))))$
 
4234
          (%t11)                     - A
 
4235
                                        %106 %107 %108
 
4236
 
 
4237
 
 
4238
 -- Option variable: igeowedge_flag
 
4239
     Default value: `false'
 
4240
 
 
4241
     Controls the behavior of the wedge product and exterior
 
4242
     derivative. When set to `false' (the default), the notion of
 
4243
     differential forms will correspond with that of a totally
 
4244
     antisymmetric covariant tensor field.  When set to `true',
 
4245
     differential forms will agree with the notion of the volume
 
4246
     element.
 
4247
 
 
4248
 
 
4249
28.2.8 Exporting TeX expressions
 
4250
--------------------------------
 
4251
 
 
4252
The `itensor' package provides limited support for exporting tensor
 
4253
expressions to TeX. Since `itensor' expressions appear as function
 
4254
calls, the regular Maxima `tex' command will not produce the expected
 
4255
output. You can try instead the `tentex' command, which attempts to
 
4256
translate tensor expressions into appropriately indexed TeX objects.
 
4257
 
 
4258
 -- Function: tentex (<expr>)
 
4259
     To use the `tentex' function, you must first load `tentex', as in
 
4260
     the following example:
 
4261
 
 
4262
 
 
4263
          (%i1) load(itensor);
 
4264
          (%o1)      /share/tensor/itensor.lisp
 
4265
          (%i2) load(tentex);
 
4266
          (%o2)       /share/tensor/tentex.lisp
 
4267
          (%i3) idummyx:m;
 
4268
          (%o3)                                  m
 
4269
          (%i4) ishow(icurvature([j,k,l],[i]))$
 
4270
                      m1       i           m1       i           i            i
 
4271
          (%t4)  ichr2    ichr2     - ichr2    ichr2     - ichr2      + ichr2
 
4272
                      j k      m1 l        j l      m1 k        j l,k        j k,l
 
4273
          (%i5) tentex(%)$
 
4274
          $$\Gamma_{j\,k}^{m_1}\,\Gamma_{l\,m_1}^{i}-\Gamma_{j\,l}^{m_1}\,
 
4275
           \Gamma_{k\,m_1}^{i}-\Gamma_{j\,l,k}^{i}+\Gamma_{j\,k,l}^{i}$$
 
4276
 
 
4277
     Note the use of the `idummyx' assignment, to avoid the appearance
 
4278
     of the percent sign in the TeX expression, which may lead to
 
4279
     compile errors.
 
4280
 
 
4281
     NB: This version of the `tentex' function is somewhat experimental.
 
4282
 
 
4283
 
 
4284
28.2.9 Interfacing with ctensor
 
4285
-------------------------------
 
4286
 
 
4287
The `itensor' package has the ability to generate Maxima code that can
 
4288
then be executed in the context of the `ctensor' package. The function
 
4289
that performs this task is `ic_convert'.
 
4290
 
 
4291
 -- Function: ic_convert (<eqn>)
 
4292
     Converts the `itensor' equation <eqn> to a `ctensor' assignment
 
4293
     statement.  Implied sums over dummy indices are made explicit
 
4294
     while indexed objects are transformed into arrays (the array
 
4295
     subscripts are in the order of covariant followed by contravariant
 
4296
     indices of the indexed objects). The derivative of an indexed
 
4297
     object will be replaced by the noun form of `diff' taken with
 
4298
     respect to `ct_coords' subscripted by the derivative index. The
 
4299
     Christoffel symbols `ichr1' and `ichr2' will be translated to
 
4300
     `lcs' and `mcs', respectively and if `metricconvert' is `true'
 
4301
     then all occurrences of the metric with two covariant
 
4302
     (contravariant) indices will be renamed to `lg' (`ug'). In
 
4303
     addition, `do' loops will be introduced summing over all free
 
4304
     indices so that the transformed assignment statement can be
 
4305
     evaluated by just doing `ev'. The following examples demonstrate
 
4306
     the features of this function.
 
4307
 
 
4308
          (%i1) load(itensor);
 
4309
          (%o1)      /share/tensor/itensor.lisp
 
4310
          (%i2) eqn:ishow(t([i,j],[k])=f([],[])*g([l,m],[])*a([],[m],j)*b([i],[l,k]))$
 
4311
                                       k        m   l k
 
4312
          (%t2)                       t    = f a   b    g
 
4313
                                       i j      ,j  i    l m
 
4314
          (%i3) ic_convert(eqn);
 
4315
          (%o3) for i thru dim do (for j thru dim
 
4316
 
 
4317
          do (for k thru dim do t        : f sum(sum(diff(a , ct_coords ) b
 
4318
                                 i, j, k                   m           j   i, l, k
 
4319
 
 
4320
           g    , l, 1, dim), m, 1, dim)))
 
4321
            l, m
 
4322
          (%i4) imetric(g);
 
4323
          (%o4)                                done
 
4324
          (%i5) metricconvert:true;
 
4325
          (%o5)                                true
 
4326
          (%i6) ic_convert(eqn);
 
4327
          (%o6) for i thru dim do (for j thru dim
 
4328
 
 
4329
          do (for k thru dim do t        : f sum(sum(diff(a , ct_coords ) b
 
4330
                                 i, j, k                   m           j   i, l, k
 
4331
 
 
4332
           lg    , l, 1, dim), m, 1, dim)))
 
4333
             l, m
 
4334
 
 
4335
 
 
4336
28.2.10 Reserved words
 
4337
----------------------
 
4338
 
 
4339
The following Maxima words are used by the `itensor' package internally
 
4340
and should not be redefined:
 
4341
 
 
4342
       Keyword    Comments
 
4343
       ------------------------------------------
 
4344
       indices2() Internal version of indices()
 
4345
       conti      Lists contravariant indices
 
4346
       covi       Lists covariant indices of a indexed object
 
4347
       deri       Lists derivative indices of an indexed object
 
4348
       name       Returns the name of an indexed object
 
4349
       concan
 
4350
       irpmon
 
4351
       lc0
 
4352
       _lc2kdt0
 
4353
       _lcprod
 
4354
       _extlc
 
4355
 
 
4356
 
 
4357
File: maxima.info,  Node: ctensor,  Next: atensor,  Prev: itensor,  Up: Top
 
4358
 
 
4359
29 ctensor
 
4360
**********
 
4361
 
 
4362
* Menu:
 
4363
 
 
4364
* Introduction to ctensor::
 
4365
* Definitions for ctensor::
 
4366
 
 
4367
 
 
4368
File: maxima.info,  Node: Introduction to ctensor,  Next: Definitions for ctensor,  Prev: ctensor,  Up: ctensor
 
4369
 
 
4370
29.1 Introduction to ctensor
 
4371
============================
 
4372
 
 
4373
`ctensor' is a component tensor manipulation package.  To use the
 
4374
`ctensor' package, type `load(ctensor)'.  To begin an interactive
 
4375
session with `ctensor', type `csetup()'.  You are first asked to
 
4376
specify the dimension of the manifold. If the dimension is 2, 3 or 4
 
4377
then the list of coordinates defaults to `[x,y]', `[x,y,z]' or
 
4378
`[x,y,z,t]' respectively.  These names may be changed by assigning a
 
4379
new list of coordinates to the variable `ct_coords' (described below)
 
4380
and the user is queried about this. Care must be taken to avoid the
 
4381
coordinate names conflicting with other object definitions.
 
4382
 
 
4383
   Next, the user enters the metric either directly or from a file by
 
4384
specifying its ordinal position.  The metric is stored in the matrix
 
4385
`lg'. Finally, the metric inverse is computed and stored in the matrix
 
4386
`ug'. One has the option of carrying out all calculations in a power
 
4387
series.
 
4388
 
 
4389
   A sample protocol is begun below for the static, spherically
 
4390
symmetric metric (standard coordinates) which will be applied to the
 
4391
problem of deriving Einstein's vacuum equations (which lead to the
 
4392
Schwarzschild solution) as an example. Many of the functions in
 
4393
`ctensor' will be displayed for the standard metric as examples.
 
4394
 
 
4395
     (%i1) load(ctensor);
 
4396
     (%o1)      /share/tensor/ctensor.mac
 
4397
     (%i2) csetup();
 
4398
     Enter the dimension of the coordinate system:
 
4399
     4;
 
4400
     Do you wish to change the coordinate names?
 
4401
     n;
 
4402
     Do you want to
 
4403
     1. Enter a new metric?
 
4404
 
 
4405
     2. Enter a metric from a file?
 
4406
 
 
4407
     3. Approximate a metric with a Taylor series?
 
4408
     1;
 
4409
 
 
4410
     Is the matrix  1. Diagonal  2. Symmetric  3. Antisymmetric  4. General
 
4411
     Answer 1, 2, 3 or 4
 
4412
     1;
 
4413
     Row 1 Column 1:
 
4414
     a;
 
4415
     Row 2 Column 2:
 
4416
     x^2;
 
4417
     Row 3 Column 3:
 
4418
     x^2*sin(y)^2;
 
4419
     Row 4 Column 4:
 
4420
     -d;
 
4421
 
 
4422
     Matrix entered.
 
4423
     Enter functional dependencies with the DEPENDS function or 'N' if none
 
4424
     depends([a,d],x);
 
4425
     Do you wish to see the metric?
 
4426
     y;
 
4427
                               [ a  0       0        0  ]
 
4428
                               [                        ]
 
4429
                               [     2                  ]
 
4430
                               [ 0  x       0        0  ]
 
4431
                               [                        ]
 
4432
                               [         2    2         ]
 
4433
                               [ 0  0   x  sin (y)   0  ]
 
4434
                               [                        ]
 
4435
                               [ 0  0       0       - d ]
 
4436
     (%o2)                                done
 
4437
     (%i3) christof(mcs);
 
4438
                                                 a
 
4439
                                                  x
 
4440
     (%t3)                          mcs        = ---
 
4441
                                       1, 1, 1   2 a
 
4442
 
 
4443
                                                  1
 
4444
     (%t4)                           mcs        = -
 
4445
                                        1, 2, 2   x
 
4446
 
 
4447
                                                  1
 
4448
     (%t5)                           mcs        = -
 
4449
                                        1, 3, 3   x
 
4450
 
 
4451
                                                 d
 
4452
                                                  x
 
4453
     (%t6)                          mcs        = ---
 
4454
                                       1, 4, 4   2 d
 
4455
 
 
4456
                                                   x
 
4457
     (%t7)                          mcs        = - -
 
4458
                                       2, 2, 1     a
 
4459
 
 
4460
                                                cos(y)
 
4461
     (%t8)                         mcs        = ------
 
4462
                                      2, 3, 3   sin(y)
 
4463
 
 
4464
                                                    2
 
4465
                                               x sin (y)
 
4466
     (%t9)                      mcs        = - ---------
 
4467
                                   3, 3, 1         a
 
4468
 
 
4469
     (%t10)                   mcs        = - cos(y) sin(y)
 
4470
                                 3, 3, 2
 
4471
 
 
4472
                                                 d
 
4473
                                                  x
 
4474
     (%t11)                         mcs        = ---
 
4475
                                       4, 4, 1   2 a
 
4476
     (%o11)                               done
 
4477
 
 
4478
 
 
4479
File: maxima.info,  Node: Definitions for ctensor,  Prev: Introduction to ctensor,  Up: ctensor
 
4480
 
 
4481
29.2 Definitions for ctensor
 
4482
============================
 
4483
 
 
4484
29.2.1 Initialization and setup
 
4485
-------------------------------
 
4486
 
 
4487
 -- Function: csetup ()
 
4488
     A function in the `ctensor' (component tensor) package which
 
4489
     initializes the package and allows the user to enter a metric
 
4490
     interactively. See `ctensor' for more details.
 
4491
 
 
4492
 -- Function: cmetric (<dis>)
 
4493
 -- Function: cmetric ()
 
4494
     A function in the `ctensor' (component tensor) package that
 
4495
     computes the metric inverse and sets up the package for further
 
4496
     calculations.
 
4497
 
 
4498
     If `cframe_flag' is false, the function computes the inverse metric
 
4499
     `ug' from the (user-defined) matrix `lg'. The metric determinant is
 
4500
     also computed and stored in the variable `gdet'. Furthermore, the
 
4501
     package determines if the metric is diagonal and sets the value of
 
4502
     `diagmetric' accordingly. If the optional argument <dis> is
 
4503
     present and not equal to `false', the user is prompted to see the
 
4504
     metric inverse.
 
4505
 
 
4506
     If `cframe_flag' is `true', the function expects that the values of
 
4507
     `fri' (the inverse frame matrix) and `lfg' (the frame metric) are
 
4508
     defined. From these, the frame matrix `fr' and the inverse frame
 
4509
     metric `ufg' are computed.
 
4510
 
 
4511
 
 
4512
 -- Function: ct_coordsys (<coordinate_system>, <extra_arg>)
 
4513
 -- Function: ct_coordsys (<coordinate_system>)
 
4514
     Sets up a predefined coordinate system and metric. The argument
 
4515
     <coordinate_system> can be one of the following symbols:
 
4516
 
 
4517
 
 
4518
            SYMBOL               Dim Coordinates       Description/comments
 
4519
            --------------------------------------------------------------------------
 
4520
            cartesian2d           2  [x,y]             Cartesian 2D coordinate system
 
4521
            polar                 2  [r,phi]           Polar coordinate system
 
4522
            elliptic              2  [u,v]             Elliptic coordinate system
 
4523
            confocalelliptic      2  [u,v]             Confocal elliptic coordinates
 
4524
            bipolar               2  [u,v]             Bipolar coordinate system
 
4525
            parabolic             2  [u,v]             Parabolic coordinate system
 
4526
            cartesian3d           3  [x,y,z]           Cartesian 3D coordinate system
 
4527
            polarcylindrical      3  [r,theta,z]       Polar 2D with cylindrical z
 
4528
            ellipticcylindrical   3  [u,v,z]           Elliptic 2D with cylindrical z
 
4529
            confocalellipsoidal   3  [u,v,w]           Confocal ellipsoidal
 
4530
            bipolarcylindrical    3  [u,v,z]           Bipolar 2D with cylindrical z
 
4531
            paraboliccylindrical  3  [u,v,z]           Parabolic 2D with cylindrical z
 
4532
            paraboloidal          3  [u,v,phi]         Paraboloidal coordinates
 
4533
            conical               3  [u,v,w]           Conical coordinates
 
4534
            toroidal              3  [u,v,phi]         Toroidal coordinates
 
4535
            spherical             3  [r,theta,phi]     Spherical coordinate system
 
4536
            oblatespheroidal      3  [u,v,phi]         Oblate spheroidal coordinates
 
4537
            oblatespheroidalsqrt  3  [u,v,phi]
 
4538
            prolatespheroidal     3  [u,v,phi]         Prolate spheroidal coordinates
 
4539
            prolatespheroidalsqrt 3  [u,v,phi]
 
4540
            ellipsoidal           3  [r,theta,phi]     Ellipsoidal coordinates
 
4541
            cartesian4d           4  [x,y,z,t]         Cartesian 4D coordinate system
 
4542
            spherical4d           4  [r,theta,eta,phi] Spherical 4D coordinate system
 
4543
            exteriorschwarzschild 4  [t,r,theta,phi]   Schwarzschild metric
 
4544
            interiorschwarzschild 4  [t,z,u,v]         Interior Schwarzschild metric
 
4545
            kerr_newman           4  [t,r,theta,phi]   Charged axially symmetric metric
 
4546
 
 
4547
     `coordinate_system' can also be a list of transformation functions,
 
4548
     followed by a list containing the coordinate variables. For
 
4549
     instance, you can specify a spherical metric as follows:
 
4550
 
 
4551
 
 
4552
          (%i1) load(ctensor);
 
4553
          (%o1)       /share/tensor/ctensor.mac
 
4554
          (%i2) ct_coordsys([r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),
 
4555
                r*sin(theta),[r,theta,phi]]);
 
4556
          (%o2)                                done
 
4557
          (%i3) lg:trigsimp(lg);
 
4558
                                     [ 1  0         0        ]
 
4559
                                     [                       ]
 
4560
                                     [     2                 ]
 
4561
          (%o3)                      [ 0  r         0        ]
 
4562
                                     [                       ]
 
4563
                                     [         2    2        ]
 
4564
                                     [ 0  0   r  cos (theta) ]
 
4565
          (%i4) ct_coords;
 
4566
          (%o4)                           [r, theta, phi]
 
4567
          (%i5) dim;
 
4568
          (%o5)                                  3
 
4569
 
 
4570
     Transformation functions can also be used when `cframe_flag' is
 
4571
     `true':
 
4572
 
 
4573
 
 
4574
          (%i1) load(ctensor);
 
4575
          (%o1)       /share/tensor/ctensor.mac
 
4576
          (%i2) cframe_flag:true;
 
4577
          (%o2)                                true
 
4578
          (%i3) ct_coordsys([r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),
 
4579
                r*sin(theta),[r,theta,phi]]);
 
4580
          (%o3)                                done
 
4581
          (%i4) fri;
 
4582
                [ cos(phi) cos(theta)  - cos(phi) r sin(theta)  - sin(phi) r cos(theta) ]
 
4583
                [                                                                       ]
 
4584
          (%o4) [ sin(phi) cos(theta)  - sin(phi) r sin(theta)   cos(phi) r cos(theta)  ]
 
4585
                [                                                                       ]
 
4586
                [     sin(theta)            r cos(theta)                   0            ]
 
4587
          (%i5) cmetric();
 
4588
          (%o5)                                false
 
4589
          (%i6) lg:trigsimp(lg);
 
4590
                                     [ 1  0         0        ]
 
4591
                                     [                       ]
 
4592
                                     [     2                 ]
 
4593
          (%o6)                      [ 0  r         0        ]
 
4594
                                     [                       ]
 
4595
                                     [         2    2        ]
 
4596
                                     [ 0  0   r  cos (theta) ]
 
4597
 
 
4598
     The optional argument <extra_arg> can be any one of the following:
 
4599
 
 
4600
     `cylindrical' tells `ct_coordsys' to attach an additional
 
4601
     cylindrical coordinate.
 
4602
 
 
4603
     `minkowski' tells `ct_coordsys' to attach an additional coordinate
 
4604
     with negative metric signature.
 
4605
 
 
4606
     `all' tells `ct_coordsys' to call `cmetric' and `christof(false)'
 
4607
     after setting up the metric.
 
4608
 
 
4609
     If the global variable `verbose' is set to `true', `ct_coordsys'
 
4610
     displays the values of `dim', `ct_coords', and either `lg' or
 
4611
     `lfg' and `fri', depending on the value of `cframe_flag'.
 
4612
 
 
4613
 
 
4614
 -- Function: init_ctensor ()
 
4615
     Initializes the `ctensor' package.
 
4616
 
 
4617
     The `init_ctensor' function reinitializes the `ctensor' package.
 
4618
     It removes all arrays and matrices used by `ctensor', resets all
 
4619
     flags, resets `dim' to 4, and resets the frame metric to the
 
4620
     Lorentz-frame.
 
4621
 
 
4622
 
 
4623
29.2.2 The tensors of curved space
 
4624
----------------------------------
 
4625
 
 
4626
The main purpose of the `ctensor' package is to compute the tensors of
 
4627
curved space(time), most notably the tensors used in general relativity.
 
4628
 
 
4629
   When a metric base is used, `ctensor' can compute the following
 
4630
tensors:
 
4631
 
 
4632
 
 
4633
      lg  -- ug
 
4634
        \      \
 
4635
         lcs -- mcs -- ric -- uric
 
4636
                   \      \       \
 
4637
                    \      tracer - ein -- lein
 
4638
                     \
 
4639
                      riem -- lriem -- weyl
 
4640
                          \
 
4641
                           uriem
 
4642
 
 
4643
   `ctensor' can also work using moving frames. When `cframe_flag' is
 
4644
set to `true', the following tensors can be calculated:
 
4645
 
 
4646
 
 
4647
      lfg -- ufg
 
4648
          \
 
4649
      fri -- fr -- lcs -- mcs -- lriem -- ric -- uric
 
4650
           \                       |  \      \       \
 
4651
            lg -- ug               |   weyl   tracer - ein -- lein
 
4652
                                   |\
 
4653
                                   | riem
 
4654
                                   |
 
4655
                                   \uriem
 
4656
 
 
4657
 -- Function: christof (<dis>)
 
4658
     A function in the `ctensor' (component tensor) package.  It
 
4659
     computes the Christoffel symbols of both kinds.  The argument
 
4660
     <dis> determines which results are to be immediately displayed.
 
4661
     The Christoffel symbols of the first and second kinds are stored
 
4662
     in the arrays `lcs[i,j,k]' and `mcs[i,j,k]' respectively and
 
4663
     defined to be symmetric in the first two indices. If the argument
 
4664
     to `christof' is `lcs' or `mcs' then the unique non-zero values of
 
4665
     `lcs[i,j,k]' or `mcs[i,j,k]', respectively, will be displayed. If
 
4666
     the argument is `all' then the unique non-zero values of
 
4667
     `lcs[i,j,k]' and `mcs[i,j,k]' will be displayed.  If the argument
 
4668
     is `false' then the display of the elements will not occur. The
 
4669
     array elements `mcs[i,j,k]' are defined in such a manner that the
 
4670
     final index is contravariant.
 
4671
 
 
4672
 
 
4673
 -- Function: ricci (<dis>)
 
4674
     A function in the `ctensor' (component tensor) package. `ricci'
 
4675
     computes the covariant (symmetric) components `ric[i,j]' of the
 
4676
     Ricci tensor.  If the argument <dis> is `true', then the non-zero
 
4677
     components are displayed.
 
4678
 
 
4679
 
 
4680
 -- Function: uricci (<dis>)
 
4681
     This function first computes the covariant components `ric[i,j]'
 
4682
     of the Ricci tensor.  Then the mixed Ricci tensor is computed
 
4683
     using the contravariant metric tensor.  If the value of the
 
4684
     argument <dis> is `true', then these mixed components, `uric[i,j]'
 
4685
     (the index `i' is covariant and the index `j' is contravariant),
 
4686
     will be displayed directly.  Otherwise, `ricci(false)' will simply
 
4687
     compute the entries of the array `uric[i,j]' without displaying
 
4688
     the results.
 
4689
 
 
4690
 
 
4691
 -- Function: scurvature ()
 
4692
     Returns the scalar curvature (obtained by contracting the Ricci
 
4693
     tensor) of the Riemannian manifold with the given metric.
 
4694
 
 
4695
 
 
4696
 -- Function: einstein (<dis>)
 
4697
     A function in the `ctensor' (component tensor) package.
 
4698
     `einstein' computes the mixed Einstein tensor after the
 
4699
     Christoffel symbols and Ricci tensor have been obtained (with the
 
4700
     functions `christof' and `ricci').  If the argument <dis> is
 
4701
     `true', then the non-zero values of the mixed Einstein tensor
 
4702
     `ein[i,j]' will be displayed where `j' is the contravariant index.
 
4703
     The variable `rateinstein' will cause the rational simplification
 
4704
     on these components. If `ratfac' is `true' then the components will
 
4705
     also be factored.
 
4706
 
 
4707
 
 
4708
 -- Function: leinstein (<dis>)
 
4709
     Covariant Einstein-tensor. `leinstein' stores the values of the
 
4710
     covariant Einstein tensor in the array `lein'. The covariant
 
4711
     Einstein-tensor is computed from the mixed Einstein tensor `ein'
 
4712
     by multiplying it with the metric tensor. If the argument <dis> is
 
4713
     `true', then the non-zero values of the covariant Einstein tensor
 
4714
     are displayed.
 
4715
 
 
4716
 
 
4717
 -- Function: riemann (<dis>)
 
4718
     A function in the `ctensor' (component tensor) package.  `riemann'
 
4719
     computes the Riemann curvature tensor from the given metric and
 
4720
     the corresponding Christoffel symbols. The following index
 
4721
     conventions are used:
 
4722
 
 
4723
                          l      _l       _l       _l   _m    _l   _m
 
4724
           R[i,j,k,l] =  R    = |      - |      + |    |   - |    |
 
4725
                          ijk     ij,k     ik,j     mk   ij    mj   ik
 
4726
 
 
4727
     This notation is consistent with the notation used by the `itensor'
 
4728
     package and its `icurvature' function.  If the optional argument
 
4729
     <dis> is `true', the non-zero components `riem[i,j,k,l]' will be
 
4730
     displayed.  As with the Einstein tensor, various switches set by
 
4731
     the user control the simplification of the components of the
 
4732
     Riemann tensor.  If `ratriemann' is `true', then rational
 
4733
     simplification will be done. If `ratfac' is `true' then each of
 
4734
     the components will also be factored.
 
4735
 
 
4736
     If the variable `cframe_flag' is `false', the Riemann tensor is
 
4737
     computed directly from the Christoffel-symbols. If `cframe_flag' is
 
4738
     `true', the covariant Riemann-tensor is computed first from the
 
4739
     frame field coefficients.
 
4740
 
 
4741
 
 
4742
 -- Function: lriemann (<dis>)
 
4743
     Covariant Riemann-tensor (`lriem[]').
 
4744
 
 
4745
     Computes the covariant Riemann-tensor as the array `lriem'. If the
 
4746
     argument <dis> is `true', unique nonzero values are displayed.
 
4747
 
 
4748
     If the variable `cframe_flag' is `true', the covariant Riemann
 
4749
     tensor is computed directly from the frame field coefficients.
 
4750
     Otherwise, the (3,1) Riemann tensor is computed first.
 
4751
 
 
4752
     For information on index ordering, see `riemann'.
 
4753
 
 
4754
 
 
4755
 -- Function: uriemann (<dis>)
 
4756
     Computes the contravariant components of the Riemann curvature
 
4757
     tensor as array elements `uriem[i,j,k,l]'.  These are displayed if
 
4758
     <dis> is `true'.
 
4759
 
 
4760
 
 
4761
 -- Function: rinvariant ()
 
4762
     Forms the Kretchmann-invariant (`kinvariant') obtained by
 
4763
     contracting the tensors
 
4764
 
 
4765
          lriem[i,j,k,l]*uriem[i,j,k,l].
 
4766
 
 
4767
     This object is not automatically simplified since it can be very
 
4768
     large.
 
4769
 
 
4770
 
 
4771
 -- Function: weyl (<dis>)
 
4772
     Computes the Weyl conformal tensor.  If the argument <dis> is
 
4773
     `true', the non-zero components `weyl[i,j,k,l]' will be displayed
 
4774
     to the user.  Otherwise, these components will simply be computed
 
4775
     and stored.  If the switch `ratweyl' is set to `true', then the
 
4776
     components will be rationally simplified; if `ratfac' is `true'
 
4777
     then the results will be factored as well.
 
4778
 
 
4779
 
 
4780
29.2.3 Taylor series expansion
 
4781
------------------------------
 
4782
 
 
4783
The `ctensor' package has the ability to truncate results by assuming
 
4784
that they are Taylor-series approximations. This behavior is controlled
 
4785
by the `ctayswitch' variable; when set to true, `ctensor' makes use
 
4786
internally of the function `ctaylor' when simplifying results.
 
4787
 
 
4788
   The `ctaylor' function is invoked by the following `ctensor'
 
4789
functions:
 
4790
 
 
4791
 
 
4792
         Function     Comments
 
4793
         ---------------------------------
 
4794
         christof()   For mcs only
 
4795
         ricci()
 
4796
         uricci()
 
4797
         einstein()
 
4798
         riemann()
 
4799
         weyl()
 
4800
         checkdiv()
 
4801
 
 
4802
 -- Function: ctaylor ()
 
4803
     The `ctaylor' function truncates its argument by converting it to
 
4804
     a Taylor-series using `taylor', and then calling `ratdisrep'. This
 
4805
     has the combined effect of dropping terms higher order in the
 
4806
     expansion variable `ctayvar'. The order of terms that should be
 
4807
     dropped is defined by `ctaypov'; the point around which the series
 
4808
     expansion is carried out is specified in `ctaypt'.
 
4809
 
 
4810
     As an example, consider a simple metric that is a perturbation of
 
4811
     the Minkowski metric. Without further restrictions, even a diagonal
 
4812
     metric produces expressions for the Einstein tensor that are far
 
4813
     too complex:
 
4814
 
 
4815
 
 
4816
          (%i1) load(ctensor);
 
4817
          (%o1)       /share/tensor/ctensor.mac
 
4818
          (%i2) ratfac:true;
 
4819
          (%o2)                                true
 
4820
          (%i3) derivabbrev:true;
 
4821
          (%o3)                                true
 
4822
          (%i4) ct_coords:[t,r,theta,phi];
 
4823
          (%o4)                         [t, r, theta, phi]
 
4824
          (%i5) lg:matrix([-1,0,0,0],[0,1,0,0],[0,0,r^2,0],[0,0,0,r^2*sin(theta)^2]);
 
4825
                                  [ - 1  0  0         0        ]
 
4826
                                  [                            ]
 
4827
                                  [  0   1  0         0        ]
 
4828
                                  [                            ]
 
4829
          (%o5)                   [          2                 ]
 
4830
                                  [  0   0  r         0        ]
 
4831
                                  [                            ]
 
4832
                                  [              2    2        ]
 
4833
                                  [  0   0  0   r  sin (theta) ]
 
4834
          (%i6) h:matrix([h11,0,0,0],[0,h22,0,0],[0,0,h33,0],[0,0,0,h44]);
 
4835
                                      [ h11   0    0    0  ]
 
4836
                                      [                    ]
 
4837
                                      [  0   h22   0    0  ]
 
4838
          (%o6)                       [                    ]
 
4839
                                      [  0    0   h33   0  ]
 
4840
                                      [                    ]
 
4841
                                      [  0    0    0   h44 ]
 
4842
          (%i7) depends(l,r);
 
4843
          (%o7)                               [l(r)]
 
4844
          (%i8) lg:lg+l*h;
 
4845
                   [ h11 l - 1      0          0                 0            ]
 
4846
                   [                                                          ]
 
4847
                   [     0      h22 l + 1      0                 0            ]
 
4848
                   [                                                          ]
 
4849
          (%o8)    [                        2                                 ]
 
4850
                   [     0          0      r  + h33 l            0            ]
 
4851
                   [                                                          ]
 
4852
                   [                                    2    2                ]
 
4853
                   [     0          0          0       r  sin (theta) + h44 l ]
 
4854
          (%i9) cmetric(false);
 
4855
          (%o9)                                done
 
4856
          (%i10) einstein(false);
 
4857
          (%o10)                               done
 
4858
          (%i11) ntermst(ein);
 
4859
          [[1, 1], 62]
 
4860
          [[1, 2], 0]
 
4861
          [[1, 3], 0]
 
4862
          [[1, 4], 0]
 
4863
          [[2, 1], 0]
 
4864
          [[2, 2], 24]
 
4865
          [[2, 3], 0]
 
4866
          [[2, 4], 0]
 
4867
          [[3, 1], 0]
 
4868
          [[3, 2], 0]
 
4869
          [[3, 3], 46]
 
4870
          [[3, 4], 0]
 
4871
          [[4, 1], 0]
 
4872
          [[4, 2], 0]
 
4873
          [[4, 3], 0]
 
4874
          [[4, 4], 46]
 
4875
          (%o12)                               done
 
4876
 
 
4877
     However, if we recompute this example as an approximation that is
 
4878
     linear in the variable `l', we get much simpler expressions:
 
4879
 
 
4880
 
 
4881
          (%i14) ctayswitch:true;
 
4882
          (%o14)                               true
 
4883
          (%i15) ctayvar:l;
 
4884
          (%o15)                                 l
 
4885
          (%i16) ctaypov:1;
 
4886
          (%o16)                                 1
 
4887
          (%i17) ctaypt:0;
 
4888
          (%o17)                                 0
 
4889
          (%i18) christof(false);
 
4890
          (%o18)                               done
 
4891
          (%i19) ricci(false);
 
4892
          (%o19)                               done
 
4893
          (%i20) einstein(false);
 
4894
          (%o20)                               done
 
4895
          (%i21) ntermst(ein);
 
4896
          [[1, 1], 6]
 
4897
          [[1, 2], 0]
 
4898
          [[1, 3], 0]
 
4899
          [[1, 4], 0]
 
4900
          [[2, 1], 0]
 
4901
          [[2, 2], 13]
 
4902
          [[2, 3], 2]
 
4903
          [[2, 4], 0]
 
4904
          [[3, 1], 0]
 
4905
          [[3, 2], 2]
 
4906
          [[3, 3], 9]
 
4907
          [[3, 4], 0]
 
4908
          [[4, 1], 0]
 
4909
          [[4, 2], 0]
 
4910
          [[4, 3], 0]
 
4911
          [[4, 4], 9]
 
4912
          (%o21)                               done
 
4913
          (%i22) ratsimp(ein[1,1]);
 
4914
                                   2      2  4               2     2
 
4915
          (%o22) - (((h11 h22 - h11 ) (l )  r  - 2 h33 l    r ) sin (theta)
 
4916
                                        r               r r
 
4917
 
 
4918
                                          2               2      4    2
 
4919
                            - 2 h44 l    r  - h33 h44 (l ) )/(4 r  sin (theta))
 
4920
                                     r r                r
 
4921
 
 
4922
     This capability can be useful, for instance, when working in the
 
4923
     weak field limit far from a gravitational source.
 
4924
 
 
4925
 
 
4926
29.2.4 Frame fields
 
4927
-------------------
 
4928
 
 
4929
When the variable `cframe_flag' is set to true, the `ctensor' package
 
4930
performs its calculations using a moving frame.
 
4931
 
 
4932
 -- Function: frame_bracket (<fr>, <fri>, <diagframe>)
 
4933
     The frame bracket (`fb[]').
 
4934
 
 
4935
     Computes the frame bracket according to the following definition:
 
4936
 
 
4937
             c          c         c        d     e
 
4938
          ifb   = ( ifri    - ifri    ) ifr   ifr
 
4939
             ab         d,e       e,d      a     b
 
4940
 
 
4941
 
 
4942
29.2.5 Algebraic classification
 
4943
-------------------------------
 
4944
 
 
4945
A new feature (as of November, 2004) of `ctensor' is its ability to
 
4946
compute the Petrov classification of a 4-dimensional spacetime metric.
 
4947
For a demonstration of this capability, see the file
 
4948
`share/tensor/petrov.dem'.
 
4949
 
 
4950
 -- Function: nptetrad ()
 
4951
     Computes a Newman-Penrose null tetrad (`np') and its raised-index
 
4952
     counterpart (`npi'). See `petrov' for an example.
 
4953
 
 
4954
     The null tetrad is constructed on the assumption that a
 
4955
     four-diemensional orthonormal frame metric with metric signature
 
4956
     (-,+,+,+) is being used.  The components of the null tetrad are
 
4957
     related to the inverse frame matrix as follows:
 
4958
 
 
4959
 
 
4960
          np  = (fri  + fri ) / sqrt(2)
 
4961
            1       1      2
 
4962
 
 
4963
          np  = (fri  - fri ) / sqrt(2)
 
4964
            2       1      2
 
4965
 
 
4966
          np  = (fri  + %i fri ) / sqrt(2)
 
4967
            3       3         4
 
4968
 
 
4969
          np  = (fri  - %i fri ) / sqrt(2)
 
4970
            4       3         4
 
4971
 
 
4972
 
 
4973
 -- Function: psi (<dis>)
 
4974
     Computes the five Newman-Penrose coefficients `psi[0]'...`psi[4]'.
 
4975
     If `psi' is set to `true', the coefficients are displayed.  See
 
4976
     `petrov' for an example.
 
4977
 
 
4978
     These coefficients are computed from the Weyl-tensor in a
 
4979
     coordinate base.  If a frame base is used, the Weyl-tensor is
 
4980
     first converted to a coordinate base, which can be a
 
4981
     computationally expensive procedure. For this reason, in some
 
4982
     cases it may be more advantageous to use a coordinate base in the
 
4983
     first place before the Weyl tensor is computed. Note however, that
 
4984
     constructing a Newman-Penrose null tetrad requires a frame base.
 
4985
     Therefore, a meaningful computation sequence may begin with a
 
4986
     frame base, which is then used to compute `lg' (computed
 
4987
     automatically by `cmetric' and then `ug'. At this point, you can
 
4988
     switch back to a coordinate base by setting `cframe_flag' to false
 
4989
     before beginning to compute the Christoffel symbols. Changing to a
 
4990
     frame base at a later stage could yield inconsistent results, as
 
4991
     you may end up with a mixed bag of tensors, some computed in a
 
4992
     frame base, some in a coordinate base, with no means to
 
4993
     distinguish between the two.
 
4994
 
 
4995
 
 
4996
 -- Function: petrov ()
 
4997
     Computes the Petrov classification of the metric characterized by
 
4998
     `psi[0]'...`psi[4]'.
 
4999
 
 
5000
     For example, the following demonstrates how to obtain the
 
5001
     Petrov-classification of the Kerr metric:
 
5002
 
 
5003
          (%i1) load(ctensor);
 
5004
          (%o1)       /share/tensor/ctensor.mac
 
5005
          (%i2) (cframe_flag:true,gcd:spmod,ctrgsimp:true,ratfac:true);
 
5006
          (%o2)                                true
 
5007
          (%i3) ct_coordsys(exteriorschwarzschild,all);
 
5008
          (%o3)                                done
 
5009
          (%i4) ug:invert(lg)$
 
5010
          (%i5) weyl(false);
 
5011
          (%o5)                                done
 
5012
          (%i6) nptetrad(true);
 
5013
          (%t6) np =
 
5014
 
 
5015
                 [  sqrt(r - 2 m)           sqrt(r)                                     ]
 
5016
                 [ ---------------   ---------------------      0             0         ]
 
5017
                 [ sqrt(2) sqrt(r)   sqrt(2) sqrt(r - 2 m)                              ]
 
5018
                 [                                                                      ]
 
5019
                 [  sqrt(r - 2 m)            sqrt(r)                                    ]
 
5020
                 [ ---------------  - ---------------------     0             0         ]
 
5021
                 [ sqrt(2) sqrt(r)    sqrt(2) sqrt(r - 2 m)                             ]
 
5022
                 [                                                                      ]
 
5023
                 [                                              r      %i r sin(theta)  ]
 
5024
                 [        0                    0             -------   ---------------  ]
 
5025
                 [                                           sqrt(2)       sqrt(2)      ]
 
5026
                 [                                                                      ]
 
5027
                 [                                              r       %i r sin(theta) ]
 
5028
                 [        0                    0             -------  - --------------- ]
 
5029
                 [                                           sqrt(2)        sqrt(2)     ]
 
5030
 
 
5031
                                       sqrt(r)          sqrt(r - 2 m)
 
5032
          (%t7) npi = matrix([- ---------------------, ---------------, 0, 0],
 
5033
                                sqrt(2) sqrt(r - 2 m)  sqrt(2) sqrt(r)
 
5034
 
 
5035
                    sqrt(r)            sqrt(r - 2 m)
 
5036
          [- ---------------------, - ---------------, 0, 0],
 
5037
             sqrt(2) sqrt(r - 2 m)    sqrt(2) sqrt(r)
 
5038
 
 
5039
                     1               %i
 
5040
          [0, 0, ---------, --------------------],
 
5041
                 sqrt(2) r  sqrt(2) r sin(theta)
 
5042
 
 
5043
                     1                 %i
 
5044
          [0, 0, ---------, - --------------------])
 
5045
                 sqrt(2) r    sqrt(2) r sin(theta)
 
5046
 
 
5047
          (%o7)                                done
 
5048
          (%i7) psi(true);
 
5049
          (%t8)                              psi  = 0
 
5050
                                                0
 
5051
 
 
5052
          (%t9)                              psi  = 0
 
5053
                                                1
 
5054
 
 
5055
                                                    m
 
5056
          (%t10)                             psi  = --
 
5057
                                                2    3
 
5058
                                                    r
 
5059
 
 
5060
          (%t11)                             psi  = 0
 
5061
                                                3
 
5062
 
 
5063
          (%t12)                             psi  = 0
 
5064
                                                4
 
5065
          (%o12)                               done
 
5066
          (%i12) petrov();
 
5067
          (%o12)                                 D
 
5068
 
 
5069
     The Petrov classification function is based on the algorithm
 
5070
     published in "Classifying geometries in general relativity: III
 
5071
     Classification in practice" by Pollney, Skea, and d'Inverno,
 
5072
     Class. Quant. Grav. 17 2885-2902 (2000).  Except for some simple
 
5073
     test cases, the implementation is untested as of December 19,
 
5074
     2004, and is likely to contain errors.
 
5075
 
 
5076
 
 
5077
29.2.6 Torsion and nonmetricity
 
5078
-------------------------------
 
5079
 
 
5080
`ctensor' has the ability to compute and include torsion and
 
5081
nonmetricity coefficients in the connection coefficients.
 
5082
 
 
5083
   The torsion coefficients are calculated from a user-supplied tensor
 
5084
`tr', which should be a rank (2,1) tensor. From this, the torsion
 
5085
coefficients `kt' are computed according to the following formulae:
 
5086
 
 
5087
 
 
5088
                   m          m      m
 
5089
            - g  tr   - g   tr   - tr   g
 
5090
               im  kj    jm   ki     ij  km
 
5091
     kt   = -------------------------------
 
5092
       ijk                 2
 
5093
 
 
5094
 
 
5095
       k     km
 
5096
     kt   = g   kt
 
5097
       ij         ijm
 
5098
 
 
5099
   Note that only the mixed-index tensor is calculated and stored in the
 
5100
array `kt'.
 
5101
 
 
5102
   The nonmetricity coefficients are calculated from the user-supplied
 
5103
nonmetricity vector `nm'. From this, the nonmetricity coefficients
 
5104
`nmc' are computed as follows:
 
5105
 
 
5106
 
 
5107
                  k    k        km
 
5108
            -nm  D  - D  nm  + g   nm  g
 
5109
        k      i  j    i   j         m  ij
 
5110
     nmc  = ------------------------------
 
5111
        ij                2
 
5112
 
 
5113
   where D stands for the Kronecker-delta.
 
5114
 
 
5115
   When `ctorsion_flag' is set to `true', the values of `kt' are
 
5116
substracted from the mixed-indexed connection coefficients computed by
 
5117
`christof' and stored in `mcs'. Similarly, if `cnonmet_flag' is set to
 
5118
`true', the values of `nmc' are substracted from the mixed-indexed
 
5119
connection coefficients.
 
5120
 
 
5121
   If necessary, `christof' calls the functions `contortion' and
 
5122
`nonmetricity' in order to compute `kt' and `nm'.
 
5123
 
 
5124
 -- Function: contortion (<tr>)
 
5125
     Computes the (2,1) contortion coefficients from the torsion tensor
 
5126
     <tr>.
 
5127
 
 
5128
 
 
5129
 -- Function: nonmetricity (<nm>)
 
5130
     Computes the (2,1) nonmetricity coefficients from the nonmetricity
 
5131
     vector <nm>.
 
5132
 
 
5133
 
 
5134
29.2.7 Miscellaneous features
 
5135
-----------------------------
 
5136
 
 
5137
 -- Function: ctransform (<M>)
 
5138
     A function in the `ctensor' (component tensor) package which will
 
5139
     perform a coordinate transformation upon an arbitrary square
 
5140
     symmetric matrix <M>. The user must input the functions which
 
5141
     define the transformation.  (Formerly called `transform'.)
 
5142
 
 
5143
 
 
5144
 -- Function: findde (<A>, <n>)
 
5145
     returns a list of the unique differential equations (expressions)
 
5146
     corresponding to the elements of the <n> dimensional square array
 
5147
     <A>. Presently, <n> may be 2 or 3. `deindex' is a global list
 
5148
     containing the indices of <A> corresponding to these unique
 
5149
     differential equations. For the Einstein tensor (`ein'), which is
 
5150
     a two dimensional array, if computed for the metric in the example
 
5151
     below, `findde' gives the following independent differential
 
5152
     equations:
 
5153
 
 
5154
          (%i1) load(ctensor);
 
5155
          (%o1)       /share/tensor/ctensor.mac
 
5156
          (%i2) derivabbrev:true;
 
5157
          (%o2)                                true
 
5158
          (%i3) dim:4;
 
5159
          (%o3)                                  4
 
5160
          (%i4) lg:matrix([a,0,0,0],[0,x^2,0,0],[0,0,x^2*sin(y)^2,0],[0,0,0,-d]);
 
5161
                                    [ a  0       0        0  ]
 
5162
                                    [                        ]
 
5163
                                    [     2                  ]
 
5164
                                    [ 0  x       0        0  ]
 
5165
          (%o4)                     [                        ]
 
5166
                                    [         2    2         ]
 
5167
                                    [ 0  0   x  sin (y)   0  ]
 
5168
                                    [                        ]
 
5169
                                    [ 0  0       0       - d ]
 
5170
          (%i5) depends([a,d],x);
 
5171
          (%o5)                            [a(x), d(x)]
 
5172
          (%i6) ct_coords:[x,y,z,t];
 
5173
          (%o6)                            [x, y, z, t]
 
5174
          (%i7) cmetric();
 
5175
          (%o7)                                done
 
5176
          (%i8) einstein(false);
 
5177
          (%o8)                                done
 
5178
          (%i9) findde(ein,2);
 
5179
                                                      2
 
5180
          (%o9) [d  x - a d + d, 2 a d d    x - a (d )  x - a  d d  x + 2 a d d
 
5181
                  x                     x x         x        x    x            x
 
5182
 
 
5183
                                                                  2          2
 
5184
                                                          - 2 a  d , a  x + a  - a]
 
5185
                                                               x      x
 
5186
          (%i10) deindex;
 
5187
          (%o10)                     [[1, 1], [2, 2], [4, 4]]
 
5188
 
 
5189
 
 
5190
 -- Function: cograd ()
 
5191
     Computes the covariant gradient of a scalar function allowing the
 
5192
     user to choose the corresponding vector name as the example under
 
5193
     `contragrad' illustrates.
 
5194
 
 
5195
 -- Function: contragrad ()
 
5196
     Computes the contravariant gradient of a scalar function allowing
 
5197
     the user to choose the corresponding vector name as the example
 
5198
     below for the Schwarzschild metric illustrates:
 
5199
 
 
5200
 
 
5201
          (%i1) load(ctensor);
 
5202
          (%o1)       /share/tensor/ctensor.mac
 
5203
          (%i2) derivabbrev:true;
 
5204
          (%o2)                                true
 
5205
          (%i3) ct_coordsys(exteriorschwarzschild,all);
 
5206
          (%o3)                                done
 
5207
          (%i4) depends(f,r);
 
5208
          (%o4)                               [f(r)]
 
5209
          (%i5) cograd(f,g1);
 
5210
          (%o5)                                done
 
5211
          (%i6) listarray(g1);
 
5212
          (%o6)                            [0, f , 0, 0]
 
5213
                                                r
 
5214
          (%i7) contragrad(f,g2);
 
5215
          (%o7)                                done
 
5216
          (%i8) listarray(g2);
 
5217
                                         f  r - 2 f  m
 
5218
                                          r        r
 
5219
          (%o8)                      [0, -------------, 0, 0]
 
5220
                                               r
 
5221
 
 
5222
 
 
5223
 -- Function: dscalar ()
 
5224
     computes the tensor d'Alembertian of the scalar function once
 
5225
     dependencies have been declared upon the function. For example:
 
5226
 
 
5227
          (%i1) load(ctensor);
 
5228
          (%o1)       /share/tensor/ctensor.mac
 
5229
          (%i2) derivabbrev:true;
 
5230
          (%o2)                                true
 
5231
          (%i3) ct_coordsys(exteriorschwarzschild,all);
 
5232
          (%o3)                                done
 
5233
          (%i4) depends(p,r);
 
5234
          (%o4)                               [p(r)]
 
5235
          (%i5) factor(dscalar(p));
 
5236
                                    2
 
5237
                              p    r  - 2 m p    r + 2 p  r - 2 m p
 
5238
                               r r           r r        r          r
 
5239
          (%o5)               --------------------------------------
 
5240
                                                 2
 
5241
                                                r
 
5242
 
 
5243
 
 
5244
 -- Function: checkdiv ()
 
5245
     computes the covariant divergence of the mixed second rank tensor
 
5246
     (whose first index must be covariant) by printing the
 
5247
     corresponding n components of the vector field (the divergence)
 
5248
     where n = `dim'. If the argument to the function is `g' then the
 
5249
     divergence of the Einstein tensor will be formed and must be zero.
 
5250
     In addition, the divergence (vector) is given the array name `div'.
 
5251
 
 
5252
 -- Function: cgeodesic (<dis>)
 
5253
     A function in the `ctensor' (component tensor) package.
 
5254
     `cgeodesic' computes the geodesic equations of motion for a given
 
5255
     metric.  They are stored in the array `geod[i]'.  If the argument
 
5256
     <dis> is `true' then these equations are displayed.
 
5257
 
 
5258
 
 
5259
 -- Function: bdvac (<f>)
 
5260
     generates the covariant components of the vacuum field equations of
 
5261
     the Brans- Dicke gravitational theory. The scalar field is
 
5262
     specified by the argument <f>, which should be a (quoted) function
 
5263
     name with functional dependencies, e.g., `'p(x)'.
 
5264
 
 
5265
     The components of the second rank covariant field tensor are
 
5266
     represented by the array `bd'.
 
5267
 
 
5268
 
 
5269
 -- Function: invariant1 ()
 
5270
     generates the mixed Euler- Lagrange tensor (field equations) for
 
5271
     the invariant density of R^2. The field equations are the
 
5272
     components of an array named `inv1'.
 
5273
 
 
5274
 
 
5275
 -- Function: invariant2 ()
 
5276
     *** NOT YET IMPLEMENTED ***
 
5277
 
 
5278
     generates the mixed Euler- Lagrange tensor (field equations) for
 
5279
     the invariant density of `ric[i,j]*uriem[i,j]'. The field
 
5280
     equations are the components of an array named `inv2'.
 
5281
 
 
5282
 
 
5283
 -- Function: bimetric ()
 
5284
     *** NOT YET IMPLEMENTED ***
 
5285
 
 
5286
     generates the field equations of Rosen's bimetric theory. The field
 
5287
     equations are the components of an array named `rosen'.
 
5288
 
 
5289
 
 
5290
29.2.8 Utility functions
 
5291
------------------------
 
5292
 
 
5293
 -- Function: diagmatrixp (<M>)
 
5294
     Returns `true' if <M> is a diagonal matrix or (2D) array.
 
5295
 
 
5296
 
 
5297
 -- Function: symmetricp (<M>)
 
5298
     Returns `true' if <M> is a symmetric matrix or (2D) array.
 
5299
 
 
5300
 
 
5301
 -- Function: ntermst (<f>)
 
5302
     gives the user a quick picture of the "size" of the doubly
 
5303
     subscripted tensor (array) <f>.  It prints two element lists where
 
5304
     the second element corresponds to NTERMS of the components
 
5305
     specified by the first elements.  In this way, it is possible to
 
5306
     quickly find the non-zero expressions and attempt simplification.
 
5307
 
 
5308
 
 
5309
 -- Function: cdisplay (<ten>)
 
5310
     displays all the elements of the tensor <ten>, as represented by a
 
5311
     multidimensional array. Tensors of rank 0 and 1, as well as other
 
5312
     types of variables, are displayed as with `ldisplay'. Tensors of
 
5313
     rank 2 are displayed as 2-dimensional matrices, while tensors of
 
5314
     higher rank are displayed as a list of 2-dimensional matrices. For
 
5315
     instance, the Riemann-tensor of the Schwarzschild metric can be
 
5316
     viewed as:
 
5317
 
 
5318
          (%i1) load(ctensor);
 
5319
          (%o1)       /share/tensor/ctensor.mac
 
5320
          (%i2) ratfac:true;
 
5321
          (%o2)                                true
 
5322
          (%i3) ct_coordsys(exteriorschwarzschild,all);
 
5323
          (%o3)                                done
 
5324
          (%i4) riemann(false);
 
5325
          (%o4)                                done
 
5326
          (%i5) cdisplay(riem);
 
5327
                         [ 0               0                    0            0      ]
 
5328
                         [                                                          ]
 
5329
                         [                              2                           ]
 
5330
                         [      3 m (r - 2 m)   m    2 m                            ]
 
5331
                         [ 0  - ------------- + -- - ----       0            0      ]
 
5332
                         [            4          3     4                            ]
 
5333
                         [           r          r     r                             ]
 
5334
                         [                                                          ]
 
5335
              riem     = [                                 m (r - 2 m)              ]
 
5336
                  1, 1   [ 0               0               -----------       0      ]
 
5337
                         [                                      4                   ]
 
5338
                         [                                     r                    ]
 
5339
                         [                                                          ]
 
5340
                         [                                              m (r - 2 m) ]
 
5341
                         [ 0               0                    0       ----------- ]
 
5342
                         [                                                   4      ]
 
5343
                         [                                                  r       ]
 
5344
 
 
5345
                                          [    2 m (r - 2 m)       ]
 
5346
                                          [ 0  -------------  0  0 ]
 
5347
                                          [          4             ]
 
5348
                                          [         r              ]
 
5349
                               riem     = [                        ]
 
5350
                                   1, 2   [ 0        0        0  0 ]
 
5351
                                          [                        ]
 
5352
                                          [ 0        0        0  0 ]
 
5353
                                          [                        ]
 
5354
                                          [ 0        0        0  0 ]
 
5355
 
 
5356
                                          [         m (r - 2 m)    ]
 
5357
                                          [ 0  0  - -----------  0 ]
 
5358
                                          [              4         ]
 
5359
                                          [             r          ]
 
5360
                               riem     = [                        ]
 
5361
                                   1, 3   [ 0  0        0        0 ]
 
5362
                                          [                        ]
 
5363
                                          [ 0  0        0        0 ]
 
5364
                                          [                        ]
 
5365
                                          [ 0  0        0        0 ]
 
5366
 
 
5367
                                          [            m (r - 2 m) ]
 
5368
                                          [ 0  0  0  - ----------- ]
 
5369
                                          [                 4      ]
 
5370
                                          [                r       ]
 
5371
                               riem     = [                        ]
 
5372
                                   1, 4   [ 0  0  0        0       ]
 
5373
                                          [                        ]
 
5374
                                          [ 0  0  0        0       ]
 
5375
                                          [                        ]
 
5376
                                          [ 0  0  0        0       ]
 
5377
 
 
5378
                                         [       0         0  0  0 ]
 
5379
                                         [                         ]
 
5380
                                         [       2 m               ]
 
5381
                                         [ - ------------  0  0  0 ]
 
5382
                              riem     = [    2                    ]
 
5383
                                  2, 1   [   r  (r - 2 m)          ]
 
5384
                                         [                         ]
 
5385
                                         [       0         0  0  0 ]
 
5386
                                         [                         ]
 
5387
                                         [       0         0  0  0 ]
 
5388
 
 
5389
                             [     2 m                                         ]
 
5390
                             [ ------------  0        0               0        ]
 
5391
                             [  2                                              ]
 
5392
                             [ r  (r - 2 m)                                    ]
 
5393
                             [                                                 ]
 
5394
                             [      0        0        0               0        ]
 
5395
                             [                                                 ]
 
5396
                  riem     = [                         m                       ]
 
5397
                      2, 2   [      0        0  - ------------        0        ]
 
5398
                             [                     2                           ]
 
5399
                             [                    r  (r - 2 m)                 ]
 
5400
                             [                                                 ]
 
5401
                             [                                         m       ]
 
5402
                             [      0        0        0         - ------------ ]
 
5403
                             [                                     2           ]
 
5404
                             [                                    r  (r - 2 m) ]
 
5405
 
 
5406
                                          [ 0  0       0        0 ]
 
5407
                                          [                       ]
 
5408
                                          [            m          ]
 
5409
                                          [ 0  0  ------------  0 ]
 
5410
                               riem     = [        2              ]
 
5411
                                   2, 3   [       r  (r - 2 m)    ]
 
5412
                                          [                       ]
 
5413
                                          [ 0  0       0        0 ]
 
5414
                                          [                       ]
 
5415
                                          [ 0  0       0        0 ]
 
5416
 
 
5417
                                          [ 0  0  0       0       ]
 
5418
                                          [                       ]
 
5419
                                          [               m       ]
 
5420
                                          [ 0  0  0  ------------ ]
 
5421
                               riem     = [           2           ]
 
5422
                                   2, 4   [          r  (r - 2 m) ]
 
5423
                                          [                       ]
 
5424
                                          [ 0  0  0       0       ]
 
5425
                                          [                       ]
 
5426
                                          [ 0  0  0       0       ]
 
5427
 
 
5428
                                                [ 0  0  0  0 ]
 
5429
                                                [            ]
 
5430
                                                [ 0  0  0  0 ]
 
5431
                                                [            ]
 
5432
                                     riem     = [ m          ]
 
5433
                                         3, 1   [ -  0  0  0 ]
 
5434
                                                [ r          ]
 
5435
                                                [            ]
 
5436
                                                [ 0  0  0  0 ]
 
5437
 
 
5438
                                                [ 0  0  0  0 ]
 
5439
                                                [            ]
 
5440
                                                [ 0  0  0  0 ]
 
5441
                                                [            ]
 
5442
                                     riem     = [    m       ]
 
5443
                                         3, 2   [ 0  -  0  0 ]
 
5444
                                                [    r       ]
 
5445
                                                [            ]
 
5446
                                                [ 0  0  0  0 ]
 
5447
 
 
5448
                                         [   m                      ]
 
5449
                                         [ - -   0   0       0      ]
 
5450
                                         [   r                      ]
 
5451
                                         [                          ]
 
5452
                                         [        m                 ]
 
5453
                                         [  0   - -  0       0      ]
 
5454
                              riem     = [        r                 ]
 
5455
                                  3, 3   [                          ]
 
5456
                                         [  0    0   0       0      ]
 
5457
                                         [                          ]
 
5458
                                         [              2 m - r     ]
 
5459
                                         [  0    0   0  ------- + 1 ]
 
5460
                                         [                 r        ]
 
5461
 
 
5462
                                              [ 0  0  0    0   ]
 
5463
                                              [                ]
 
5464
                                              [ 0  0  0    0   ]
 
5465
                                              [                ]
 
5466
                                   riem     = [            2 m ]
 
5467
                                       3, 4   [ 0  0  0  - --- ]
 
5468
                                              [             r  ]
 
5469
                                              [                ]
 
5470
                                              [ 0  0  0    0   ]
 
5471
 
 
5472
                                          [       0        0  0  0 ]
 
5473
                                          [                        ]
 
5474
                                          [       0        0  0  0 ]
 
5475
                                          [                        ]
 
5476
                               riem     = [       0        0  0  0 ]
 
5477
                                   4, 1   [                        ]
 
5478
                                          [      2                 ]
 
5479
                                          [ m sin (theta)          ]
 
5480
                                          [ -------------  0  0  0 ]
 
5481
                                          [       r                ]
 
5482
 
 
5483
                                          [ 0        0        0  0 ]
 
5484
                                          [                        ]
 
5485
                                          [ 0        0        0  0 ]
 
5486
                                          [                        ]
 
5487
                               riem     = [ 0        0        0  0 ]
 
5488
                                   4, 2   [                        ]
 
5489
                                          [         2              ]
 
5490
                                          [    m sin (theta)       ]
 
5491
                                          [ 0  -------------  0  0 ]
 
5492
                                          [          r             ]
 
5493
 
 
5494
                                        [ 0  0          0          0 ]
 
5495
                                        [                            ]
 
5496
                                        [ 0  0          0          0 ]
 
5497
                                        [                            ]
 
5498
                             riem     = [ 0  0          0          0 ]
 
5499
                                 4, 3   [                            ]
 
5500
                                        [                2           ]
 
5501
                                        [         2 m sin (theta)    ]
 
5502
                                        [ 0  0  - ---------------  0 ]
 
5503
                                        [                r           ]
 
5504
 
 
5505
                           [        2                                             ]
 
5506
                           [   m sin (theta)                                      ]
 
5507
                           [ - -------------         0                0         0 ]
 
5508
                           [         r                                            ]
 
5509
                           [                                                      ]
 
5510
                           [                         2                            ]
 
5511
                           [                    m sin (theta)                     ]
 
5512
                riem     = [        0         - -------------         0         0 ]
 
5513
                    4, 4   [                          r                           ]
 
5514
                           [                                                      ]
 
5515
                           [                                          2           ]
 
5516
                           [                                   2 m sin (theta)    ]
 
5517
                           [        0                0         ---------------  0 ]
 
5518
                           [                                          r           ]
 
5519
                           [                                                      ]
 
5520
                           [        0                0                0         0 ]
 
5521
 
 
5522
          (%o5)                                done
 
5523
 
 
5524
 -- Function: deleten (<L>, <n>)
 
5525
     Returns a new list consisting of <L> with the <n>'th element
 
5526
     deleted.
 
5527
 
 
5528
29.2.9 Variables used by `ctensor'
 
5529
----------------------------------
 
5530
 
 
5531
 -- Option variable: dim
 
5532
     Default value: 4
 
5533
 
 
5534
     An option in the `ctensor' (component tensor) package.  `dim' is
 
5535
     the dimension of the manifold with the default 4. The command
 
5536
     `dim: n' will reset the dimension to any other value `n'.
 
5537
 
 
5538
 
 
5539
 -- Option variable: diagmetric
 
5540
     Default value: `false'
 
5541
 
 
5542
     An option in the `ctensor' (component tensor) package.  If
 
5543
     `diagmetric' is `true' special routines compute all geometrical
 
5544
     objects (which contain the metric tensor explicitly) by taking
 
5545
     into consideration the diagonality of the metric. Reduced run
 
5546
     times will, of course, result. Note: this option is set
 
5547
     automatically by `csetup' if a diagonal metric is specified.
 
5548
 
 
5549
 
 
5550
 -- Option variable: ctrgsimp
 
5551
     Causes trigonometric simplifications to be used when tensors are
 
5552
     computed. Presently, `ctrgsimp' affects only computations
 
5553
     involving a moving frame.
 
5554
 
 
5555
 
 
5556
 -- Option variable: cframe_flag
 
5557
     Causes computations to be performed relative to a moving frame as
 
5558
     opposed to a holonomic metric. The frame is defined by the inverse
 
5559
     frame array `fri' and the frame metric `lfg'. For computations
 
5560
     using a Cartesian frame, `lfg' should be the unit matrix of the
 
5561
     appropriate dimension; for computations in a Lorentz frame, `lfg'
 
5562
     should have the appropriate signature.
 
5563
 
 
5564
 
 
5565
 -- Option variable: ctorsion_flag
 
5566
     Causes the contortion tensor to be included in the computation of
 
5567
     the connection coefficients. The contortion tensor itself is
 
5568
     computed by `contortion' from the user-supplied tensor `tr'.
 
5569
 
 
5570
 
 
5571
 -- Option variable: cnonmet_flag
 
5572
     Causes the nonmetricity coefficients to be included in the
 
5573
     computation of the connection coefficients. The nonmetricity
 
5574
     coefficients are computed from the user-supplied nonmetricity
 
5575
     vector `nm' by the function `nonmetricity'.
 
5576
 
 
5577
 
 
5578
 -- Option variable: ctayswitch
 
5579
     If set to `true', causes some `ctensor' computations to be carried
 
5580
     out using Taylor-series expansions. Presently, `christof', `ricci',
 
5581
     `uricci', `einstein', and `weyl' take into account this setting.
 
5582
 
 
5583
 
 
5584
 -- Option variable: ctayvar
 
5585
     Variable used for Taylor-series expansion if `ctayswitch' is set to
 
5586
     `true'.
 
5587
 
 
5588
 
 
5589
 -- Option variable: ctaypov
 
5590
     Maximum power used in Taylor-series expansion when `ctayswitch' is
 
5591
     set to `true'.
 
5592
 
 
5593
 
 
5594
 -- Option variable: ctaypt
 
5595
     Point around which Taylor-series expansion is carried out when
 
5596
     `ctayswitch' is set to `true'.
 
5597
 
 
5598
 
 
5599
 -- System variable: gdet
 
5600
     The determinant of the metric tensor `lg'. Computed by `cmetric'
 
5601
     when `cframe_flag' is set to `false'.
 
5602
 
 
5603
 
 
5604
 -- Option variable: ratchristof
 
5605
     Causes rational simplification to be applied by `christof'.
 
5606
 
 
5607
 
 
5608
 -- Option variable: rateinstein
 
5609
     Default value: `true'
 
5610
 
 
5611
     If `true' rational simplification will be performed on the
 
5612
     non-zero components of Einstein tensors; if `ratfac' is `true'
 
5613
     then the components will also be factored.
 
5614
 
 
5615
 
 
5616
 -- Option variable: ratriemann
 
5617
     Default value: `true'
 
5618
 
 
5619
     One of the switches which controls simplification of Riemann
 
5620
     tensors; if `true', then rational simplification will be done; if
 
5621
     `ratfac' is `true' then each of the components will also be
 
5622
     factored.
 
5623
 
 
5624
 
 
5625
 -- Option variable: ratweyl
 
5626
     Default value: `true'
 
5627
 
 
5628
     If `true', this switch causes the `weyl' function to apply
 
5629
     rational simplification to the values of the Weyl tensor. If
 
5630
     `ratfac' is `true', then the components will also be factored.
 
5631
 
 
5632
 -- Variable: lfg
 
5633
     The covariant frame metric. By default, it is initialized to the
 
5634
     4-dimensional Lorentz frame with signature (+,+,+,-). Used when
 
5635
     `cframe_flag' is `true'.
 
5636
 
 
5637
 -- Variable: ufg
 
5638
     The inverse frame metric. Computed from `lfg' when `cmetric' is
 
5639
     called while `cframe_flag' is set to `true'.
 
5640
 
 
5641
 -- Variable: riem
 
5642
     The (3,1) Riemann tensor. Computed when the function `riemann' is
 
5643
     invoked. For information about index ordering, see the description
 
5644
     of `riemann'.
 
5645
 
 
5646
     if `cframe_flag' is `true', `riem' is computed from the covariant
 
5647
     Riemann-tensor `lriem'.
 
5648
 
 
5649
 
 
5650
 -- Variable: lriem
 
5651
     The covariant Riemann tensor. Computed by `lriemann'.
 
5652
 
 
5653
 
 
5654
 -- Variable: uriem
 
5655
     The contravariant Riemann tensor. Computed by `uriemann'.
 
5656
 
 
5657
 
 
5658
 -- Variable: ric
 
5659
     The mixed Ricci-tensor. Computed by `ricci'.
 
5660
 
 
5661
 
 
5662
 -- Variable: uric
 
5663
     The contravariant Ricci-tensor. Computed by `uricci'.
 
5664
 
 
5665
 
 
5666
 -- Variable: lg
 
5667
     The metric tensor. This tensor must be specified (as a `dim' by
 
5668
     `dim' matrix) before other computations can be performed.
 
5669
 
 
5670
 
 
5671
 -- Variable: ug
 
5672
     The inverse of the metric tensor. Computed by `cmetric'.
 
5673
 
 
5674
 
 
5675
 -- Variable: weyl
 
5676
     The Weyl tensor. Computed by `weyl'.
 
5677
 
 
5678
 
 
5679
 -- Variable: fb
 
5680
     Frame bracket coefficients, as computed by `frame_bracket'.
 
5681
 
 
5682
 
 
5683
 -- Variable: kinvariant
 
5684
     The Kretchmann invariant. Computed by `rinvariant'.
 
5685
 
 
5686
 
 
5687
 -- Variable: np
 
5688
     A Newman-Penrose null tetrad. Computed by `nptetrad'.
 
5689
 
 
5690
 
 
5691
 -- Variable: npi
 
5692
     The raised-index Newman-Penrose null tetrad. Computed by
 
5693
     `nptetrad'.  Defined as `ug.np'. The product `np.transpose(npi)'
 
5694
     is constant:
 
5695
 
 
5696
          (%i39) trigsimp(np.transpose(npi));
 
5697
                                        [  0   - 1  0  0 ]
 
5698
                                        [                ]
 
5699
                                        [ - 1   0   0  0 ]
 
5700
          (%o39)                        [                ]
 
5701
                                        [  0    0   0  1 ]
 
5702
                                        [                ]
 
5703
                                        [  0    0   1  0 ]
 
5704
 
 
5705
 
 
5706
 -- Variable: tr
 
5707
     User-supplied rank-3 tensor representing torsion. Used by
 
5708
     `contortion'.
 
5709
 
 
5710
 -- Variable: kt
 
5711
     The contortion tensor, computed from `tr' by `contortion'.
 
5712
 
 
5713
 -- Variable: nm
 
5714
     User-supplied nonmetricity vector. Used by `nonmetricity'.
 
5715
 
 
5716
 -- Variable: nmc
 
5717
     The nonmetricity coefficients, computed from `nm' by
 
5718
     `nonmetricity'.
 
5719
 
 
5720
 
 
5721
 -- System variable: tensorkill
 
5722
     Variable indicating if the tensor package has been initialized.
 
5723
     Set and used by `csetup', reset by `init_ctensor'.
 
5724
 
 
5725
 
 
5726
 -- Option variable: ct_coords
 
5727
     Default value: `[]'
 
5728
 
 
5729
     An option in the `ctensor' (component tensor) package.
 
5730
     `ct_coords' contains a list of coordinates.  While normally
 
5731
     defined when the function `csetup' is called, one may redefine the
 
5732
     coordinates with the assignment `ct_coords: [j1, j2, ..., jn]'
 
5733
     where the j's are the new coordinate names.  See also `csetup'.
 
5734
 
 
5735
 
 
5736
29.2.10 Reserved names
 
5737
----------------------
 
5738
 
 
5739
The following names are used internally by the `ctensor' package and
 
5740
should not be redefined:
 
5741
 
 
5742
       Name         Description
 
5743
       ---------------------------------------
 
5744
       _lg()        Evaluates to lfg if frame metric used, lg otherwise
 
5745
       _ug()        Evaluates to ufg if frame metric used, ug otherwise
 
5746
       cleanup()    Removes items drom the deindex list
 
5747
       contract4()  Used by psi()
 
5748
       filemet()    Used by csetup() when reading the metric from a file
 
5749
       findde1()    Used by findde()
 
5750
       findde2()    Used by findde()
 
5751
       findde3()    Used by findde()
 
5752
       kdelt()      Kronecker-delta (not generalized)
 
5753
       newmet()     Used by csetup() for setting up a metric interactively
 
5754
       setflags()   Used by init_ctensor()
 
5755
       readvalue()
 
5756
       resimp()
 
5757
       sermet()     Used by csetup() for entering a metric as Taylor-series
 
5758
       txyzsum()
 
5759
       tmetric()    Frame metric, used by cmetric() when cframe_flag:true
 
5760
       triemann()   Riemann-tensor in frame base, used when cframe_flag:true
 
5761
       tricci()     Ricci-tensor in frame base, used when cframe_flag:true
 
5762
       trrc()       Ricci rotation coefficients, used by christof()
 
5763
       yesp()
 
5764
 
 
5765
29.2.11 Changes
 
5766
---------------
 
5767
 
 
5768
In November, 2004, the `ctensor' package was extensively rewritten.
 
5769
Many functions and variables have been renamed in order to make the
 
5770
package compatible with the commercial version of Macsyma.
 
5771
 
 
5772
       New Name     Old Name        Description
 
5773
       --------------------------------------------------------------------------
 
5774
       ctaylor()    DLGTAYLOR()     Taylor-series expansion of an expression
 
5775
       lgeod[]      EM              Geodesic equations
 
5776
       ein[]        G[]             Mixed Einstein-tensor
 
5777
       ric[]        LR[]            Mixed Ricci-tensor
 
5778
       ricci()      LRICCICOM()     Compute the mixed Ricci-tensor
 
5779
       ctaypov      MINP            Maximum power in Taylor-series expansion
 
5780
       cgeodesic()  MOTION          Compute geodesic equations
 
5781
       ct_coords    OMEGA           Metric coordinates
 
5782
       ctayvar      PARAM           Taylor-series expansion variable
 
5783
       lriem[]      R[]             Covariant Riemann-tensor
 
5784
       uriemann()   RAISERIEMANN()  Compute the contravariant Riemann-tensor
 
5785
       ratriemann   RATRIEMAN       Rational simplification of the Riemann-tensor
 
5786
       uric[]       RICCI[]         Contravariant Ricci-tensor
 
5787
       uricci()     RICCICOM()      Compute the contravariant Ricci-tensor
 
5788
       cmetric()    SETMETRIC()     Set up the metric
 
5789
       ctaypt       TAYPT           Point for Taylor-series expansion
 
5790
       ctayswitch   TAYSWITCH       Taylor-series setting switch
 
5791
       csetup()     TSETUP()        Start interactive setup session
 
5792
       ctransform() TTRANSFORM()    Interactive coordinate transformation
 
5793
       uriem[]      UR[]            Contravariant Riemann-tensor
 
5794
       weyl[]       W[]             (3,1) Weyl-tensor
 
5795
 
 
5796
 
 
5797
File: maxima.info,  Node: atensor,  Next: Series,  Prev: ctensor,  Up: Top
 
5798
 
 
5799
30 atensor
 
5800
**********
 
5801
 
 
5802
* Menu:
 
5803
 
 
5804
* Introduction to atensor::
 
5805
* Definitions for atensor::
 
5806
 
 
5807
 
 
5808
File: maxima.info,  Node: Introduction to atensor,  Next: Definitions for atensor,  Prev: atensor,  Up: atensor
 
5809
 
 
5810
30.1 Introduction to atensor
 
5811
============================
 
5812
 
 
5813
`atensor' is an algebraic tensor manipulation package. To use `atensor',
 
5814
type `load(atensor)', followed by a call to the `init_atensor' function.
 
5815
 
 
5816
   The essence of `atensor' is a set of simplification rules for the
 
5817
noncommutative (dot) product operator ("`.'"). `atensor' recognizes
 
5818
several algebra types; the corresponding simplification rules are put
 
5819
into effect when the `init_atensor' function is called.
 
5820
 
 
5821
   The capabilities of `atensor' can be demonstrated by defining the
 
5822
algebra of quaternions as a Clifford-algebra Cl(0,2) with two basis
 
5823
vectors. The three quaternionic imaginary units are then the two basis
 
5824
vectors and their product, i.e.:
 
5825
 
 
5826
         i = v     j = v     k = v  . v
 
5827
              1         2         1    2
 
5828
 
 
5829
   Although the `atensor' package has a built-in definition for the
 
5830
quaternion algebra, it is not used in this example, in which we
 
5831
endeavour to build the quaternion multiplication table as a matrix:
 
5832
 
 
5833
 
 
5834
     (%i1) load(atensor);
 
5835
     (%o1)       /share/tensor/atensor.mac
 
5836
     (%i2) init_atensor(clifford,0,0,2);
 
5837
     (%o2)                                done
 
5838
     (%i3) atensimp(v[1].v[1]);
 
5839
     (%o3)                                 - 1
 
5840
     (%i4) atensimp((v[1].v[2]).(v[1].v[2]));
 
5841
     (%o4)                                 - 1
 
5842
     (%i5) q:zeromatrix(4,4);
 
5843
                                     [ 0  0  0  0 ]
 
5844
                                     [            ]
 
5845
                                     [ 0  0  0  0 ]
 
5846
     (%o5)                           [            ]
 
5847
                                     [ 0  0  0  0 ]
 
5848
                                     [            ]
 
5849
                                     [ 0  0  0  0 ]
 
5850
     (%i6) q[1,1]:1;
 
5851
     (%o6)                                  1
 
5852
     (%i7) for i thru adim do q[1,i+1]:q[i+1,1]:v[i];
 
5853
     (%o7)                                done
 
5854
     (%i8) q[1,4]:q[4,1]:v[1].v[2];
 
5855
     (%o8)                               v  . v
 
5856
                                          1    2
 
5857
     (%i9) for i from 2 thru 4 do for j from 2 thru 4 do
 
5858
           q[i,j]:atensimp(q[i,1].q[1,j]);
 
5859
     (%o9)                                done
 
5860
     (%i10) q;
 
5861
                        [    1        v         v      v  . v  ]
 
5862
                        [              1         2      1    2 ]
 
5863
                        [                                      ]
 
5864
                        [   v         - 1     v  . v    - v    ]
 
5865
                        [    1                 1    2      2   ]
 
5866
     (%o10)             [                                      ]
 
5867
                        [   v      - v  . v     - 1      v     ]
 
5868
                        [    2        1    2              1    ]
 
5869
                        [                                      ]
 
5870
                        [ v  . v      v        - v       - 1   ]
 
5871
                        [  1    2      2          1            ]
 
5872
 
 
5873
   `atensor' recognizes as base vectors indexed symbols, where the
 
5874
symbol is that stored in `asymbol' and the index runs between 1 and
 
5875
`adim'.  For indexed symbols, and indexed symbols only, the bilinear
 
5876
forms `sf', `af', and `av' are evaluated. The evaluation substitutes
 
5877
the value of `aform[i,j]' in place of `fun(v[i],v[j])' where `v'
 
5878
represents the value of `asymbol' and `fun' is either `af' or `sf'; or,
 
5879
it substitutes `v[aform[i,j]]' in place of `av(v[i],v[j])'.
 
5880
 
 
5881
   Needless to say, the functions `sf', `af' and `av' can be redefined.
 
5882
 
 
5883
   When the `atensor' package is loaded, the following flags are set:
 
5884
 
 
5885
     dotscrules:true;
 
5886
     dotdistrib:true;
 
5887
     dotexptsimp:false;
 
5888
 
 
5889
   If you wish to experiment with a nonassociative algebra, you may also
 
5890
consider setting `dotassoc' to `false'. In this case, however,
 
5891
`atensimp' will not always be able to obtain the desired
 
5892
simplifications.
 
5893
 
 
5894
 
 
5895
File: maxima.info,  Node: Definitions for atensor,  Prev: Introduction to atensor,  Up: atensor
 
5896
 
 
5897
30.2 Definitions for atensor
 
5898
============================
 
5899
 
 
5900
 -- Function: init_atensor (<alg_type>, <opt_dims>)
 
5901
 -- Function: init_atensor (<alg_type>)
 
5902
     Initializes the `atensor' package with the specified algebra type.
 
5903
     <alg_type> can be one of the following:
 
5904
 
 
5905
     `universal': The universal algebra has no commutation rules.
 
5906
 
 
5907
     `grassmann': The Grassman algebra is defined by the commutation
 
5908
     relation `u.v+v.u=0'.
 
5909
 
 
5910
     `clifford': The Clifford algebra is defined by the commutation
 
5911
     relation `u.v+v.u=-2*sf(u,v)' where `sf' is a symmetric
 
5912
     scalar-valued function. For this algebra, <opt_dims> can be up to
 
5913
     three nonnegative integers, representing the number of positive,
 
5914
     degenerate, and negative dimensions of the algebra, respectively.
 
5915
     If any <opt_dims> values are supplied, `atensor' will configure the
 
5916
     values of `adim' and `aform' appropriately. Otherwise, `adim' will
 
5917
     default to 0 and `aform' will not be defined.
 
5918
 
 
5919
     `symmetric': The symmetric algebra is defined by the commutation
 
5920
     relation `u.v-v.u=0'.
 
5921
 
 
5922
     `symplectic': The symplectic algebra is defined by the commutation
 
5923
     relation `u.v-v.u=2*af(u,v)' where `af' is an antisymmetric
 
5924
     scalar-valued function. For the symplectic algebra, <opt_dims> can
 
5925
     be up to two nonnegative integers, representing the nondegenerate
 
5926
     and degenerate dimensions, respectively. If any <opt_dims> values
 
5927
     are supplied, `atensor' will configure the values of `adim' and
 
5928
     `aform' appropriately. Otherwise, `adim' will default to 0 and
 
5929
     `aform' will not be defined.
 
5930
 
 
5931
     `lie_envelop': The algebra of the Lie envelope is defined by the
 
5932
     commutation relation `u.v-v.u=2*av(u,v)' where `av' is an
 
5933
     antisymmetric function.
 
5934
 
 
5935
     The `init_atensor' function also recognizes several predefined
 
5936
     algebra types:
 
5937
 
 
5938
     `complex' implements the algebra of complex numbers as the
 
5939
     Clifford algebra Cl(0,1). The call `init_atensor(complex)' is
 
5940
     equivalent to `init_atensor(clifford,0,0,1)'.
 
5941
 
 
5942
     `quaternion' implements the algebra of quaternions. The call
 
5943
     `init_atensor(quaternion)' is equivalent to
 
5944
     `init_atensor(clifford,0,0,2)'.
 
5945
 
 
5946
     `pauli' implements the algebra of Pauli-spinors as the
 
5947
     Clifford-algebra Cl(3,0). A call to `init_atensor(pauli)' is
 
5948
     equivalent to `init_atensor(clifford,3)'.
 
5949
 
 
5950
     `dirac' implements the algebra of Dirac-spinors as the
 
5951
     Clifford-algebra Cl(3,1). A call to `init_atensor(dirac)' is
 
5952
     equivalent to `init_atensor(clifford,3,0,1)'.
 
5953
 
 
5954
 
 
5955
 -- Function: atensimp (<expr>)
 
5956
     Simplifies an algebraic tensor expression <expr> according to the
 
5957
     rules configured by a call to `init_atensor'. Simplification
 
5958
     includes recursive application of commutation relations and
 
5959
     resolving calls to `sf', `af', and `av' where applicable. A
 
5960
     safeguard is used to ensure that the function always terminates,
 
5961
     even for complex expressions.
 
5962
 
 
5963
 
 
5964
 -- Function: alg_type
 
5965
     The algebra type. Valid values are `universal', `grassmann',
 
5966
     `clifford', `symmetric', `symplectic' and `lie_envelop'.
 
5967
 
 
5968
 
 
5969
 -- Variable: adim
 
5970
     Default value: 0
 
5971
 
 
5972
     The dimensionality of the algebra. `atensor' uses the value of
 
5973
     `adim' to determine if an indexed object is a valid base vector.
 
5974
     See `abasep'.
 
5975
 
 
5976
 
 
5977
 -- Variable: aform
 
5978
     Default value: `ident(3)'
 
5979
 
 
5980
     Default values for the bilinear forms `sf', `af', and `av'. The
 
5981
     default is the identity matrix `ident(3)'.
 
5982
 
 
5983
 
 
5984
 -- Variable: asymbol
 
5985
     Default value: `v'
 
5986
 
 
5987
     The symbol for base vectors..
 
5988
 
 
5989
 
 
5990
 -- Function: sf (<u>, <v>)
 
5991
     A symmetric scalar function that is used in commutation relations.
 
5992
     The default implementation checks if both arguments are base
 
5993
     vectors using `abasep' and if that is the case, substitutes the
 
5994
     corresponding value from the matrix `aform'.
 
5995
 
 
5996
 
 
5997
 -- Function: af (<u>, <v>)
 
5998
     An antisymmetric scalar function that is used in commutation
 
5999
     relations.  The default implementation checks if both arguments
 
6000
     are base vectors using `abasep' and if that is the case,
 
6001
     substitutes the corresponding value from the matrix `aform'.
 
6002
 
 
6003
 
 
6004
 -- Function: av (<u>, <v>)
 
6005
     An antisymmetric function that is used in commutation relations.
 
6006
     The default implementation checks if both arguments are base
 
6007
     vectors using `abasep' and if that is the case, substitutes the
 
6008
     corresponding value from the matrix `aform'.
 
6009
 
 
6010
     For instance:
 
6011
 
 
6012
          (%i1) load(atensor);
 
6013
          (%o1)       /share/tensor/atensor.mac
 
6014
          (%i2) adim:3;
 
6015
          (%o2)                                  3
 
6016
          (%i3) aform:matrix([0,3,-2],[-3,0,1],[2,-1,0]);
 
6017
                                         [  0    3   - 2 ]
 
6018
                                         [               ]
 
6019
          (%o3)                          [ - 3   0    1  ]
 
6020
                                         [               ]
 
6021
                                         [  2   - 1   0  ]
 
6022
          (%i4) asymbol:x;
 
6023
          (%o4)                                  x
 
6024
          (%i5) av(x[1],x[2]);
 
6025
          (%o5)                                 x
 
6026
                                                 3
 
6027
 
 
6028
 
 
6029
 -- Function: abasep (<v>)
 
6030
     Checks if its argument is an `atensor' base vector. That is, if it
 
6031
     is an indexed symbol, with the symbol being the same as the value
 
6032
     of `asymbol', and the index having a numeric value between 1 and
 
6033
     `adim'.
 
6034
 
 
6035
 
 
6036
 
 
6037
File: maxima.info,  Node: Series,  Next: Number Theory,  Prev: atensor,  Up: Top
 
6038
 
 
6039
31 Series
 
6040
*********
 
6041
 
 
6042
* Menu:
 
6043
 
 
6044
* Introduction to Series::
 
6045
* Definitions for Series::
 
6046
 
 
6047
 
 
6048
File: maxima.info,  Node: Introduction to Series,  Next: Definitions for Series,  Prev: Series,  Up: Series
 
6049
 
 
6050
31.1 Introduction to Series
 
6051
===========================
 
6052
 
 
6053
Maxima contains functions `taylor' and `powerseries' for finding the
 
6054
series of differentiable functions.   It also has tools such as `nusum'
 
6055
capable of finding the closed form of some series.   Operations such as
 
6056
addition and multiplication work as usual on series. This section
 
6057
presents the global variables which control the expansion.
 
6058
 
 
6059
 
 
6060
File: maxima.info,  Node: Definitions for Series,  Prev: Introduction to Series,  Up: Series
 
6061
 
 
6062
31.2 Definitions for Series
 
6063
===========================
 
6064
 
 
6065
 -- Option variable: cauchysum
 
6066
     Default value: `false'
 
6067
 
 
6068
     When multiplying together sums with `inf' as their upper limit, if
 
6069
     `sumexpand' is `true' and `cauchysum' is `true' then the Cauchy
 
6070
     product will be used rather than the usual product.  In the Cauchy
 
6071
     product the index of the inner summation is a function of the
 
6072
     index of the outer one rather than varying independently.
 
6073
 
 
6074
     Example:
 
6075
 
 
6076
          (%i1) sumexpand: false$
 
6077
          (%i2) cauchysum: false$
 
6078
          (%i3) s: sum (f(i), i, 0, inf) * sum (g(j), j, 0, inf);
 
6079
                                inf         inf
 
6080
                                ====        ====
 
6081
                                \           \
 
6082
          (%o3)                ( >    f(i))  >    g(j)
 
6083
                                /           /
 
6084
                                ====        ====
 
6085
                                i = 0       j = 0
 
6086
          (%i4) sumexpand: true$
 
6087
          (%i5) cauchysum: true$
 
6088
          (%i6) ''s;
 
6089
                           inf     i1
 
6090
                           ====   ====
 
6091
                           \      \
 
6092
          (%o6)             >      >     g(i1 - i2) f(i2)
 
6093
                           /      /
 
6094
                           ====   ====
 
6095
                           i1 = 0 i2 = 0
 
6096
 
 
6097
 
 
6098
 -- Function: deftaylor (<f_1>(<x_1>), <expr_1>, ..., <f_n>(<x_n>),
 
6099
          <expr_n>)
 
6100
     For each function <f_i> of one variable <x_i>, `deftaylor' defines
 
6101
     <expr_i> as the Taylor series about zero.  <expr_i> is typically a
 
6102
     polynomial in <x_i> or a summation; more general expressions are
 
6103
     accepted by `deftaylor' without complaint.
 
6104
 
 
6105
     `powerseries (<f_i>(<x_i>), <x_i>, 0)' returns the series defined
 
6106
     by `deftaylor'.
 
6107
 
 
6108
     `deftaylor' returns a list of the functions <f_1>, ..., <f_n>.
 
6109
     `deftaylor' evaluates its arguments.
 
6110
 
 
6111
     Example:
 
6112
 
 
6113
          (%i1) deftaylor (f(x), x^2 + sum(x^i/(2^i*i!^2), i, 4, inf));
 
6114
          (%o1)                          [f]
 
6115
          (%i2) powerseries (f(x), x, 0);
 
6116
                                inf
 
6117
                                ====      i1
 
6118
                                \        x         2
 
6119
          (%o2)                  >     -------- + x
 
6120
                                /       i1    2
 
6121
                                ====   2   i1!
 
6122
                                i1 = 4
 
6123
          (%i3) taylor (exp (sqrt (f(x))), x, 0, 4);
 
6124
                                2         3          4
 
6125
                               x    3073 x    12817 x
 
6126
          (%o3)/T/     1 + x + -- + ------- + -------- + . . .
 
6127
                               2     18432     307200
 
6128
 
 
6129
 
 
6130
 -- Option variable: maxtayorder
 
6131
     Default value: `true'
 
6132
 
 
6133
     When `maxtayorder' is `true', then during algebraic manipulation
 
6134
     of (truncated) Taylor series, `taylor' tries to retain as many
 
6135
     terms as are known to be correct.
 
6136
 
 
6137
 
 
6138
 -- Function: niceindices (<expr>)
 
6139
     Renames the indices of sums and products in <expr>.  `niceindices'
 
6140
     attempts to rename each index to the value of `niceindicespref[1]',
 
6141
     unless that name appears in the summand or multiplicand, in which
 
6142
     case `niceindices' tries the succeeding elements of
 
6143
     `niceindicespref' in turn, until an unused variable is found.  If
 
6144
     the entire list is exhausted, additional indices are constructed
 
6145
     by appending integers to the value of `niceindicespref[1]', e.g.,
 
6146
     `i0', `i1', `i2', ....
 
6147
 
 
6148
     `niceindices' returns an expression.  `niceindices' evaluates its
 
6149
     argument.
 
6150
 
 
6151
     Example:
 
6152
 
 
6153
          (%i1) niceindicespref;
 
6154
          (%o1)                  [i, j, k, l, m, n]
 
6155
          (%i2) product (sum (f (foo + i*j*bar), foo, 1, inf), bar, 1, inf);
 
6156
                           inf    inf
 
6157
                          /===\   ====
 
6158
                           ! !    \
 
6159
          (%o2)            ! !     >      f(bar i j + foo)
 
6160
                           ! !    /
 
6161
                          bar = 1 ====
 
6162
                                  foo = 1
 
6163
          (%i3) niceindices (%);
 
6164
                               inf  inf
 
6165
                              /===\ ====
 
6166
                               ! !  \
 
6167
          (%o3)                ! !   >    f(i j l + k)
 
6168
                               ! !  /
 
6169
                              l = 1 ====
 
6170
                                    k = 1
 
6171
 
 
6172
 
 
6173
 -- Option variable: niceindicespref
 
6174
     Default value: `[i, j, k, l, m, n]'
 
6175
 
 
6176
     `niceindicespref' is the list from which `niceindices' takes the
 
6177
     names of indices for sums and products.
 
6178
 
 
6179
     The elements of `niceindicespref' are typically names of variables,
 
6180
     although that is not enforced by `niceindices'.
 
6181
 
 
6182
     Example:
 
6183
 
 
6184
          (%i1) niceindicespref: [p, q, r, s, t, u]$
 
6185
          (%i2) product (sum (f (foo + i*j*bar), foo, 1, inf), bar, 1, inf);
 
6186
                           inf    inf
 
6187
                          /===\   ====
 
6188
                           ! !    \
 
6189
          (%o2)            ! !     >      f(bar i j + foo)
 
6190
                           ! !    /
 
6191
                          bar = 1 ====
 
6192
                                  foo = 1
 
6193
          (%i3) niceindices (%);
 
6194
                               inf  inf
 
6195
                              /===\ ====
 
6196
                               ! !  \
 
6197
          (%o3)                ! !   >    f(i j q + p)
 
6198
                               ! !  /
 
6199
                              q = 1 ====
 
6200
                                    p = 1
 
6201
 
 
6202
 
 
6203
 -- Function: nusum (<expr>, <x>, <i_0>, <i_1>)
 
6204
     Carries out indefinite hypergeometric summation of <expr> with
 
6205
     respect to <x> using a decision procedure due to R.W. Gosper.
 
6206
     <expr> and the result must be expressible as products of integer
 
6207
     powers, factorials, binomials, and rational functions.
 
6208
 
 
6209
     The terms "definite" and "indefinite summation" are used
 
6210
     analogously to "definite" and "indefinite integration".  To sum
 
6211
     indefinitely means to give a symbolic result for the sum over
 
6212
     intervals of variable length, not just e.g. 0 to inf.  Thus, since
 
6213
     there is no formula for the general partial sum of the binomial
 
6214
     series, `nusum' can't do it.
 
6215
 
 
6216
     `nusum' and `unsum' know a little about sums and differences of
 
6217
     finite products.  See also `unsum'.
 
6218
 
 
6219
     Examples:
 
6220
 
 
6221
          (%i1) nusum (n*n!, n, 0, n);
 
6222
 
 
6223
          Dependent equations eliminated:  (1)
 
6224
          (%o1)                     (n + 1)! - 1
 
6225
          (%i2) nusum (n^4*4^n/binomial(2*n,n), n, 0, n);
 
6226
                               4        3       2              n
 
6227
                2 (n + 1) (63 n  + 112 n  + 18 n  - 22 n + 3) 4      2
 
6228
          (%o2) ------------------------------------------------ - ------
 
6229
                              693 binomial(2 n, n)                 3 11 7
 
6230
          (%i3) unsum (%, n);
 
6231
                                        4  n
 
6232
                                       n  4
 
6233
          (%o3)                   ----------------
 
6234
                                  binomial(2 n, n)
 
6235
          (%i4) unsum (prod (i^2, i, 1, n), n);
 
6236
                              n - 1
 
6237
                              /===\
 
6238
                               ! !   2
 
6239
          (%o4)              ( ! !  i ) (n - 1) (n + 1)
 
6240
                               ! !
 
6241
                              i = 1
 
6242
          (%i5) nusum (%, n, 1, n);
 
6243
 
 
6244
          Dependent equations eliminated:  (2 3)
 
6245
                                      n
 
6246
                                    /===\
 
6247
                                     ! !   2
 
6248
          (%o5)                      ! !  i  - 1
 
6249
                                     ! !
 
6250
                                    i = 1
 
6251
 
 
6252
 
 
6253
 -- Function: pade (<taylor_series>, <numer_deg_bound>,
 
6254
          <denom_deg_bound>)
 
6255
     Returns a list of all rational functions which have the given
 
6256
     Taylor series expansion where the sum of the degrees of the
 
6257
     numerator and the denominator is less than or equal to the
 
6258
     truncation level of the power series, i.e.  are "best"
 
6259
     approximants, and which additionally satisfy the specified degree
 
6260
     bounds.
 
6261
 
 
6262
     <taylor_series> is a univariate Taylor series.  <numer_deg_bound>
 
6263
     and <denom_deg_bound> are positive integers specifying degree
 
6264
     bounds on the numerator and denominator.
 
6265
 
 
6266
     <taylor_series> can also be a Laurent series, and the degree
 
6267
     bounds can be `inf' which causes all rational functions whose total
 
6268
     degree is less than or equal to the length of the power series to
 
6269
     be returned.  Total degree is defined as `<numer_deg_bound> +
 
6270
     <denom_deg_bound>'.  Length of a power series is defined as
 
6271
     `"truncation level" + 1 - min(0, "order of series")'.
 
6272
 
 
6273
          (%i1) taylor (1 + x + x^2 + x^3, x, 0, 3);
 
6274
                                        2    3
 
6275
          (%o1)/T/             1 + x + x  + x  + . . .
 
6276
          (%i2) pade (%, 1, 1);
 
6277
                                           1
 
6278
          (%o2)                       [- -----]
 
6279
                                         x - 1
 
6280
          (%i3) t: taylor(-(83787*x^10 - 45552*x^9 - 187296*x^8
 
6281
                             + 387072*x^7 + 86016*x^6 - 1507328*x^5
 
6282
                             + 1966080*x^4 + 4194304*x^3 - 25165824*x^2
 
6283
                             + 67108864*x - 134217728)
 
6284
                 /134217728, x, 0, 10);
 
6285
                              2    3       4       5       6        7
 
6286
                       x   3 x    x    15 x    23 x    21 x    189 x
 
6287
          (%o3)/T/ 1 - - + ---- - -- - ----- + ----- - ----- - ------
 
6288
                       2    16    32   1024    2048    32768   65536
 
6289
 
 
6290
                                            8         9          10
 
6291
                                      5853 x    2847 x    83787 x
 
6292
                                    + ------- + ------- - --------- + . . .
 
6293
                                      4194304   8388608   134217728
 
6294
          (%i4) pade (t, 4, 4);
 
6295
          (%o4)                          []
 
6296
 
 
6297
     There is no rational function of degree 4 numerator/denominator,
 
6298
     with this power series expansion.  You must in general have degree
 
6299
     of the numerator and degree of the denominator adding up to at
 
6300
     least the degree of the power series, in order to have enough
 
6301
     unknown coefficients to solve.
 
6302
 
 
6303
          (%i5) pade (t, 5, 5);
 
6304
                               5                4                 3
 
6305
          (%o5) [- (520256329 x  - 96719020632 x  - 489651410240 x
 
6306
 
 
6307
                            2
 
6308
           - 1619100813312 x  - 2176885157888 x - 2386516803584)
 
6309
 
 
6310
                         5                 4                  3
 
6311
          /(47041365435 x  + 381702613848 x  + 1360678489152 x
 
6312
 
 
6313
                            2
 
6314
           + 2856700692480 x  + 3370143559680 x + 2386516803584)]
 
6315
 
 
6316
 
 
6317
 -- Option variable: powerdisp
 
6318
     Default value: `false'
 
6319
 
 
6320
     When `powerdisp' is `true', a sum is displayed with its terms in
 
6321
     order of increasing power.  Thus a polynomial is displayed as a
 
6322
     truncated power series, with the constant term first and the
 
6323
     highest power last.
 
6324
 
 
6325
     By default, terms of a sum are displayed in order of decreasing
 
6326
     power.
 
6327
 
 
6328
 
 
6329
 -- Function: powerseries (<expr>, <x>, <a>)
 
6330
     Returns the general form of the power series expansion for <expr>
 
6331
     in the variable <x> about the point <a> (which may be `inf' for
 
6332
     infinity).
 
6333
 
 
6334
     If `powerseries' is unable to expand <expr>, `taylor' may give the
 
6335
     first several terms of the series.
 
6336
 
 
6337
     When `verbose' is `true', `powerseries' prints progress messages.
 
6338
 
 
6339
          (%i1) verbose: true$
 
6340
          (%i2) powerseries (log(sin(x)/x), x, 0);
 
6341
          can't expand
 
6342
                                           log(sin(x))
 
6343
          so we'll try again after applying the rule:
 
6344
                                                  d
 
6345
                                                / -- (sin(x))
 
6346
                                                [ dx
 
6347
                                  log(sin(x)) = i ----------- dx
 
6348
                                                ]   sin(x)
 
6349
                                                /
 
6350
          in the first simplification we have returned:
 
6351
                                       /
 
6352
                                       [
 
6353
                                       i cot(x) dx - log(x)
 
6354
                                       ]
 
6355
                                       /
 
6356
                              inf
 
6357
                              ====        i1  2 i1             2 i1
 
6358
                              \      (- 1)   2     bern(2 i1) x
 
6359
                               >     ------------------------------
 
6360
                              /                i1 (2 i1)!
 
6361
                              ====
 
6362
                              i1 = 1
 
6363
          (%o2)                -------------------------------------
 
6364
                                                2
 
6365
 
 
6366
 
 
6367
 -- Option variable: psexpand
 
6368
     Default value: `false'
 
6369
 
 
6370
     When `psexpand' is `true', an extended rational function
 
6371
     expression is displayed fully expanded.  The switch `ratexpand'
 
6372
     has the same effect.
 
6373
 
 
6374
     When `psexpand' is `false', a multivariate expression is displayed
 
6375
     just as in the rational function package.
 
6376
 
 
6377
     When `psexpand' is  `multi', then terms with the same total degree
 
6378
     in the variables are grouped together.
 
6379
 
 
6380
 
 
6381
 -- Function: revert (<expr>, <x>)
 
6382
 -- Function: revert2 (<expr>, <x>, <n>)
 
6383
     These functions return the reversion of <expr>, a Taylor series
 
6384
     about zero in the variable <x>.  `revert' returns a polynomial of
 
6385
     degree equal to the highest power in <expr>.  `revert2' returns a
 
6386
     polynomial of degree <n>, which may be greater than, equal to, or
 
6387
     less than the degree of <expr>.
 
6388
 
 
6389
     `load ("revert")' loads these functions.
 
6390
 
 
6391
     Examples:
 
6392
 
 
6393
          (%i1) load ("revert")$
 
6394
          (%i2) t: taylor (exp(x) - 1, x, 0, 6);
 
6395
                             2    3    4    5     6
 
6396
                            x    x    x    x     x
 
6397
          (%o2)/T/      x + -- + -- + -- + --- + --- + . . .
 
6398
                            2    6    24   120   720
 
6399
          (%i3) revert (t, x);
 
6400
                         6       5       4       3       2
 
6401
                     10 x  - 12 x  + 15 x  - 20 x  + 30 x  - 60 x
 
6402
          (%o3)/R/ - --------------------------------------------
 
6403
                                          60
 
6404
          (%i4) ratexpand (%);
 
6405
                               6    5    4    3    2
 
6406
                              x    x    x    x    x
 
6407
          (%o4)             - -- + -- - -- + -- - -- + x
 
6408
                              6    5    4    3    2
 
6409
          (%i5) taylor (log(x+1), x, 0, 6);
 
6410
                              2    3    4    5    6
 
6411
                             x    x    x    x    x
 
6412
          (%o5)/T/       x - -- + -- - -- + -- - -- + . . .
 
6413
                             2    3    4    5    6
 
6414
          (%i6) ratsimp (revert (t, x) - taylor (log(x+1), x, 0, 6));
 
6415
          (%o6)                           0
 
6416
          (%i7) revert2 (t, x, 4);
 
6417
                                    4    3    2
 
6418
                                   x    x    x
 
6419
          (%o7)                  - -- + -- - -- + x
 
6420
                                   4    3    2
 
6421
 
 
6422
 
 
6423
 -- Function: taylor (<expr>, <x>, <a>, <n>)
 
6424
 -- Function: taylor (<expr>, [<x_1>, <x_2>, ...], <a>, <n>)
 
6425
 -- Function: taylor (<expr>, [<x>, <a>, <n>, 'asymp])
 
6426
 -- Function: taylor (<expr>, [<x_1>, <x_2>, ...], [<a_1>, <a_2>, ...],
 
6427
          [<n_1>, <n_2>, ...])
 
6428
     `taylor (<expr>, <x>, <a>, <n>)' expands the expression <expr> in
 
6429
     a truncated Taylor or Laurent series in the variable <x> around
 
6430
     the point <a>, containing terms through `(<x> - <a>)^<n>'.
 
6431
 
 
6432
     If <expr> is of the form `<f>(<x>)/<g>(<x>)' and `<g>(<x>)' has no
 
6433
     terms up to degree <n> then `taylor' attempts to expand `<g>(<x>)'
 
6434
     up to degree `2 <n>'.  If there are still no nonzero terms,
 
6435
     `taylor' doubles the degree of the expansion of `<g>(<x>)' so long
 
6436
     as the degree of the expansion is less than or equal to `<n>
 
6437
     2^taylordepth'.
 
6438
 
 
6439
     `taylor (<expr>, [<x_1>, <x_2>, ...], <a>, <n>)' returns a
 
6440
     truncated power series of degree <n> in all variables <x_1>,
 
6441
     <x_2>, ...  about the point `(<a>, <a>, ...)'.
 
6442
 
 
6443
     `taylor (<expr>, [<x_1>, <a_1>, <n_1>], [<x_2>, <a_2>, <n_2>],
 
6444
     ...)'  returns a truncated power series in the variables <x_1>,
 
6445
     <x_2>, ...  about the point `(<a_1>, <a_2>, ...)', truncated at
 
6446
     <n_1>, <n_2>, ....
 
6447
 
 
6448
     `taylor (<expr>, [<x_1>, <x_2>, ...], [<a_1>, <a_2>, ...], [<n_1>,
 
6449
     <n_2>, ...])' returns a truncated power series in the variables
 
6450
     <x_1>, <x_2>, ...  about the point `(<a_1>, <a_2>, ...)',
 
6451
     truncated at <n_1>, <n_2>, ....
 
6452
 
 
6453
     `taylor (<expr>, [<x>, <a>, <n>, 'asymp])' returns an expansion of
 
6454
     <expr> in negative powers of `<x> - <a>'.  The highest order term
 
6455
     is `(<x> - <a>)^<-n>'.
 
6456
 
 
6457
     When `maxtayorder' is `true', then during algebraic manipulation
 
6458
     of (truncated) Taylor series, `taylor' tries to retain as many
 
6459
     terms as are known to be correct.
 
6460
 
 
6461
     When `psexpand' is `true', an extended rational function
 
6462
     expression is displayed fully expanded.  The switch `ratexpand'
 
6463
     has the same effect.  When `psexpand' is `false', a multivariate
 
6464
     expression is displayed just as in the rational function package.
 
6465
     When `psexpand' is  `multi', then terms with the same total degree
 
6466
     in the variables are grouped together.
 
6467
 
 
6468
     See also the `taylor_logexpand' switch for controlling expansion.
 
6469
 
 
6470
     Examples:
 
6471
 
 
6472
          (%i1) taylor (sqrt (sin(x) + a*x + 1), x, 0, 3);
 
6473
                                     2             2
 
6474
                       (a + 1) x   (a  + 2 a + 1) x
 
6475
          (%o1)/T/ 1 + --------- - -----------------
 
6476
                           2               8
 
6477
 
 
6478
                                             3      2             3
 
6479
                                         (3 a  + 9 a  + 9 a - 1) x
 
6480
                                       + -------------------------- + . . .
 
6481
                                                     48
 
6482
          (%i2) %^2;
 
6483
                                              3
 
6484
                                             x
 
6485
          (%o2)/T/           1 + (a + 1) x - -- + . . .
 
6486
                                             6
 
6487
          (%i3) taylor (sqrt (x + 1), x, 0, 5);
 
6488
                                 2    3      4      5
 
6489
                            x   x    x    5 x    7 x
 
6490
          (%o3)/T/      1 + - - -- + -- - ---- + ---- + . . .
 
6491
                            2   8    16   128    256
 
6492
          (%i4) %^2;
 
6493
          (%o4)/T/                  1 + x + . . .
 
6494
          (%i5) product ((1 + x^i)^2.5, i, 1, inf)/(1 + x^2);
 
6495
                                   inf
 
6496
                                  /===\
 
6497
                                   ! !    i     2.5
 
6498
                                   ! !  (x  + 1)
 
6499
                                   ! !
 
6500
                                  i = 1
 
6501
          (%o5)                   -----------------
 
6502
                                        2
 
6503
                                       x  + 1
 
6504
          (%i6) ev (taylor(%, x,  0, 3), keepfloat);
 
6505
                                         2           3
 
6506
          (%o6)/T/    1 + 2.5 x + 3.375 x  + 6.5625 x  + . . .
 
6507
          (%i7) taylor (1/log (x + 1), x, 0, 3);
 
6508
                                         2       3
 
6509
                           1   1   x    x    19 x
 
6510
          (%o7)/T/         - + - - -- + -- - ----- + . . .
 
6511
                           x   2   12   24    720
 
6512
          (%i8) taylor (cos(x) - sec(x), x, 0, 5);
 
6513
                                          4
 
6514
                                     2   x
 
6515
          (%o8)/T/                - x  - -- + . . .
 
6516
                                         6
 
6517
          (%i9) taylor ((cos(x) - sec(x))^3, x, 0, 5);
 
6518
          (%o9)/T/                    0 + . . .
 
6519
          (%i10) taylor (1/(cos(x) - sec(x))^3, x, 0, 5);
 
6520
                                                         2          4
 
6521
                      1     1       11      347    6767 x    15377 x
 
6522
          (%o10)/T/ - -- + ---- + ------ - ----- - ------- - --------
 
6523
                       6      4        2   15120   604800    7983360
 
6524
                      x    2 x    120 x
 
6525
 
 
6526
                                                                    + . . .
 
6527
          (%i11) taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6);
 
6528
                         2  2       4      2   4
 
6529
                        k  x    (3 k  - 4 k ) x
 
6530
          (%o11)/T/ 1 - ----- - ----------------
 
6531
                          2            24
 
6532
 
 
6533
                                              6       4       2   6
 
6534
                                         (45 k  - 60 k  + 16 k ) x
 
6535
                                       - -------------------------- + . . .
 
6536
                                                    720
 
6537
          (%i12) taylor ((x + 1)^n, x, 0, 4);
 
6538
                                2       2     3      2         3
 
6539
                              (n  - n) x    (n  - 3 n  + 2 n) x
 
6540
          (%o12)/T/ 1 + n x + ----------- + --------------------
 
6541
                                   2                 6
 
6542
 
 
6543
                                         4      3       2         4
 
6544
                                       (n  - 6 n  + 11 n  - 6 n) x
 
6545
                                     + ---------------------------- + . . .
 
6546
                                                    24
 
6547
          (%i13) taylor (sin (y + x), x, 0, 3, y, 0, 3);
 
6548
                         3                 2
 
6549
                        y                 y
 
6550
          (%o13)/T/ y - -- + . . . + (1 - -- + . . .) x
 
6551
                        6                 2
 
6552
 
 
6553
                              3                       2
 
6554
                         y   y            2      1   y            3
 
6555
                    + (- - + -- + . . .) x  + (- - + -- + . . .) x  + . . .
 
6556
                         2   12                  6   12
 
6557
          (%i14) taylor (sin (y + x), [x, y], 0, 3);
 
6558
                               3        2      2      3
 
6559
                              x  + 3 y x  + 3 y  x + y
 
6560
          (%o14)/T/   y + x - ------------------------- + . . .
 
6561
                                          6
 
6562
          (%i15) taylor (1/sin (y + x), x, 0, 3, y, 0, 3);
 
6563
                    1   y              1    1               1            2
 
6564
          (%o15)/T/ - + - + . . . + (- -- + - + . . .) x + (-- + . . .) x
 
6565
                    y   6               2   6                3
 
6566
                                       y                    y
 
6567
 
 
6568
                                                     1            3
 
6569
                                                + (- -- + . . .) x  + . . .
 
6570
                                                      4
 
6571
                                                     y
 
6572
          (%i16) taylor (1/sin (y + x), [x, y], 0, 3);
 
6573
                                       3         2       2        3
 
6574
                      1     x + y   7 x  + 21 y x  + 21 y  x + 7 y
 
6575
          (%o16)/T/ ----- + ----- + ------------------------------- + . . .
 
6576
                    x + y     6                   360
 
6577
 
 
6578
 
 
6579
 -- Option variable: taylordepth
 
6580
     Default value: 3
 
6581
 
 
6582
     If there are still no nonzero terms, `taylor' doubles the degree
 
6583
     of the expansion of `<g>(<x>)' so long as the degree of the
 
6584
     expansion is less than or equal to `<n> 2^taylordepth'.
 
6585
 
 
6586
 
 
6587
 -- Function: taylorinfo (<expr>)
 
6588
     Returns information about the Taylor series <expr>.  The return
 
6589
     value is a list of lists.  Each list comprises the name of a
 
6590
     variable, the point of expansion, and the degree of the expansion.
 
6591
 
 
6592
     `taylorinfo' returns `false' if <expr> is not a Taylor series.
 
6593
 
 
6594
     Example:
 
6595
 
 
6596
          (%i1) taylor ((1 - y^2)/(1 - x), x, 0, 3, [y, a, inf]);
 
6597
                            2                       2
 
6598
          (%o1)/T/ - (y - a)  - 2 a (y - a) + (1 - a )
 
6599
 
 
6600
                   2                        2
 
6601
           + (1 - a  - 2 a (y - a) - (y - a) ) x
 
6602
 
 
6603
                   2                        2   2
 
6604
           + (1 - a  - 2 a (y - a) - (y - a) ) x
 
6605
 
 
6606
                   2                        2   3
 
6607
           + (1 - a  - 2 a (y - a) - (y - a) ) x  + . . .
 
6608
          (%i2) taylorinfo(%);
 
6609
          (%o2)               [[y, a, inf], [x, 0, 3]]
 
6610
 
 
6611
 
 
6612
 -- Function: taylorp (<expr>)
 
6613
     Returns `true' if <expr> is a Taylor series, and `false' otherwise.
 
6614
 
 
6615
 
 
6616
 -- Option variable: taylor_logexpand
 
6617
     Default value: `true'
 
6618
 
 
6619
     `taylor_logexpand' controls expansions of logarithms in `taylor'
 
6620
     series.
 
6621
 
 
6622
     When `taylor_logexpand' is `true', all logarithms are expanded
 
6623
     fully so that zero-recognition problems involving logarithmic
 
6624
     identities do not disturb the expansion process.  However, this
 
6625
     scheme is not always mathematically correct since it ignores
 
6626
     branch information.
 
6627
 
 
6628
     When `taylor_logexpand' is set to `false', then the only expansion
 
6629
     of logarithms that occur is that necessary to obtain a formal
 
6630
     power series.
 
6631
 
 
6632
 
 
6633
 -- Option variable: taylor_order_coefficients
 
6634
     Default value: `true'
 
6635
 
 
6636
     `taylor_order_coefficients' controls the ordering of coefficients
 
6637
     in a Taylor series.
 
6638
 
 
6639
     When `taylor_order_coefficients' is `true', coefficients of taylor
 
6640
     series are ordered canonically.
 
6641
 
 
6642
 
 
6643
 -- Function: taylor_simplifier (<expr>)
 
6644
     Simplifies coefficients of the power series <expr>.  `taylor'
 
6645
     calls this function.
 
6646
 
 
6647
 
 
6648
 -- Option variable: taylor_truncate_polynomials
 
6649
     Default value: `true'
 
6650
 
 
6651
     When `taylor_truncate_polynomials' is `true', polynomials are
 
6652
     truncated based upon the input truncation levels.
 
6653
 
 
6654
     Otherwise, polynomials input to `taylor' are considered to have
 
6655
     infinite precison.
 
6656
 
 
6657
 
 
6658
 -- Function: taytorat (<expr>)
 
6659
     Converts <expr> from `taylor' form to canonical rational
 
6660
     expression (CRE) form.  The effect is the same as `rat (ratdisrep
 
6661
     (<expr>))', but faster.
 
6662
 
 
6663
 
 
6664
 -- Function: trunc (<expr>)
 
6665
     Annotates the internal representation of the general expression
 
6666
     <expr> so that it is displayed as if its sums were truncated
 
6667
     Taylor series.  <expr> is not otherwise modified.
 
6668
 
 
6669
     Example:
 
6670
 
 
6671
          (%i1) expr: x^2 + x + 1;
 
6672
                                      2
 
6673
          (%o1)                      x  + x + 1
 
6674
          (%i2) trunc (expr);
 
6675
                                          2
 
6676
          (%o2)                  1 + x + x  + . . .
 
6677
          (%i3) is (expr = trunc (expr));
 
6678
          (%o3)                         true
 
6679
 
 
6680
 
 
6681
 -- Function: unsum (<f>, <n>)
 
6682
     Returns the first backward difference `<f>(<n>) - <f>(<n> - 1)'.
 
6683
     Thus `unsum' in a sense is the inverse of `sum'.
 
6684
 
 
6685
     See also `nusum'.
 
6686
 
 
6687
     Examples:
 
6688
 
 
6689
          (%i1) g(p) := p*4^n/binomial(2*n,n);
 
6690
                                               n
 
6691
                                            p 4
 
6692
          (%o1)               g(p) := ----------------
 
6693
                                      binomial(2 n, n)
 
6694
          (%i2) g(n^4);
 
6695
                                        4  n
 
6696
                                       n  4
 
6697
          (%o2)                   ----------------
 
6698
                                  binomial(2 n, n)
 
6699
          (%i3) nusum (%, n, 0, n);
 
6700
                               4        3       2              n
 
6701
                2 (n + 1) (63 n  + 112 n  + 18 n  - 22 n + 3) 4      2
 
6702
          (%o3) ------------------------------------------------ - ------
 
6703
                              693 binomial(2 n, n)                 3 11 7
 
6704
          (%i4) unsum (%, n);
 
6705
                                        4  n
 
6706
                                       n  4
 
6707
          (%o4)                   ----------------
 
6708
                                  binomial(2 n, n)
 
6709
 
 
6710
 
 
6711
 -- Option variable: verbose
 
6712
     Default value: `false'
 
6713
 
 
6714
     When `verbose' is `true', `powerseries' prints progress messages.
 
6715
 
 
6716
 
 
6717
 
 
6718
File: maxima.info,  Node: Number Theory,  Next: Symmetries,  Prev: Series,  Up: Top
 
6719
 
 
6720
32 Number Theory
 
6721
****************
 
6722
 
 
6723
* Menu:
 
6724
 
 
6725
* Definitions for Number Theory::
 
6726
 
 
6727
 
 
6728
File: maxima.info,  Node: Definitions for Number Theory,  Prev: Number Theory,  Up: Number Theory
 
6729
 
 
6730
32.1 Definitions for Number Theory
 
6731
==================================
 
6732
 
 
6733
 -- Function: bern (<n>)
 
6734
     Returns the <n>'th Bernoulli number for integer <n>.  Bernoulli
 
6735
     numbers equal to zero are suppressed if `zerobern' is `false'.
 
6736
 
 
6737
     See also `burn'.
 
6738
 
 
6739
          (%i1) zerobern: true$
 
6740
          (%i2) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
 
6741
                            1  1       1      1        1
 
6742
          (%o2)       [1, - -, -, 0, - --, 0, --, 0, - --]
 
6743
                            2  6       30     42       30
 
6744
          (%i3) zerobern: false$
 
6745
          (%i4) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
 
6746
                      1  1    1   5     691   7    3617  43867
 
6747
          (%o4) [1, - -, -, - --, --, - ----, -, - ----, -----]
 
6748
                      2  6    30  66    2730  6    510    798
 
6749
 
 
6750
 
 
6751
 -- Function: bernpoly (<x>, <n>)
 
6752
     Returns the <n>'th Bernoulli polynomial in the variable <x>.
 
6753
 
 
6754
 
 
6755
 -- Function: bfzeta (<s>, <n>)
 
6756
     Returns the Riemann zeta function for the argument <s>.  The
 
6757
     return value is a big float (bfloat); <n> is the number of digits
 
6758
     in the return value.
 
6759
 
 
6760
     `load ("bffac")' loads this function.
 
6761
 
 
6762
 
 
6763
 -- Function: bfhzeta (<s>, <h>, <n>)
 
6764
     Returns the Hurwitz zeta function for the arguments <s> and <h>.
 
6765
     The return value is a big float (bfloat); <n> is the number of
 
6766
     digits in the return value.
 
6767
 
 
6768
     The Hurwitz zeta function is defined as
 
6769
 
 
6770
          sum ((k+h)^-s, k, 0, inf)
 
6771
 
 
6772
     `load ("bffac")' loads this function.
 
6773
 
 
6774
 
 
6775
 -- Function: binomial (<x>, <y>)
 
6776
     The binomial coefficient `<x>!/(<y>! (<x> - <y>)!)'.  If <x> and
 
6777
     <y> are integers, then the numerical value of the binomial
 
6778
     coefficient is computed.  If <y>, or <x - y>, is an integer, the
 
6779
     binomial coefficient is expressed as a polynomial.
 
6780
 
 
6781
     Examples:
 
6782
 
 
6783
          (%i1) binomial (11, 7);
 
6784
          (%o1)                          330
 
6785
          (%i2) 11! / 7! / (11 - 7)!;
 
6786
          (%o2)                          330
 
6787
          (%i3) binomial (x, 7);
 
6788
                  (x - 6) (x - 5) (x - 4) (x - 3) (x - 2) (x - 1) x
 
6789
          (%o3)   -------------------------------------------------
 
6790
                                        5040
 
6791
          (%i4) binomial (x + 7, x);
 
6792
                (x + 1) (x + 2) (x + 3) (x + 4) (x + 5) (x + 6) (x + 7)
 
6793
          (%o4) -------------------------------------------------------
 
6794
                                         5040
 
6795
          (%i5) binomial (11, y);
 
6796
          (%o5)                    binomial(11, y)
 
6797
 
 
6798
 
 
6799
 -- Function: burn (<n>)
 
6800
     Returns the <n>'th Bernoulli number for integer <n>.  `burn' may
 
6801
     be more efficient than `bern' for large, isolated <n> (perhaps <n>
 
6802
     greater than 105 or so), as `bern' computes all the Bernoulli
 
6803
     numbers up to index <n> before returning.
 
6804
 
 
6805
     `burn' exploits the observation that (rational) Bernoulli numbers
 
6806
     can be approximated by (transcendental) zetas with tolerable
 
6807
     efficiency.
 
6808
 
 
6809
     `load ("bffac")' loads this function.
 
6810
 
 
6811
 
 
6812
 -- Function: cf (<expr>)
 
6813
     Converts <expr> into a continued fraction.  <expr> is an expression
 
6814
     comprising continued fractions and square roots of integers.
 
6815
     Operands in the expression may be combined with arithmetic
 
6816
     operators.  Aside from continued fractions and square roots,
 
6817
     factors in the expression must be integer or rational numbers.
 
6818
     Maxima does not know about operations on continued fractions
 
6819
     outside of `cf'.
 
6820
 
 
6821
     `cf' evaluates its arguments after binding `listarith' to `false'.
 
6822
     `cf' returns a continued fraction, represented as a list.
 
6823
 
 
6824
     A continued fraction `a + 1/(b + 1/(c + ...))' is represented by
 
6825
     the list `[a, b, c, ...]'.  The list elements `a', `b', `c', ...
 
6826
     must evaluate to integers.  <expr> may also contain `sqrt (n)'
 
6827
     where `n' is an integer.  In this case `cf' will give as many
 
6828
     terms of the continued fraction as the value of the variable
 
6829
     `cflength' times the period.
 
6830
 
 
6831
     A continued fraction can be evaluated to a number by evaluating
 
6832
     the arithmetic representation returned by `cfdisrep'.  See also
 
6833
     `cfexpand' for another way to evaluate a continued fraction.
 
6834
 
 
6835
     See also `cfdisrep', `cfexpand', and `cflength'.
 
6836
 
 
6837
     Examples:
 
6838
 
 
6839
        * <expr> is an expression comprising continued fractions and
 
6840
          square roots of integers.
 
6841
 
 
6842
               (%i1) cf ([5, 3, 1]*[11, 9, 7] + [3, 7]/[4, 3, 2]);
 
6843
               (%o1)               [59, 17, 2, 1, 1, 1, 27]
 
6844
               (%i2) cf ((3/17)*[1, -2, 5]/sqrt(11) + (8/13));
 
6845
               (%o2)        [0, 1, 1, 1, 3, 2, 1, 4, 1, 9, 1, 9, 2]
 
6846
 
 
6847
        * `cflength' controls how many periods of the continued fraction
 
6848
          are computed for algebraic, irrational numbers.
 
6849
 
 
6850
               (%i1) cflength: 1$
 
6851
               (%i2) cf ((1 + sqrt(5))/2);
 
6852
               (%o2)                    [1, 1, 1, 1, 2]
 
6853
               (%i3) cflength: 2$
 
6854
               (%i4) cf ((1 + sqrt(5))/2);
 
6855
               (%o4)               [1, 1, 1, 1, 1, 1, 1, 2]
 
6856
               (%i5) cflength: 3$
 
6857
               (%i6) cf ((1 + sqrt(5))/2);
 
6858
               (%o6)           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
 
6859
 
 
6860
        * A continued fraction can be evaluated by evaluating the
 
6861
          arithmetic representation returned by `cfdisrep'.
 
6862
 
 
6863
               (%i1) cflength: 3$
 
6864
               (%i2) cfdisrep (cf (sqrt (3)))$
 
6865
               (%i3) ev (%, numer);
 
6866
               (%o3)                   1.731707317073171
 
6867
 
 
6868
        * Maxima does not know about operations on continued fractions
 
6869
          outside of `cf'.
 
6870
 
 
6871
               (%i1) cf ([1,1,1,1,1,2] * 3);
 
6872
               (%o1)                     [4, 1, 5, 2]
 
6873
               (%i2) cf ([1,1,1,1,1,2]) * 3;
 
6874
               (%o2)                  [3, 3, 3, 3, 3, 6]
 
6875
 
 
6876
 
 
6877
 -- Function: cfdisrep (<list>)
 
6878
     Constructs and returns an ordinary arithmetic expression of the
 
6879
     form `a + 1/(b + 1/(c + ...))' from the list representation of a
 
6880
     continued fraction `[a, b, c, ...]'.
 
6881
 
 
6882
          (%i1) cf ([1, 2, -3] + [1, -2, 1]);
 
6883
          (%o1)                     [1, 1, 1, 2]
 
6884
          (%i2) cfdisrep (%);
 
6885
                                            1
 
6886
          (%o2)                     1 + ---------
 
6887
                                              1
 
6888
                                        1 + -----
 
6889
                                                1
 
6890
                                            1 + -
 
6891
                                                2
 
6892
 
 
6893
 
 
6894
 -- Function: cfexpand (<x>)
 
6895
     Returns a matrix of the numerators and denominators of the last
 
6896
     (column 1) and next-to-last (column 2) convergents of the
 
6897
     continued fraction <x>.
 
6898
 
 
6899
          (%i1) cf (rat (ev (%pi, numer)));
 
6900
 
 
6901
          `rat' replaced 3.141592653589793 by 103993//33102 = 3.141592653011902
 
6902
          (%o1)                  [3, 7, 15, 1, 292]
 
6903
          (%i2) cfexpand (%);
 
6904
                                   [ 103993  355 ]
 
6905
          (%o2)                    [             ]
 
6906
                                   [ 33102   113 ]
 
6907
          (%i3) %[1,1]/%[2,1], numer;
 
6908
          (%o3)                   3.141592653011902
 
6909
 
 
6910
 
 
6911
 -- Option variable: cflength
 
6912
     Default value: 1
 
6913
 
 
6914
     `cflength' controls the number of terms of the continued fraction
 
6915
     the function `cf' will give, as the value `cflength' times the
 
6916
     period.  Thus the default is to give one period.
 
6917
 
 
6918
          (%i1) cflength: 1$
 
6919
          (%i2) cf ((1 + sqrt(5))/2);
 
6920
          (%o2)                    [1, 1, 1, 1, 2]
 
6921
          (%i3) cflength: 2$
 
6922
          (%i4) cf ((1 + sqrt(5))/2);
 
6923
          (%o4)               [1, 1, 1, 1, 1, 1, 1, 2]
 
6924
          (%i5) cflength: 3$
 
6925
          (%i6) cf ((1 + sqrt(5))/2);
 
6926
          (%o6)           [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
 
6927
 
 
6928
 
 
6929
 -- Function: divsum (<n>, <k>)
 
6930
 -- Function: divsum (<n>)
 
6931
     `divsum (<n>, <k>)' returns the sum of the divisors of <n> raised
 
6932
     to the <k>'th power.
 
6933
 
 
6934
     `divsum (<n>)' returns the sum of the divisors of <n>.
 
6935
 
 
6936
          (%i1) divsum (12);
 
6937
          (%o1)                          28
 
6938
          (%i2) 1 + 2 + 3 + 4 + 6 + 12;
 
6939
          (%o2)                          28
 
6940
          (%i3) divsum (12, 2);
 
6941
          (%o3)                          210
 
6942
          (%i4) 1^2 + 2^2 + 3^2 + 4^2 + 6^2 + 12^2;
 
6943
          (%o4)                          210
 
6944
 
 
6945
 
 
6946
 -- Function: euler (<n>)
 
6947
     Returns the <n>'th Euler number for nonnegative integer <n>.
 
6948
 
 
6949
     For the Euler-Mascheroni constant, see `%gamma'.
 
6950
 
 
6951
          (%i1) map (euler, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
 
6952
          (%o1)    [1, 0, - 1, 0, 5, 0, - 61, 0, 1385, 0, - 50521]
 
6953
 
 
6954
 
 
6955
 -- Constant: %gamma
 
6956
     The Euler-Mascheroni constant, 0.5772156649015329 ....
 
6957
 
 
6958
 
 
6959
 -- Function: factorial (<x>)
 
6960
     Represents the factorial function. Maxima treats `factorial (<x>)'
 
6961
     the same as `<x>!'.  See `!'.
 
6962
 
 
6963
 
 
6964
 -- Function: fib (<n>)
 
6965
     Returns the <n>'th Fibonacci number.  `fib(0)' equal to 0 and
 
6966
     `fib(1)' equal to 1, and `fib (-<n>)' equal to `(-1)^(<n> + 1) *
 
6967
     fib(<n>)'.
 
6968
 
 
6969
     After calling `fib', `prevfib' is equal to `fib (<x> - 1)', the
 
6970
     Fibonacci number preceding the last one computed.
 
6971
 
 
6972
          (%i1) map (fib, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
 
6973
          (%o1)         [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
 
6974
 
 
6975
 
 
6976
 -- Function: fibtophi (<expr>)
 
6977
     Expresses Fibonacci numbers in terms of the constant `%phi', which
 
6978
     is `(1 + sqrt(5))/2', approximately 1.61803399.
 
6979
 
 
6980
     By default, Maxima does not know about `%phi'.  After executing
 
6981
     `tellrat (%phi^2 - %phi - 1)' and `algebraic: true', `ratsimp' can
 
6982
     simplify some expressions containing `%phi'.
 
6983
 
 
6984
          (%i1) fibtophi (fib (n));
 
6985
                                     n             n
 
6986
                                 %phi  - (1 - %phi)
 
6987
          (%o1)                  -------------------
 
6988
                                     2 %phi - 1
 
6989
          (%i2) fib (n-1) + fib (n) - fib (n+1);
 
6990
          (%o2)          - fib(n + 1) + fib(n) + fib(n - 1)
 
6991
          (%i3) ratsimp (fibtophi (%));
 
6992
          (%o3)                           0
 
6993
 
 
6994
 
 
6995
 -- Function: ifactors (<n>)
 
6996
     For a positive integer <n> returns the factorization of <n>. If
 
6997
     `n=p1^e1..pk^nk' is the decomposition of <n> into prime factors,
 
6998
     ifactors returns `[[p1, e1], ... , [pk, ek]]'.
 
6999
 
 
7000
     Factorization methods used are trial divisions by primes up to
 
7001
     9973, Pollard's rho method and elliptic curve method.
 
7002
 
 
7003
          (%i1) ifactors(51575319651600);
 
7004
          (%o1)     [[2, 4], [3, 2], [5, 2], [1583, 1], [9050207, 1]]
 
7005
          (%i2) apply("*", map(lambda([u], u[1]^u[2]), %));
 
7006
          (%o2)                        51575319651600
 
7007
 
 
7008
 
 
7009
 -- Function: inrt (<x>, <n>)
 
7010
     Returns the integer <n>'th root of the absolute value of <x>.
 
7011
 
 
7012
          (%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$
 
7013
          (%i2) map (lambda ([a], inrt (10^a, 3)), l);
 
7014
          (%o2) [2, 4, 10, 21, 46, 100, 215, 464, 1000, 2154, 4641, 10000]
 
7015
 
 
7016
 
 
7017
 -- Function: inv_mod (<n>, <m>)
 
7018
     Computes the inverse of <n> modulo <m>.  `inv_mod (n,m)' returns
 
7019
     `false', if <n> is a zero divisor modulo <m>.
 
7020
 
 
7021
          (%i1) inv_mod(3, 41);
 
7022
          (%o1)                           14
 
7023
          (%i2) ratsimp(3^-1), modulus=41;
 
7024
          (%o2)                           14
 
7025
          (%i3) inv_mod(3, 42);
 
7026
          (%o3)                          false
 
7027
 
 
7028
 
 
7029
 -- Function: jacobi (<p>, <q>)
 
7030
     Returns the Jacobi symbol of <p> and <q>.
 
7031
 
 
7032
          (%i1) l: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]$
 
7033
          (%i2) map (lambda ([a], jacobi (a, 9)), l);
 
7034
          (%o2)         [1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 1, 0]
 
7035
 
 
7036
 
 
7037
 -- Function: lcm (<expr_1>, ..., <expr_n>)
 
7038
     Returns the least common multiple of its arguments.  The arguments
 
7039
     may be general expressions as well as integers.
 
7040
 
 
7041
     `load ("functs")' loads this function.
 
7042
 
 
7043
 
 
7044
 -- Function: minfactorial (<expr>)
 
7045
     Examines <expr> for occurrences of two factorials which differ by
 
7046
     an integer.  `minfactorial' then turns one into a polynomial times
 
7047
     the other.
 
7048
 
 
7049
          (%i1) n!/(n+2)!;
 
7050
                                         n!
 
7051
          (%o1)                       --------
 
7052
                                      (n + 2)!
 
7053
          (%i2) minfactorial (%);
 
7054
                                          1
 
7055
          (%o2)                    ---------------
 
7056
                                   (n + 1) (n + 2)
 
7057
 
 
7058
 
 
7059
 -- Function: power_mod (<a>, <n>, <m>)
 
7060
     Uses a modular algorithm to compute `a^n mod m' where <a> and <n>
 
7061
     are integers and <m> is a positive integer.  If <n> is negative,
 
7062
     `inv_mod' is used to find the modular inverse.
 
7063
 
 
7064
          (%i1) power_mod(3, 15, 5);
 
7065
          (%o1)                          2
 
7066
          (%i2) mod(3^15,5);
 
7067
          (%o2)                          2
 
7068
          (%i3) power_mod(2, -1, 5);
 
7069
          (%o3)                          3
 
7070
          (%i4) inv_mod(2,5);
 
7071
          (%o4)                          3
 
7072
 
 
7073
 
 
7074
 -- Function: next_prime (<n>)
 
7075
     Returns the smallest prime bigger than <n>.
 
7076
 
 
7077
          (%i1) next_prime(27);
 
7078
          (%o1)                       29
 
7079
 
 
7080
 
 
7081
 -- Function: partfrac (<expr>, <var>)
 
7082
     Expands the expression <expr> in partial fractions with respect to
 
7083
     the main variable <var>.  `partfrac' does a complete partial
 
7084
     fraction decomposition.  The algorithm employed is based on the
 
7085
     fact that the denominators of the partial fraction expansion (the
 
7086
     factors of the original denominator) are relatively prime.  The
 
7087
     numerators can be written as linear combinations of denominators,
 
7088
     and the expansion falls out.
 
7089
 
 
7090
          (%i1) 1/(1+x)^2 - 2/(1+x) + 2/(2+x);
 
7091
                                2       2        1
 
7092
          (%o1)               ----- - ----- + --------
 
7093
                              x + 2   x + 1          2
 
7094
                                              (x + 1)
 
7095
          (%i2) ratsimp (%);
 
7096
                                           x
 
7097
          (%o2)                 - -------------------
 
7098
                                   3      2
 
7099
                                  x  + 4 x  + 5 x + 2
 
7100
          (%i3) partfrac (%, x);
 
7101
                                2       2        1
 
7102
          (%o3)               ----- - ----- + --------
 
7103
                              x + 2   x + 1          2
 
7104
                                              (x + 1)
 
7105
 
 
7106
 -- Function: primep (<n>)
 
7107
     Primality test. If `primep (n)' returns `false', <n> is a
 
7108
     composite number and if it returns `true', <n> is a prime number
 
7109
     with very high probability.
 
7110
 
 
7111
     For <n> less than 341550071728321 a deterministic version of
 
7112
     Miller-Rabin's test is used. If `primep (n)' returns `true', then
 
7113
     <n> is a prime number.
 
7114
 
 
7115
     For <n> bigger than 34155071728321 `primep' uses
 
7116
     `primep_number_of_tests' Miller-Rabin's pseudo-primality tests and
 
7117
     one Lucas pseudo-primality test. The probability that <n> will
 
7118
     pass one Miller-Rabin test is less than 1/4. Using the default
 
7119
     value 25 for `primep_number_of_tests', the probability of <n>
 
7120
     beeing composite is much smaller that 10^-15.
 
7121
 
 
7122
 
 
7123
 -- Option variable: primep_number_of_tests
 
7124
     Default value: 25
 
7125
 
 
7126
     Number of Miller-Rabin's tests used in `primep'.
 
7127
 
 
7128
 -- Function: prev_prime (<n>)
 
7129
     Returns the greatest prime smaller than <n>.
 
7130
 
 
7131
          (%i1) prev_prime(27);
 
7132
          (%o1)                       23
 
7133
 
 
7134
 -- Function: qunit (<n>)
 
7135
     Returns the principal unit of the real quadratic number field
 
7136
     `sqrt (<n>)' where <n> is an integer, i.e., the element whose norm
 
7137
     is unity.  This amounts to solving Pell's equation `a^2 - <n> b^2
 
7138
     = 1'.
 
7139
 
 
7140
          (%i1) qunit (17);
 
7141
          (%o1)                     sqrt(17) + 4
 
7142
          (%i2) expand (% * (sqrt(17) - 4));
 
7143
          (%o2)                           1
 
7144
 
 
7145
 
 
7146
 -- Function: totient (<n>)
 
7147
     Returns the number of integers less than or equal to <n> which are
 
7148
     relatively prime to <n>.
 
7149
 
 
7150
 
 
7151
 -- Option variable: zerobern
 
7152
     Default value: `true'
 
7153
 
 
7154
     When `zerobern' is `false', `bern' excludes the Bernoulli numbers
 
7155
     which are equal to zero.  See `bern'.
 
7156
 
 
7157
 
 
7158
 -- Function: zeta (<n>)
 
7159
     Returns the Riemann zeta function if <x> is a negative integer, 0,
 
7160
     1, or a positive even number, and returns a noun form `zeta (<n>)'
 
7161
     for all other arguments, including rational noninteger, floating
 
7162
     point, and complex arguments.
 
7163
 
 
7164
     See also `bfzeta' and `zeta%pi'.
 
7165
 
 
7166
          (%i1) map (zeta, [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]);
 
7167
                                               2              4
 
7168
                     1        1     1       %pi            %pi
 
7169
          (%o1) [0, ---, 0, - --, - -, inf, ----, zeta(3), ----, zeta(5)]
 
7170
                    120       12    2        6              90
 
7171
 
 
7172
 
 
7173
 -- Option variable: zeta%pi
 
7174
     Default value: `true'
 
7175
 
 
7176
     When `zeta%pi' is `true', `zeta' returns an expression
 
7177
     proportional to `%pi^n' for even integer `n'.  Otherwise, `zeta'
 
7178
     returns a noun form `zeta (n)' for even integer `n'.
 
7179
 
 
7180
          (%i1) zeta%pi: true$
 
7181
          (%i2) zeta (4);
 
7182
                                           4
 
7183
                                        %pi
 
7184
          (%o2)                         ----
 
7185
                                         90
 
7186
          (%i3) zeta%pi: false$
 
7187
          (%i4) zeta (4);
 
7188
          (%o4)                        zeta(4)
 
7189
 
 
7190
 
 
7191
 
 
7192
File: maxima.info,  Node: Symmetries,  Next: Groups,  Prev: Number Theory,  Up: Top
 
7193
 
 
7194
33 Symmetries
 
7195
*************
 
7196
 
 
7197
* Menu:
 
7198
 
 
7199
* Definitions for Symmetries::
1030
7200