Mathematica For The Beginner

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Atcm98''.

nb

MATHEMATICA FOR THE BEGINNER


Tilak de Alwis
Department of Mathematics
Southeastern Louisiana University
Hammond, LA 70402, USA
FMAT1117@SELU.EDU

Abstract
In this tutorial we will explain some elementary aspects of the computer algebra system Mathematica
3.0. The tutorial is mainly divided into five sections : Arithmetic and Numerical Calculations, Algebra,
Calculus, Graphing in Two and Three Dimensions, and Animations. In the first section Arithmetic and
Numerical Calculations, we will cover the topics such as exponentiation, square roots, logarithms,
absolute values, factoring integers, and approximating numbers to arbitrary precision. This section at
the same time provides the user a feel for the syntax of the Mathematica language. In the second
section covering Algebra, we will show how to factor, expand and simplify algebraic expressions. One
highlight in this section is how to use Mathematica to mimic the functional notation. In the same
section, we will show how to solve single equations and systems of equations. In the third section on
Calculus, we discuss differentiation, indefinite and definite integration, and limits of functions. The
fourth section covers one of the most important aspects of the tutorial, Two and Three Dimensional
Graphing. Starting with graphing a simple function, we will discuss in detail very many aspects of
graphing. Among them include various plot options in Mathematica, such as, "PlotStyle",
"AspectRatio", "Axes", "AxesLabel", "Frame", "PlotLabel", etc. We will also explain parametric and
implicit plotting as well. The final section is devoted to showing how to use Mathematica as an
animation tool.

Atcm98''.nb

1.

Arithmetic and Numerical Calculations

1. Fraction calculations

+3 s 2  4 s 5/ s + 2 s 3  +5 s 6/ ^ 2/
414/5

2. Approximations
N#Sqrt#2', 100'
1.414213562373095048801688724209698078569671875376948073176679737990732478\
462107038850387534327641573

3. Approximating other radicals and exponents


N#3 +5/ ^ +1 s 3/  23 ^ 4, 13'
279846.1299278

4. Calculations involving pi and e


N#Pi, 200'
3.141592653589793238462643383279502884197169399375105820974944592307816406\
286208998628034825342117067982148086513282306647093844609550582231725359\
4081284811174502841027019385211055596446229489549303820

N#Exp#1', 100'
2.718281828459045235360287471352662497757247093699959574966967627724076630\
353547594571382178525166427

5. Absolute values
Abs#E  Pi'
-E + Pi

N#%'
0.423311

6. Logarithms

Atcm98''.nb

N#Log#100', 12'
4.60517018599

N#Log#10, E', 12'


0.434294481903

Log#2, 8'
3

7. Trigonometric functions
N#Sin#30''
-0.988032

Sin#30 Degree'
1
2

Cos#Pi s 4'
1
-----------Sqrt[2]

8. Complex numbers

+2  3 I/ +4  2 I/
14 + 8 I

Abs#14  8 I'
2 Sqrt[65]

2.

Algebra

1. Factoring polynomials
Factor#x ^ 8  1'
2
4
(-1 + x) (1 + x) (1 + x ) (1 + x )

Factor#x ^ 12  y ^ 12'
2
2
2
2
2
2
4
2 2
4
(x - y) (x + y) (x + y ) (x - x y + y ) (x + x y + y ) (x - x y + y )

Atcm98''.nb

2. Expanding polynomials.
Expand#+2 x  3 y/ ^ 10'
10
9
8 2
7 3
6 4
1024 x
- 15360 x y + 103680 x y - 414720 x y + 1088640 x y 5 5
4 6
3 7
2 8
1959552 x y + 2449440 x y - 2099520 x y + 1180980 x y 9
10
393660 x y + 59049 y

Factor#%'
10
(2 x - 3 y)

3. Simplifying algebraic expressions


Simplify#x +1  x/  +2 x  3/ ^ 2'
2
9 - 11 x + 5 x

Simplify#1 s +1  x/  1 s +1  x/'
-2
-----------2
-1 + x

3. Evaluating expressions at a given value


2 x^3  3 x^2  4 x  5

s. x ! 3

44

+2 x y/ s Sqrt#x ^ 2  y ^ 2' s. x ! 2.3, y ! 4.3


4.05621

4. Functional notation and evaluating functions


f#x_' : 2 x ^ 2  3 x  5
f#3'
14

g#x_, y_' :

+x  2 y/ s Sqrt#x ^ 2  y ^ 2'

g#3, 4'

-1
5. Making a table of values for a given function

Atcm98''.nb

Table#2 x ^ 2  3,

x,  5, 5, 0.5'

{47, 37.5, 29., 21.5, 15., 9.5, 5., 1.5, -1., -2.5, -3., -2.5, -1., 1.5, 5.
21.5, 29., 37.5, 47.}

6. Summations and products


