1. Introduction and Survey

In the 21st century computers are in the process of changing all aspects of our lives. That includes also mathematics - both the way we do it and even the kind of problems that interest us. The ability to make computations far beyond anything that was possible without the aid of computers has opened up previously inaccessible areas of research to anyone equipped with a computer,   suitable software and some mathematical knowledge.  This has lead to the creation of sophisticated programs intended for dealing with all aspects of computational mathematics - symbolic manipulation, numerical computation and visualization (including interactive one).  A leading program of this type is Mathematica produced by Wolfram Research. Mathematica is, of course, not only a tool of research and exploring new areas of computational mathematics but also an extremely effective aid in studying traditional ones. The aim of this essay is to give a brief introduction to some of the possibilities offered by this remarkable program. For this purpose we have made use of a number of exmaples, some of which are due to the authors of this text, some have been borrowed from Mathematica’s official  documentation and some from various sources on the Internet.

Basic information about Mathematica

The main web-page

The main website for current information, useful projects, plug-ins, learning center
 and documentation is www.wolfram.com . At this website one can also find a free CDF-Player,  thousands of demonstrations with source files and educational videos.

Mathematica is  one of the most powerful and sophisticated systems for symbolic and numerical computation and visualization. But it is also more than that. Wolfram Research used to describe Mathematica as a “system for doing mathematics by computer” but it has since changed this to “ the only development platform fully integrating computation into complete work-flows”. In other words, Wolfram Research now conceives Mathematica as essentially a universal tool for almost every purpose - symbolic and numerical computation and programming being a central aspect (but this is not the whole story). For example, Mathematica is also an advanced technical typesetting tool, which can produce mathematical documents of quality comparable to TEX and Latex but in a fully WYSIWYG (What You See is What You Get) way. At the same time, these documents can contain “live” mathematical formulas and graphics that can be send to another person (a collaborator, a student or a professor) who can use them to verify the correctness of results or to perform additional computations etc.

In terms of its overall abilities Mathematica currently has no comparable rival (except, perhaps, for suites of several applications). But if we restrict our attention only to computation, there are other programs (e.g. Maple, MatLab and others) that can do similar things. As a mathematical tool, Mathematica is a “general purpose” system. It is very strong in both symbolic and numeric computation. It has very many powerful specialized functions for subjects as different as polynomial algebra, graph theory, statistics of financial mathematics. However, in some areas (particularly in pure mathematics) there are specialized programs (such as MAGMA, Singular, Macaulay2 etc.) which can do some things that Mathematica cannot do without additional programming or can do them  faster (which in certain situations can be crucial).

The official distributor of Mathematica in Poland is the company Gambit <http://www.mathematica.pl>.

Wolfram Research sites and projects

Wolfram Research has a number of sites and projects of interest both  to Mathematica users and the general public:

Mathworld  <http://mathworld.wolfram.com/>

Mathworld is a very useful and extensive web  resource with definitions, examples and main theorems in mathematics (and often  - Mathematica files in the NB format, i.e., Mathematica notebooks .)

Wolfram Alpha  <http://www.wolframalpha.com/>

Wolfram Alpha - Mathematica (and more) for everyone!

Wolfram Demonstrations Project <http://demonstrations.wolfram.com>

Education

Wolfram Research has an extensive educational program. To register for on-line Wolfram Educational Group (WEG) seminars and classes, one can visit  
  <http://www.wolfram.com/services/education/calendar.cgi> 
