What is an operating system? Types of operating systems. Modern systems of computer mathematics
I will not hide the fact that the catalyst for writing this post was the lovers of hiking, taken from the book by V. I. Arnold. In this regard, the idea arose to consider a simple mathematical problem, the solution of which shows that the capabilities of the SCA often rest on a rather natural upper limit, and in order to obtain a compact solution suitable for further analysis, it is necessary to tighten the convolutions a little.
1. System of trigonometric equations
When, in the not too distant 2003, I started working on my Ph.D. thesis, I was faced with the need to solve a system of trigonometric equations of the formParameters a, b, A, B are positive. Conditions are imposed on the roots of the equation
Where do we encounter such systems? When calculating the kinematics of closed four-link, for example. Such a closed four-link was in my work, I came across almost the same about a year ago, when I undertook to make a “coven” (I helped one professor in his work).
Then, in 2003, I just got acquainted with the Maple system and was delighted with its capabilities, naturally I entrusted this system to her. And a "bummer" was waiting for me ... Let's see what solution Maple 18 and Mathematica 10 give for this task today.
2. Solution of the problem in the SKA "on the forehead"
In my favorite Maple, we set the system of equationsrestart; eq01:= a*cos(x) + b*cos(y) = A; eq02:= a*sin(x) - b*sin(y) = B;
And we try to solve
Solv:= solve((eq01, eq02), (x, y));
And we get...
This bug didn't fit into the online LaTeX, so I had to provide a screenshot. This result is obtained due to the fact that the formulation of the problem is too general. It is necessary to indicate to the system which solution we are interested in using the condition (3)
Solv:= solve((eq1, eq2, x > 0 and x< Pi, y >0 and y< Pi}, {x, y});
In this case, the result looks better
Once again I apologize to the reader for the clumsy screenshot and note that we have received two solutions to the system (1) - (3) and now we still have to figure out which answer corresponds to the mechanical meaning of the problem (it is there, yes), and given that behind a, b, A and B can be quite significant expressions (not dependent, of course, on x and y) we should be pretty sad at this point.
Mathematica 10 does better with these equations in the sense that it gets the final form common solution, part of which is on the screen
If the system is supplemented with condition (3), then Wolfram tells us that Solve[...] does not have a solution method for such a case (I would be grateful to the reader for a hint on this issue, because I think that I myself have not studied the issue completely, but for now continue the story).
In addition, both SKAs give out a blasphemous arc tangent in their solution, which is not always convenient for various reasons, which I will not talk about - in each case there are different reasons.
When my now deceased "boss" saw these decisions in 2003, he thought and said that "these crocodiles need to be combed", which made me plunge into further thought. And I again armed myself with a piece of paper and a pencil ...
3. SKA + brain
To obtain a sufficiently compact solution, it is necessary to transform the system (1) - (3) to a linear one with respect to the unknowns. To do this, you need to use the school knowledge of trigonometry.So, let's square equations (1) and (2) and add them, moving everything that does not depend on x and y to the right side of the equation
Left1:= lhs(eq01): left2:= lhs(eq02): right1:= rhs(eq01): right2:= rhs(eq02): eq03:= simplify(left1^2 + left2^2)= right1^2 + right2^2; eq03:= eq03 - (a^2 + b^2); left3:= combine(lhs(eq03)); eq03_1:= left3 = rhs(eq03);
Using the formula "cosine of the sum", we obtain a new equation
Now, resolving it with respect to the sum of unknowns, we arrive at the linear equation
A linear equation is also linear in Africa - having found one unknown, we get another. Let's deal with another unknown by eliminating x from one of their equations. Since we have condition (3), it is obvious that
And this gives us the opportunity to use the basic trigonometric identity without the ambiguity "plus or minus"
We take the cosine of x from the first equation
Getting, thus for the sine x
In order not to puff over the paper, let's entrust all this to Maple
Eq01_1:= subs(cos(x) = u, eq01); slv:= solve(eq01_1, u); eq02_1:= subs(sin(x) = sqrt(1-slv^2), eq02); eq02_1:= eq02_1 + b*sin(y);
Having the output equation
Equation (7) must be squared and some transformations carried out
Left:= expand(lhs(eq02_1)^2): right:= expand(rhs(eq02_1)^2): eq02_2:= collect(simplify(right - left), b); eq02_3:= subs(coeff(eq02_2, b) = tmp, eq02_2); slv2:= solve(eq02_3, tmp); eq02_4:= -2*A*cos(y) + 2*B*sin(y) = slv2; eq02_5:= eq02_4/(-2);
And now let's perform, known to many, "feint with ears"
Left2:= lhs(eq02_5); left3:= subs(A = O2A*cos(xi), B = O2A*sin(xi), left2); left4:= subs(O2A = sqrt(A^2 + B^2), combine(left3));
That is, we divide both sides of the equation by and fold the left side according to the cosine formula of the sum, rightly assuming that
We get a new equation
Which we successfully solve for y
Eq02_6:= left4 = rhs(eq02_5); slv3:= subs(xi = arccos(A/sqrt(A^2 + B^2)), solve(eq02_6, y)):
As you can see, the game came out quite compact. We return to equation (5) and find x
Send your good work in the knowledge base is simple. Use the form below
Students, graduate students, young scientists who use the knowledge base in their studies and work will be very grateful to you.
Course work
COMPARATIVE ANALYSIS OF COMPUTER MATHEMATICS SYSTEMS
INTRODUCTION
CHAPTER 1
1.1 Variables and constants
1.2 Vectors and matrices
1.3 Operators
1.4 Built-in functions
1.5 Programming
1.6 Solving Equations
1.7 Symbolic calculations
1.8 Graphs
1.9 Polar plots
1.10 Surface plots
CHAPTER 2
2.1 Operating environment of the MATLAB system
2.2 Arrays, matrices and operations with them
2.3 Mathematical functions and operations
2.4 Linear algebra
2.5 Data analysis and processing
2.6 Graphic commands and functions
2.7 Programming in the MATLAB environment
CHAPTER 3
3.1 Mathematica as a calculator
3.2 Palettes and buttons
3.3 Computing power of the Mathematica system
3.4 Mathematica features
3.5 Building calculations
3.6 Visualization in Mathematica
3.7 Basic approach to describing objects
3.8 Mathematica as a programming language
CHAPTER 4. Comparative analysis. Conclusion
CHAPTER 5. Practical part
List of sources used
Attachment 1
Annex 2
Appendix 3
Appendix 4
Annex 5
Appendix 6
Annex 7
Appendix 8
Appendix 9
APPENDIX 10
Introduction
In our time, in connection with the development of information technology, the so-called computer mathematics systems, or they are also called mathematical packages, have appeared that make it easier to perform various mathematical tasks, help to check the solution of a problem using a computer program. The time for completing tasks of varying complexity is greatly reduced. For hundreds of thousands of professionals in various industries, engaged in engineering and scientific research, computer mathematics systems have provided an excellent environment for organizing calculations. Therefore, familiarity with the basics of organizing mathematical packages can be useful both for specialists starting to master this system and for university students in various specialties. They have an extremely wide range of tools that translate complex mathematical algorithms into programs, the so-called elementary functions and a huge number of non-elementary functions. , algebraic and logical operations. Most of the exercises from the course higher mathematics can be solved with just one command. You can calculate integrals, solve differential equations, ordinary equations and systems of linear equations. Provided a wide range of work with matrices, vectors. It is possible to build two-dimensional and three-dimensional graphs. There are several mathematical packages such as Mathcad, MATLAB, Mathematica, Maple, Statistica and others. But on an example, consider three of them: Mathcad, MATLAB and Mathematica; each separately - its features and interface, and then we will conduct a comparative analysis between them.
Chapter 1.Mathcad
Mathcad is a software tool, an environment for performing various mathematical and technical calculations on a computer, equipped with an easy-to-learn and easy-to-use graphical interface that provides the user with tools for working with formulas, numbers, graphs and texts. More than a hundred operators and logical functions are available in the Mathcad environment, designed for numerical and symbolic solving of mathematical problems of varying complexity. The menu in Mathcad is nothing unusual: like many other programs, there are various toolbars, a formatting bar. In addition, there is the "Math" panel, which includes such panels as "Calculator", "Graphics", "Matrices", "Calculations", "Calculation", "Logic", "Programming", "Greek" and "Symbol" . These panels contain various non-keyboard characters and functions.
1.1 Variables and constants
Valid Mathcad variable and function names, predefined variables like this, and number representations are described here. Mathcad handles complex numbers just as easily as real numbers. Mathcad variables can take complex values, and most of the built-in functions are defined for complex arguments.
Names
Mathcad distinguishes between Greek and Roman letters.
If you use a Greek character instead of the corresponding Roman character in a variable or function name, Mathcad will treat it as a different name.
Letter indices
If you place a dot in a variable name, Mathcad displays everything that follows it as a subscript. You can use these literal subscripts to create variables with names like vel init and u air .
Predefined Variables
Mathcad contains eight variables, the values of which are determined immediately after starting the program. These variables are called predefined or built-in variables. Predefined variables or have a common meaning, like p and e, or used as internal variables that control how Mathcad works, like ORIGIN and TOL.
You can control the TOL, ORIGIN, PRNPRECISION, and PRNCOLWIDTH values without having to explicitly define them in the worksheet.
The complete list of predefined Mathcad variables and their default values is given below. See "Table 1" ("Appendix 1").
Numbers
This section describes different types numbers used by Mathcad and how they are written in formulas.
Numbers Used
Mathcad interprets anything that starts with a digit as a number. The figure may be accompanied by:
other numbers,
decimal point
digits after the decimal point,
one of the letters h or o for hexadecimal and octal numbers, i or j for complex numbers.
Mathcad uses a dot to separate the fractional part of a decimal, while a comma is used to separate numbers from each other, such as discrete argument values or numbers in an input table.
imaginary numbers
To enter an imaginary number, you need to enter the symbol of the imaginary unit after its modulus i or j, for example, 1 i or 2.5 j. Can not use i or j by themselves to denote the imaginary unit.
1.2 Vectors and matrices
Arrays in Mathcad are described here. While ordinary variables (scalars) store a single value, arrays store many values. As is common in linear algebra, arrays that have only one column will often be called vectors, all others matrices.
Array Calculations
Variables can represent arrays just like scalars. Defining a variable as an array is much like defining a scalar.
For example, if we define a vector v, You can now use the name v instead of the vector itself in any expression.
Subscripts and superscripts
You can access individual array elements using subscripts. You can also refer to an individual array column using a superscript. To print a subscript, use the buttons on the toolbar.
The vector and matrix elements are usually numbered starting from row zero and column zero.
Vector and matrix operators
Some of the Mathcad operators have special meanings when applied to vectors and matrices. For example, the multiplication symbol simply means multiplication when applied to two numbers, but it also means dot product when applied to vectors, and matrix multiplication when applied to matrices. The list of vector and matrix operators is given below. See "Table 2" ("Appendix 2").
Vector and matrix functions
Mathcad contains functions for common linear algebra operations with arrays. These functions are intended for use with vectors and matrices. Unless it is explicitly stated that a function is defined for a vector or matrix argument, you should not use arrays as an argument in it.
Array Dimensions and Range
Mathcad has several functions that return information regarding the size of an array and the range of its elements: rows(A)- number of rows in the array A,cols(A)- number of columns in the array A, length(v)- the number of elements in the vector v,max(A)- the largest element in the array A.
Special Matrix Types
You can use the following functions to generate from an array or scalar a matrix of a special type or shape. These are the features diag(returns a diagonal matrix) , reref(Step Matrix) identity(n) (identity matrix n x n) and other functions.
Matrix Special Features
You can also find the rank of a matrix: rank(A) and the norm: normal1(A).
Formation of new matrices from existing ones
Mathcad has functions for joining matrices together -- side by side, or one on top of the other. One of them: stack (A, B) - array formed by location A above B. Mathcad also has a function to extract a submatrix: submatrix (BUT, ir, jr, ic, jc) - A submatrix consisting of all elements contained in rows with ir on jc and columns with ic on jc.
1.3 Operators
Mathcad uses common operators like + and /, as well as operators defined for matrices, such as transposition and determinant operators, and special operators such as calculating integrals and derivatives.
List of operators
A partial list of Mathcad operators is given below. See "Table 3" ("Appendix 3"). Most operators can be entered into a working document using the operator palettes. To open the operator palette, click on the desired button on the button strip directly below the menu commands.
All operators listed in the table can be typed from the keyboard, can be found on the toolbar in the menu Maths. These are the panels Arithmetic, Mathanalysis, Boolean.
1.4 Built-in functions
Many of Mathcad's built-in functions are listed and described here.
The functions used to work with vectors and matrices are described in Section “Vectors and Matrices”.
Inserting built-in functions
To insert a function in Mathcad, you can click on the toolbar Paste ->Function.
Transcendent Functions
This section describes Mathcad's trigonometric, hyperbolic, and exponential functions, along with their inverses.
Trigonometric functions and their inverses. Mathcad trigonometric functions and their inverses are defined for any complex argument. They also return complex values wherever needed.
Here is some of them: sin(z)- returns the sine of z, asin(z)- returns the angle in radians whose sine is z, sec(z)- returns 1/cos(z), secant z. Rest trigonometric functions are defined in a similar way.
Hyperbolic functions
These functions can also take a complex argument and return complex values. Hyperbolic functions are closely related to trigonometric functions.
One of them - sinh(z)- returns the hyperbolic sine of z.
Logarithmic and exponential functions
Mathcad logarithmic and exponential functions can take a complex argument and return complex values: exp(z)- returns e to the power of z, log(z)- returns the natural logarithm of z,
log(z)- returns the logarithm of z to base 10.
Truncation and rounding functions
All of these functions extract some part of their argument.
Functions Re, Im and arg extract the corresponding part of the complex number (real, imaginary, and when z is in the form re i q). Functions ceil and floor return the nearest integer greater than and less than the argument, respectively. These functions can be used to create a function that returns the fractional part of a number.
Sort functions
Mathcad contains three functions for sorting arrays and one for reversing the order of their elements:
sort(v)- returns the elements of the vector v, sorted in ascending order.
1.5 Programming
Mathcad allows you to write programs. A program in Mathcad is an expression, which in turn consists of other expressions. Mathcad programs contain constructs much like programming language constructs: conditional control transfers, loop statements, variable scopes, subroutines, and recursion. Writing programs in Mathcad allows you to solve problems that are impossible or very difficult to solve in another way.
Creating programs
The Mathcad program is a special case of the Mathcad expression. Like any expression, a program returns a value if it is followed by an equals sign. Just as a variable or function can be defined with an expression, it can also be defined with a program.
The main difference between a program and an expression is how the calculations are specified. When using an expression, the algorithm for obtaining a response must be described by a single operator. As many statements as needed can be used in a program.
Conditional statements
Normally, Mathcad executes program statements in order from top to bottom. There may be cases in which a statement needs to be executed only if a certain condition is met. This can be achieved using the “ if”.
Cycles
One of the greatest advantages of programming is the ability to repeatedly execute a sequence of statements in a loop. Mathcad offers two types of loops that differ in the way they define the end condition of the loop.
If the required number of loop executions is known in advance, it is advisable to use a loop of the type for.
If the loop must terminate upon the fulfillment of a certain condition, and the moment of fulfillment of this condition is not known in advance, then it is advisable to use a loop of the type while.
Programs within programs
One of the features that determine the flexibility of programming methods is the ability to use some program structures within others. In Mathcad, this can be done in three ways:
· One of the statements of the program can be made, in turn, a program.
· You can define a program somewhere else and call it from other programs as if it were a subroutine.
You can define a function in a recursive way.
1.6 Solving Equations
Learn how to use Mathcad to solve equations and systems of equations. It is possible to solve both one equation with one unknown and systems of equations with several unknowns. The maximum number of equations and unknowns in the system is fifty.
Solving one equation
To solve one equation with one unknown, the function is used root(f(z), z) - returns the z value at which the expression or function f(z) goes to 0.
Function root designed to solve one equation with one unknown.
Systems of equations
Mathcad makes it possible to solve systems of equations as well. The result of the solution of the system will be the numerical value of the desired root. For symbolic solution of equations, it is necessary to use blocks of symbolic solution of equations. In the symbolic solution of equations, the desired root is expressed in terms of other variables and constants.
find (z1, z2, z3, . . .) - returns the solution of the system of equations. The number of arguments must be equal to the number of unknowns.
Keyword Given, standing at the beginning of the definition of the equation, the equations themselves and the inequalities that follow it, and any expression containing the function find, called block for solving equations.
1.7 Symbolic calculations
This describes symbolic transformations in Mathcad. Symbolic conversions are described below. See "Table 4" ("Appendix 4").
1.8 Graphs
Plots in Mathcad are both versatile and easy to use. To create a graph, click where you want to insert the graph, select Cartesian Graph from the Graph menu, and fill in the empty fields. You can format graphs in every possible way by changing the appearance of the axes and the style of the curves and using various labels.
Insert a graph
To insert a graph into Mathcad, you can click on the toolbar " Graphic arts".
In general, graphs are built on the basis of available templates. Initially, you need to define the graph function.
The bottom, top, left and right borders of the chart are edited. If you double-click on the graph with the left mouse button, the graph setting will appear: coordinate axes, color, line output style. You can also set the range in increments. A range is required to define a function parametrically.
1.9 Polar plots
In some cases, when plotting graphs, it is more convenient to use polar rather than Cartesian coordinates. Mathcad allows you to build polar plots.
Here you can also edit the graph and place multiple graphs in one area.
1.10 Surface plots
Along with two-dimensional and three-dimensional graphs, you can include in Mathcad working documents. Unlike 2D plots, which use discrete arguments and functions, 3D plots require a matrix of values. This shows how a matrix can be represented as a surface in 3D space. It also covers the creation, use, and formatting of surfaces in 3D space.
Chapter 2 MATLAB
MATLAB is an interactive system whose main object is an array, for which you do not need to specify the dimension explicitly. This makes it possible to solve many computational problems associated with vector-matrix formulations, significantly reducing the time that would be required for programming in scalar languages like C or FORTRAN.
MATLAB is both an operating environment and a programming language. One of the greatest strengths of the system is that programs can be written in MATLAB for reuse. The user can write specialized functions and programs himself, which are issued in the form of M-files.
2.1 OpMATLAB iteration environment
The operating environment of the MATLAB system is a set of interfaces that support the connection of this system with the outside world. This is a dialogue with the user through the command line or a graphical interface, viewing the workspace and access paths, the editor and debugger of M-files, working with files and the DOS shell, exporting and importing data, interactive access to help information, dynamic interaction with external Microsoft systems Word, Excel Microsoft Word, Excel, etc. These interfaces are implemented through the command window, toolbar, workspace and access path viewers, M-file editor/debugger, special menus, etc.
command window
The MATLAB command window contains options that can be viewed in "Table 5" ("Appendix 5").
Dashboard
The toolbar of the command window of the MATLAB system allows you to provide easy access to operations on M-files.
These operations include:
Creation of a new M-file (New File);
Opening an existing M-file (Open File);
Fragment copying (Copy);
Fragment insertion (Paste);
Viewing the workspace (Workspace Browser);
current help (Help).
M-file editor/debugger
The MATLAB system includes the M-file Editor/Debugger, which can be called from the command line with the edit or edit command<имя М-файла>.
2.2 Arrays, matrices and operations with them
Arrays are the basic objects in the MATLAB system. Functions for forming arrays and matrices, operations on matrices, and special matrices are described below.
Formation of arrays of a special type
ZEROS - formation of an array of zeros
ONES - formation of an array of units
EYE - formation of an identity matrix
CROSS - vector product
Matrix operations
DIAG - formation or extraction of matrix diagonals
TRIU - formation of an upper triangular matrix (array)
· FLIPUD - rotation of the matrix relative to the horizontal axis and others.
Special matrices
· MAGIC - magic square
2.3 Mathematic functions and operations
MATLAB has an extensive library of mathematical functions. Each function has a specific name. The function maps the values of its arguments to the value of the result.
Function arguments are always specified in parentheses after the function name and, if there is more than one, separated by commas.
Mathematical operations
a+b - addition
a=b - assignment operator
a.*b - element-wise multiplication
a*b - matrix multiplication
a.^b - element-wise exponentiation
a^b - matrix exponentiation
a>b - more
a>=b - greater than or equal to
a~=b - unequal
a==b - equals
a&b - logical AND
a|b - logical OR
~a - logical NOT
a." - transposition
a" - complex conjugate transposition
b(a) - indexing
Basic Functions
ABS - absolute value
ANGLE - complex number argument
REAL, IMAG - real and imaginary parts of a complex number
· CEIL, FIX, FLOOR, ROUND - rounding functions
Transcendent Functions
SQRT - square root
EXP - exponential function
LOG - natural logarithm function
LOG10 - logarithm functions
Trigonometric functions
SIN, SINH - sine functions
COS, COSH - cosine functions
TAN, TANH - tangent functions
COT, COTH - cotangent functions
2.4 Linear algebra
A matrix as a mathematical object arises when solving specific computational problems, and primarily when solving systems of linear algebraic equations and eigenvalue problems. Applied problems that generate matrices determine for them a special set of admissible operations, among which the multiplication operation occupies a special place.
Consider the functions of the MATLAB system that support working with matrices.
Matrix characteristics
NORM - norms of vectors and matrices
RANK - matrix rank
DET - matrix determinant
RREF - triangular matrix
2.5 Data analysis and processing
This chapter describes the functions of the MATLAB system that are designed to analyze and process data specified as numeric arrays. Here, the functions of calculating the average, median, finite differences, gradient are considered. Numerical integration functions, solutions of the Cauchy problem for systems of ordinary differential equations.
Basic operations
· SUM, CUMSUM - summation of array elements
· PROD, CUMPROD - product of array elements
SORT - sort array elements in ascending order
MAX - determination of the maximum elements of the array
MIN - definition of the minimum array elements
Numerical integration
TRAPZ - trapezoidal integration
· QUAD, QUAD8 - calculation of integrals by quadrature method
Integration of ordinary differential equations
· ODE23, ODE45 - solution of the Cauchy problem for systems of ordinary differential equations
Calculation of minima and zeros of a function
FMIN, FORTIONS - minimization of a function of one variable
FMINS - function minimization of several variables
FZERO - finding zeros of a function of one variable
· FPLOT - plotting functions of one variable
2.6 Graphic commands and functions
Starting with version 4.0, the MATLAB system includes a powerful graphics subsystem that supports both visualization tools for two-dimensional and three-dimensional graphics on the terminal screen and presentation graphics tools.
The elementary graphical functions of the MATLAB system allow you to build on the screen the following types graphs: linear, logarithmic, polar.
For each graph, you can set a title, apply the designation of the axes and scale grid.
2D Plots
PLOT - graph on a linear scale
LOGLOG - graph on a logarithmic scale
· SEMILOGX, SEMILOGY - graph in a semi-logarithmic scale
· POLAR - graph in polar coordinates
3D Graphs
The MATLAB system provides several commands and functions for constructing three-dimensional graphs.
The values of the elements of a numeric array are treated as the z-coordinates of points above the plane defined by the x and y coordinates. There are several ways to connect these points. The first of them is the connection of points in a section (the plot3 function), the second is the construction of mesh surfaces (the mesh and surf functions).
· PLOT3 - construction of lines and points in three-dimensional space
MESH, MESHC, MESHZ - three-dimensional mesh surface
SURF, SURFC - shaded mesh surface
· ZOOM - chart scale control
COLORMAP - color palette
Labels and explanations for charts
· TITLE - titles for two- and three-dimensional graphs
XLABEL, YLABEL, ZLABEL - designation of axes
· TEXT - adding text to the current chart
Special Graphics
The dedicated graphics section includes graphics commands and functions for bar graphs, histograms, vector and complex element displays, discrete data sequence output, and moving paths for both 2D and 3D graphics.
BAR - bar charts
HIST - building a histogram
STEM - discrete graphics
STAIRS - step chart
WATERFALL - three-dimensional surface
2.7 Programming in the MATLAB environment
Programming
Files that contain MATLAB language codes are called M-files. A text editor is used to create an M-file; the M-file call is preceded by the assignment of values to the input arguments; the result is the value of the output variable. Thus, the whole procedure includes two operations:
· Create an M-file using a text editor.
Call an M-file from the command line or from another M-file:
Types of M-files. There are two types of M-files: M-scenarios and M-functions with the characteristics indicated in "Table 6" ("Appendix 6").
M-file structure.
An M-file designed as a function consists of the following components:
function definition string
The first line of the comment
· Comment
function body
Creation of M-files. M-scenarios. M-functions
M-files are plain text files that are created with a text editor. For Operating Environment personal computer MATLAB supports a dedicated built-in editor/debugger, although any other ASCII text editor can be used.
M-scenarios
Scripts are the simplest type of M-file - they have no input or output arguments. They are used to automate repetitive calculations. Scripts operate on data from the workspace and can generate new data for further processing in the same file. The data that is used in a script is stored in the workspace after the script ends and can be used for further calculations.
M-functions
M-functions are M-files that allow input and output arguments. They operate on variables within their own workspace, separate from the workspace of the MATLAB system.
The structure of the M-function. The M-function consists of:
function definition strings;
the first line of the comment;
The actual commentary
body of the function
inline comments
Every function in the MATLAB system contains a function definition string like this one.
If the function has more than one output argument, the list of output arguments is enclosed in square brackets. Input arguments, if present, are enclosed in parentheses. Commas are used to separate arguments in the input and output lists.
The names of the input variables may, but need not, be the same as the names specified in the function definition line.
Comment. For M-files, you can create an online tooltip by entering text on one or more comment lines.
Function body. The body of the function contains the MATLAB language code that performs the calculations and assigns values to the output arguments. Statements in a function body can consist of function calls, program flow control constructs, interactive I/O, calculations, assignments, comments, and empty strings.
Chapter 3 Mathematica
Mathematica, created ten years ago, has an extremely wide range of tools that translate complex mathematical algorithms into programs. All the so-called elementary functions and a huge number of non-elementary ones; algebraic and logical operations. The Mathematica system is very widespread in the world, it has captured huge areas of application in scientific and engineering research, as well as in the education system.
3 .1 Mathematica as a calculator
You can use Mathematica just like a calculator: you enter data and Mathematica outputs the result.
Mathematica automatically handles numbers of any size.
You can work in standard mathematical notation using palettes or special keyboard shortcuts.
An important feature of the Mathematica system is its ability to operate with symbolic expressions as easily as with numbers.
Solving an equation in Mathematica. The roots of the equation are found using the function solve. The roots of the equation are functions that depend on a parameter.
The calculation of the integral is carried out similarly to the calculations in other
math packages.
You can use Mathematica to plot 2D and 3D function graphs.
The graph of this function is shown in "Figure 1" ("Appendix 7").
You can take advantage of the many computing capabilities of Mathematica by simply clicking one of the buttons in the standard palettes.
3.2 Palettes and Buttons
Palettes and buttons provide a simple and fully customizable point-and-click interface for Mathematica.
Mathematica comes with several standard palettes.
Part of the palette BasicCalculations shown in "Table 7" ("Appendix 8").
Palettes are an extension of the presented keyboard.
In the palette, the symbol means the position where you want to insert some expression: Log , 2 , Exp, etc.
Creating your own palette is very easy.
Using the Create Table/Matrix/Palette command in the Input menu, you can create your own palette.
You can create your palettes to enter any function or operator, such as Expand, Factor, Simplify.
3.3 CalculateThe power of Mathematica
Mathematica provides great computing power while remaining as easy to use as a calculator.
This command creates a 100x100 matrix of random numbers.
On most computers, Mathematica takes less than a second to calculate all the eigenvalues of this matrix and present their moduli in the form of a graph, which is shown in "Figure 2" ("Appendix 9").
Mathematica can operate on numbers of any size. On most computers, calculating the exact value of 1000! in Mathematica takes less than a second. Mathematica easily copes with algebraic transformations, such as factoring a polynomial into factors: the command factor() .
Mathematica uses sophisticated algorithms to simplify expressions: the command Simplify() .
In many types of calculations, the Mathematica system is the world record holder in terms of the speed of calculations and the amount of information processed.
3.4 Mathematica features
The Mathematica system combines a large stock of mathematical knowledge and uses its own algorithms.
Mathematica implements hundreds of special functions used in pure and applied mathematics.
The Mathematica system can calculate the values of special functions with any parameters and with any precision.
Mathematica can calculate many different types of integrals.
Mathematica can also calculate finite and infinite sums and products.
Mathematica can solve a wide range of ordinary and partial differential equations.
The built-in algorithms of the Mathematica system are able to cope with a wide range of mathematical problems.
3.5 Building calculations
The ability to work with formulas will allow you to easily combine all parts of the calculation together.
calculation eigenvalues matrices: command Eigenvalues[{{},{}}].
Mathematica can calculate eigenvalues even if there are symbolic parameters in the matrix.
Built-in system functions Mathematica is designed so that the result of one function can be easily used as input to another function.
3.6 Visavisualization in Mathematica
Mathematica makes it easy to create great images.
This command draws a 3D parametric plot with most options automatically selected.
The graph itself is presented in "Figure 3" ("Appendix 10").
Mathematica contains graphical primitives with which you can build 2D and 3D graphs of any complexity.
List of primitives representing a point.
3.7 Basic approach to describing Mathematica objects
Mathematica is based on the idea that everything can be represented as a symbolic expression.
All symbolic expressions are written in a single form: head.
Item List:
Algebraic expression:
The equation:
Boolean expression:
Team:
Schedule:
3.8 Mathematicsatica as a programming language
Mathematica has a very flexible and intuitive programming language built into it.
The Mathematica language supports all the major modern programming methods, and also provides some new features.
procedural programming
Many operations are automatically propagated to lists.
This command concatenates nested lists.
Functional programming
The command is a "pure function". An argument is substituted for the character.
Chapter 4. Comparative analysis. Conclusion
We will carry out a comparative analysis of computer mathematics systems in the form of a table.
Comparison criterion |
||||
Interface |
Like "wysiwyg". The set of expressions comes from the position of the cursor. You have to enter relatively few keyboard expressions, as there are various tool palettes in the command window. |
Three windows: a command window, all variables and their types, and a hint window. There is a prompt string, denoted by ">>". Unlike Mathcad, all functions have to be entered from the keyboard. |
The prompt line, unlike MATLAB, is divided into two regions: input and output, which together make up the region of the entire expression. The input area can be edited. There is also a palette with Greek letters, various symbols and a math analysis panel. |
|
Working with arrays and matrices |
A sufficient set of functions is provided for performing various operations with matrices and vectors. Some operations can be taken from the corresponding palette, others can be entered from the keyboard or pasted from the menu Insert->Functions. |
Similarly to Mathematica, matrices and vectors are formed using a list of elements. Functions are entered from the keyboard. |
A multidimensional dataset is created using a list entered from the keyboard. Also, functions for working with matrices and vectors are introduced from the keyboard. |
|
Solving Equations |
Distinguishes between solving equations and systems of equations. Commands can be typed from the keyboard, can be inserted from the menu. |
Solves equations and systems of equations by a function with different parameters. |
Contains several functions for solving equations and systems of equations. Functions can find roots of equations with a parameter. There is also a function for special solutions. |
|
Mathematical Operators |
The table contains a number of operators, both simple ones like addition, and calculating the sum, product, integrals and derivatives, etc., which can be entered from the keyboard or inserted from the corresponding palette. |
Here, unlike Mathcad, all operators are entered from the keyboard as separate symbols and functions. A relatively detailed list of operators is given. |
Just like in MATLAB, operators have to be entered from the keyboard, but some can also be found on the tool palette. |
|
Built-in Functions |
They are built on the principle of all functions: the name of the function and the parameters in brackets. It is possible to single out the functions of simplifying the expression, opening brackets, trigonometric and a number of others. |
Here, only functions that are entered from the keyboard are mainly used. |
A lot of functions for various purposes with a different number of parameters are given. Help the user in solving various problems. |
|
Programming |
Templates are provided for creating programs and subroutines. The output value is last value calculated by the program. Also inside the program, you can use the functions described earlier. Programs are written in the same file as all calculations. |
Here programs are created as separate M-files. If you write a program for a function, then this function can be used as a standard one. You can also insert comments into the program. |
You can create various functions and operate on them. Allows you to create programs within one input block. The result will be the last calculated value. Unlike Mathcad, where programs are written "in a column", here they are written in a line. |
|
Graphic features |
Graphs are built on the basis of available templates. Main types: graph in the Cartesian plane, in the polar coordinate system, three-dimensional in the form of a smooth surface, in the form of contour curves, etc. First, the function of the graph, the range, is set, then the graph itself is built, which can be edited. |
The graph function is created from the command line. Graphs are created on forms in a certain coordinate system. You can specify chart properties in the plotting command. |
The function that draws the graph ends with "PLOT" in the 2D case, and "PLOT 3D" in the 3D case. To build a graph, you must first define a function. You can also edit the chart. |
Conclusion
As can be seen from the comparative analysis, all mathematical packages are similar to each other. They have similar principles for constructing calculations, graphs of functions. Mathcad, MATLAB, and Mathematica both have lists of built-in functions and operators. But there are also differences, for example, in the interface, programming methods. At this level of development of education, I think that it is impossible to do without computer mathematics systems. Otherwise, why did they appear then?
Chapter 5. Practical part
It was required to create a website with the same title of the term paper, namely "Comparative analysis of computer mathematics systems".
The site was created to bring information about the purpose of computer mathematics systems to everyone.
The site contains the following html pages: 1 - Main page; 2 - Mathcad; 3 - MATLAB; 4 - Mathematica; 5 - Comparative analysis. Conclusion.
Pages Mathcad, MATLAB, Mathematica, in turn, also contain several pages.
The folder structure for storing the structure of the site is as follows: a folder "sweta" has been created, which contains all the pages and all the contents of the site. This folder contains the main page ind.htm and all pages of the site.
Also in this folder is the ind.files folder, which contains the mystyle.css style sheet, graphic files connected to the site pages, and several folders, which in turn also contain graphic files connected to the site pages.
File ind . htm, as mentioned earlier, is the main page.
On this page in the upper left corner there is a label that is directly related to the name of the site and illustrates it to some extent. The label is a necessary link of the main page of the site.
Next to the label is the actual name of the site. In the center of the page is a table consisting of two columns: the first contains a menu, also designed as a table; in the right - part of the narrative, that is, the introduction.
At the bottom of the main page there is a ticker with the website creator's email address.
From the main page, using hyperlinks, you can get to four pages - these are the files ind1.htm - general about Mathcad, ind2.htm - general about MATLAB, ind3.htm - general about Mathematica and ind4.htm - comparative analysis of mathematical packages and output.
On these pages, a menu is located at the top, followed by general information about a particular package and hyperlinks to individual pages of the site intended for Mathcad, MATLAB, and Mathematica, respectively. You can return back to the main menu using the hyperlinks located at the top of these pages. Most of the pages include pictures illustrating the theory posted on the site.
All html files, numbered from one, belong to the Mathcad system, numbered from two - to MATLAB, from three - to the Mathematica system.
The general background of the site is light lilac, which makes it easier to read the text and is prudent if the user begins to print the web page.
Font - 13.5 size, therefore, reads well.
All pages of the site are created using a style sheet called mystyle.css. It includes headings of levels 1-4, menu items of levels 1-4, hyperlinks, tables and table cells, body text.
The style sheet is connected as an external file, a link to it is embedded in the document using the tag .
The following tags were used to create the site.
- is a container that contains all the content of a web page.
- title of the document.- designed to create one table cell.
- designed to display on a web page images in GIF, JPEG or PNG graphic format. Specifies a text paragraph. Sets a newline at the location where this tag occurs. - container for changing font characteristics: size, color, typeface.
|