An Introduction To MATHEMATICA PDF
An Introduction To MATHEMATICA PDF
Srinivasarao Thota
Assistant Professor in Mathematics
National Workshop
on
Computational Methods in Engineering and Mathematics using
MATLAB and MATHEMATICA
(Marudhar Engineering College, Bikaner)
1 Introduction
2 Syntax and Grammar
3 Basic Calculations (Algebra)
4 Solving Equations
5 Basic Calculations (Calculus)
6 Differential Equations
7 Control Structures
8 A Simple Program
9 Some selected toolboxes
1 Addition : 2+2
2 Subtraction : 4-1
3 Multiplication : 3∗2 and also : 3 2
4 Division : 15/2
5 Exponentiation : 42
6 Factorial : 4!
1 a list : {1, 2, 3, 4}
2 a function : f [x, y ]
3 a list element : v [[1]]
4 parentheses for grouping : 2 ∗ (3 + 5)
5 a rule : x− > 5
6 a definition : f [x− ] := 2x + 5
7 an assignment : x = 42
Lists
1 A 3-vector : v = {1, 4, 2}
2 A 2 × 2 matrix : m = {{1, 2}, {3, 4}}
Create a list
1 Range[10]
2 Array[Factorial, 6]
3 Table[x 2 , {x, 4, 12}]
1 Solve[x 2 == 1, x]
2 Solve[{x + 2y == 3, 2x − y == 5}, {x, y }]
3 Solve[{x + 2y == 3, 2x − y == 5}, x, y ]
4 Solve[2x 2 == 3, x]
5 NSolve[2x 2 == 3, x]
6 FindRoot[2x 2 == 3, {x, 3}]
7 Solve[2x 2 == 3 && 5x + 1 == 2, x]
An expression
expr = 2 + 3x + x 2 − Log [x]
Differentiation
1 D[expr, x]
2 D[expr, x, x]
Integration
1 Integrate[expr, x]
2 Integrate[expr, {x, 0, 1}]
3 NIntegrate[expr,{x, 0, 1}]
Numerical methods
NDSolve[{y 0 [x] == y [x], y [0] == 1}, y , {x, 0, 2}]
1 Limit[Sin[x]/x, x− > 0]
2 Limit[1/x, x− > 0, Direction− > 1]
3 Residue[1/x, {x, 0}]
4 ConstrainedMax[x − y , {x < 2y , x < 4}, {x, y }]
5 ConstrainedMin[x − y , {x > 3y , x > 2}, {x, y }]
6 mat = {{1, 2}, {3, 4}}
7 Det[mat]
8 Eigenvalues[mat]
9 Eigenvectors[mat]
multitable[num− ] :=
Module[{i},
Print[num ”multiplication table”];
For [i = 0, i < 10, i + +
Print[num∗i];
];
];
Homogeneous Equations
A homogeneous equation
Exact Equations
P[x− , y− ] := -(5x 2 − 2y 2 + 11)
Q[x− , y− ] := (Sin[y] + 4 x*y + 3)
Simplify[D[P[x, y], y] - D[Q[x, y], x]]
eqn = y’[x] == -P[x, y[x]]/Q[x, y[x]]
sol = DSolve[eqn, y[x], x]