# Introduction to Wolfram Mathematica

Mathematica is a computational, mathematics, tool.  It is shipped free with Raspberry Pi. In this blog entry, we will look at some basic functions to get you started quick on the subject.

To fire up Mathematica on Raspberry Pi, either click on the Mathematica icon or on the Wolfram icon for command line interface (see image below). Alternatively, you can run Wolfram from the terminal by typing `wolfram` at the command prompt.

Now that we launched our Mathematica interface, let’s have some fun!

It is a must that you cheer the world from Mathematica, so type `Print["Hello World!"]` at the wolfram prompt. Here is the result:

`````` pi@raspberrypi:~ \$ wolfram
Mathematica 12.0.1 Kernel for Linux ARM (32-bit)
In:= Print["Hello World!"]
Hello World!``````

Next, let’s do some basic arithmetic:

`````` In:= 2 + 3
Out= 5

In:= 33 * 37
Out= 1221

In:= 1/(2+2)
1
Out= -
4``````

Note that for precision purposes Mathematica returned the result of our last expression in fraction format. You can view the numeric equivalent by using the `N[]` function. By default, Mathematica displays the value up to 6 significant figures. However, this can be overridden by specifying the significant places in the `N[]` function. The `(* ... *)` are inline comments. Example:

``````In:= N[1/(2+2)]
Out= 0.25

In:= N[1/3]
Out= 0.333333

In:= N[1/33, 2] (* specify 2 significant places *)
Out= 0.030

In:= N[Sqrt]
Out= 1.41421

In:= N[1/Sqrt]
Out= 0.707107

In:= Sqrt[-25] (* Use of complex numbers *)
Out= 5 I ``````

``````In:= Cos[Pi]
Out= -1

In:= Sin[45 Degree]
1
Out= -------
Sqrt``````

Note that trig functions expect radian values as parameters. You can use degrees as your input by specifying `Degree` in your arguments.

You can also ask Mathematica to simplify or solve any mathematical equation. See examples below.

``````In:= Simplify[Sin[x]^2 + Cos[x]^2]
Out= 1

In:= TrigReduce[Sin[x]^2 + 2 * Cos[x]^2]
3 + Cos[2 x]
Out= ------------
2

In:= Solve[x^2 + 2x + 2 == 0, x]
Out= {{x -> -1 - I}, {x -> -1 + I}}

In:= Solve[ 2*a*x + y == 1 && b*x - y == 3, {x, y}]
4            6 a - b
Out= {{x -> -------, y -> -(-------)}}
2 a + b         2 a + b``````

We end this short and quick overview by plotting some nice graphs.

Clounce hopes that this short and light introduction to Mathematica helps you to get started quickly. Mathematica is much more powerful and complex than described above, and it can be used to solve very simple equations like the ones used above or to solve complex differential equations and advanced physics problems. Enjoy and have fun with mathematics!