Maxima - Tips & Tricks, or we collect bit by bit info how to work on it
Human memory is a mystery to me. Being the owner of a weak memory since childhood, I always forget about some of the nuances of the world around me. However, this data should be at hand. And when notepad is not enough, text files come to the rescue. One of these files contains a small assembly of everyday and everyday Maxima commands .
I think that all of us know this system of computer algebra. She is not a competitor to Wolfram Mathematica, but it has exactly the functionality that I require from mathematical software. To put it simpler and more accessible, you can count on everything, from sticks to supercomputers, and by no means always the tasks of engineering practice are completely transferred from paper to program code. One example, which I honestly barely found, is the forgotten craft of our conversion production - an all-metal household vacuum civil thermos, which was previously produced in the Urals in the USSR. In order to establish its production, the institute in which I study, de facto manually calculated on calculating machines all the necessary parameters of the working equipment. Therefore, the Mathematica license is not an indicator or qualification of practicality. I can count, I repeat, on everything.
From words to deeds. Below are categorized those moments in the Maxima documentation that are desirable for a novice user of this SKA.
** or ^ - exponentiation;
% Is the last output cell;
_ Is the last input cell;
% th (n) - returns the nth output cell from the end;
$ - jamming the output of the result;
kill (all) - clear the session;
describe (name) or? name - help for specific words;
example (name) - usage example;
demo () - executes programs from the demo files supplied with the system;
'expression - prevents the evaluation of the expression;
'' expression - analogue ev (forced expression evaluation);
num (%) - fraction numerator;
denom (%) - denominator of the fraction;
coeff (n, x, 3) - returns the coefficient of a variable to a given degree;
depends ([m, y], [x, z]) - sets the dependence of m (x, z) and y (x, z);
second (y = 14) - will extract 14;
subst - substitution of one expression into another;
changevar (%, x - 3 - y, y, x); - replacement of variables in the expression;
%, y = x-3 - reverse substitution;
float (%) - convert to real form;
nouns (%) - reveals generally all imperfect forms - including derivatives including;
eval - on the contrary, it additionally conducts another calculation process. expressions may also include some characters, which may also have their own meanings; and such a chain of “nested values” can continue arbitrarily deeply. One call to the ev function (without the eval option) descends along this chain one level in depth: noeval blocks the calculation stage itself; those. it can be used to apply other options of the ev function to the expression without recalculating it;
lhs (eq) - rhs (eq) - the left and right parts of some expression;
eliminate ([x + y + z = 1, x + y = 2, x + z = 3], [z]) - exclude a variable or several variables from the system of equations, that is, reduce the dimension of the system;
gcd (420.1176) - GCD;
mod (x, y) - the remainder of dividing x by y with the sign x;
signum (x) - will return +1 if x> 0, -1 if x <0;
max / min;
log (x) - NATURAL logarithm ("ln (x)");
floor (4.445) - rounding down;
ceiling (4.445) - rounding up;
listofvars (%) turns the original expression into a list of the variables it contains;
numer: true (or numeric: true) - calculations only with a floating point, and not with rational numbers;
bindtest - prohibits the use of a symbol in expressions until it is assigned a value;
batch () loads the Maxima file with the extension .mac or .mc (from the original name of the program - Macsyma) and executes the expressions contained in it.
batchload (), loads the batch file “silently”: all functions and variables assigned in it become available, but the results are not visible, and all the stored I / O, including the values of% and _ characters and the results returned by% th (), remain the same as before the call.
file_search_maxima - a variable containing directories of user files and files of SKA itself;
~ / .maxima - standard system catalog;
file_search_lisp and file_search_demo - functions for finding the corresponding files;
load () - a wrapper over two file upload functions, just shorter;
loadfile () - downloads the Lisp source file (paired to save ());
stringout () - unloads any expressions and Maxima functions to a file;
declare () - add a fact to the fact base;
facts (name) or facts () - find out the current state of the database;
remove () - remove properties from the database;
assume () - takes as arguments any quantity of the most common equalities and inequalities in a logical form, that is, not “a = b”, “a # b”, but “equal (a, b)”, “not equal (a , b). ” Of the logical operators, the use of and is also allowed (in essence, assume (x> 0 and x <1) is the same as assume (x> 0, x <1)), but not or - the fact base does not support information of the form “ or"; and it’s not about syntax, but rather about constructions, that is, expressions like not (a> b and a
diff (expression) - finds the total differential of the expression, which is the sum of all partial derivatives with respect to the variables of the expression;
diff (expression, variable) - finds the partial derivative of the first order;
diff (expression, variable, N) - finds the partial derivative of the Nth order;
diff (expression, x_1, N_1, x_2, N_2, ...) - finds the sum of the partial derivatives;
derivlist (x, y, ..., v) - derivatives with respect to the variables specified as arguments, as well as full differentials (since they do not depend on any variables);
integrate (%, x) - integration;
romberg (cos (sin (x + 1)), x, 0, 1) - numerical integration by the Romberg method;
limit ((x ^ 2 - 1) / (x ^ 2 + 1), x, inf) - calculation of limits;
limit ((x ^ 2 - 1) / (x ^ 2 + 1), x, minf);
limit (tan (x), x,% pi / 2, plus) - limit on the right;
limit (tan (x), x,% pi / 2, minus) - on the left;
tlimit (...) - an attempt to find the limit with the tlimswitch flag raised (see below);
sum (i, i, 1, 100) - the sum of the series;
product - product of a series (syntax similar to sum);
sum (1 / x ^ 2, x, 1, inf), simpsum = true; - to perform the summation, you need to specify the option "simpsum = true";
sumcontract (sum1 + sum2) - sum reduction;
taylor (sin (x), x, 0, 8) - rows;
niceindices (powerseries (sin (x), x, 0)) - series with simplification;
simp: false - disable forced simplification "on the fly";
ratdenomdivide - by default, the system variable is set to true. In this case, each fraction in which the numerator is the sum is decomposed into the sum of fractions with the same denominator. If you set this option to false, then all fractions with the same denominator will be combined into one fraction with the numerator as the sum of the numerators of the initial fractions;
expand () - expand brackets, simplify;
distrib () - expand (), but only one level in depth;
combine () - a function that collects fractions with the same denominators;
trigsimp (%) - trigonometric simplifications through the basic trigonometric identity;
trigrat (%) - similarly, stronger;
trigreduce (%) - convert trigonometric expressions to canonical finite trigonometric series (Fourier sums) [converts a trigonometric expression as a sum of terms, each of which contains one sine or cosine];
trigexpand (%) - “reveals” the arguments of trigonometric functions, according to the rules of trigonometric functions of the sum of angles;
partfrac (%) - decomposition into simple fractions;
ratsimp (%) - quickly simplify the amount of rational expressions;
fullratsimp (expression) - sequentially applies the ratsimp function to the expression, as well as some irrational transformations, and repeats these actions in a loop until the expression stops changing during the conversion (slower, but gives a more reliable result);
ratexpand (%) - leads fractions to a common denominator;
radcan (%) - “reduce” exponentials with logarithms, passing to the canonical radical [simplification of exponential, logarithmic, and power (with rational degrees) functions];
factor - minimizes the expression in brackets;
factorsum () - if the polynomial cannot be represented as the product of several factors, it can be tried to convert it into the sum of such products;
0. Also there are such functions as: atensimp, foursimp, fullratsimp, logarc, rootscontract, scsimp, simplify_sum, vectorsimp.
1. After ratexpand () in both the numerator and denominator of the fraction, all brackets will be expanded, in the case of rat (), the terms where, for example, two variables are present, will be grouped, and one of them will be put out of brackets.
2. expand expands the brackets at all levels of nesting, and ratexpand expands the rational expression of only the first level, while subexpressions that are not rational are not processed;
3. ratexpand leads the fraction terms to a common denominator, and expand does not;
4. Expand is not affected by the system option ratdenomdivide;
5. expand does not convert the final decimal notation to rational numbers, regardless of the value of the keepfloat system option.
6. maxposex and maxnegex - variables that control the expansion of raising to an integer - the maximum positive and negative exponents that will be expanded by this expand function (Default 1000), you can reassign directly in the expand () function;
7. expop and expon - variables that specify the maximum positive and negative degrees that will be opened automatically without calling the functions of the expand group (by default 0, that is, the degrees are not automatically opened at all);
8. Flag - halfangles - controls the disclosure of half-angle formulas;
Two flags - trigexpandplus and trigexpandtimes - are respectively responsible for applying the formulas for the sums of angles and multiple angles (set by default);
9. Flags trigsign and triginverses - the first takes the traditional two values (the default is true) and regulates the removal of the character outside the trigonometric function. The triginverses flag is three-digit, and its default value is all. He is responsible for handling combinations of the form sin (asin (x)) or atan (tan (x)). The value of all allows you to reveal these combinations in both directions (I recall that at the same time some of the roots will be lost); a value of true leaves only the expansion of the form sin (asin (x)) permitted, that is, it blocks the variant with loss of periodic values; and the case false prohibits both directions of transformations;
10. Flag tlimswitch. By default, it is also turned off, and if you enable it, the limit function will, if it is impossible to find the limit in other ways, try to find it by expanding the sublimit function in a Taylor series in the vicinity of a given point;
11. The only flag directly related to the diff function itself is the derivabbrev flag, which affects the display of derivatives in Maxima output cells. By default, it is false, and derivatives are indicated as fractions with the letter d; if it is set to true, derivatives will be displayed in an abbreviated form, with differentiation variables recorded as indices.
12. solveradcan - the flag is false by default, and setting this flag to true will force solve to use radcan, which in some cases can help solve problems that without this key will make it impossible to find the exact solution.
A: matrix ([1,2], [3,4]);
Matrix determinant. Function determinant (matrix).
Transpose matrix. Function transpose (matrix).
Inverse matrix calculation. Function invert (matrix).
Construction of the characteristic polynomial of a matrix. Charpoly function (matrix, var).
Addition of matrices (sign "+"). Memberwise adds up all the elements of two matrices.
Subtraction (“-” sign). It is exactly the same as addition, but matrix elements are subtracted.
Matrix division (“/” sign). Division is slightly different from addition, each element of one matrix is divided by the corresponding element of another matrix.
Multiplication of matrices term by term (“*” sign). This operator works the same as addition: the elements of the first matrix are multiplied by the corresponding elements of the second matrix. This is not the matrix multiplication that is usually implied in a course in linear algebra!
Matrix multiplication (“.” Sign, period).
addcol (V1, [9,10]) - add a column to the matrix;
addrow (V1, [9,10]) - add a row to the matrix;
V1: submatrix (V1, 6,7) - remove the 6th and 7th columns from the matrix V1;
submatrix (the starting number of the deleted row, the ending number of the deleted row;
Matrix name ;) - reducing the number of rows;
M [j, i] - access to a specific element of the array M;
zeromatrix (m, n) - creation of a zero matrix of dimension m * n;
ident (n) - creation of a unit square matrix;
diagmatrix (n, x) - creating a diagonal square matrix of dimension n * n;
transpose (M) - transpose of the matrix M;
matrix_size (M) - determination of the number of columns and rows of the matrix;
rank (M) - determination of the rank of the matrix;
mattrace (M) - definition of the trace (the sum of the diagonal elements) of the square matrix (* the application is preceded by loading the package for working with matrices: load ("nchrpl"));
determinant (M) - calculation of the determinant (determinant) of a square matrix;
invert (M) - calculation of the matrix inverse to M.
1)
ode2 (equation, function, variable). The function is usually y, and the variable is x;
In addition to solving the differential equation in general form, it is possible to solve equations with initial conditions (a boundary value problem). To do this, it is necessary to solve the equation in general form using the functionode2, and then use one of the functions for finding the initial conditions:
ic1 (solution, point x, value y at point x) —for solving differential equations of the first order with the initial condition;
ic2 (solution, point x, value of y at point x, value of y 'at point x) - for solving differential equations of the second order with the initial condition;
bc2 (solution, point x1, value of y at point x1, point of x2, value of y at point x2) - for solving differential equations of the second order with initial conditions in the form of two points;
2)
desolve (differential equation, variable);
If a system of differential equations is being solved or there are several variables, then the equation and / or variables are presented in the form of a list:
desolve ([list of equations], [variable1, variable2, ...]);
As for the previous version, to denote derivatives in differential equations, the diff function is used, which has the form 'diff (f (x), x);
atvalue (function, variable = point, value at point) - initial values.
plot2d (sin (x), [x, 0.6]);
plot2d (sin (x), [x, 0,1], [y, 0,1]);
plot2d ([parametric, realpart (W (% i * t)), imagpart (W (% i * t))], [t, 0,100], [nticks, 1000]) $
Parametric graphs are constructed as follows:
[parametric, x (t), y (t)]. Therefore, from the above formula, parametric functions were substituted. Further, [t, 0,100] is the range of points in which to draw the hodograph. Here, each turns out differently, it is clear that the curve goes either to 0 or to infinity, the main thing here is not to overdo it. It is recommended to play around with a range of t values to determine where and where the curve is moving. This example originates at the point [-1, 0] and tends to [0, 0]. [nticks, 1000] - this parameter sets the number of points for interpolating the graph. The more of them, the smoother the chart will look and the more time it will take to build it.
Graphs in polar coordinates - the draw2d function is used with the following arguments:
user_preamble = "set grid polar", // construction in polar coordinates;
nticks = n, // n is the number of points;
xrange = [dx1, dx2], // range of variation x;
yrange = [dy1, dy2], // range of variation y;
color = red, // color;
line_width = k, // width of the line with which the chart is built;
title = “general name of the chart”,
polar (function, variable, lower_boundary_of_variable, upper_variable_variable) // function for plotting;
The first and last arguments to the function are required. The first initiates the construction of the graph in polar coordinates, the last (polar) is the function by which the graph is built.
plot3d ((((x - 10) / 5) * ((y - 10) / 5), [x, 0.20], [y, 0.20]) - three-dimensional (3D) graphics;
Editing three-dimensional graphics is carried out in the same way as two-dimensional.
A three-dimensional surface can be replaced by a gradient color transition. To do this, use the "set view map" option.
for, while, until etc.
Examples:
for i in s do
for k: 1 thru b: 3 do
for variable: beginning step step thru end do expression
for variable: beginning step step while condition do expression
for variable: beginning step step unless condition do expression
Function definition:
f1 (x, y): = x + y;
_- ============================== -_
########## OTHER ###### #######
. =================================.
The Russian designation is in Maxima:
arccos - acos
arcsin - asin
arctg - atan
ch - cosh
sh - sinh
ctg - cot
ln - log
tg - tan
Symbols of the Greek alphabet:
Gamma; Theta Psi etc.
Data processing:
1)
load (descriptive) $ / * load extension * /
a: [1,2,3,4];
mean (a); / * = 5/2 average * /
var (a); / * = 5/4 variance * /
std (a); / * =? 5/2 standard deviation * /
mean (arithmetic mean);
median
variance (variance);
deviation (standard deviation);
2)
a: [1.0,2.0,3.0,4.0];
for i in a do ldisp (sin (i) / i);
Calculation of derivatives with respect to all variables included in the expression:
eq: x * l / k; / * source expression * /
res: 0 $ for i in listofvars (eq) do res: res + (diff (eq, i) * concat ("d", (i))) ^ 2 $
For greater accuracy, there is a special function bfloat () (big float, big float), as well as the ffprec variable - for the number of decimal places. That is, to increase / decrease accuracy, you need to assign a different numerical value to the fpprec variable and use the bfloat () function instead of float (). The numer variable needs to be false.
By default, Maxima works in the ISS system: meter-kilogram-second:
2 * m;
2 * cm;
setunits ([centigram, inch, minute]) - the arguments of which are the three basic units of measurement: weight, length and time;
setunits ([kg, m, s]);
convert (inch, [sm]); - translation of units of measure;
stringout ("/ Users / myusername / file1maxima.mc", INPUT);
To save all your work as a "tape" that can be replayed later, all your input can be saved to a file.
batch ("/ Users / myusername / file1maxima.mc");
Loading the saved file: the saved file can also be loaded directly, although the exact numbering of lines will change from the original calculation.
SIMPSUM: TRUE;
sum (k, k, 1, n), simpsum;
=> \ displaystyle {{n ^ 2 + n} \ over {2}}
product (1 / (n ^ 2), n, 1,10); Products work in much the same way.
niceindices (powerseries (% e ^ x, x, 0));
=> \ displaystyle \ sum_ {i = 0} ^ {\ infty} {{{x ^ {i}} \ over {i!}}}
taylor (% e ^ x, x, 0, 5);
=> \ displaystyle 1 + x + {{x ^ 2} \ over {2}} + {{x ^ 3} \ over {6}} + {{x ^ 4} \ over {24}} + {{x ^ 5} \ over {120}} + \ cdots
trunc (%); Since the output of taylor has special properties, we need to convert it into a polynomial.
load ("newton");
=> / sw / share / maxima / 5.9.0rc3 / share / numeric / newton.mac
newton (x ^ 7-5 * x ^ 6 + 4 * x ^ 4-5 * x ^ 2 + x + 2.1) ;
=> 8.194213634964119B-1
tex (%) - convert the expression to the form TeX;
$$ \ left (x + 1 \ right) ^ 2 $$
Convert TeX to PDF:
1. Paste the following five lines verbatim into the text editor:
\ documentclass {article}
\ pagestyle {empty}
\ begin {document}
\ huge
\ end {document}
2. Copy the tex () output line, and paste it between the \ huge and \ end {document} lines.
3. Save the result in text format as: myoutput.txt
4. In the terminal window, navigate to the directory where you saved myoutput.txt
5. type:
pdflatex myoutput.txt
6. Hit return - a PDF file called myoutput.pdf containing your typeset equation will now be created in this directory.
load (to_poly_solve); - additional procedures for solving systems of algebraic equations;
to_poly_solve ([3 * z1 + z2 + 2 = 0, sqrt (z1) = z2], [z1, z2]);
sol: rk ([rk1, rk2, gamma, w], [gamma, w, fi, tetta], [0,% pi / 8,% pi / 2, 0], [t, 0, Tmax with_stdout ("gamma .txt ", for k: 1 thru points do print (sol [k] [1], sol [k] [2])) is an example of entering data from a file.
Now let's look at a typical example of using Maxima in student life. interestingly this process was shown in an article on Habréearlier. I, in turn, will only rotate the coordinate axes in one equation:
Result:
2 * uen * cos (2 * x) -2 * uen
I think that all of us know this system of computer algebra. She is not a competitor to Wolfram Mathematica, but it has exactly the functionality that I require from mathematical software. To put it simpler and more accessible, you can count on everything, from sticks to supercomputers, and by no means always the tasks of engineering practice are completely transferred from paper to program code. One example, which I honestly barely found, is the forgotten craft of our conversion production - an all-metal household vacuum civil thermos, which was previously produced in the Urals in the USSR. In order to establish its production, the institute in which I study, de facto manually calculated on calculating machines all the necessary parameters of the working equipment. Therefore, the Mathematica license is not an indicator or qualification of practicality. I can count, I repeat, on everything.
From words to deeds. Below are categorized those moments in the Maxima documentation that are desirable for a novice user of this SKA.
General functionality
** or ^ - exponentiation;
% Is the last output cell;
_ Is the last input cell;
% th (n) - returns the nth output cell from the end;
$ - jamming the output of the result;
kill (all) - clear the session;
describe (name) or? name - help for specific words;
example (name) - usage example;
demo () - executes programs from the demo files supplied with the system;
'expression - prevents the evaluation of the expression;
'' expression - analogue ev (forced expression evaluation);
num (%) - fraction numerator;
denom (%) - denominator of the fraction;
coeff (n, x, 3) - returns the coefficient of a variable to a given degree;
depends ([m, y], [x, z]) - sets the dependence of m (x, z) and y (x, z);
second (y = 14) - will extract 14;
subst - substitution of one expression into another;
changevar (%, x - 3 - y, y, x); - replacement of variables in the expression;
%, y = x-3 - reverse substitution;
float (%) - convert to real form;
nouns (%) - reveals generally all imperfect forms - including derivatives including;
eval - on the contrary, it additionally conducts another calculation process. expressions may also include some characters, which may also have their own meanings; and such a chain of “nested values” can continue arbitrarily deeply. One call to the ev function (without the eval option) descends along this chain one level in depth: noeval blocks the calculation stage itself; those. it can be used to apply other options of the ev function to the expression without recalculating it;
lhs (eq) - rhs (eq) - the left and right parts of some expression;
eliminate ([x + y + z = 1, x + y = 2, x + z = 3], [z]) - exclude a variable or several variables from the system of equations, that is, reduce the dimension of the system;
gcd (420.1176) - GCD;
mod (x, y) - the remainder of dividing x by y with the sign x;
signum (x) - will return +1 if x> 0, -1 if x <0;
max / min;
log (x) - NATURAL logarithm ("ln (x)");
floor (4.445) - rounding down;
ceiling (4.445) - rounding up;
listofvars (%) turns the original expression into a list of the variables it contains;
numer: true (or numeric: true) - calculations only with a floating point, and not with rational numbers;
bindtest - prohibits the use of a symbol in expressions until it is assigned a value;
batch () loads the Maxima file with the extension .mac or .mc (from the original name of the program - Macsyma) and executes the expressions contained in it.
batchload (), loads the batch file “silently”: all functions and variables assigned in it become available, but the results are not visible, and all the stored I / O, including the values of% and _ characters and the results returned by% th (), remain the same as before the call.
file_search_maxima - a variable containing directories of user files and files of SKA itself;
~ / .maxima - standard system catalog;
file_search_lisp and file_search_demo - functions for finding the corresponding files;
load () - a wrapper over two file upload functions, just shorter;
loadfile () - downloads the Lisp source file (paired to save ());
stringout () - unloads any expressions and Maxima functions to a file;
declare () - add a fact to the fact base;
facts (name) or facts () - find out the current state of the database;
remove () - remove properties from the database;
assume () - takes as arguments any quantity of the most common equalities and inequalities in a logical form, that is, not “a = b”, “a # b”, but “equal (a, b)”, “not equal (a , b). ” Of the logical operators, the use of and is also allowed (in essence, assume (x> 0 and x <1) is the same as assume (x> 0, x <1)), but not or - the fact base does not support information of the form “ or"; and it’s not about syntax, but rather about constructions, that is, expressions like not (a> b and a
Derivatives, limits, rows ...
diff (expression) - finds the total differential of the expression, which is the sum of all partial derivatives with respect to the variables of the expression;
diff (expression, variable) - finds the partial derivative of the first order;
diff (expression, variable, N) - finds the partial derivative of the Nth order;
diff (expression, x_1, N_1, x_2, N_2, ...) - finds the sum of the partial derivatives;
derivlist (x, y, ..., v) - derivatives with respect to the variables specified as arguments, as well as full differentials (since they do not depend on any variables);
integrate (%, x) - integration;
romberg (cos (sin (x + 1)), x, 0, 1) - numerical integration by the Romberg method;
limit ((x ^ 2 - 1) / (x ^ 2 + 1), x, inf) - calculation of limits;
limit ((x ^ 2 - 1) / (x ^ 2 + 1), x, minf);
limit (tan (x), x,% pi / 2, plus) - limit on the right;
limit (tan (x), x,% pi / 2, minus) - on the left;
tlimit (...) - an attempt to find the limit with the tlimswitch flag raised (see below);
sum (i, i, 1, 100) - the sum of the series;
product - product of a series (syntax similar to sum);
sum (1 / x ^ 2, x, 1, inf), simpsum = true; - to perform the summation, you need to specify the option "simpsum = true";
sumcontract (sum1 + sum2) - sum reduction;
taylor (sin (x), x, 0, 8) - rows;
niceindices (powerseries (sin (x), x, 0)) - series with simplification;
Simplification
simp: false - disable forced simplification "on the fly";
ratdenomdivide - by default, the system variable is set to true. In this case, each fraction in which the numerator is the sum is decomposed into the sum of fractions with the same denominator. If you set this option to false, then all fractions with the same denominator will be combined into one fraction with the numerator as the sum of the numerators of the initial fractions;
expand () - expand brackets, simplify;
distrib () - expand (), but only one level in depth;
combine () - a function that collects fractions with the same denominators;
trigsimp (%) - trigonometric simplifications through the basic trigonometric identity;
trigrat (%) - similarly, stronger;
trigreduce (%) - convert trigonometric expressions to canonical finite trigonometric series (Fourier sums) [converts a trigonometric expression as a sum of terms, each of which contains one sine or cosine];
trigexpand (%) - “reveals” the arguments of trigonometric functions, according to the rules of trigonometric functions of the sum of angles;
partfrac (%) - decomposition into simple fractions;
ratsimp (%) - quickly simplify the amount of rational expressions;
fullratsimp (expression) - sequentially applies the ratsimp function to the expression, as well as some irrational transformations, and repeats these actions in a loop until the expression stops changing during the conversion (slower, but gives a more reliable result);
ratexpand (%) - leads fractions to a common denominator;
radcan (%) - “reduce” exponentials with logarithms, passing to the canonical radical [simplification of exponential, logarithmic, and power (with rational degrees) functions];
factor - minimizes the expression in brackets;
factorsum () - if the polynomial cannot be represented as the product of several factors, it can be tried to convert it into the sum of such products;
0. Also there are such functions as: atensimp, foursimp, fullratsimp, logarc, rootscontract, scsimp, simplify_sum, vectorsimp.
1. After ratexpand () in both the numerator and denominator of the fraction, all brackets will be expanded, in the case of rat (), the terms where, for example, two variables are present, will be grouped, and one of them will be put out of brackets.
2. expand expands the brackets at all levels of nesting, and ratexpand expands the rational expression of only the first level, while subexpressions that are not rational are not processed;
3. ratexpand leads the fraction terms to a common denominator, and expand does not;
4. Expand is not affected by the system option ratdenomdivide;
5. expand does not convert the final decimal notation to rational numbers, regardless of the value of the keepfloat system option.
6. maxposex and maxnegex - variables that control the expansion of raising to an integer - the maximum positive and negative exponents that will be expanded by this expand function (Default 1000), you can reassign directly in the expand () function;
7. expop and expon - variables that specify the maximum positive and negative degrees that will be opened automatically without calling the functions of the expand group (by default 0, that is, the degrees are not automatically opened at all);
8. Flag - halfangles - controls the disclosure of half-angle formulas;
Two flags - trigexpandplus and trigexpandtimes - are respectively responsible for applying the formulas for the sums of angles and multiple angles (set by default);
9. Flags trigsign and triginverses - the first takes the traditional two values (the default is true) and regulates the removal of the character outside the trigonometric function. The triginverses flag is three-digit, and its default value is all. He is responsible for handling combinations of the form sin (asin (x)) or atan (tan (x)). The value of all allows you to reveal these combinations in both directions (I recall that at the same time some of the roots will be lost); a value of true leaves only the expansion of the form sin (asin (x)) permitted, that is, it blocks the variant with loss of periodic values; and the case false prohibits both directions of transformations;
10. Flag tlimswitch. By default, it is also turned off, and if you enable it, the limit function will, if it is impossible to find the limit in other ways, try to find it by expanding the sublimit function in a Taylor series in the vicinity of a given point;
11. The only flag directly related to the diff function itself is the derivabbrev flag, which affects the display of derivatives in Maxima output cells. By default, it is false, and derivatives are indicated as fractions with the letter d; if it is set to true, derivatives will be displayed in an abbreviated form, with differentiation variables recorded as indices.
12. solveradcan - the flag is false by default, and setting this flag to true will force solve to use radcan, which in some cases can help solve problems that without this key will make it impossible to find the exact solution.
Matrices
A: matrix ([1,2], [3,4]);
Matrix determinant. Function determinant (matrix).
Transpose matrix. Function transpose (matrix).
Inverse matrix calculation. Function invert (matrix).
Construction of the characteristic polynomial of a matrix. Charpoly function (matrix, var).
Addition of matrices (sign "+"). Memberwise adds up all the elements of two matrices.
Subtraction (“-” sign). It is exactly the same as addition, but matrix elements are subtracted.
Matrix division (“/” sign). Division is slightly different from addition, each element of one matrix is divided by the corresponding element of another matrix.
Multiplication of matrices term by term (“*” sign). This operator works the same as addition: the elements of the first matrix are multiplied by the corresponding elements of the second matrix. This is not the matrix multiplication that is usually implied in a course in linear algebra!
Matrix multiplication (“.” Sign, period).
addcol (V1, [9,10]) - add a column to the matrix;
addrow (V1, [9,10]) - add a row to the matrix;
V1: submatrix (V1, 6,7) - remove the 6th and 7th columns from the matrix V1;
submatrix (the starting number of the deleted row, the ending number of the deleted row;
Matrix name ;) - reducing the number of rows;
M [j, i] - access to a specific element of the array M;
zeromatrix (m, n) - creation of a zero matrix of dimension m * n;
ident (n) - creation of a unit square matrix;
diagmatrix (n, x) - creating a diagonal square matrix of dimension n * n;
transpose (M) - transpose of the matrix M;
matrix_size (M) - determination of the number of columns and rows of the matrix;
rank (M) - determination of the rank of the matrix;
mattrace (M) - definition of the trace (the sum of the diagonal elements) of the square matrix (* the application is preceded by loading the package for working with matrices: load ("nchrpl"));
determinant (M) - calculation of the determinant (determinant) of a square matrix;
invert (M) - calculation of the matrix inverse to M.
Ordinary Differential Equations
1)
ode2 (equation, function, variable). The function is usually y, and the variable is x;
In addition to solving the differential equation in general form, it is possible to solve equations with initial conditions (a boundary value problem). To do this, it is necessary to solve the equation in general form using the functionode2, and then use one of the functions for finding the initial conditions:
ic1 (solution, point x, value y at point x) —for solving differential equations of the first order with the initial condition;
ic2 (solution, point x, value of y at point x, value of y 'at point x) - for solving differential equations of the second order with the initial condition;
bc2 (solution, point x1, value of y at point x1, point of x2, value of y at point x2) - for solving differential equations of the second order with initial conditions in the form of two points;
2)
desolve (differential equation, variable);
If a system of differential equations is being solved or there are several variables, then the equation and / or variables are presented in the form of a list:
desolve ([list of equations], [variable1, variable2, ...]);
As for the previous version, to denote derivatives in differential equations, the diff function is used, which has the form 'diff (f (x), x);
atvalue (function, variable = point, value at point) - initial values.
Graphs
plot2d (sin (x), [x, 0.6]);
plot2d (sin (x), [x, 0,1], [y, 0,1]);
plot2d ([parametric, realpart (W (% i * t)), imagpart (W (% i * t))], [t, 0,100], [nticks, 1000]) $
Parametric graphs are constructed as follows:
[parametric, x (t), y (t)]. Therefore, from the above formula, parametric functions were substituted. Further, [t, 0,100] is the range of points in which to draw the hodograph. Here, each turns out differently, it is clear that the curve goes either to 0 or to infinity, the main thing here is not to overdo it. It is recommended to play around with a range of t values to determine where and where the curve is moving. This example originates at the point [-1, 0] and tends to [0, 0]. [nticks, 1000] - this parameter sets the number of points for interpolating the graph. The more of them, the smoother the chart will look and the more time it will take to build it.
Graphs in polar coordinates - the draw2d function is used with the following arguments:
user_preamble = "set grid polar", // construction in polar coordinates;
nticks = n, // n is the number of points;
xrange = [dx1, dx2], // range of variation x;
yrange = [dy1, dy2], // range of variation y;
color = red, // color;
line_width = k, // width of the line with which the chart is built;
title = “general name of the chart”,
polar (function, variable, lower_boundary_of_variable, upper_variable_variable) // function for plotting;
The first and last arguments to the function are required. The first initiates the construction of the graph in polar coordinates, the last (polar) is the function by which the graph is built.
plot3d ((((x - 10) / 5) * ((y - 10) / 5), [x, 0.20], [y, 0.20]) - three-dimensional (3D) graphics;
Editing three-dimensional graphics is carried out in the same way as two-dimensional.
A three-dimensional surface can be replaced by a gradient color transition. To do this, use the "set view map" option.
Programming (more in the documentation)
for, while, until etc.
Examples:
for i in s do
for k: 1 thru b: 3 do
for variable: beginning step step thru end do expression
for variable: beginning step step while condition do expression
for variable: beginning step step unless condition do expression
Function definition:
f1 (x, y): = x + y;
_- ============================== -_
########## OTHER ###### #######
. =================================.
The Russian designation is in Maxima:
arccos - acos
arcsin - asin
arctg - atan
ch - cosh
sh - sinh
ctg - cot
ln - log
tg - tan
Symbols of the Greek alphabet:
Gamma; Theta Psi etc.
Data processing:
1)
load (descriptive) $ / * load extension * /
a: [1,2,3,4];
mean (a); / * = 5/2 average * /
var (a); / * = 5/4 variance * /
std (a); / * =? 5/2 standard deviation * /
mean (arithmetic mean);
median
variance (variance);
deviation (standard deviation);
2)
a: [1.0,2.0,3.0,4.0];
for i in a do ldisp (sin (i) / i);
Calculation of derivatives with respect to all variables included in the expression:
eq: x * l / k; / * source expression * /
res: 0 $ for i in listofvars (eq) do res: res + (diff (eq, i) * concat ("d", (i))) ^ 2 $
For greater accuracy, there is a special function bfloat () (big float, big float), as well as the ffprec variable - for the number of decimal places. That is, to increase / decrease accuracy, you need to assign a different numerical value to the fpprec variable and use the bfloat () function instead of float (). The numer variable needs to be false.
By default, Maxima works in the ISS system: meter-kilogram-second:
2 * m;
2 * cm;
setunits ([centigram, inch, minute]) - the arguments of which are the three basic units of measurement: weight, length and time;
setunits ([kg, m, s]);
convert (inch, [sm]); - translation of units of measure;
stringout ("/ Users / myusername / file1maxima.mc", INPUT);
To save all your work as a "tape" that can be replayed later, all your input can be saved to a file.
batch ("/ Users / myusername / file1maxima.mc");
Loading the saved file: the saved file can also be loaded directly, although the exact numbering of lines will change from the original calculation.
SIMPSUM: TRUE;
sum (k, k, 1, n), simpsum;
=> \ displaystyle {{n ^ 2 + n} \ over {2}}
product (1 / (n ^ 2), n, 1,10); Products work in much the same way.
niceindices (powerseries (% e ^ x, x, 0));
=> \ displaystyle \ sum_ {i = 0} ^ {\ infty} {{{x ^ {i}} \ over {i!}}}
taylor (% e ^ x, x, 0, 5);
=> \ displaystyle 1 + x + {{x ^ 2} \ over {2}} + {{x ^ 3} \ over {6}} + {{x ^ 4} \ over {24}} + {{x ^ 5} \ over {120}} + \ cdots
trunc (%); Since the output of taylor has special properties, we need to convert it into a polynomial.
load ("newton");
=> / sw / share / maxima / 5.9.0rc3 / share / numeric / newton.mac
newton (x ^ 7-5 * x ^ 6 + 4 * x ^ 4-5 * x ^ 2 + x + 2.1) ;
=> 8.194213634964119B-1
tex (%) - convert the expression to the form TeX;
$$ \ left (x + 1 \ right) ^ 2 $$
Convert TeX to PDF:
1. Paste the following five lines verbatim into the text editor:
\ documentclass {article}
\ pagestyle {empty}
\ begin {document}
\ huge
\ end {document}
2. Copy the tex () output line, and paste it between the \ huge and \ end {document} lines.
3. Save the result in text format as: myoutput.txt
4. In the terminal window, navigate to the directory where you saved myoutput.txt
5. type:
pdflatex myoutput.txt
6. Hit return - a PDF file called myoutput.pdf containing your typeset equation will now be created in this directory.
load (to_poly_solve); - additional procedures for solving systems of algebraic equations;
to_poly_solve ([3 * z1 + z2 + 2 = 0, sqrt (z1) = z2], [z1, z2]);
sol: rk ([rk1, rk2, gamma, w], [gamma, w, fi, tetta], [0,% pi / 8,% pi / 2, 0], [t, 0, Tmax with_stdout ("gamma .txt ", for k: 1 thru points do print (sol [k] [1], sol [k] [2])) is an example of entering data from a file.
Now let's look at a typical example of using Maxima in student life. interestingly this process was shown in an article on Habréearlier. I, in turn, will only rotate the coordinate axes in one equation:
F:uxx+2*uxy+cos(x)^2*uyy-ctg(x)*(ux+uy); /*искомое уравнение*/
A:F,uxx=uxx,uxy=0,uyy=0,ux=0,uy=0$ A:A/uxx$
B:F,uxx=0,uxy=uxy,uyy=0,ux=0,uy=0$ B:B/(2*uxy)$
C:F,uxx=0,uxy=0,uyy=uyy,ux=0,uy=0$ C:C/(uyy)$
D:F,uxx=0,uxy=0,uyy=0,ux=ux,uy=0$ D:D/(ux)$
E:F,uxx=0,uxy=0,uyy=0,ux=0,uy=uy$ E:E/(uy)$
print("A = ",A)$ print("B = ",B)$ print("C = ",C)$ print("D = ",D)$ print("E = ",E)$
delta:B^2-A*C$
print("Delta = ", delta)$
/*так как я знаю, что дельта > 0, перехожу сражу к решению гиперболического уравнения */
A*'diff(y,x,1)^2-2*B*'diff(y,x,1)+C=0;
'diff(y,x,1)=(2*B+sqrt((2*B)^2-4*A*C))/(2*A);
ode2(%,y,x);
solve(%,%c)$
w1:rhs(%[1])$ print("w1 = ",w1)$
'diff(y,x,1)=(2*B-sqrt((2*B)^2-4*A*C))/(2*A);
ode2(%,y,x);
solve(%,%c)$
w2:rhs(%[1])$ print("w2 = ",w2)$
ux:un*diff(w2,x)+ue*diff(w1,x);
uy:un*diff(w2,y)+ue*diff(w1,y);
uxx:un*diff(diff(w2,x),x)+unn*diff(w2,x)^2+2*uen*diff(w1,x)*diff(w2,x)+ue*diff(diff(w1,x),x)+uee*diff(w1,x)^2;
uxy:un*diff(diff(w2,x),y)+uen*(diff(w1,x)*diff(w2,y)+diff(w1,y)*diff(w2,x))+unn*diff(w2,x)*diff(w2,y)+ue*diff(diff(w1,x),y)+uee*
diff(w1,x)*diff(w1,y);
uyy:un*diff(diff(w2,y),y)+unn*diff(w2,y)^2+2*uen*diff(w1,y)*diff(w2,y)+ue*diff(diff(w1,y),y)+uee*diff(w1,y)^2;
uy*E+ux*D+uyy*C+2*uxy*B+uxx*A;
%,ctg(x)=cos(x)/sin(x); trigrat(%);
Result:
2 * uen * cos (2 * x) -2 * uen