The Wolfram Education Group (WEG)  offers a wide range of free on-line seminars featuring the latest version of Mathematica  (see http://www.wolfram.com/services/education/seminars/).

There are conferences/master classes/other events in Europe and in particular, in Poland. In Warsaw, ICM (the interdisciplinary center at UW) has Mathematica and  provides  some training.

The Mathematica Journal

The Mathematica Journal <http://www.mathematica-journal.com/> is an on-line journal with research and educational papers.

Other Mathematica related sites

There is an excellent and free introduction to Mathematica programming due to Leonid Shifrin:
http://www.mathprogramming-intro.org/
Also the Mathematica Guidebooks <http://www.mathematicaguidebooks.org/index.shtml> provide a wealth of applications and examples, particularly from physics but also from other areas. Unfortunately the guidebooks are still not fully compatible with Mathematica 6 and later versions so they are only suitable for users who are advanced enough to update the relevant parts themselves.

Finally there is an excellent Mathematica discussion group (known as the MathGroup) 
http://groups.google.com/group/comp.soft-sys.math.mathematica/topics?pli=1
You can ask any questions about any aspect of Mathematica and get a variety of answers from Mathematica experts, including Wolfram Research employees. Sometimes you can even have your math problems solved for you. 
This is really the best Mathematica centered resource on the Web, if you know how to make use of it.

The above is, of course, not intended to be a exhaustive account of Mathematica related resources on the Internet. Far from it, the number of  both general purpose and specialised sites intended for beginners as well as advanced users is huge and constantly increasing (e.g. blog.wolfram.com, Mathematica Tips on Twitter etc).

SELECTED EXAMPLES OF WHAT MATHEMATICA CAN DO

Computational applications

Built-in functions

A large number of problems (even some “real life” ones)  can be solved by simply applying one of Mathematica’s built-in “functions” (the word “function” in connection with Mathematica is used in a somewhat different sense than in mathematics, closer to what in other programming languages is called a “procedure”).  Among the most useful of these functions are Solve and  Reduce. These are very general functions that use a large ensemble of advanced algorithms to solve all kinds of equations and inequalities, many of which would appear unsolvable even to people with good knowledge of mathematics. We will looks at some remarkable examples of the sort of  thing that can be accomplished with Reduce.
(In version 8 the functions Solve became very enhanced and can solve many of the problems that Reduce can, but it often uses somewhat different techniques. Probably the main difference between the two functions is that Reduce always attempts to return the complete solutions of a problem while Solve will in some situations return a partial solution.)

Perhaps the most basic and frequently performed task in mathematics is solving equations. Reduce can be used, of course, to solve equations (and systems of equations) far too complicated to solve by hand. We start by looking at a simple cubic equation, which Mathematica can solve using the famous formula of del Ferro (often attributed to Tartaglia):

Reduce[x^3-x+1==0,x,Cubics->True]

We can also ask Mathematica to compute the real root only:

Reduce[x^3-x+1==0,x,Reals,Cubics->True]

We can compute it’s numerical value to arbitrary precision:

N[%,30]

From the work of Abel and Galois it is known that no solutions of the above kind (in terms of radicals) can be given for polynomial equations of degree higher than 5. However, this does not stop Mathematica :

Reduce[x^5-x+1==0,x]

Again the values can be computed to arbitrary precision:

N[%,30]

Reduce can also deal with purely symbolic problems. For example, consider the quadratic equation a (x^2)+b x+c==0.  Let’s obtain the well known condition for it to have two equal roots.

Reduce[(Subscript[∃, x,a (x^2)+b x+c==0])(Subscript[∀, y,a (y^2)+b y+c==0])x==y,{a,b,c}]

Let’s now try something non-polynomial. Here is a trigonometric equation.  We ask Reduce to solve it for a range of values  in an interval, where there is a finite number of solutions:

Reduce[Cos[x]==Sin[x]&&0<x<2Pi,x]//FullSimplify

We can also obtain a complete solution without a restriction on the domain of solutions.

Reduce[Cos[x]==Sin[x],x]//FullSimplify

Here is an equation that seems impossible to solve by hand, but Reduce can do it:

Reduce[Cos[Cos[x]]==Sin[Sin[x]]&&Abs[x]<1,x]

N[%,10]

All the solutions are complex numbers. Reduce can prove that there are no real solutions:

Reduce[Cos[Cos[x]]==Sin[Sin[x]],x,Reals]

Here is a completely different kind of equation, this time over the integers.

Reduce[n!+n==726&&n>0,n,Integers]

Let’s now try something harder - a “real life” problem. There is an Internet forum, called the MathGroup,  where people post questions about Mathematica, including mathematical questions they try to solve with Mathematica. Solutions are posted by other users including some of the staff of Wolfram Research. One such question was posted by Ivan Smirnov in January 2011 (the whole thread can be found here:  Smirnov’s problem

Are there any integer solutions of (x^10)+(y^10)+(z^10)=(t^2)?

It is easy to find trivial solutions where two of the three variables x,y,z are zero, so let’s look for such solutions. Reduce cannot solve the complete problem but it can quickly verify that there are no solutions for t≤(10^4).

Reduce[x^10+y^10+z^10==t^2&&0≤x&&0<y&&x≤y&&y≤z&&1≤t≤10^4,{x,y,z,t},Integers]//Timing

In fact (after changing certain settings which limit the number of cases Reduce will consider, one can verify that there are no solutions for 1≤t≤(10^10).

Reduce can be very useful in many undergraduate courses. For example, in Analysis 1 one often needs to prove that a certain integer sequence is monotonic. Consider, for example, the problem

Reduce[(n^(1/n))>(((n+1))^(1/(n+1)))&&n>0,n,Integers]

Programming

Although many problems can be solved just by applying built-in functions, in many cases there is no built-in function that will do all the work by itself. In such cases we need to do our own programming. Here are some recent problems taken from the MathGroup.

Find three 2 - digit prime numbers such that :
(i)  The average of any two of the three is a prime number, and
 (ii) The average of all three is also a prime number

There is no Mathematica function that will automatically answer a question like this, but the answer can be found with a few lines of Mathematica code:

ls1=Select[Range[11,99],PrimeQ];
ls2=Tuples[ls1,{3}];
ls3=DeleteCases[Union[Sort/@ls2],{___,x_,___,x_,___}];
Select[ls3,And@@PrimeQ/@Mean/@Partition[#1,2,1,{1,1}]&]

Here is another question from the MathGroup:

What' s the easiest way to determine the length of the repeating cycle for decimal expansions of fractions? For example, 1/7 == 0.14285714285714285714. . .so the length of its repeating cycle
(142857) is 6. For 1/3 the length of the cycle is obviously 1. For some fractions, e.g., 1/4, the decimal expansion is not cyclical (in base 10).

We use programming to define a function lengthOfCycle. We make use of several built-in Mathematica functions, in particular, IntegerExponent and MultiplicativeOrder.  If we could not use these functions the program would have to be much longer, more complicated and less efficient.

lengthOfCycle[x_Rational]:=Module[{n=Denominator[x],a,b},a=IntegerExponent[n,2];
b=IntegerExponent[n,5];MultiplicativeOrder[10,n/(2^a*5^b)]]

lengthOfCycle[1/7]

In certain situations programs written in  Mathematica programming language can be much slower than programs written in typed and compiled languages such as C, Java, etc (although, of course, writing such programs in Mathematica is almost always much quicker). However, for many types of programs this difference can be greatly reduced by “compiling”. Not every kind of Mathematica program can be successfully compiled but when it can, this can make a very big difference to performance. Here is an example where a non-compiled Mathematica program performs rather poorly. We will give only a compiled version, that is very fast. The program constructs an Ulam spiral and is due to Daniel Lichtblau of Wolfram Research:

ulamSpiral=Compile[{{len,_Integer}},Module[{dat=Range[len],x=0,y=0,shift=1,i=0,j=0,xincr={1,0,-1,0},yincr={0,1,0,-1},shiftincr={0,1,0,1}},Select[Table[i++;
If[i≥shift,i=1;shift+=shiftincr[[Mod[j,4,1]]];j++;];
x+=xincr[[Mod[j,4,1]]];y+=yincr[[Mod[j,4,1]]];
If[PrimeQ[dat[[num]]],{x,y},{1000,1000}],{num,len}],Abs[First[#]]<1000&]],{{PrimeQ[_],True|False}}];

Making a spiral with 60 000 points takes only a fraction of a second:

ls=ulamSpiral[60000];//Timing

We can view the spiral as a collection of points:

ListPlot[ls]

or of lines

ListLinePlot[ls]

In Mathematica version 8, this can be speeded up further by using the option CompilationTarget->"C", which however, requires that a C-compiler be installed on the computer.

Specialized Mathematics

Mathematica contains a large number of specialized functions for various areas of mathematics, ranging from Group Theory and Number Theory to Statistics (a vast number of statistical distributions are available as built-in functions) and financial mathematics. A particularly interesting aspect is Mathematica’s ability to obtain live financial data from the Internet and analyze them by means of a variety of specific financial functions. As an example we compare the performance of the value of the index of the American NASDAQ stock exchange (on which most US technology companies are represented) and of Apple Computer Inc.

data1= FinancialData["^IXIC", "Jan. 1, 2007"];

g1=DateListPlot[data1, Joined -> True,PlotLabel->"NASDAQ Composite"];

data2= FinancialData["AAPL", "Jan. 1, 2007"];

g2 = DateListPlot[data2, Joined -> True,PlotLabel->"Apple"];

GraphicsGrid[{{g1,g2}}]

Graphics

Mathematica has remarkable graphic capabilities. Here is an example of a mathematical graphic related to the subject of iteration of functions in the complex plane and “fractals”.

Beyond Graphics - Interactive Dynamics

A completely new set of features, that have nothing quite similar in other programs, appeared in Mathematica 6.  These involve interactive “dynamic” abilities that are difficult to describe in a static format, but can be seen below.

Wolfram Demonstrations Project

It is difficult to describe on a static page how remarkably useful this functionality is in all kinds of situations, including both research and teaching. A single interactive Mathematica notebook can replace dozens of static pictures.

Here we see one example.  It shows the convergence of the power series (∑_(n=1)^∞)((z^n)/(n^k)) on the unit disk (Abs[z])≤1 for k=0,1,2….  Here we only see the case n=1, when the series converges in the unit disk and everywhere on the boundary except at the point z=1. The graphic on the left shows the complex values over the unit disk of a finite sum of terms of the series, on the right we see the values of the analytic function defined by the series. The modulus of the complex values of a function is represented by the height of the graph and the argument by colour. In the first graphic a shorter finite sum is used, in the second a longer. We can see the improvement in the approximation and the singular behaviour at z=1. We can also interactively choose any point on the unit disk and see the modulus of the difference between the values of the corresponding finite sum and the infinite series. Again, this is the sort of thing that would be very difficult to reproduce by other means.

The CDF Format and the CDF Player

With version 8 of Mathematica a new file format for Mathematica files was introduced.

The CDF player makes it easy to use Mathematica in class or at home even when students do not have Mathematica themselves. It is a free program that can be downloaded from Wolfram’s web site.
Wolfram CDF Player

Wolfram Alpha

Wolfram Alpha - Mathematica for everyone!

Wolfram Alpha received a great deal of publicity when it first appeared and it may even be better known than Mathematica,  but not many people seem to realize that Wolfram Alpha is based on Mathematica and, in effect, provides the general public with free access to much of Mathematica’s functionality. Moreover, it does not require learning the Mathematica syntax. Indeed, the most famous aspect of Wolfram Alpha is its ability to use “free form” mathematical input - just type in what you want Wolfram Alpha to do for you in ordinary English (other language input is planned for the future) and Wolfram Alpha will attempt to guess what you want and then will use Mathematica to obtain the answer. In fact, the answers returned my Wolfram Alpha are generally more complete then Mathematica would normally return (they can all be obtained with Mathematica but it may require several commands or even some programming). Here is an example of computing the integral ∫x log(x)dx with Wolfram Alpha. Just type: “indefinite integral of x log(x) “ and you will obtain the output shown below. In versions of Mathematica earlier than 8, a very precise syntax would be needed to obtain the same result (version 8 of Mathematica can also use “free form” input).