⬆️ ⬇️

Introduction to Wolfram Mathematica



Introduction



On Habré, Mathematica has been mentioned many times and if you want to start working with it, then this article is for you. I will talk about the main aspects of working with her and show some interesting innovations from the latest versions of Wolfram Mathematica .



Wolfram Mathematica is software, not only for mathematical calculations, it is much more: from modeling and simulation, visualization, documentation, to creating websites. Mathematica has the ability to make function calls and receive calls from C, .NET, Java and other languages, generate C code, compile stand-alone libraries and executable files.

All the advantages of Mathematica can be found on the official website. ru



To get started with Mathematica, you need to get it and install it on your computer. Mathematica works great on Windows, Mac, Linux.

You can download and try Mathematica for free at the office. site .

If you decide to buy it, then the prices for it are quite reasonable. For example, for a student for the semester version, it will cost $ 44.95. For home use at $ 295. If you plan to use it for commercial purposes, then the best license option is Standard Edition (you get a Premier Service subscription and free updates).

')



Study of



The best Mathematica book is the built-in Help. It has a huge pile of tutorials and tips. A great many examples. Everything you might need is there. This is the first place to look for the right information. However, if you need more, there is a huge variety of Mathematica communities on the Internet. (For example: mathematica.stackexchange.com ).



Notebooks and Cells



All calculations in Mathematica are in notebooks. And they have the extension .nb . The notebooks contain both the code and the results of the calculations. Notebooks are divided into different types of cells:









The numbering of the cells goes in the order in which you started them. To calculate the cell value, press SHIFT + ENTER or right ENTER, or Evaluation -> Evaluate Cells.



To refer to the value of the last calculated cell, use the% sign.







Infinite accuracy



One of the great things about Mathematica is the concept of infinite precision. If the result of the calculations is the root of two, then it will write like that.







You can ask to round off the answer like this:







Or add a fractional part (or just a point) to the numbers in the expression:









Entering formulas





In Mathematica implemented a convenient input formulas. But for starters, you may find the palettes useful (Palettes -> Basic Math Assistant is on the right).



Each button on the palette has its own hot keys. For example, to write an integral sign you need to press Esc int Esc.



Here is a list of the most commonly used hotkeys:







Expressions, Lists, Functions





All that is written inside the cells is an expression. Each expression consists of a head and a list. For example, in the expression Power [2, 2]. In it, the head is Power, and the list is 2, 2.

Even 2 + 2 is an expression. To see how Mathematica interprets input, there is a FullForm function:







The Hold function asks the math not to evaluate the expression. The inverse function is Evaluate.



Lists in Mathematica are created with curly braces: {...}, which is an abbreviation of List [...].



For manipulating lists in Mathematica there is a huge pile of functions. All you may ever need is already there. You just have to find the desired function.



In order to get a list item there is a Part function, with an abbreviated version in the form of double square brackets [[...]] or with thick brackets (Esc [[Esc)



Since everything is an expression (and lists, too), we can get the expression head in this way:







Thus the index of the first item in the list is 1.



It is also possible to replace the head of any expression. This is done by the Apply function [head, expression]. Or its shortened version of @@.







In Mathematica, there are several ways to apply functions (heads) to expressions. These are the usual square brackets: f [x], prefix: f @ x, postfix: x // f







As well as infix: from x ~ f ~ y we get f [x, y].



Single line programming



In Mathematica there are many functions for ordinary programming, such as For, If, Switch. However, it is better not to use them unless absolutely necessary. Since almost all of the same can be done in one line with the help of special functions and their combination (at first it can be difficult to adapt to this programming style).



Here is a good video demonstrating how some of the functions work:







Dynamic interactive computing



One of Mathematica 's great features is dynamic computation. They allow you to manipulate data and look at how the result dynamically changes.



For dynamic calculations, the functions Dynamic, Manipulate, etc. are used.







Conclusion



In the article I talked about the main aspects of work in Mathematica . There are also several other important points, such as patterns, modules, kernels. I will tell about them next time if this topic is interesting for you.



PS Tell me about all the errors found in PM.



UPDATE

Pictures disappeared. Restored post on my blog elfet.ru/introduction-to-wolfram-mathematica

Source: https://habr.com/ru/post/180925/



All Articles