Sum#i ^ 3  2 i ^ 2  5, i, 1, 12'
4844

Product#2 i  3, i, 1, 12'


71152682225625

7. Solving equations
Solve#3 x ^ 2  2 x  1

0, x'

1
{{x -> -(-)}, {x -> 1}}
3

x s. %
1
{-(-), 1}
3

Solve#x ^ 4  x ^ 3  6 x ^ 2  8 x  16

0, x'

{{x -> -2}, {x -> 1}, {x -> -2 I Sqrt[2]}, {x -> 2 I Sqrt[2]}}

NSolve#+2 x  1/ ^ 2  1

x ^ 3  2 x, x'

{{x -> -0.44949}, {x -> 0.}, {x -> 4.44949}}

FindRoot#+2 x  1/ ^ 2  1

x ^ 3  2 x, x, 6'

{x -> 4.44949}

8. Solving systems of equations


Solve#2 x  3 y

4,

13
14
{{x -> --,
- y -> --}}
17
17

3.

Calculus

1. Derivatives of functions

3 x  4 y

1, x, y'

Atcm98''.nb

D#x ^ 4, x'
3
4 x

D#x ^ 4, x, 2'


2
12 x

Here is another method of finding and evaluating derivatives of a function.


f#x_' : x ^ 4

f'#x'
3
4 x

f''#x'
2
12 x

f'#5'
500

2. Indefinite and definite integrals of functions


Integrate#x ^ 2, x'
3
x
-3

Integrate#x ^ 2, x, 1, 2'


7
3

NIntegrate#Sin#x ^ 2', x, 0, 1'


0.310268

3. Limits of functions
Limit#+x ^ 2  4/ s +x  2/, x ! 2'
4

Limit#1 s x, x ! Infinity'
0

Atcm98''.nb

4.

Graphing Functions

1. Single variable functions - Basic plot command


Plot#x ^ 2, x,

 3, 3'

8
6
4
2
-3 -2 -1

-Graphics-

2. Single variable functions - Plots with styling


Plot#x ^ 2, x,

 2, 2,

PlotStyle ! RGBColor#0.6, 0.4, 0.8''

4
3
2
1
-2

-1

-Graphics-

Plot#x ^ 2, x,

 2, 2,

4
3
2
1
-2

-1

-Graphics-

PlotStyle ! Thickness#1 s 50''

Atcm98''.nb

Plot#x ^ 2, x,  2, 2, PlotStyle !


RGBColor#0.2, 0.6, 0.1',
Thickness#1 s 80', Dashing#0.05, 0.02''
4
3
2
1
-2

-1

-Graphics-

3 . Graphing more than one function


Plot#5  x ^ 2, 2 x  2, x,  4, 4, PlotStyle !
RGBColor#1, 0, 0', Thickness#1 s 90',
RGBColor#0, 0, 1', Thickness#1 s 200''
10
5
-4

-2

-5
-10

-Graphics-

4. Implicit plots

 Graphics`ImplicitPlot`
ImplicitPlot#x ^ 2  y ^ 2
3
2
1
-3 -2 -1
-1
-2
-3

1 2 3

-Graphics-Graphics-

5. Parametric plots

9, x,

 4, 4'

Atcm98''.nb

ParametricPlot#Cos#t', Sin#t', t, 0, 2 Pi'


1
0.5
-1 -0.5
-0.5

0.5

-1

-Graphics-

Show#%, AspectRatio ! Automatic'


1
0.5
-1 -0.5

0.5

-0.5
-1

-Graphics-

6. Graphing two variable functions


Plot3D#x ^ 2  y ^ 2, x,
20
0
-20
-4
4-2
0

 5, 5, y,  5, 5'

4
2
0
-2
2 4 -4

-SurfaceGraphics-

Plot3D#Sin#x ^ 2  y ^ 2' s Sqrt#x ^ 2  y ^ 2', x,

0.4
0.2
0
-0.2
-0.4
-5

5
0

0
-5

-SurfaceGraphics-

 8, 8, y,  8, 8'

Atcm98''.nb

5.

10

Animations

1. Animating a parabola
Do#Plot#k x ^ 2, x,  2, 2, PlotRange !  2, 2,  7, 7,
PlotStyle ! Thickness#1 s 120', RGBColor#1, 0, 0'',
k,  3, 3, 0.5'
6
4
2
-2 -1.5 -1 -0.5
-2

0.5

1.5

-4
-6

2. Cubic polynomials, roots and tangents


4
3
2
1
0

1.251.51.75 2 2.252.52.75 3

-1
-2

3. Animation of a 3-D surface


Do[Plot3D[k*Sin[x^2 + y^2]/Sqrt[x^2 + y^2], {x, -8, 8},
{y, -8,8}, PlotRange -> {-7, 7}], {k, -7, 7, 0.5}]

5
0
-5
-5

5
0

0
-5

You might also like