12
File: maxima.info, Node: Definitions for Expressions, Prev: SYNTAX, Up: Expressions
14
Definitions for Expressions
12
File: maxima.info, Node: Definitions for Differential Equations, Prev: Differential Equations, Up: Differential Equations
14
22.1 Definitions for Differential Equations
15
===========================================
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.
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
35
'diff(f,x,2)=sin(x)+'diff(g,x);
36
'diff(f,x)+x^2-f=2*'diff(g,x,2);
38
is not the proper format. The correct way is:
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);
43
The call is then `desolve([%o3,%o4],[f(x),g(x)]);' .
45
If initial conditions at 0 are known, they should be supplied
46
before calling `desolve' by using `atvalue'.
48
(%i1) 'diff(f(x),x)='diff(g(x),x)+sin(x);
50
(%o1) -- (f(x)) = -- (g(x)) + sin(x)
52
(%i2) 'diff(g(x),x,2)='diff(f(x),x)-cos(x);
55
(%o2) --- (g(x)) = -- (f(x)) - cos(x)
58
(%i3) atvalue('diff(g(x),x),x=0,a);
60
(%i4) atvalue(f(x),x=0,1);
62
(%i5) desolve([%o1,%o2],[f(x),g(x)]);
64
(%o5) [f(x) = a %e - a + 1, g(x) =
67
cos(x) + a %e - a + g(0) - 1]
68
(%i6) [%o1,%o2],%o5,diff;
70
(%o6) [a %e = a %e , a %e - cos(x) = a %e - cos(x)]
72
If `desolve' cannot obtain a solution, it returns `false'.
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.
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'
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.
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,
128
(%i1) x^2*'diff(y,x) + 3*y*x = sin(x)/x;
130
(%o1) x -- + 3 x y = ------
134
(%o2) y = -----------
137
(%i3) ic1(%o2,x=%pi,y=0);
139
(%o3) y = - ----------
142
(%i4) 'diff(y,x,2) + y*'diff(y,x)^3 = 0;
145
(%o4) --- + y (--) = 0
151
(%o5) ------------ = x + %k2
153
(%i6) ratsimp(ic2(%o5,x=0,y=0,'diff(y,x)=2));
156
(%o6) - ---------- = x
158
(%i7) bc2(%o5,x=0,y=1,x=1,y=3);
161
(%o7) --------- = x - -
166
File: maxima.info, Node: Numerical, Next: Statistics, Prev: Differential Equations, Up: Top
173
* Introduction to Numerical::
175
* Definitions for Numerical::
176
* Definitions for Fourier Series::
179
File: maxima.info, Node: Introduction to Numerical, Next: Fourier packages, Prev: Numerical, Up: Numerical
181
23.1 Introduction to Numerical
182
==============================
185
File: maxima.info, Node: Fourier packages, Next: Definitions for Numerical, Prev: Introduction to Numerical, Up: Numerical
187
23.2 Fourier packages
188
=====================
190
The `fft' package comprises functions for the numerical (not symbolic)
191
computation of the fast Fourier transform. `load ("fft")' loads this
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'.
201
File: maxima.info, Node: Definitions for Numerical, Next: Definitions for Fourier Series, Prev: Fourier packages, Up: Numerical
203
23.3 Definitions for Numerical
204
==============================
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
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
219
The input arrays must be the same size and 1-dimensional. The
220
array size need not be a power of 2.
222
`polartorect' is the inverse function of `recttopolar'.
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
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
238
The computed angle is in the range `-%pi' to `%pi'.
240
The input arrays must be the same size and 1-dimensional. The
241
array size need not be a power of 2.
243
`recttopolar' is the inverse function of `polartorect'.
246
-- Function: ift (<real_array>, <imaginary_array>)
247
Fast inverse discrete Fourier transform. `load ("fft")' loads this
248
function into Maxima.
250
`ift' carries out the inverse complex fast Fourier transform on
251
1-dimensional floating point arrays. The inverse transform is
254
x[j]: sum (y[j] exp (+2 %i %pi j k / n), k, 0, n-1)
256
See `fft' for more details.
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.
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
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.
276
The discrete Fourier transform and inverse transform are defined
277
as follows. Let `x' be the original data, with
279
x[i]: real_array[i] + %i imaginary_array[i]
281
Let `y' be the transformed data. The forward and inverse
284
y[k]: (1/n) sum (x[j] exp (-2 %i %pi j k / n), j, 0, n-1)
286
x[j]: sum (y[j] exp (+2 %i %pi j k / n), k, 0, n-1)
288
Suitable arrays can be allocated by the `array' function. For
291
array (my_array, float, n-1)$
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
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
306
a[j]: real_array[j] + real_array[n-j]
307
b[j]: imaginary_array[j] - imaginary_array[n-j]
309
for j equal to 1 through n/2-1, and
311
a[n/2]: real_array[n/2]
314
`recttopolar' translates complex values of the form `a + b %i' to
315
the form `r %e^(%i t)'. See `recttopolar'.
317
`polartorect' translates complex values of the form `r %e^(%i t)'
318
to the form `a + b %i'. See `polartorect'.
320
`demo ("fft")' displays a demonstration of the `fft' package.
323
-- Option variable: fortindent
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.
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
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.
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.
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.
353
When `fortspaces' is `true', `fortran' fills out each printed line
354
with spaces to 80 columns.
356
`fortran' evaluates its arguments; quoting an argument defeats
357
evaluation. `fortran' always returns `done'.
361
(%i1) expr: (a + b)^12$
362
(%i2) fortran (expr);
365
(%i3) fortran ('x=expr);
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
373
(%i5) fortran ('x=7+5*%i);
376
(%i6) fortran ('x=[1,2,3,4]);
385
-- Option variable: fortspaces
386
Default value: `false'
388
When `fortspaces' is `true', `fortran' fills out each printed line
389
with spaces to 80 columns.
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.
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'.
403
(%i1) expr: 1e-155*x^2 - 5.5*x + 5.2e155;
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:
411
floating point overflow
413
Automatically continuing.
414
To reenable the Lisp debugger set *debugger-hook* to nil.
415
(%i4) ev (expr2, x=1e155);
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
441
find_root (sin(x) = x/2, x, %pi, 0.1);
445
find_root (sin(x) = x/2, x, 0.1, %pi);
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.
453
(%i1) f(x) := sin(x) - x/2;
455
(%o1) f(x) := sin(x) - -
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
467
-- Option variable: find_root_abs
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.
481
-- Option variable: find_root_error
482
Default value: `true'
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
496
-- Option variable: find_root_rel
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.
511
File: maxima.info, Node: Definitions for Fourier Series, Prev: Definitions for Numerical, Up: Numerical
513
23.4 Definitions for Fourier Series
514
===================================
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).
521
-- Function: remfun (<f>, <expr>)
522
-- Function: remfun (<f>, <expr>, <x>)
523
`remfun (<f>, <expr>)' replaces all occurrences of `<f> (<arg>)'
526
`remfun (<f>, <expr>, <x>)' replaces all occurrences of `<f>
527
(<arg>)' by <arg> in <expr> only if <arg> contains the variable
531
-- Function: funp (<f>, <expr>)
532
-- Function: funp (<f>, <expr>, <x>)
533
`funp (<f>, <expr>)' returns `true' if <expr> contains the
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>.
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))'.
549
`absint (<f>, <x>)' is equivalent to `absint (<f>, <x>, pos)'.
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
556
-- Function: fourier (<f>, <x>, <p>)
557
Returns a list of the Fourier coefficients of `<f>(<x>)' defined
558
on the interval `[-%pi, %pi]'.
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'.
566
-- Option variable: sinnpiflag
567
Default value: `true'
572
-- Option variable: cosnpiflag
573
Default value: `true'
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'.
584
-- Function: fourcos (<f>, <x>, <p>)
585
Returns the Fourier cosine coefficients for `<f>(<x>)' defined on
589
-- Function: foursin (<f>, <x>, <p>)
590
Returns the Fourier sine coefficients for `<f>(<x>)' defined on
594
-- Function: totalfourier (<f>, <x>, <p>)
595
Returns `fourexpand (foursimp (fourier (<f>, <x>, <p>)), <x>, <p>,
599
-- Function: fourint (<f>, <x>)
600
Constructs and returns a list of the Fourier integral coefficients
601
of `<f>(<x>)' defined on `[minf, inf]'.
604
-- Function: fourintcos (<f>, <x>)
605
Returns the Fourier cosine integral coefficients for `<f>(<x>)' on
609
-- Function: fourintsin (<f>, <x>)
610
Returns the Fourier sine integral coefficients for `<f>(<x>)' on
615
File: maxima.info, Node: Statistics, Next: Arrays, Prev: Numerical, Up: Top
622
* Definitions for Statistics::
625
File: maxima.info, Node: Definitions for Statistics, Prev: Statistics, Up: Statistics
627
24.1 Definitions for Statistics
628
===============================
630
-- Function: gauss (<mean>, <sd>)
631
Returns a random floating point number from a normal distribution
632
with mean <mean> and standard deviation <sd>.
636
File: maxima.info, Node: Arrays, Next: Matrices and Linear Algebra, Prev: Statistics, Up: Top
643
* Definitions for Arrays::
646
File: maxima.info, Node: Definitions for Arrays, Prev: Arrays, Up: Arrays
648
25.1 Definitions for Arrays
15
649
===========================
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.
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
658
`array (<name>, <dim_1>, ..., <dim_n>)' creates a general array.
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.
664
`array ([<name_1>, ..., <name_m>], <dim_1>, ..., <dim_n>)' creates
665
m arrays, all of the same dimensions.
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
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.
684
This is reminiscent of `apply', except the first argument is an
685
array instead of a function.
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.
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'.
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'.
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'.
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'.
715
`arrayinfo' and `listarray' applied to a declared array.
717
(%i1) array (aa, 2, 3);
719
(%i2) aa [2, 3] : %pi;
721
(%i3) aa [1, 2] : %e;
723
(%i4) arrayinfo (aa);
724
(%o4) [declared, 2, [2, 3]]
725
(%i5) listarray (aa);
726
(%o5) [#####, #####, #####, #####, #####, #####, %e, #####,
727
#####, #####, #####, %pi]
729
`arrayinfo' and `listarray' applied to an undeclared (hashed)
732
(%i1) bb [FOO] : (a + b)^2;
735
(%i2) bb [BAR] : (c - d)^3;
738
(%i3) arrayinfo (bb);
739
(%o3) [hashed, 1, [BAR], [FOO]]
740
(%i4) listarray (bb);
742
(%o4) [(c - d) , (b + a) ]
744
`arrayinfo' and `listarray' applied to an array function.
746
(%i1) cc [x, y] := y / x;
758
(%i4) arrayinfo (cc);
759
(%o4) [hashed, 2, [4, z], [u, v]]
760
(%i5) listarray (cc);
765
`arrayinfo' and `listarray' applied to a subscripted function.
767
(%i1) dd [x] (y) := y ^ x;
773
(%o2) lambda([y], y )
776
(%o3) lambda([y], y )
777
(%i4) arrayinfo (dd);
778
(%o4) [hashed, 1, [b + a], [v - u]]
779
(%i5) listarray (dd);
781
(%o5) [lambda([y], y ), lambda([y], y )]
784
-- Function: arraymake (<name>, [<i_1>, ..., <i_n>])
785
Returns the expression `<name> [<i_1>, ..., <i_n>]'.
787
This is reminiscent of `funmake', except the return value is an
788
unevaluated array reference instead of an unevaluated function
792
-- System variable: arrays
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.
801
See also `array', `arrayapply', `arrayinfo', `arraymake',
802
`fillarray', `listarray', and `rearray'.
806
(%i1) array (aa, 5, 7);
808
(%i2) bb [FOO] : (a + b)^2;
811
(%i3) cc [x] := x/100;
815
(%i4) dd : make_array ('any, 7);
816
(%o4) {Array: #(NIL NIL NIL NIL NIL NIL NIL)}
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.
830
-- Function: fillarray (<A>, <B>)
831
Fills array <A> from <B>, which is a list or an array.
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.
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.
842
`fillarray' returns its first argument.
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.
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'.
855
For undeclared arrays, array functions, and subscripted functions,
856
the elements correspond to the index values returned by
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.
867
`listarray' and `arrayinfo' applied to a declared array.
869
(%i1) array (aa, 2, 3);
871
(%i2) aa [2, 3] : %pi;
873
(%i3) aa [1, 2] : %e;
875
(%i4) listarray (aa);
876
(%o4) [#####, #####, #####, #####, #####, #####, %e, #####,
877
#####, #####, #####, %pi]
878
(%i5) arrayinfo (aa);
879
(%o5) [declared, 2, [2, 3]]
881
`listarray' and `arrayinfo' applied to an undeclared (hashed)
884
(%i1) bb [FOO] : (a + b)^2;
887
(%i2) bb [BAR] : (c - d)^3;
890
(%i3) listarray (bb);
892
(%o3) [(c - d) , (b + a) ]
893
(%i4) arrayinfo (bb);
894
(%o4) [hashed, 1, [BAR], [FOO]]
896
`listarray' and `arrayinfo' applied to an array function.
898
(%i1) cc [x, y] := y / x;
910
(%i4) listarray (cc);
914
(%i5) arrayinfo (cc);
915
(%o5) [hashed, 2, [4, z], [u, v]]
917
`listarray' and `arrayinfo' applied to a subscripted function.
919
(%i1) dd [x] (y) := y ^ x;
925
(%o2) lambda([y], y )
928
(%o3) lambda([y], y )
929
(%i4) listarray (dd);
931
(%o4) [lambda([y], y ), lambda([y], y )]
932
(%i5) arrayinfo (dd);
933
(%o5) [hashed, 1, [b + a], [v - u]]
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.
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
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.
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
964
`remarray (all)' removes all items in the global list `arrays'.
966
It may be necessary to use this function if it is desired to
967
redefine the values in a hashed array.
969
`remarray' returns the list of arrays removed.
972
-- Function: subvar (<x>, <i>)
973
Evaluates the subscripted expression `<x>[<i>]'.
975
`subvar' evaluates its arguments.
977
`arraymake (<x>, [<i>]' constructs the expression `<x>[<i>]', but
978
does not evaluate it.
989
(%i4) foo : [aa, bb, cc, dd, ee]$
993
(%i6) arraymake (x, [i]);
1000
-- Option variable: use_fast_arrays
1001
- if `true' then only two types of arrays are recognized.
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.
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
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'.
1029
File: maxima.info, Node: Matrices and Linear Algebra, Next: Affine, Prev: Arrays, Up: Top
1031
26 Matrices and Linear Algebra
1032
******************************
1036
* Introduction to Matrices and Linear Algebra::
1037
* Definitions for Matrices and Linear Algebra::
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
1042
26.1 Introduction to Matrices and Linear Algebra
1043
================================================
1052
File: maxima.info, Node: Dot, Next: Vectors, Prev: Introduction to Matrices and Linear Algebra, Up: Introduction to Matrices and Linear Algebra
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
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
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
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'.
1083
File: maxima.info, Node: Vectors, Next: eigen, Prev: Dot, Up: Introduction to Matrices and Linear Algebra
1088
`vect' is a package of functions for vector analysis. `load ("vect")'
1089
loads this package, and `demo ("vect")' displays a demonstration.
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
1100
The `vect' package contains these functions: `vectorsimp',
1101
`scalefactors', `express', `potential', and `vectorpotential'.
1103
Warning: the `vect' package declares the dot operator `.' to be a
1104
commutative operator.
1107
File: maxima.info, Node: eigen, Prev: Vectors, Up: Introduction to Matrices and Linear Algebra
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")'.
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.
1121
The functions in the `eigen' package are `innerproduct',
1122
`unitvector', `columnvector', `gramschmidt', `eigenvalues',
1123
`eigenvectors', `uniteigenvectors', and `similaritytransform'.
1126
File: maxima.info, Node: Definitions for Matrices and Linear Algebra, Prev: Introduction to Matrices and Linear Algebra, Up: Matrices and Linear Algebra
1128
26.2 Definitions for Matrices and Linear Algebra
1129
================================================
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>.
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>.
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>.
1146
-- Function: augcoefmatrix ([<eqn_1>, ..., <eqn_m>], [<x_1>, ...,
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>).
1154
(%i1) m: [2*x - (a - 1)*y = 5*b, c + b*y + a*x = 0]$
1155
(%i2) augcoefmatrix (m, [x, y]);
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>))'.
1166
(%i1) a: matrix ([3, 1], [2, 4]);
1170
(%i2) expand (charpoly (a, lambda));
1172
(%o2) lambda - 7 lambda + 10
1173
(%i3) (programmode: true, solve (%));
1174
(%o3) [lambda = 5, lambda = 2]
1175
(%i4) matrix ([x1], [x2]);
1179
(%i5) ev (a . % - lambda*%, %th(2)[1]);
1185
(%i7) x2^2 + x1^2 = 1;
1188
(%i8) solve ([%th(2), %], [x1, x2]);
1190
(%o8) [[x1 = - -------, x2 = - -------],
1194
[x1 = -------, x2 = -------]]
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>.
1202
(%i1) coefmatrix([2*x-(a-1)*y+5*b = 0, b*y+a*x = 3], [x,y]);
1208
-- Function: col (<M>, <i>)
1209
Returns the <i>'th column of the matrix <M>. The return value is
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>.
1218
`covect' is a synonym for `columnvector'.
1220
`load ("eigen")' loads this function.
1222
This is useful if you want to use parts of the outputs of the
1223
functions in this package in matrix calculations.
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]);
1240
-- Function: conjugate (<x>)
1241
Returns the complex conjugate of <x>.
1243
(%i1) declare ([aa, bb], real, cc, complex, ii, imaginary);
1246
(%i2) conjugate (aa + bb*%i);
1249
(%i3) conjugate (cc);
1252
(%i4) conjugate (ii);
1255
(%i5) conjugate (xx + yy);
1257
(%o5) conjugate(yy) + conjugate(xx)
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.
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,
1271
-- Function: determinant (<M>)
1272
Computes the determinant of <M> by a method similar to Gaussian
1275
The form of the result depends upon the setting of the switch
1278
There is a special routine for computing sparse determinants which
1279
is called when the switches `ratmx' and `sparse' are both `true'.
1282
-- Option variable: detout
1283
Default value: `false'
1285
When `detout' is `true', the determinant of a matrix whose inverse
1286
is computed is factored out of the inverse.
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
1295
(%i1) m: matrix ([a, b], [c, d]);
1300
(%i3) doallmxops: false$
1301
(%i4) doscmxops: false$
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>)').
1315
<n> must evaluate to an integer, otherwise `diagmatrix' complains
1316
with an error message.
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>.
1323
-- Option variable: doallmxops
1324
Default value: `true'
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.
1331
-- Option variable: domxexpt
1332
Default value: `true'
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
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.
1345
(%i1) m: matrix ([1, %i], [a+b, %pi]);
1349
(%i2) domxexpt: false$
1355
(%i4) domxexpt: true$
1364
-- Option variable: domxmxops
1365
Default value: `true'
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.
1372
-- Option variable: domxnctimes
1373
Default value: `false'
1375
When `domxnctimes' is `true', non-commutative products of matrices
1379
-- Option variable: dontfactor
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
1390
-- Option variable: doscmxops
1391
Default value: `false'
1393
When `doscmxops' is `true', scalar-matrix operations are carried
1397
-- Option variable: doscmxplus
1398
Default value: `false'
1400
When `doscmxplus' is `true', scalar-matrix operations yield a
1401
matrix result. This switch is not subsumed under `doallmxops'.
1404
-- Option variable: dot0nscsimp
1405
Default value: `true'
1407
When `dot0nscsimp' is `true', a non-commutative product of zero
1408
and a nonscalar term is simplified to a commutative product.
1411
-- Option variable: dot0simp
1412
Default value: `true'
1414
When `dot0simp' is `true', a non-commutative product of zero and a
1415
scalar term is simplified to a commutative product.
1418
-- Option variable: dot1simp
1419
Default value: `true'
1421
When `dot1simp' is `true', a non-commutative product of one and
1422
another term is simplified to a commutative product.
1425
-- Option variable: dotassoc
1426
Default value: `true'
1428
When `dotassoc' is `true', an expression `(A.B).C' simplifies to
1432
-- Option variable: dotconstrules
1433
Default value: `true'
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.
1441
-- Option variable: dotdistrib
1442
Default value: `false'
1444
When `dotdistrib' is `true', an expression `A.(B + C)' simplifies
1448
-- Option variable: dotexptsimp
1449
Default value: `true'
1451
When `dotexptsimp' is `true', an expression `A.A' simplifies to
1455
-- Option variable: dotident
1458
`dotident' is the value returned by `X^^0'.
1461
-- Option variable: dotscrules
1462
Default value: `false'
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)'.
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.
1475
`triangularize' also carries out Gaussian elimination, but it does
1476
not normalize the leading non-zero element in each row.
1478
`lu_factor' and `cholesky' are other functions which yield
1479
triangularized matrices.
1481
(%i1) M: matrix ([3, 7, aa, bb], [-1, 8, 5, 2], [9, 2, 11, 4]);
1495
[ 0 0 1 ----------- ]
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.
1506
`eivals' is a synonym for `eigenvalues'.
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.
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.
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.
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.
1535
`eivects' is a synonym for `eigenvectors'.
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.
1542
The flags that affect this function are:
1544
`nondiagonalizable' is set to `true' or `false' depending on
1545
whether the matrix is nondiagonalizable or diagonalizable after
1546
`eigenvectors' returns.
1548
`hermitianmatrix' when `true', causes the degenerate eigenvectors
1549
of the Hermitian matrix to be orthogonalized using the
1550
Gram-Schmidt algorithm.
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'.
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'.
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>.
1571
-- Function: entermatrix (<m>, <n>)
1572
Returns an <m> by <n> matrix, reading the elements interactively.
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
1579
If <n> is not equal to <m>, Maxima prompts for each element.
1581
The elements may be any expressions, which are evaluated.
1582
`entermatrix' evaluates its arguments.
1585
(%i2) m: entermatrix (n, n)$
1587
Is the matrix 1. Diagonal 2. Symmetric 3. Antisymmetric 4. General
1588
Answer 1, 2, 3 or 4 :
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.)
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.
1624
If a selected element `i,j' of the array is undefined, the matrix
1625
will contain a symbolic element `<a>[i,j]'.
1629
(%i1) h [i, j] := 1 / (i + j - 1);
1631
(%o1) h := ---------
1633
(%i2) genmatrix (h, 3, 3);
1645
(%i3) array (a, fixnum, 2, 2);
1647
(%i4) a [1, 1] : %e;
1649
(%i5) a [2, 2] : %pi;
1651
(%i6) genmatrix (a, 2, 2);
1655
(%i7) genmatrix (lambda ([i, j], j - i), 3, 3);
1661
(%i8) genmatrix (B, 2, 2);
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
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.
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.
1687
`gschmit' (note spelling) is a synonym for `gramschmidt'.
1689
`load ("eigen")' loads this function.
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]);
1702
(%i3) y: gramschmidt (x);
1705
(%o3) [[1, 2, 3], [- ---, - --, ---], [- ----, ----, 0]]
1707
(%i4) i: innerproduct$
1708
(%i5) [i (y[1], y[2]), i (y[2], y[3]), i (y[3], y[1])];
1712
-- Function: hach (<a>, <b>, <m>, <n>, <l>)
1713
`hach' is an implementation of Hacijan's linear programming
1716
`load ("kach")' loads this function. `demo ("kach")' executes a
1717
demonstration of this function.
1720
-- Function: ident (<n>)
1721
Returns an <n> by <n> identity matrix.
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.
1732
`load ("eigen")' loads this function.
1734
`inprod' is a synonym for `innerproduct'.
1737
-- Function: invert (<M>)
1738
Returns the inverse of the matrix <M>. The inverse is computed by
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.
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.
1749
The current implementation is inefficient for matrices of high
1752
When `detout' is `true', the determinant is factored out of the
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
1761
expand (adjoint (m)) / expand (determinant (m))
1762
invert (m) := adjoint (m) / determinant (m)
1764
See `^^' (noncommutative exponent) for another method of inverting
1768
-- Option variable: lmxchar
1771
`lmxchar' is the character displayed as the left delimiter of a
1772
matrix. See also `rmxchar'.
1777
(%i2) matrix ([a, b, c], [d, e, f], [g, h, i]);
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
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).
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.
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'.
1808
There are additional options which are related to matrices. These
1809
are: `lmxchar', `rmxchar', `ratmx', `listarith', `detout',
1810
`scalarmatrix', and `sparse'.
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'.
1819
* Construction of matrices from lists.
1821
(%i1) x: matrix ([17, 3], [-8, 11]);
1825
(%i2) y: matrix ([%pi, %e], [a, b]);
1830
* Addition, element by element.
1837
* Subtraction, element by element.
1844
* Multiplication, element by element.
1851
* Division, element by element.
1862
* Matrix to a scalar exponent, element by element.
1869
* Scalar base to a matrix exponent, element by element.
1878
* Matrix base to a matrix exponent. This is not carried out
1889
* Noncommutative matrix multiplication.
1892
[ 3 a + 17 %pi 3 b + 17 %e ]
1894
[ 11 a - 8 %pi 11 b - 8 %e ]
1896
[ 17 %pi - 8 %e 3 %pi + 11 %e ]
1898
[ 17 a - 8 b 11 b + 3 a ]
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'.
1915
* A matrix raised to a -1 exponent with noncommutative
1916
exponentiation is the matrix inverse, if it exists.
1926
(%i15) x . (x ^^ -1);
1932
-- Function: matrixmap (<f>, <M>)
1933
Returns a matrix with element `i,j' equal to `<f>(<M>[i,j])'.
1935
See also `map', `fullmap', `fullmapl', and `apply'.
1938
-- Function: matrixp (<expr>)
1939
Returns `true' if <expr> is a matrix, otherwise `false'.
1942
-- Option variable: matrix_element_add
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
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
38
default: ["] is the character used to draw the box in the BOX and
39
in the DPART and LPART functions.
42
- special operator: CONSTANT
43
- makes ai a constant as is %PI.
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.
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.
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
73
CONSTANT - makes ai a constant as is %PI.
75
MAINVAR - makes ai a MAINVAR. The ordering scale for atoms:
76
numbers < constants (e.g. %E,%PI) < scalars < other variables <
79
SCALAR - makes ai a scalar.
81
NONSCALAR - makes ai behave as does a list or matrix with respect
84
NOUN - makes the function ai a noun so that it won't be evaluated
87
EVFUN - makes ai known to the EV function so that it will get
88
applied if its name is mentioned. Initial evfuns are
90
TRIGREDUCE, BFLOAT, RATSIMP, RATEXPAND, and RADCAN
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.
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
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,
110
he useful features of functions include:
112
DECREASING, ODDFUN (odd function), EVENFUN (even function),
113
COMMUTATIVE (or SYMMETRIC), ANTISYMMETRIC, LASSOCIATIVE and
115
DECLARE(F,INCREASING) is in all respects equivalent to
117
ASSUME(KIND(F,INCREASING))
118
The ai and fi may also be lists of objects or features. The
120
FEATUREP(object,feature)
121
may be used to determine if an object has been DECLAREd to have
122
"feature". See DESCRIBE(FEATURES); .
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")$'.
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.
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
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);
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.
187
- Variable: EXPTISOLATE
188
default: [FALSE] if TRUE will cause ISOLATE(expr,var); to examine
189
exponents of atoms (like %E) which contain var.
192
- Variable: EXPTSUBST
193
default: [FALSE] if TRUE permits substitutions such as Y for %E**X
194
in %E**(A*X) to take place.
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.
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!!
214
- Function: IMAGPART (exp)
215
returns the imaginary part of the expression exp.
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).
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.
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
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 ...
256
(%i2) INPART(%o1,3,2);
260
(%i4) 'LIMIT(F(X)**G(X+1),X,0,MINUS);
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);
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); .
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.
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.
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]
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.
317
- Function: LOPOW (exp, v)
318
the lowest exponent of v which explicitly appears in exp. Thus
320
LOPOW((X+Y)**2+(X+Y)**A,X+Y) ==> MIN(A,2)
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
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
343
(%i1) X/(X-Y)**2-1/(X-Y)-F(X)/(X-Y)**3;
345
(%o1) - ----- + -------- - --------
348
(%i2) MULTTHRU((X-Y)**3,%);
350
(%o2) - (X - Y) + X (X - Y) - F(X)
351
(%i3) RATEXPAND(%o2);
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);
356
(B + A ) S + 2 A B S + A B
357
(%o4) --------------------------------
363
(%o5) - + --- + -------
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)
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.
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
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.
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
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.
407
- Variable: OPTIMPREFIX
408
default: [%] - The prefix used for generated symbols by the
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
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);).
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);.
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);).
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);
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);
467
(%i3) PARTITION([A,B,F(A),C],A);
468
(%o3) [[B,C],[A,F(A)]]
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
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));
484
(%o1) - LOG(SQRT(X + 1) + 1) + ------- + -----
486
(%i2) PICKAPART(%,1);
487
(%t2) - LOG(SQRT(X + 1) + 1)
1952
See also `matrix_element_mult' and `matrix_element_transpose'.
1956
(%i1) matrix_element_add: "*"$
1957
(%i2) matrix_element_mult: "^"$
1958
(%i3) aa: matrix ([a, b, c], [d, e, f]);
1962
(%i4) bb: matrix ([u, v, w], [x, y, z]);
1966
(%i5) aa . transpose (bb);
1974
-- Option variable: matrix_element_mult
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.
1983
The dot operator `.' is a useful choice in some contexts.
1985
See also `matrix_element_add' and `matrix_element_transpose'.
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];
1993
(%o3) sqrt((c - z) + (b - y) + (a - x) )
1994
(%i4) aa: matrix ([a, b, c], [d, e, f]);
1998
(%i5) bb: matrix ([u, v, w], [x, y, z]);
2002
(%i6) aa . transpose (bb);
2004
[ sqrt((c - w) + (b - v) + (a - u) ) ]
2007
[ sqrt((f - w) + (e - v) + (d - u) ) ]
2010
[ sqrt((c - z) + (b - y) + (a - x) ) ]
2013
[ sqrt((f - z) + (e - y) + (d - x) ) ]
2016
-- Option variable: matrix_element_transpose
2017
Default value: `false'
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.
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'.
2033
The default value, `false', means no operation is applied.
2035
See also `matrix_element_add' and `matrix_element_mult'.
2039
(%i1) declare (a, nonscalar)$
2040
(%i2) transpose ([a, b]);
2044
(%i3) matrix_element_transpose: nonscalars$
2045
(%i4) transpose ([a, b]);
2049
(%i5) matrix_element_transpose: transpose$
2050
(%i6) transpose ([a, 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 ]
2059
(%i9) transpose (m);
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>.
2069
`mattrace' is called by `ncharpoly', an alternative to Maxima's
2072
`load ("nchrpl")' loads this function.
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.
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>)'.
2084
`ncexpt' is not the name of a function or operator; the name only
2085
appears in output, and is not recognized in input.
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'.
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.
2102
`load ("nchrpl")' loads this file.
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.
2111
-- Declaration: nonscalar
2112
Makes atoms behave as does a list or matrix with respect to the
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.
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.
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>.
2130
<rank> may return the wrong answer if it cannot determine that a
2131
matrix element that is equivalent to zero is indeed so.
2134
-- Option variable: ratmx
2135
Default value: `false'
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.
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
2149
-- Function: row (<M>, <i>)
2150
Returns the <i>'th row of the matrix <M>. The return value is a
2154
-- Option variable: scalarmatrixp
2155
Default value: `true'
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.
2161
When `scalarmatrixp' is `all', then all 1 x 1 matrices are
2162
simplified to scalars.
2164
When `scalarmatrixp' is `false', 1 x 1 matrices are not simplified
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
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.
2190
`<M> [<i>, <j>]: <x>' has the same effect, but returns <x> instead
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.
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'.
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
2215
`load ("eigen")' loads this function.
2217
`simtran' is a synonym for `similaritytransform'.
2220
-- Option variable: sparse
2221
Default value: `false'
2223
When `sparse' is `true', and if `ratmx' is `true', then
2224
`determinant' will use special routines for computing sparse
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.
2235
-- Function: transpose (<M>)
2236
Returns the transpose of <M>.
2238
If <M> is a matrix, the return value is another matrix <N> such
2239
that `N[i,j] = M[j,i]'.
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]'.
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.
2251
`lu_factor' and `cholesky' are other functions which yield
2252
triangularized matrices.
2254
(%i1) M: matrix ([3, 7, aa, bb], [-1, 8, 5, 2], [9, 2, 11, 4]);
2260
(%i2) triangularize (M);
2263
(%o2) [ 0 - 74 - 56 - 22 ]
2265
[ 0 0 626 - 74 aa 238 - 74 bb ]
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
2276
The flags mentioned in the description of the `eigenvectors'
2277
command have the same effects in this one as well.
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.
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.
2292
`load ("eigen")' loads this function.
2294
`ueivects' is a synonym for `uniteigenvectors'.
2297
-- Function: unitvector (<x>)
2298
-- Function: uvect (<x>)
2299
Returns <x>/norm(<x>); this is a unit vector in the same direction
2302
`load ("eigen")' loads this function.
2304
`uvect' is a synonym for `unitvector'.
2307
-- Function: vectorsimp (<expr>)
2308
Applies simplifications and expansions according to the following
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'.
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
2324
Simplifies p ~ (q ~ r) to (p . r)*q - (p . q)*r.
2327
Simplifies curl curl p to grad div p + div grad p.
2329
`expandlaplaciantodivgrad'
2330
Simplifies laplacian p to div grad p.
2333
Enables `expandcrossplus' and `expandcrosscross'.
2336
Enables `expanddotplus', `expandcrossplus', `expandgradplus',
2337
`expanddivplus', `expandcurlplus', and `expandlaplacianplus'.
2340
Enables `expandgradprod', `expanddivprod', and
2341
`expandlaplacianprod'.
2343
These flags have all been declared `evflag'.
2346
-- Option variable: vect_cross
2347
Default value: `false'
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',
2354
-- Function: zeromatrix (<m>, <n>)
2355
Returns an <m> by <n> matrix, all elements of which are zero.
2358
-- Special symbol: [
2359
-- Special symbol: ]
2360
`[' and `]' mark the beginning and end, respectively, of a list.
2362
`[' and `]' also enclose the subscripts of a list, array, hash
2363
array, or array function.
2371
(%i3) array (y, fixnum, 3);
2377
(%i6) z['foo]: 'bar;
2381
(%i8) g[k] := 1/(k^2+1);
2393
File: maxima.info, Node: Affine, Next: itensor, Prev: Matrices and Linear Algebra, Up: Top
2400
* Definitions for Affine::
2403
File: maxima.info, Node: Definitions for Affine, Prev: Affine, Up: Affine
2405
27.1 Definitions for Affine
2406
===========================
2408
-- Function: fast_linsolve ([<expr_1>, ..., <expr_m>], [<x_1>, ...,
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> =
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>.
2420
`fast_linsolve' is faster than `linsolve' for system of equations
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.
2429
grobner_basis ([3*x^2+1, y*x])$
2431
polysimp (y^2*x + x^3*9 + 2) ==> -3*x + 2
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>, ...,
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.
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.
2453
The degree is that returned by `nc_degree'. This in turn is
2454
influenced by the weights of individual variables.
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'.
2462
-- Function: nc_degree (<p>)
2463
Returns the degree of a noncommutative polynomial <p>. See
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.
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
2479
set_up_dot_simplifications ([y.x + x.y], 3);
2480
fast_central_elements ([x, y], 2);
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.
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>, ...,
2501
-- Function: monomial_dimensions (<n>)
2502
Compute the Hilbert series through degree <n> for the current
2506
-- Function: extract_linear_equations ([<p_1>, ..., <p_n>], [<m_1>,
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.
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>.
2520
-- Option variable: all_dotsimp_denoms
2521
Default value: `false'
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'.
2527
By default, denominators are not collected by `dotsimp'.
2531
File: maxima.info, Node: itensor, Next: ctensor, Prev: Affine, Up: Top
2538
* Introduction to itensor::
2539
* Definitions for itensor::
2542
File: maxima.info, Node: Introduction to itensor, Next: Definitions for itensor, Prev: itensor, Up: itensor
2544
28.1 Introduction to itensor
2545
============================
2547
Maxima implements symbolic tensor manipulation of two distinct types:
2548
component tensor manipulation (`ctensor' package) and indicial tensor
2549
manipulation (`itensor' package).
2551
Nota bene: Please see the note on 'new tensor notation' below.
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.
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.
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
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.
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.
2594
28.1.1 New tensor notation
2595
--------------------------
2597
Until now, the `itensor' package in Maxima has used a notation that
2598
sometimes led to incorrect index ordering. Consider the following, for
2603
(%i3) ishow(g([],[j,k])*g([],[i,l])*a([i,j],[]))$
2607
(%i4) ishow(contract(%))$
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.
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.
2624
In this new notation, the previous example yields a correct result:
2626
(%i5) ishow(g([-j,-k],[])*g([-i,-l],[])*a([i,j],[]))$
2630
(%i6) ishow(contract(%))$
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.
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
2646
28.1.2 Indicial tensor manipulation
2647
-----------------------------------
2649
The indicial tensor manipulation package may be loaded by
2650
`load(itensor)'. Demos are also available: try `demo(tensor)'.
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.
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.
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.
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.
2698
A sample session below demonstrates how to load the `itensor'
2699
package, specify the name of the metric, and perform some simple
2702
(%i1) load(itensor);
2703
(%o1) /share/tensor/itensor.lisp
2706
(%i3) components(g([i,j],[]),p([i,j],[])*e([],[]))$
2707
(%i4) ishow(g([k,l],[]))$
2710
(%i5) ishow(diff(v([i],[]),t))$
2714
(%i7) ishow(diff(v([i],[]),t))$
2718
(%i8) ishow(idiff(v([i],[]),j))$
2721
(%i9) ishow(extdiff(v([i],[]),j))$
495
(%o4) %t4 + %t3 + %t2
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.
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");.
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)
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.
523
- Function: RECTFORM (exp)
524
returns an expression of the form A + B*%I, where A and B are
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.
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.
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]);
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));
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.
586
- Function: VERBIFY (f)
587
returns the function name f in its verb form (See also VERB, NOUN,
592
File: maxima.info, Node: Simplification, Next: Plotting, Prev: Expressions, Up: Top
599
* Definitions for Simplification::
602
File: maxima.info, Node: Definitions for Simplification, Prev: Simplification, Up: Simplification
604
Definitions for Simplification
605
==============================
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.
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.
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.
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,
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;
648
DEMOIVRE(exp) will cause the conversion without setting the switch
649
or having to re-evaluate the expression with EV.
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.
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.
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")$'.
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'.
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.
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'.
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
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.
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
741
default: [-1] gives the highest factorial which is automatically
742
expanded. If it is -1 then all integers are expanded.
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
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
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.)
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
784
- Variable: MAXAPPLYDEPTH
785
default: [10000] - the maximum depth to which APPLY1 and APPLY2
789
- Variable: MAXAPPLYHEIGHT
790
default: [10000] - the maximum height to which APPLYB1 will reach
795
default: [1000] - the largest negative exponent which will be
796
expanded by the EXPAND command (see also MAXPOSEX).
800
default: [1000] - the largest exponent which will be expanded with
801
the EXPAND command (see also MAXNEGEX).
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).
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.
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.
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.
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
845
default: [FALSE] - if TRUE will cause NOUNs to display with a
846
single quote. This switch is always TRUE when displaying function
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.
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.
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).
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.
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.
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.
895
- declaration: POSFUN
896
- POSitive FUNction, e.g. DECLARE(F,POSFUN); IS(F(X)>0); -> TRUE.
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.
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
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.)
940
- Variable: RADPRODEXPAND
941
- this switch has been renamed RADEXPAND.
944
- Variable: RADSUBSTFLAG
945
default: [FALSE] - if TRUE permits RATSUBST to make substitutions
946
such as U for SQRT(X) in X.
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
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); .
965
causes exp to be simplified regardless of the setting of the
966
switch SIMP which inhibits simplification if FALSE.
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
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.
988
- Variable: SUMEXPAND
989
default: [FALSE] if TRUE, products of sums and exponentiated sums
990
are converted into nested sums. For example:
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)
996
If FALSE, they are left alone. See also CAUCHYSUM.
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)
1005
- Variable: SUMSPLITFACT
1006
default: [TRUE] - if set to FALSE will cause MINFACTORIAL to be
1007
applied after a FACTCOMB.
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.
1016
- Function: UNKNOWN (exp)
1017
returns TRUE iff exp contains an operator or function not known to
1018
the built-in simplifier.
1022
File: maxima.info, Node: Plotting, Next: Input and Output, Prev: Simplification, Up: Top
1029
* Definitions for Plotting::
2726
(%i10) ishow(liediff(v,w([i],[])))$
2730
(%i11) ishow(covdiff(v([i],[]),j))$
2734
(%i12) ishow(ev(%,ichr2))$
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
2741
(%i13) iframe_flag:true;
2743
(%i14) ishow(covdiff(v([i],[]),j))$
2747
(%i15) ishow(ev(%,icc2))$
2751
(%i16) ishow(radcan(ev(%,ifc2,ifc1)))$
2753
(%t16) - (ifg v ifb + ifg v ifb - 2 v
2754
%6 j %8 i %6 i j %8 i,j
2759
(%i17) ishow(canform(s([i,j],[])-s([j,i])))$
2762
(%i18) decsym(s,2,0,[sym(all)],[]);
2764
(%i19) ishow(canform(s([i,j],[])-s([j,i])))$
2766
(%i20) ishow(canform(a([i,j],[])+a([j,i])))$
2769
(%i21) decsym(a,2,0,[anti(all)],[]);
2771
(%i22) ishow(canform(a([i,j],[])+a([j,i])))$
2775
File: maxima.info, Node: Definitions for itensor, Prev: Introduction to itensor, Up: itensor
2777
28.2 Definitions for itensor
2778
============================
2780
28.2.1 Managing indexed objects
2781
-------------------------------
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').
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>.
2798
-- Function: listoftens
2799
Lists all tensors in a tensorial expression, complete with their
2803
(%i6) ishow(a([i,j],[k])*b([u],[],v)+c([x,y],[])*d([],[])*e)$
2807
(%i7) ishow(listoftens(%))$
2809
(%t7) [a , b , c , d]
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).
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.
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))$
2835
(%o3) [[l, p, i, n, o, q, r], [k, j, m]]
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.
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.
2863
(%i1) load(itensor);
2864
(%o1) /share/tensor/itensor.lisp
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(%)$
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
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;
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
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;
2892
(%i8) rename(%th(2));
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
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
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.
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
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
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.
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.
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'.
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'.
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)'.
2976
Components can be assigned to an indexed expression in four ways,
2977
two of which involve the use of the `components' command:
2979
1) As an indexed expression. For instance:
2982
(%i2) components(g([],[i,j]),e([],[i])*p([],[j]))$
2983
(%i3) ishow(g([],[i,j]))$
2990
(%i6) components(g([i,j],[]),lg);
2992
(%i7) ishow(g([i,j],[]))$
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,
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]))$
3013
(%i6) ishow(h([i,j],[k],l))$
3018
4) Using Maxima's pattern matching capabilities, specifically the
3019
`defrule' and `applyb1' commands:
3022
(%i1) load(itensor);
3023
(%o1) /share/tensor/itensor.lisp
3024
(%i2) matchdeclare(l1,listp);
3026
(%i3) defrule(r1,m(l1,[]),(i1:idummy(),
3027
g([l1[1],l1[2]],[])*q([i1],[])*e([],[i1])))$
3029
(%i4) defrule(r2,m([],l1),(i1:idummy(),
3030
w([],[l1[1],l1[2]])*e([i1],[])*q([],[i1])))$
3032
(%i5) ishow(m([i,n],[])*m([],[i,m]))$
3036
(%i6) ishow(rename(applyb1(%,r1,r2)))$
3042
-- Function: remcomps (<tensor>)
3043
Unbinds all values from <tensor> which were assigned with the
3044
`components' function.
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:
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)]);
3061
[ sqrt(-------) 0 0 0 ]
3066
[ 0 0 r sin(theta) 0 ]
3069
[ 0 0 0 sqrt(-------) ]
3071
(%i4) components(g([i,j],[]),lg);
3073
(%i5) showcomps(g([i,j],[]));
3075
[ sqrt(-------) 0 0 0 ]
3080
i j [ 0 0 r sin(theta) 0 ]
3083
[ 0 0 0 sqrt(-------) ]
3087
The `showcomps' command can also display components of a tensor of
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').
3098
-- Option variable: idummyx
3101
Is the prefix for dummy indices (see the example under `indices').
3104
-- Option variable: icounter
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: `%').
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.
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.
3127
-- Function: kdels (<L1>, <L2>)
3128
Symmetricized Kronecker delta, used in some calculations. For
3132
(%i1) load(itensor);
3133
(%o1) /share/tensor/itensor.lisp
3134
(%i2) kdelta([1,2],[2,1]);
3136
(%i3) kdels([1,2],[2,1]);
3138
(%i4) ishow(kdelta([a,b],[c,d]))$
3140
(%t4) kdelta kdelta - kdelta kdelta
3142
(%i4) ishow(kdels([a,b],[c,d]))$
3144
(%t4) kdelta kdelta + kdelta kdelta
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
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'.
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]))$
3170
(%t2) levi_civita a levi_civita
3172
(%i3) ishow(ev(expr,levi_civita))$
3174
(%t3) kdelta a kdelta
3176
(%i4) ishow(ev(%,kdelta))$
3178
(%t4) (kdelta kdelta - kdelta kdelta ) a
3182
(kdelta kdelta - kdelta kdelta )
3184
(%i5) ishow(lc2kdt(expr))$
3186
(%t5) a kdelta kdelta - a kdelta kdelta
3188
(%i6) ishow(contract(expand(%)))$
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.
3198
(%i7) expr:ishow('levi_civita([],[i,j])*'levi_civita([],[k,l])*a([j,k],[]))$
3200
(%t7) levi_civita levi_civita a
3202
(%i8) ishow(lc2kdt(expr))$
3203
Maxima encountered a Lisp error:
3205
Error in $IMETRIC [or a callee]:
3206
$IMETRIC [or a callee] requires less than two arguments.
3208
Automatically continuing.
3209
To reenable the Lisp debugger set *debugger-hook* to nil.
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
3216
(%i11) ishow(contract(expand(%)))$
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:
3228
(%i1) load(itensor);
3229
(%o1) /share/tensor/itensor.lisp
3230
(%i2) el1:ishow('levi_civita([i,j,k],[])*a([],[i])*a([],[j]))$
3232
(%t2) a a levi_civita
3234
(%i3) el2:ishow('levi_civita([],[i,j,k])*a([i])*a([j]))$
3236
(%t3) levi_civita a a
3238
(%i4) ishow(canform(contract(expand(applyb1(el1,lc_l,lc_u)))))$
3240
(%i5) ishow(canform(contract(expand(applyb1(el2,lc_l,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'.
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.
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'.
3264
-- Function: concan (<expr>)
3265
Similar to `canten' but also performs index contraction.
3268
28.2.2 Tensor symmetries
3269
------------------------
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'.
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.
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])))$
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)],[]);
3308
(%i5) ishow(canform(expr))$
3311
(%i6) remsym(a,3,0);
3313
(%i7) decsym(a,3,0,[anti(all)],[]);
3315
(%i8) ishow(canform(expr))$
3317
(%i9) remsym(a,3,0);
3319
(%i10) decsym(a,3,0,[cyc(all)],[]);
3321
(%i11) ishow(canform(expr))$
3324
(%i12) dispsym(a,3,0);
3325
(%o12) [[cyc, [[1, 2, 3]], []]]
3328
-- Function: remsym (<tensor>, <m>, <n>)
3329
Removes all symmetry properties from <tensor> which has <m>
3330
covariant indices and <n> contravariant indices.
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
3346
28.2.3 Indicial tensor calculus
3347
-------------------------------
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.
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'.
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.
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:
3384
(%i1) load(itensor);
3385
(%o1) /share/tensor/itensor.lisp
3386
(%i2) ishow(liediff(v,a([i,j],[])*b([],[k],l)))$
3388
(%t2) b (v a + v a + v a )
3389
,l i j,%2 ,j i %2 ,i %2 j
3392
+ (v b - b v + v b ) a
3393
,%1 l ,l ,%1 ,l ,%1 i j
3396
-- Function: rediff (<ten>)
3397
Evaluates all occurrences of the `idiff' command in the tensorial
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)'.
3411
-- Function: evundiff (<expr>)
3412
Equivalent to the execution of `undiff', followed by `ev' and
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:
3419
(%i1) load(itensor);
3420
(%o1) /share/tensor/itensor.lisp
3421
(%i2) icurvature([i,j,k],[l],m);
3422
Maxima encountered a Lisp error:
3424
Error in $ICURVATURE [or a callee]:
3425
$ICURVATURE [or a callee] requires less than three arguments.
3427
Automatically continuing.
3428
To reenable the Lisp debugger set *debugger-hook* to nil.
3430
However, if `icurvature' is entered in noun form, it can be
3431
evaluated using `evundiff':
3433
(%i3) ishow('icurvature([i,j,k],[l],m))$
3437
(%i4) ishow(evundiff(%))$
3439
(%t4) - ichr2 - ichr2 ichr2 - ichr2 ichr2
3440
i k,j m %1 j i k,m %1 j,m i k
3443
+ ichr2 + ichr2 ichr2 + ichr2 ichr2
3444
i j,k m %1 k i j,m %1 k,m i j
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
3453
(%i6) ishow(ichr2([i,j],[k],l))$
3456
j %3,i l i j,%3 l i %3,j l
3457
(%t6) -----------------------------------------
3462
,l j %3,i i j,%3 i %3,j
3463
+ -----------------------------------
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.
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.
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.
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))$
3488
(%i3) ishow(flushnd(%,a,3))$
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.
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.
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)'.
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:
3523
(%i1) load(itensor);
3524
(%o1) /share/tensor/itensor.lisp
3525
(%i2) ishow(g([],[a,b],c))$
3529
(%i3) ishow(conmetderiv(%,g))$
3531
(%t3) - g ichr2 - g ichr2
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
3542
g g + g g = (g g ) = (kdelta ) = 0
3543
,d bc bc,d bc ,d c ,d
3559
which follows from the symmetries of the Christoffel symbols.
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.
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:
3575
(%i1) load(itensor);
3576
(%o1) /share/tensor/itensor.lisp
3579
(%i3) ishow(g([],[a,b])*g([],[b,c])*g([a,b],[],d)*g([b,c],[],e))$
3583
(%i4) ishow(canform(%))$
3585
errexp1 has improper indices
3586
-- an error. Quitting. To debug this try debugmode(true);
3587
(%i5) ishow(simpmetderiv(%))$
3591
(%i6) flipflag:not flipflag;
3593
(%i7) ishow(simpmetderiv(%th(2)))$
3597
(%i8) flipflag:not flipflag;
3599
(%i9) ishow(simpmetderiv(%th(2),stop))$
3603
(%i10) ishow(contract(%))$
3608
See also `weyl.dem' for an example that uses `simpmetderiv' and
3609
`conmetderiv' together to simplify contractions of the Weyl tensor.
3612
-- Function: flush1deriv (<expr>, <tensor>)
3613
Set to zero, in `expr', all occurrences of `tensor' that have
3614
exactly one derivative index.
3617
28.2.4 Tensors in curved spaces
3618
-------------------------------
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.
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
3635
-- Function: ichr1 ([<i>, <j>, <k>])
3636
Yields the Christoffel symbol of the first kind via the definition
3639
To evaluate the Christoffel symbols for a particular metric, the
3640
variable `imetric' must be assigned a name as in the example under
3644
-- Function: ichr2 ([<i>, <j>], [<k>])
3645
Yields the Christoffel symbol of the second kind defined by the
3648
ichr2([i,j],[k]) = g (g + g - g )/2
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
3656
icurvature = - ichr2 - ichr2 ichr2 + ichr2
3657
i j k i k,j %1 j i k i j,k
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
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: [];
3679
(%i3) ishow(covdiff(%,s))$
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
3685
(%i5) ishow(ev(%th(2),ichr2))$
3688
i %1 s %4,j j s,%4 j %4,s
3689
(%t5) - ------------------------------------------
3693
%1 j s %3,i i s,%3 i %3,s
3694
- ------------------------------------------
3698
i j s %2,%1 %1 s,%2 %1 %2,s k
3699
+ ------------------------------------------- + a
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.
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.
3720
(%i1) load(itensor);
3721
(%o1) /share/tensor/itensor.lisp
3722
(%i2) ishow(icurvature([r,s,t],[u]))$
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))$
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))$
3734
(%t4) - ichr2 + ichr2 + ichr2 - ichr2 - ichr2
3735
t s,r t r,s s t,r s r,t r t,s
3744
28.2.5 Moving frames
3745
--------------------
3747
Maxima now has the ability to perform calculations using moving frames.
3748
These can be orthonormal frames (tetrads, vielbeins) or an arbitrary
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'
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.
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
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.
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:
3779
(%i1) load(itensor);
3780
(%o1) /share/tensor/itensor.lisp
3781
(%i2) iframe_flag:true;
3783
(%i3) ishow(covdiff(v([],[i]),j))$
3787
(%i4) ishow(ev(%,icc2))$
3789
(%t4) v (ifc2 + ichr2 ) + v
3791
(%i5) ishow(ev(%,ifc2))$
3793
v ifg (ifb - ifb + ifb )
3794
j %2 %1 %2 %1 j %1 j %2 i
3795
(%t5) -------------------------------------------------- + v
3797
(%i6) ishow(ifb([a,b,c]))$
3799
(%t6) ifr ifr (ifri - ifri )
3802
An alternate method is used to compute the frame bracket (`ifb') if
3803
the `iframe_bracket_form' flag is set to `false':
3806
(%i8) block([iframe_bracket_form:false],ishow(ifb([a,b,c])))$
3808
(%t8) (ifr ifr - ifr ifr ) ifri
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.
3818
The frame bracket. The contribution of the frame metric to the
3819
connection coefficients is expressed using the frame bracket:
3824
ifc1 = --------------------------------
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':
3834
ifb = ifr ifr (ifri - ifri - ifri itr )
3835
abc b c a d,e a e,d a f d e
3841
ifb = (ifr ifr - ifr ifr ) ifri
3846
Connection coefficients of the first kind. In `itensor', defined as
3849
icc1 = ichr1 - ikt1 - inmc1
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.
3861
Connection coefficients of the second kind. In `itensor', defined
3866
icc2 = ichr2 - ikt2 - inmc2
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.
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.
3886
ifc1 = --------------------------------
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
3904
The frame field. Contracts with the inverse frame field (`ifri') to
3905
form the frame metric (`ifg').
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.
3915
The frame metric. Defaults to `kdelta', but can be changed using
3920
The inverse frame metric. Contracts with the frame metric (`ifg')
3924
-- Option variable: iframe_bracket_form
3925
Default value: `true'
3927
Specifies how the frame bracket (`ifb') is computed.
3930
28.2.6 Torsion and nonmetricity
3931
-------------------------------
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.
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':
3950
Covariant permutation of the nonmetricity vector components.
3954
g inm - inm g - g inm
3956
inmc1 = ------------------------------
3959
(Substitute `ifg' in place of `g' if a frame metric is used.)
3963
Contravariant permutation of the nonmetricity vector components.
3964
Used in the connection coefficients if `inonmet_flag' is `true'.
3969
-inm kdelta - kdelta inm + g inm g
3971
inmc2 = -------------------------------------------
3974
(Substitute `ifg' in place of `g' if a frame metric is used.)
3978
Covariant permutation of the torsion tensor (also known as
3979
contorsion). Defined as:
3983
-g itr - g itr - itr g
3985
ikt1 = ----------------------------------
3988
(Substitute `ifg' in place of `g' if a frame metric is used.)
3992
Contravariant permutation of the torsion tensor (also known as
3993
contorsion). Defined as:
4000
(Substitute `ifg' in place of `g' if a frame metric is used.)
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:
4009
(%i1) load(itensor);
4010
(%o1) /share/tensor/itensor.lisp
4013
(%i3) covdiff(covdiff(f([],[]),i),j)-covdiff(covdiff(f([],[]),j),i)$
4016
(%t4) f ichr2 - f ichr2
4020
(%i6) itorsion_flag:true;
4022
(%i7) covdiff(covdiff(f([],[]),i),j)-covdiff(covdiff(f([],[]),j),i)$
4025
(%t8) f icc2 - f icc2 - f + f
4026
,%8 j i ,%6 i j ,j i ,i j
4027
(%i9) ishow(canform(%))$
4029
(%t9) f icc2 - f icc2
4031
(%i10) ishow(canform(ev(%,icc2)))$
4033
(%t10) f ikt2 - f ikt2
4035
(%i11) ishow(canform(ev(%,ikt2)))$
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))))))$
4043
(%t12) ------------------------------------
4045
(%i13) decsym(itr,2,1,[anti(all)],[]);
4047
(%i14) defcon(g,g,kdelta);
4049
(%i15) subst(g,nounify(g),%th(3))$
4050
(%i16) ishow(canform(contract(%)))$
4056
28.2.7 Exterior algebra
4057
-----------------------
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.
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
4072
a /\ a = -----------
4075
More generally, the product of a p-form and a q-form would be
4079
A /\ B = ------ D A B
4080
i1..ip j1..jq (p+q)! i1..ip j1..jq k1..kp l1..lq
4082
where `D' stands for the Kronecker-delta.
4084
Other authors, however, prefer a "geometric" definition that
4085
corresponds with the notion of the volume element:
4090
and, in the general case
4093
A /\ B = ----- D A B
4094
i1..ip j1..jq p! q! i1..ip j1..jq k1..kp l1..lq
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
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
4111
The behavior of the wedge product operator is controlled by the
4112
`igeowedge_flag' flag, as in the following example:
4114
(%i1) load(itensor);
4115
(%o1) /share/tensor/itensor.lisp
4116
(%i2) ishow(a([i])~b([j]))$
4121
(%i3) decsym(a,2,0,[anti(all)],[]);
4123
(%i4) ishow(a([i,j])~b([k]))$
4126
(%t4) ---------------------------
4128
(%i5) igeowedge_flag:true;
4130
(%i6) ishow(a([i])~b([j]))$
4133
(%i7) ishow(a([i,j])~b([k]))$
4134
(%t7) a b + b a - a b
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
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:
4151
(%i1) load(itensor);
4152
(%o1) /share/tensor/itensor.lisp
4153
(%i2) decsym(a,2,0,[anti(all)],[]);
4155
(%i3) ishow(a([i,j],[])|v)$
4159
(%i4) ishow(a([j,i],[])|v)$
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.
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:
4176
(%i1) load(itensor);
4177
(%o1) /share/tensor/itensor.lisp
4178
(%i2) ishow(extdiff(v([i]),j))$
4183
(%i3) decsym(a,2,0,[anti(all)],[]);
4185
(%i4) ishow(extdiff(a([i,j]),k))$
4188
(%t4) ------------------------
4190
(%i5) igeowedge_flag:true;
4192
(%i6) ishow(extdiff(v([i]),j))$
4195
(%i7) ishow(extdiff(a([i,j]),k))$
4200
-- Function: hodge (<expr>)
4201
Compute the Hodge-dual of <expr>. For instance:
4204
(%i1) load(itensor);
4205
(%o1) /share/tensor/itensor.lisp
4212
(%i5) decsym(A,3,0,[anti(all)],[])$
4214
(%i6) ishow(A([i,j,k],[]))$
4217
(%i7) ishow(canform(hodge(%)))$
4221
(%t7) -----------------------------------------
4223
(%i8) ishow(canform(hodge(%)))$
4224
%1 %2 %3 %8 %4 %5 %6 %7
4225
(%t8) levi_civita levi_civita g g
4228
%3 %108 %4 %8 %5 %6 %7
4233
(%i11) ishow(canform(contract(expand(%))))$
4238
-- Option variable: igeowedge_flag
4239
Default value: `false'
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
4249
28.2.8 Exporting TeX expressions
4250
--------------------------------
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.
4258
-- Function: tentex (<expr>)
4259
To use the `tentex' function, you must first load `tentex', as in
4260
the following example:
4263
(%i1) load(itensor);
4264
(%o1) /share/tensor/itensor.lisp
4266
(%o2) /share/tensor/tentex.lisp
4269
(%i4) ishow(icurvature([j,k,l],[i]))$
4271
(%t4) ichr2 ichr2 - ichr2 ichr2 - ichr2 + ichr2
4272
j k m1 l j l m1 k j l,k j k,l
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}$$
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
4281
NB: This version of the `tentex' function is somewhat experimental.
4284
28.2.9 Interfacing with ctensor
4285
-------------------------------
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'.
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.
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]))$
4314
(%i3) ic_convert(eqn);
4315
(%o3) for i thru dim do (for j thru dim
4317
do (for k thru dim do t : f sum(sum(diff(a , ct_coords ) b
4320
g , l, 1, dim), m, 1, dim)))
4324
(%i5) metricconvert:true;
4326
(%i6) ic_convert(eqn);
4327
(%o6) for i thru dim do (for j thru dim
4329
do (for k thru dim do t : f sum(sum(diff(a , ct_coords ) b
4332
lg , l, 1, dim), m, 1, dim)))
4336
28.2.10 Reserved words
4337
----------------------
4339
The following Maxima words are used by the `itensor' package internally
4340
and should not be redefined:
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
4357
File: maxima.info, Node: ctensor, Next: atensor, Prev: itensor, Up: Top
4364
* Introduction to ctensor::
4365
* Definitions for ctensor::
4368
File: maxima.info, Node: Introduction to ctensor, Next: Definitions for ctensor, Prev: ctensor, Up: ctensor
4370
29.1 Introduction to ctensor
4371
============================
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.
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
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.
4395
(%i1) load(ctensor);
4396
(%o1) /share/tensor/ctensor.mac
4398
Enter the dimension of the coordinate system:
4400
Do you wish to change the coordinate names?
4403
1. Enter a new metric?
4405
2. Enter a metric from a file?
4407
3. Approximate a metric with a Taylor series?
4410
Is the matrix 1. Diagonal 2. Symmetric 3. Antisymmetric 4. General
4423
Enter functional dependencies with the DEPENDS function or 'N' if none
4425
Do you wish to see the metric?
4437
(%i3) christof(mcs);
4466
(%t9) mcs = - ---------
4469
(%t10) mcs = - cos(y) sin(y)
4479
File: maxima.info, Node: Definitions for ctensor, Prev: Introduction to ctensor, Up: ctensor
4481
29.2 Definitions for ctensor
4482
============================
4484
29.2.1 Initialization and setup
4485
-------------------------------
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.
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
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
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.
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:
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
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:
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]]);
4557
(%i3) lg:trigsimp(lg);
4564
[ 0 0 r cos (theta) ]
4566
(%o4) [r, theta, phi]
4570
Transformation functions can also be used when `cframe_flag' is
4574
(%i1) load(ctensor);
4575
(%o1) /share/tensor/ctensor.mac
4576
(%i2) cframe_flag:true;
4578
(%i3) ct_coordsys([r*cos(theta)*cos(phi),r*cos(theta)*sin(phi),
4579
r*sin(theta),[r,theta,phi]]);
4582
[ cos(phi) cos(theta) - cos(phi) r sin(theta) - sin(phi) r cos(theta) ]
4584
(%o4) [ sin(phi) cos(theta) - sin(phi) r sin(theta) cos(phi) r cos(theta) ]
4586
[ sin(theta) r cos(theta) 0 ]
4589
(%i6) lg:trigsimp(lg);
4596
[ 0 0 r cos (theta) ]
4598
The optional argument <extra_arg> can be any one of the following:
4600
`cylindrical' tells `ct_coordsys' to attach an additional
4601
cylindrical coordinate.
4603
`minkowski' tells `ct_coordsys' to attach an additional coordinate
4604
with negative metric signature.
4606
`all' tells `ct_coordsys' to call `cmetric' and `christof(false)'
4607
after setting up the metric.
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'.
4614
-- Function: init_ctensor ()
4615
Initializes the `ctensor' package.
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
4623
29.2.2 The tensors of curved space
4624
----------------------------------
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.
4629
When a metric base is used, `ctensor' can compute the following
4635
lcs -- mcs -- ric -- uric
4637
\ tracer - ein -- lein
4639
riem -- lriem -- weyl
4643
`ctensor' can also work using moving frames. When `cframe_flag' is
4644
set to `true', the following tensors can be calculated:
4649
fri -- fr -- lcs -- mcs -- lriem -- ric -- uric
4651
lg -- ug | weyl tracer - ein -- lein
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.
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.
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
4691
-- Function: scurvature ()
4692
Returns the scalar curvature (obtained by contracting the Ricci
4693
tensor) of the Riemannian manifold with the given metric.
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
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
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:
4724
R[i,j,k,l] = R = | - | + | | - | |
4725
ijk ij,k ik,j mk ij mj ik
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.
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.
4742
-- Function: lriemann (<dis>)
4743
Covariant Riemann-tensor (`lriem[]').
4745
Computes the covariant Riemann-tensor as the array `lriem'. If the
4746
argument <dis> is `true', unique nonzero values are displayed.
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.
4752
For information on index ordering, see `riemann'.
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
4761
-- Function: rinvariant ()
4762
Forms the Kretchmann-invariant (`kinvariant') obtained by
4763
contracting the tensors
4765
lriem[i,j,k,l]*uriem[i,j,k,l].
4767
This object is not automatically simplified since it can be very
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.
4780
29.2.3 Taylor series expansion
4781
------------------------------
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.
4788
The `ctaylor' function is invoked by the following `ctensor'
4793
---------------------------------
4794
christof() For mcs only
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'.
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
4816
(%i1) load(ctensor);
4817
(%o1) /share/tensor/ctensor.mac
4820
(%i3) derivabbrev: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]);
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]);
4853
[ 0 0 0 r sin (theta) + h44 l ]
4854
(%i9) cmetric(false);
4856
(%i10) einstein(false);
4858
(%i11) ntermst(ein);
4877
However, if we recompute this example as an approximation that is
4878
linear in the variable `l', we get much simpler expressions:
4881
(%i14) ctayswitch:true;
4889
(%i18) christof(false);
4891
(%i19) ricci(false);
4893
(%i20) einstein(false);
4895
(%i21) ntermst(ein);
4913
(%i22) ratsimp(ein[1,1]);
4915
(%o22) - (((h11 h22 - h11 ) (l ) r - 2 h33 l r ) sin (theta)
4919
- 2 h44 l r - h33 h44 (l ) )/(4 r sin (theta))
4922
This capability can be useful, for instance, when working in the
4923
weak field limit far from a gravitational source.
4929
When the variable `cframe_flag' is set to true, the `ctensor' package
4930
performs its calculations using a moving frame.
4932
-- Function: frame_bracket (<fr>, <fri>, <diagframe>)
4933
The frame bracket (`fb[]').
4935
Computes the frame bracket according to the following definition:
4938
ifb = ( ifri - ifri ) ifr ifr
4942
29.2.5 Algebraic classification
4943
-------------------------------
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'.
4950
-- Function: nptetrad ()
4951
Computes a Newman-Penrose null tetrad (`np') and its raised-index
4952
counterpart (`npi'). See `petrov' for an example.
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:
4960
np = (fri + fri ) / sqrt(2)
4963
np = (fri - fri ) / sqrt(2)
4966
np = (fri + %i fri ) / sqrt(2)
4969
np = (fri - %i fri ) / sqrt(2)
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.
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.
4996
-- Function: petrov ()
4997
Computes the Petrov classification of the metric characterized by
4998
`psi[0]'...`psi[4]'.
5000
For example, the following demonstrates how to obtain the
5001
Petrov-classification of the Kerr metric:
5003
(%i1) load(ctensor);
5004
(%o1) /share/tensor/ctensor.mac
5005
(%i2) (cframe_flag:true,gcd:spmod,ctrgsimp:true,ratfac:true);
5007
(%i3) ct_coordsys(exteriorschwarzschild,all);
5009
(%i4) ug:invert(lg)$
5012
(%i6) nptetrad(true);
5015
[ sqrt(r - 2 m) sqrt(r) ]
5016
[ --------------- --------------------- 0 0 ]
5017
[ sqrt(2) sqrt(r) sqrt(2) sqrt(r - 2 m) ]
5019
[ sqrt(r - 2 m) sqrt(r) ]
5020
[ --------------- - --------------------- 0 0 ]
5021
[ sqrt(2) sqrt(r) sqrt(2) sqrt(r - 2 m) ]
5023
[ r %i r sin(theta) ]
5024
[ 0 0 ------- --------------- ]
5027
[ r %i r sin(theta) ]
5028
[ 0 0 ------- - --------------- ]
5031
sqrt(r) sqrt(r - 2 m)
5032
(%t7) npi = matrix([- ---------------------, ---------------, 0, 0],
5033
sqrt(2) sqrt(r - 2 m) sqrt(2) sqrt(r)
5035
sqrt(r) sqrt(r - 2 m)
5036
[- ---------------------, - ---------------, 0, 0],
5037
sqrt(2) sqrt(r - 2 m) sqrt(2) sqrt(r)
5040
[0, 0, ---------, --------------------],
5041
sqrt(2) r sqrt(2) r sin(theta)
5044
[0, 0, ---------, - --------------------])
5045
sqrt(2) r sqrt(2) r sin(theta)
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.
5077
29.2.6 Torsion and nonmetricity
5078
-------------------------------
5080
`ctensor' has the ability to compute and include torsion and
5081
nonmetricity coefficients in the connection coefficients.
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:
5089
- g tr - g tr - tr g
5091
kt = -------------------------------
5099
Note that only the mixed-index tensor is calculated and stored in the
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:
5108
-nm D - D nm + g nm g
5110
nmc = ------------------------------
5113
where D stands for the Kronecker-delta.
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.
5121
If necessary, `christof' calls the functions `contortion' and
5122
`nonmetricity' in order to compute `kt' and `nm'.
5124
-- Function: contortion (<tr>)
5125
Computes the (2,1) contortion coefficients from the torsion tensor
5129
-- Function: nonmetricity (<nm>)
5130
Computes the (2,1) nonmetricity coefficients from the nonmetricity
5134
29.2.7 Miscellaneous features
5135
-----------------------------
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'.)
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
5154
(%i1) load(ctensor);
5155
(%o1) /share/tensor/ctensor.mac
5156
(%i2) derivabbrev:true;
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]);
5170
(%i5) depends([a,d],x);
5172
(%i6) ct_coords:[x,y,z,t];
5176
(%i8) einstein(false);
5178
(%i9) findde(ein,2);
5180
(%o9) [d x - a d + d, 2 a d d x - a (d ) x - a d d x + 2 a d d
5184
- 2 a d , a x + a - a]
5187
(%o10) [[1, 1], [2, 2], [4, 4]]
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.
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:
5201
(%i1) load(ctensor);
5202
(%o1) /share/tensor/ctensor.mac
5203
(%i2) derivabbrev:true;
5205
(%i3) ct_coordsys(exteriorschwarzschild,all);
5211
(%i6) listarray(g1);
5214
(%i7) contragrad(f,g2);
5216
(%i8) listarray(g2);
5219
(%o8) [0, -------------, 0, 0]
5223
-- Function: dscalar ()
5224
computes the tensor d'Alembertian of the scalar function once
5225
dependencies have been declared upon the function. For example:
5227
(%i1) load(ctensor);
5228
(%o1) /share/tensor/ctensor.mac
5229
(%i2) derivabbrev:true;
5231
(%i3) ct_coordsys(exteriorschwarzschild,all);
5235
(%i5) factor(dscalar(p));
5237
p r - 2 m p r + 2 p r - 2 m p
5239
(%o5) --------------------------------------
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'.
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.
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)'.
5265
The components of the second rank covariant field tensor are
5266
represented by the array `bd'.
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'.
5275
-- Function: invariant2 ()
5276
*** NOT YET IMPLEMENTED ***
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'.
5283
-- Function: bimetric ()
5284
*** NOT YET IMPLEMENTED ***
5286
generates the field equations of Rosen's bimetric theory. The field
5287
equations are the components of an array named `rosen'.
5290
29.2.8 Utility functions
5291
------------------------
5293
-- Function: diagmatrixp (<M>)
5294
Returns `true' if <M> is a diagonal matrix or (2D) array.
5297
-- Function: symmetricp (<M>)
5298
Returns `true' if <M> is a symmetric matrix or (2D) array.
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.
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
5318
(%i1) load(ctensor);
5319
(%o1) /share/tensor/ctensor.mac
5322
(%i3) ct_coordsys(exteriorschwarzschild,all);
5324
(%i4) riemann(false);
5326
(%i5) cdisplay(riem);
5330
[ 3 m (r - 2 m) m 2 m ]
5331
[ 0 - ------------- + -- - ---- 0 0 ]
5335
riem = [ m (r - 2 m) ]
5336
1, 1 [ 0 0 ----------- 0 ]
5341
[ 0 0 0 ----------- ]
5346
[ 0 ------------- 0 0 ]
5357
[ 0 0 - ----------- 0 ]
5368
[ 0 0 0 - ----------- ]
5381
[ - ------------ 0 0 0 ]
5383
2, 1 [ r (r - 2 m) ]
5390
[ ------------ 0 0 0 ]
5397
2, 2 [ 0 0 - ------------ 0 ]
5402
[ 0 0 0 - ------------ ]
5409
[ 0 0 ------------ 0 ]
5411
2, 3 [ r (r - 2 m) ]
5420
[ 0 0 0 ------------ ]
5422
2, 4 [ r (r - 2 m) ]
5459
[ 0 0 0 ------- + 1 ]
5467
3, 4 [ 0 0 0 - --- ]
5480
[ ------------- 0 0 0 ]
5491
[ 0 ------------- 0 0 ]
5502
[ 0 0 - --------------- 0 ]
5507
[ - ------------- 0 0 0 ]
5512
riem = [ 0 - ------------- 0 0 ]
5517
[ 0 0 --------------- 0 ]
5524
-- Function: deleten (<L>, <n>)
5525
Returns a new list consisting of <L> with the <n>'th element
5528
29.2.9 Variables used by `ctensor'
5529
----------------------------------
5531
-- Option variable: dim
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'.
5539
-- Option variable: diagmetric
5540
Default value: `false'
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.
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.
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.
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'.
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'.
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.
5584
-- Option variable: ctayvar
5585
Variable used for Taylor-series expansion if `ctayswitch' is set to
5589
-- Option variable: ctaypov
5590
Maximum power used in Taylor-series expansion when `ctayswitch' is
5594
-- Option variable: ctaypt
5595
Point around which Taylor-series expansion is carried out when
5596
`ctayswitch' is set to `true'.
5599
-- System variable: gdet
5600
The determinant of the metric tensor `lg'. Computed by `cmetric'
5601
when `cframe_flag' is set to `false'.
5604
-- Option variable: ratchristof
5605
Causes rational simplification to be applied by `christof'.
5608
-- Option variable: rateinstein
5609
Default value: `true'
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.
5616
-- Option variable: ratriemann
5617
Default value: `true'
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
5625
-- Option variable: ratweyl
5626
Default value: `true'
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.
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'.
5638
The inverse frame metric. Computed from `lfg' when `cmetric' is
5639
called while `cframe_flag' is set to `true'.
5642
The (3,1) Riemann tensor. Computed when the function `riemann' is
5643
invoked. For information about index ordering, see the description
5646
if `cframe_flag' is `true', `riem' is computed from the covariant
5647
Riemann-tensor `lriem'.
5651
The covariant Riemann tensor. Computed by `lriemann'.
5655
The contravariant Riemann tensor. Computed by `uriemann'.
5659
The mixed Ricci-tensor. Computed by `ricci'.
5663
The contravariant Ricci-tensor. Computed by `uricci'.
5667
The metric tensor. This tensor must be specified (as a `dim' by
5668
`dim' matrix) before other computations can be performed.
5672
The inverse of the metric tensor. Computed by `cmetric'.
5676
The Weyl tensor. Computed by `weyl'.
5680
Frame bracket coefficients, as computed by `frame_bracket'.
5683
-- Variable: kinvariant
5684
The Kretchmann invariant. Computed by `rinvariant'.
5688
A Newman-Penrose null tetrad. Computed by `nptetrad'.
5692
The raised-index Newman-Penrose null tetrad. Computed by
5693
`nptetrad'. Defined as `ug.np'. The product `np.transpose(npi)'
5696
(%i39) trigsimp(np.transpose(npi));
5707
User-supplied rank-3 tensor representing torsion. Used by
5711
The contortion tensor, computed from `tr' by `contortion'.
5714
User-supplied nonmetricity vector. Used by `nonmetricity'.
5717
The nonmetricity coefficients, computed from `nm' by
5721
-- System variable: tensorkill
5722
Variable indicating if the tensor package has been initialized.
5723
Set and used by `csetup', reset by `init_ctensor'.
5726
-- Option variable: ct_coords
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'.
5736
29.2.10 Reserved names
5737
----------------------
5739
The following names are used internally by the `ctensor' package and
5740
should not be redefined:
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()
5757
sermet() Used by csetup() for entering a metric as Taylor-series
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()
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.
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
5797
File: maxima.info, Node: atensor, Next: Series, Prev: ctensor, Up: Top
5804
* Introduction to atensor::
5805
* Definitions for atensor::
5808
File: maxima.info, Node: Introduction to atensor, Next: Definitions for atensor, Prev: atensor, Up: atensor
5810
30.1 Introduction to atensor
5811
============================
5813
`atensor' is an algebraic tensor manipulation package. To use `atensor',
5814
type `load(atensor)', followed by a call to the `init_atensor' function.
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.
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.:
5826
i = v j = v k = v . v
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:
5834
(%i1) load(atensor);
5835
(%o1) /share/tensor/atensor.mac
5836
(%i2) init_atensor(clifford,0,0,2);
5838
(%i3) atensimp(v[1].v[1]);
5840
(%i4) atensimp((v[1].v[2]).(v[1].v[2]));
5842
(%i5) q:zeromatrix(4,4);
5852
(%i7) for i thru adim do q[1,i+1]:q[i+1,1]:v[i];
5854
(%i8) q[1,4]:q[4,1]:v[1].v[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]);
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])'.
5881
Needless to say, the functions `sf', `af' and `av' can be redefined.
5883
When the `atensor' package is loaded, the following flags are set:
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
5895
File: maxima.info, Node: Definitions for atensor, Prev: Introduction to atensor, Up: atensor
5897
30.2 Definitions for atensor
5898
============================
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:
5905
`universal': The universal algebra has no commutation rules.
5907
`grassmann': The Grassman algebra is defined by the commutation
5908
relation `u.v+v.u=0'.
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.
5919
`symmetric': The symmetric algebra is defined by the commutation
5920
relation `u.v-v.u=0'.
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.
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.
5935
The `init_atensor' function also recognizes several predefined
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)'.
5942
`quaternion' implements the algebra of quaternions. The call
5943
`init_atensor(quaternion)' is equivalent to
5944
`init_atensor(clifford,0,0,2)'.
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)'.
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)'.
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.
5964
-- Function: alg_type
5965
The algebra type. Valid values are `universal', `grassmann',
5966
`clifford', `symmetric', `symplectic' and `lie_envelop'.
5972
The dimensionality of the algebra. `atensor' uses the value of
5973
`adim' to determine if an indexed object is a valid base vector.
5978
Default value: `ident(3)'
5980
Default values for the bilinear forms `sf', `af', and `av'. The
5981
default is the identity matrix `ident(3)'.
5984
-- Variable: asymbol
5987
The symbol for base vectors..
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'.
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'.
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'.
6012
(%i1) load(atensor);
6013
(%o1) /share/tensor/atensor.mac
6016
(%i3) aform:matrix([0,3,-2],[-3,0,1],[2,-1,0]);
6024
(%i5) av(x[1],x[2]);
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
6037
File: maxima.info, Node: Series, Next: Number Theory, Prev: atensor, Up: Top
6044
* Introduction to Series::
6045
* Definitions for Series::
6048
File: maxima.info, Node: Introduction to Series, Next: Definitions for Series, Prev: Series, Up: Series
6050
31.1 Introduction to Series
6051
===========================
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.
6060
File: maxima.info, Node: Definitions for Series, Prev: Introduction to Series, Up: Series
6062
31.2 Definitions for Series
6063
===========================
6065
-- Option variable: cauchysum
6066
Default value: `false'
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.
6076
(%i1) sumexpand: false$
6077
(%i2) cauchysum: false$
6078
(%i3) s: sum (f(i), i, 0, inf) * sum (g(j), j, 0, inf);
6082
(%o3) ( > f(i)) > g(j)
6086
(%i4) sumexpand: true$
6087
(%i5) cauchysum: true$
6092
(%o6) > > g(i1 - i2) f(i2)
6098
-- Function: deftaylor (<f_1>(<x_1>), <expr_1>, ..., <f_n>(<x_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.
6105
`powerseries (<f_i>(<x_i>), <x_i>, 0)' returns the series defined
6108
`deftaylor' returns a list of the functions <f_1>, ..., <f_n>.
6109
`deftaylor' evaluates its arguments.
6113
(%i1) deftaylor (f(x), x^2 + sum(x^i/(2^i*i!^2), i, 4, inf));
6115
(%i2) powerseries (f(x), x, 0);
6119
(%o2) > -------- + x
6123
(%i3) taylor (exp (sqrt (f(x))), x, 0, 4);
6126
(%o3)/T/ 1 + x + -- + ------- + -------- + . . .
6130
-- Option variable: maxtayorder
6131
Default value: `true'
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.
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', ....
6148
`niceindices' returns an expression. `niceindices' evaluates its
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);
6159
(%o2) ! ! > f(bar i j + foo)
6163
(%i3) niceindices (%);
6167
(%o3) ! ! > f(i j l + k)
6173
-- Option variable: niceindicespref
6174
Default value: `[i, j, k, l, m, n]'
6176
`niceindicespref' is the list from which `niceindices' takes the
6177
names of indices for sums and products.
6179
The elements of `niceindicespref' are typically names of variables,
6180
although that is not enforced by `niceindices'.
6184
(%i1) niceindicespref: [p, q, r, s, t, u]$
6185
(%i2) product (sum (f (foo + i*j*bar), foo, 1, inf), bar, 1, inf);
6189
(%o2) ! ! > f(bar i j + foo)
6193
(%i3) niceindices (%);
6197
(%o3) ! ! > f(i j q + p)
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.
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.
6216
`nusum' and `unsum' know a little about sums and differences of
6217
finite products. See also `unsum'.
6221
(%i1) nusum (n*n!, n, 0, n);
6223
Dependent equations eliminated: (1)
6225
(%i2) nusum (n^4*4^n/binomial(2*n,n), n, 0, 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
6233
(%o3) ----------------
6235
(%i4) unsum (prod (i^2, i, 1, n), n);
6239
(%o4) ( ! ! i ) (n - 1) (n + 1)
6242
(%i5) nusum (%, n, 1, n);
6244
Dependent equations eliminated: (2 3)
6253
-- Function: pade (<taylor_series>, <numer_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
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.
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")'.
6273
(%i1) taylor (1 + x + x^2 + x^3, x, 0, 3);
6275
(%o1)/T/ 1 + x + x + x + . . .
6276
(%i2) pade (%, 1, 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);
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
6291
5853 x 2847 x 83787 x
6292
+ ------- + ------- - --------- + . . .
6293
4194304 8388608 134217728
6294
(%i4) pade (t, 4, 4);
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.
6303
(%i5) pade (t, 5, 5);
6305
(%o5) [- (520256329 x - 96719020632 x - 489651410240 x
6308
- 1619100813312 x - 2176885157888 x - 2386516803584)
6311
/(47041365435 x + 381702613848 x + 1360678489152 x
6314
+ 2856700692480 x + 3370143559680 x + 2386516803584)]
6317
-- Option variable: powerdisp
6318
Default value: `false'
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
6325
By default, terms of a sum are displayed in order of decreasing
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
6334
If `powerseries' is unable to expand <expr>, `taylor' may give the
6335
first several terms of the series.
6337
When `verbose' is `true', `powerseries' prints progress messages.
6339
(%i1) verbose: true$
6340
(%i2) powerseries (log(sin(x)/x), x, 0);
6343
so we'll try again after applying the rule:
6347
log(sin(x)) = i ----------- dx
6350
in the first simplification we have returned:
6353
i cot(x) dx - log(x)
6358
\ (- 1) 2 bern(2 i1) x
6359
> ------------------------------
6363
(%o2) -------------------------------------
6367
-- Option variable: psexpand
6368
Default value: `false'
6370
When `psexpand' is `true', an extended rational function
6371
expression is displayed fully expanded. The switch `ratexpand'
6372
has the same effect.
6374
When `psexpand' is `false', a multivariate expression is displayed
6375
just as in the rational function package.
6377
When `psexpand' is `multi', then terms with the same total degree
6378
in the variables are grouped together.
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>.
6389
`load ("revert")' loads these functions.
6393
(%i1) load ("revert")$
6394
(%i2) t: taylor (exp(x) - 1, x, 0, 6);
6397
(%o2)/T/ x + -- + -- + -- + --- + --- + . . .
6399
(%i3) revert (t, x);
6401
10 x - 12 x + 15 x - 20 x + 30 x - 60 x
6402
(%o3)/R/ - --------------------------------------------
6404
(%i4) ratexpand (%);
6407
(%o4) - -- + -- - -- + -- - -- + x
6409
(%i5) taylor (log(x+1), x, 0, 6);
6412
(%o5)/T/ x - -- + -- - -- + -- - -- + . . .
6414
(%i6) ratsimp (revert (t, x) - taylor (log(x+1), x, 0, 6));
6416
(%i7) revert2 (t, x, 4);
6419
(%o7) - -- + -- - -- + x
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>'.
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>
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>, ...)'.
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
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>, ....
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>'.
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.
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.
6468
See also the `taylor_logexpand' switch for controlling expansion.
6472
(%i1) taylor (sqrt (sin(x) + a*x + 1), x, 0, 3);
6474
(a + 1) x (a + 2 a + 1) x
6475
(%o1)/T/ 1 + --------- - -----------------
6479
(3 a + 9 a + 9 a - 1) x
6480
+ -------------------------- + . . .
6485
(%o2)/T/ 1 + (a + 1) x - -- + . . .
6487
(%i3) taylor (sqrt (x + 1), x, 0, 5);
6490
(%o3)/T/ 1 + - - -- + -- - ---- + ---- + . . .
6493
(%o4)/T/ 1 + x + . . .
6494
(%i5) product ((1 + x^i)^2.5, i, 1, inf)/(1 + x^2);
6501
(%o5) -----------------
6504
(%i6) ev (taylor(%, x, 0, 3), keepfloat);
6506
(%o6)/T/ 1 + 2.5 x + 3.375 x + 6.5625 x + . . .
6507
(%i7) taylor (1/log (x + 1), x, 0, 3);
6510
(%o7)/T/ - + - - -- + -- - ----- + . . .
6512
(%i8) taylor (cos(x) - sec(x), x, 0, 5);
6515
(%o8)/T/ - x - -- + . . .
6517
(%i9) taylor ((cos(x) - sec(x))^3, x, 0, 5);
6519
(%i10) taylor (1/(cos(x) - sec(x))^3, x, 0, 5);
6521
1 1 11 347 6767 x 15377 x
6522
(%o10)/T/ - -- + ---- + ------ - ----- - ------- - --------
6523
6 4 2 15120 604800 7983360
6527
(%i11) taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6);
6530
(%o11)/T/ 1 - ----- - ----------------
6534
(45 k - 60 k + 16 k ) x
6535
- -------------------------- + . . .
6537
(%i12) taylor ((x + 1)^n, x, 0, 4);
6539
(n - n) x (n - 3 n + 2 n) x
6540
(%o12)/T/ 1 + n x + ----------- + --------------------
6544
(n - 6 n + 11 n - 6 n) x
6545
+ ---------------------------- + . . .
6547
(%i13) taylor (sin (y + x), x, 0, 3, y, 0, 3);
6550
(%o13)/T/ y - -- + . . . + (1 - -- + . . .) x
6555
+ (- - + -- + . . .) x + (- - + -- + . . .) x + . . .
6557
(%i14) taylor (sin (y + x), [x, y], 0, 3);
6559
x + 3 y x + 3 y x + y
6560
(%o14)/T/ y + x - ------------------------- + . . .
6562
(%i15) taylor (1/sin (y + x), x, 0, 3, y, 0, 3);
6564
(%o15)/T/ - + - + . . . + (- -- + - + . . .) x + (-- + . . .) x
6569
+ (- -- + . . .) x + . . .
6572
(%i16) taylor (1/sin (y + x), [x, y], 0, 3);
6574
1 x + y 7 x + 21 y x + 21 y x + 7 y
6575
(%o16)/T/ ----- + ----- + ------------------------------- + . . .
6579
-- Option variable: taylordepth
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'.
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.
6592
`taylorinfo' returns `false' if <expr> is not a Taylor series.
6596
(%i1) taylor ((1 - y^2)/(1 - x), x, 0, 3, [y, a, inf]);
6598
(%o1)/T/ - (y - a) - 2 a (y - a) + (1 - a )
6601
+ (1 - a - 2 a (y - a) - (y - a) ) x
6604
+ (1 - a - 2 a (y - a) - (y - a) ) x
6607
+ (1 - a - 2 a (y - a) - (y - a) ) x + . . .
6608
(%i2) taylorinfo(%);
6609
(%o2) [[y, a, inf], [x, 0, 3]]
6612
-- Function: taylorp (<expr>)
6613
Returns `true' if <expr> is a Taylor series, and `false' otherwise.
6616
-- Option variable: taylor_logexpand
6617
Default value: `true'
6619
`taylor_logexpand' controls expansions of logarithms in `taylor'
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
6628
When `taylor_logexpand' is set to `false', then the only expansion
6629
of logarithms that occur is that necessary to obtain a formal
6633
-- Option variable: taylor_order_coefficients
6634
Default value: `true'
6636
`taylor_order_coefficients' controls the ordering of coefficients
6639
When `taylor_order_coefficients' is `true', coefficients of taylor
6640
series are ordered canonically.
6643
-- Function: taylor_simplifier (<expr>)
6644
Simplifies coefficients of the power series <expr>. `taylor'
6645
calls this function.
6648
-- Option variable: taylor_truncate_polynomials
6649
Default value: `true'
6651
When `taylor_truncate_polynomials' is `true', polynomials are
6652
truncated based upon the input truncation levels.
6654
Otherwise, polynomials input to `taylor' are considered to have
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.
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.
6671
(%i1) expr: x^2 + x + 1;
6676
(%o2) 1 + x + x + . . .
6677
(%i3) is (expr = trunc (expr));
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'.
6689
(%i1) g(p) := p*4^n/binomial(2*n,n);
6692
(%o1) g(p) := ----------------
6697
(%o2) ----------------
6699
(%i3) nusum (%, n, 0, 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
6707
(%o4) ----------------
6711
-- Option variable: verbose
6712
Default value: `false'
6714
When `verbose' is `true', `powerseries' prints progress messages.
6718
File: maxima.info, Node: Number Theory, Next: Symmetries, Prev: Series, Up: Top
6725
* Definitions for Number Theory::
6728
File: maxima.info, Node: Definitions for Number Theory, Prev: Number Theory, Up: Number Theory
6730
32.1 Definitions for Number Theory
6731
==================================
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'.
6739
(%i1) zerobern: true$
6740
(%i2) map (bern, [0, 1, 2, 3, 4, 5, 6, 7, 8]);
6742
(%o2) [1, - -, -, 0, - --, 0, --, 0, - --]
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
6751
-- Function: bernpoly (<x>, <n>)
6752
Returns the <n>'th Bernoulli polynomial in the variable <x>.
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.
6760
`load ("bffac")' loads this function.
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.
6768
The Hurwitz zeta function is defined as
6770
sum ((k+h)^-s, k, 0, inf)
6772
`load ("bffac")' loads this function.
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.
6783
(%i1) binomial (11, 7);
6785
(%i2) 11! / 7! / (11 - 7)!;
6787
(%i3) binomial (x, 7);
6788
(x - 6) (x - 5) (x - 4) (x - 3) (x - 2) (x - 1) x
6789
(%o3) -------------------------------------------------
6791
(%i4) binomial (x + 7, x);
6792
(x + 1) (x + 2) (x + 3) (x + 4) (x + 5) (x + 6) (x + 7)
6793
(%o4) -------------------------------------------------------
6795
(%i5) binomial (11, y);
6796
(%o5) binomial(11, y)
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.
6805
`burn' exploits the observation that (rational) Bernoulli numbers
6806
can be approximated by (transcendental) zetas with tolerable
6809
`load ("bffac")' loads this function.
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
6821
`cf' evaluates its arguments after binding `listarith' to `false'.
6822
`cf' returns a continued fraction, represented as a list.
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.
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.
6835
See also `cfdisrep', `cfexpand', and `cflength'.
6839
* <expr> is an expression comprising continued fractions and
6840
square roots of integers.
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]
6847
* `cflength' controls how many periods of the continued fraction
6848
are computed for algebraic, irrational numbers.
6851
(%i2) cf ((1 + sqrt(5))/2);
6852
(%o2) [1, 1, 1, 1, 2]
6854
(%i4) cf ((1 + sqrt(5))/2);
6855
(%o4) [1, 1, 1, 1, 1, 1, 1, 2]
6857
(%i6) cf ((1 + sqrt(5))/2);
6858
(%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
6860
* A continued fraction can be evaluated by evaluating the
6861
arithmetic representation returned by `cfdisrep'.
6864
(%i2) cfdisrep (cf (sqrt (3)))$
6865
(%i3) ev (%, numer);
6866
(%o3) 1.731707317073171
6868
* Maxima does not know about operations on continued fractions
6871
(%i1) cf ([1,1,1,1,1,2] * 3);
6873
(%i2) cf ([1,1,1,1,1,2]) * 3;
6874
(%o2) [3, 3, 3, 3, 3, 6]
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, ...]'.
6882
(%i1) cf ([1, 2, -3] + [1, -2, 1]);
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>.
6899
(%i1) cf (rat (ev (%pi, numer)));
6901
`rat' replaced 3.141592653589793 by 103993//33102 = 3.141592653011902
6902
(%o1) [3, 7, 15, 1, 292]
6907
(%i3) %[1,1]/%[2,1], numer;
6908
(%o3) 3.141592653011902
6911
-- Option variable: cflength
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.
6919
(%i2) cf ((1 + sqrt(5))/2);
6920
(%o2) [1, 1, 1, 1, 2]
6922
(%i4) cf ((1 + sqrt(5))/2);
6923
(%o4) [1, 1, 1, 1, 1, 1, 1, 2]
6925
(%i6) cf ((1 + sqrt(5))/2);
6926
(%o6) [1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2]
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.
6934
`divsum (<n>)' returns the sum of the divisors of <n>.
6938
(%i2) 1 + 2 + 3 + 4 + 6 + 12;
6940
(%i3) divsum (12, 2);
6942
(%i4) 1^2 + 2^2 + 3^2 + 4^2 + 6^2 + 12^2;
6946
-- Function: euler (<n>)
6947
Returns the <n>'th Euler number for nonnegative integer <n>.
6949
For the Euler-Mascheroni constant, see `%gamma'.
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]
6956
The Euler-Mascheroni constant, 0.5772156649015329 ....
6959
-- Function: factorial (<x>)
6960
Represents the factorial function. Maxima treats `factorial (<x>)'
6961
the same as `<x>!'. See `!'.
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) *
6969
After calling `fib', `prevfib' is equal to `fib (<x> - 1)', the
6970
Fibonacci number preceding the last one computed.
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]
6976
-- Function: fibtophi (<expr>)
6977
Expresses Fibonacci numbers in terms of the constant `%phi', which
6978
is `(1 + sqrt(5))/2', approximately 1.61803399.
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'.
6984
(%i1) fibtophi (fib (n));
6987
(%o1) -------------------
6989
(%i2) fib (n-1) + fib (n) - fib (n+1);
6990
(%o2) - fib(n + 1) + fib(n) + fib(n - 1)
6991
(%i3) ratsimp (fibtophi (%));
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]]'.
7000
Factorization methods used are trial divisions by primes up to
7001
9973, Pollard's rho method and elliptic curve method.
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
7009
-- Function: inrt (<x>, <n>)
7010
Returns the integer <n>'th root of the absolute value of <x>.
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]
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>.
7021
(%i1) inv_mod(3, 41);
7023
(%i2) ratsimp(3^-1), modulus=41;
7025
(%i3) inv_mod(3, 42);
7029
-- Function: jacobi (<p>, <q>)
7030
Returns the Jacobi symbol of <p> and <q>.
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]
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.
7041
`load ("functs")' loads this function.
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
7053
(%i2) minfactorial (%);
7055
(%o2) ---------------
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.
7064
(%i1) power_mod(3, 15, 5);
7068
(%i3) power_mod(2, -1, 5);
7074
-- Function: next_prime (<n>)
7075
Returns the smallest prime bigger than <n>.
7077
(%i1) next_prime(27);
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.
7090
(%i1) 1/(1+x)^2 - 2/(1+x) + 2/(2+x);
7092
(%o1) ----- - ----- + --------
7097
(%o2) - -------------------
7100
(%i3) partfrac (%, x);
7102
(%o3) ----- - ----- + --------
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.
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.
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.
7123
-- Option variable: primep_number_of_tests
7126
Number of Miller-Rabin's tests used in `primep'.
7128
-- Function: prev_prime (<n>)
7129
Returns the greatest prime smaller than <n>.
7131
(%i1) prev_prime(27);
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
7142
(%i2) expand (% * (sqrt(17) - 4));
7146
-- Function: totient (<n>)
7147
Returns the number of integers less than or equal to <n> which are
7148
relatively prime to <n>.
7151
-- Option variable: zerobern
7152
Default value: `true'
7154
When `zerobern' is `false', `bern' excludes the Bernoulli numbers
7155
which are equal to zero. See `bern'.
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.
7164
See also `bfzeta' and `zeta%pi'.
7166
(%i1) map (zeta, [-4, -3, -2, -1, 0, 1, 2, 3, 4, 5]);
7169
(%o1) [0, ---, 0, - --, - -, inf, ----, zeta(3), ----, zeta(5)]
7173
-- Option variable: zeta%pi
7174
Default value: `true'
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'.
7180
(%i1) zeta%pi: true$
7186
(%i3) zeta%pi: false$
7192
File: maxima.info, Node: Symmetries, Next: Groups, Prev: Number Theory, Up: Top
7199
* Definitions for Symmetries::