What is Mathematica?
Mathematica is a general system for computation.
The name "Mathematica" may suggest it's only for math, but this is not the case.
The platform began as a system for doing mathematics by computer,
but it's evolved into the Wolfram Language,
which can be used for ALL types of computation.
Today, we're going to take a tour of Mathematica
and see some of the many different ways it can be used.
When you first start Mathematica, you begin by creating a Notebook.
This is a living computational document and defaults to input/output mode.
You type in an input, and Mathematica gives you the output.
Let's begin by performing some numerical calculations.
>> Let's ask Mathematica to calculate 1/2+5 factorial times sin of pi over 2.
There are several things I'd like to point out in this calculation.
First, the result is exact.
Mathematica does not convert fractions to rounded off decimals - it treats them with infinite precision.
Next, functions in Mathematica are capitalized and use square brackets, not parentheses.
Here's another calculation: Pi to the E power.
Once again, Mathematica returns the exact value.
If you want an approximation, you can ask for it using the N function.
Just enter the number followed by the desired precision.
Algebra is no problem for Mathematica.
For example, if you want to solve a quadratic equation, use the Solve function.
First enter the equation - notice the double equals - and then tell Mathematica which variable
to solve for.
The output may look different than you expect.
This is because Mathematica returns the solutions as a list of substitution rules
which are ready for more computation work.
We'll explore the advantage of this in future lessons.
You can also solve a general quadratic equation with constants A, B, and C.
X is the variable, and the solutions are the two roots you get from the quadratic formula.
Notice we didn't tell Mathematica anything about A, B, or C.
This shows how Mathematica has no problem doing symbolic calculations.
In fact, symbolic computation lies at the heart of Mathematica.
What about systems of equations? No problem.
Again, we'll use the Solve function.
This time, we'll pass in a list of equations, and then a list of the unknown variables.
As always, the solution is exact, and returned in rule form ready for your next computation.
Calculus is also built into Mathematica.
As a demonstration, let's define the function: "sin(2x-1)cos(3x+2)" For now, don't worry
about the underscore and the colon-equals.
We'll explain this syntax in future lessons.
Remember, this is just an overview.
We can now plug numbers into this function.
And to get a sense of how this function behaves, let's graph it using the Plot function.
Just pass in the function, and then a list with the variable, the starting value, and
the stopping value to use in the plot.
If you want, by clicking on the plot, you can resize it.
Let's do a couple of integrals using this function.
Mathematica can compute definite & indefinite integrals.
In both cases, we use the "Integrate" function.
For an indefinite integral, you enter the function and then the independent variable.
For a definite integral, you enter the function and then a list
with the variable, lower bound of integration, and upper bound of integration...
You can also type in commands in standard mathematical notation using keyboard shortcuts or buttons.
This is just the tip of the tip of the iceberg for doing Mathematics in Mathematica, but
the tour must go on.
Next stop - science.
Mathematica gives you access to a world class collection of data for use in your computations.
This data is called the Wolfram Knowledgebase.
For example, in chemistry, you can query the knowledgebase for a specific molecule,
say, the caffeine molecule.
Once you have the molecule, you can plot it using the MoleculePlot function
to help you visualize its structure.
But molecules are not all planar - they live in 3-dimensional space.
For a more realistic image of a caffeine molecule, you can use the MoleculePlot3D function.
And by grabbing the molecule, you can rotate it in 3-dimensional space
to look at it from different angles.
You can compute with entities from all branches of science.
For example, let's request a list of all the planets in our solar system
by calling the EntityList function for the entity type "Planet."
These rounded rectangles are Mathematica's way to display entities.
For programmers, you can think of entities as objects.
These entities have a wide variety of properties associated with them.
You can see what data is available by using the EntityProperties function.
Here are the properties available for each planet.
The sheer volume of research quality data available in Mathematica may feel overwhelming.
Luckily, Mathematica has an autocomplete feature to assist you
so you don't have to memorize all the property names.
For example, let's request the list of all natural satellites around Jupiter.
First we access the Jupiter entity.
Next, enter an open-bracket to trigger the autocomplete feature to see all of the properties
and their names.
If we select the "Satellites" property, then we get a list of Jupiter's satellites.
The Wolfram knowledgebase is vast and growing.
There's financial data...
Geographic data...
Particle physics... and much more...
Mathematica can also import all types of media, including audio, images, and video.
Let's quickly look at how many functions there are that start with the word "Audio."
That's a lot of built-in functions.
And you don't have to import anything to use these.
When you start Mathematica, these functions are all available.
Notice the consistent naming conventions.
Earlier we plotted a function using "Plot"...
Then we plotted a Molecule using "MoleculePlot"...
And if you want to visualize the waveform of an audio file, you use .. AudioPlot!
To demonstrate this, let's import some audio.
You don't have to specify what type of data you're importing.
Mathematica can usually guess from the file extension or data format.
Let's click 'play' for some mood music.
Now that we have an Audio object, we can plot it using AudioPlot.
You can now look at various properties of this audio file.
AudioLength gives you the song length in samples.
The audio sample rate shows you how many samples per second were stored
when recording this music..
And if you divide the length by the sample rate you get the length of the track in seconds:
30 seconds.
If you look at the plot you can see this track IS 30 seconds long.
There are also functions for working with images....
All these audio and image functions can also be used when working with Video.
After all, a video clip is a sequence of images with a collection of audio tracks.
All of these examples we've seen so far use The Wolfram Language.
This is not just another programming language -
it's a computational language that powers Mathematica and many other services.
There are thousands of powerful and versatile functions in The Wolfram Language.
For example, suppose you want to load some JSON data...
an image for analysis...
or a 3D OBJ model.
With the Wolfram Language, you don't have to import special libraries or modules for each type of data.
The "Import" function can handle all three of these cases.
Furthermore, the loaded objects will all use the same underlying principle of expressions.
So you can immediately begin computing with each object.
In future lessons, we will explore the Wolfram Language in more detail,
often comparing it to other languages.
We will focus on the essential functions amidst
the vast collection of thousands of functions built into the Wolfram Language.
Many of our examples will make use of the Wolfram Knowledgebase.
You will soon see that the Wolfram Language is a computational language that's not just for computer scientists -
It was built for everyone.