Basic Statistics and Data Analysis

Lecture notes, MCQS of Statistics

Introduction to Mathematica

MATHEMATICA originally created by Steven Wolfram, a product of Wolfram Research, Inc. Mathematica is available for different operating systems, such as SGI, Sun, NeXT, Mac, DOS, and Windows. This introduction to Mathematica will help you to understand its use as mathematical and programming language with numerical, symbolic and graphical calculations.

Mathematica can be used as:

  1. A calculator for arithmetic, symbolic and algebraic calculations
  2. A language for developing transformation rules, so that general mathematical relationships can expressed
  3. An interactive environment for exploration of numerical, symbolic and graphical calculations
  4. A tool for preparing input to other programs, or to process output from other programs

Getting Started

Starting Mathematica will open a fresh window or a notebook, where we do all mathematical calculations and do some graphics. Initially windows title is “untitled-1” which can be changed after saving the notebook by name as desired. Mathematica notebook with text, graphics, and Mathematica input and output

mathematica notebook

Entering Expressions

Type 1+1 in notebook and press ENTER key from keyboard. You will get answer on the next line of work area. This is called evaluating or entering the expression. Note that Mathematica places “In[1]:=” and “out[1]=” (without quotation marks) labels to 1+1 and 2 respectively. You will also see set of brackets on the right side of input and output. The inner most brackets enclose the input and output while the outer bracket (larger bracket) groups the input and output together. Each bracket contains a cell. Each time you enter or change the input you will notice that the “In” and “Out” labels will also be changed.

Basic Artihmetic

Mathematica can perform basic operation of additions (+) , subtraction (-), multiplication (*), division (/), exponentiation(^) etc. For example write the following line for basic arithmetic in Mathematica

2*3+4^2
5*6
2(3+4)
(2-3+1)(1+2/3)-5^(-1)
6!

Using Previous Results in Mathematica

Often we need the output of first (previous) calculations in our next (coming) computation. For this purpose % symbol can be used to refer to the output of the previous cell. For example,

2^5
% + 100

Here 2^5 is added in 100.

%% refers to the result before the last results (2nd last).

Exact vs Approximation

Mathematica can gave approximate results; when we need

3^20/2^21 produces $\frac{3486784401}{2097152}$

We can force Mathematica to approximate result in decimal by putting decimal in expression (with any digit or number) such as

3.0^20/ 2^21

For a decimal in number in an expression, Mathematica consider it to be an approximation rather than an exact number.

The Author

Muhammad Imdadullah

Student and Instructor of Statistics and business mathematics. Currently Ph.D. Scholar (Statistics), Bahauddin Zakariya University Multan. Like Applied Statistics and Mathematics and Statistical Computing. Statistical and Mathematical software used are: SAS, STATA, GRETL, EVIEWS, R, SPSS, VBA in MS-Excel. Like to use type-setting LaTeX for composing Articles, thesis etc.

Leave a Reply

Copy Right © 2011-2017 ITFEATURE.COM