0% found this document useful (0 votes)
14 views126 pages

Chapter 2 Introduction To Mathematica

This document is an introduction to Mathematica, a powerful computational software system developed by Wolfram Research, highlighting its capabilities in symbolic computations, numerical calculations, and data visualization. It covers basic concepts such as arithmetic operations, defining functions, logical operations, and syntax rules, along with practical examples and common errors. The document serves as a foundational guide for users in mathematics, science, engineering, and education to effectively utilize Mathematica for various computations.

Uploaded by

mulawwg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views126 pages

Chapter 2 Introduction To Mathematica

This document is an introduction to Mathematica, a powerful computational software system developed by Wolfram Research, highlighting its capabilities in symbolic computations, numerical calculations, and data visualization. It covers basic concepts such as arithmetic operations, defining functions, logical operations, and syntax rules, along with practical examples and common errors. The document serves as a foundational guide for users in mathematics, science, engineering, and education to effectively utilize Mathematica for various computations.

Uploaded by

mulawwg
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Introduction to Mathematical

Software
Chapter 2: Introduction to Mathematica

Teklebirhan Abraha, PhD


Department of Mathematics
Aksum University
March 12, 2026
Outline
1 Getting Acquainted with Mathematica
2 Basic Concepts
Functions
3 Basic Calculations
Algebraic Manipulation
4 Lists and Table Construction
5 Two and Three Dimensional Graphs
Three-Dimensional and Specialized Plots
6 Solving Equations
7 Algebra and Trigonometry
8 Calculus
Limits
Differentiation
Integration
Multivariate Calculus
Applied Calculus
9 Ordinary Differential Equations
First-Order
T/Birhan ODEs
Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 2 / 126
Introduction to Mathematica

What is Mathematica?
▶ A powerful computational software system developed by Wolfram
Research.
▶ Capable of symbolic computations, numerical calculations, data
visualization, and more.
▶ Used in mathematics, science, engineering, finance, and education.
▶ Combines a computer algebra system with programming and
visualization capabilities.
▶ Based on the Wolfram Language.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 3 / 126
Why Use Mathematica?

Key Capabilities
▶ Symbolic algebra
▶ Numerical computation
▶ 2D and 3D graphics
▶ Data analysis and visualization
▶ Programming and algorithm development
▶ Scientific research and education

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 4 / 126
Using Palettes and Entering Expressions

Palettes Overview
▶ Mathematica allows expressions in natural textbook form.
▶ Palettes help insert mathematical symbols.
▶ The Basic Math Assistant palette is commonly used.
▶ Open it from the Palettes menu.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 5 / 126
How to Start Mathematica

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 6 / 126
Defining Functions in Mathematica

Example Function
√︀
f (x) = x2 + 1

Input
f[x_] := Sqrt[x^2 + 1]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 7 / 126
Basic Concepts: Arithmetic Operations

Standard Operators Multiplication Examples


▶ Addition: + ▶ 2 * 16 or 2 × 16
▶ Subtraction: - ▶ 2 * x or 2x (space between 2
▶ Multiplication: *, ×, or space and x implies multiplication)
▶ Division: / ▶ x * y, x × y, or x y
▶ Exponentiation: ^

Critical Distinction
xy (no space) is a single variable named xy.
x y (with a space) is the product of x and y. The space is essential!

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 8 / 126
Basic Computations

Arithmetic Operations
2 + 3
5 * 4
10/3
2^5
Sqrt[16]

Algebraic Computations
Expand[(x + 2)^3]
Factor[x^2 - 9]
Solve[x^2 - 4 == 0, x]
Simplify[(x^2 - 1)/(x - 1)]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 9 / 126
Defining Functions in Mathematica

Function Concept
A function in Mathematica:
▶ Is defined using a name and arguments.
▶ Requires a Blank ( ) after each argument name on the left-hand side.
This pattern matches any expression.
▶ Can use either = (Set) or := (SetDelayed) for definition.

Most Common Beginner Mistake


Incorrect: f[x] := x^2
Correct: f[x ] := x^2
The underscore ( ) is only used on the left-hand side to indicate a pattern
variable.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 10 / 126
Defining Functions: Examples

Single-Variable Function
Define f (x) = x 3 − 2x:

f[x_] := x^3 - 2x
f[3] (* This returns 21 *)

Multiple Arguments
g[x_, y_] := x^2 + y^2
g[3, 4] (* This returns 25 *)

Every argument on the left-hand side needs a blank ( ) pattern.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 11 / 126
Set (=) vs SetDelayed (:=)

Set (=) SetDelayed (:=)


▶ Evaluates the right-hand side ▶ Evaluates the right-hand side each
immediately. time the function is called.
▶ Stores the resulting value. ▶ Good for dynamic behavior (e.g.,
▶ Good for constants or when the when definition depends on a global
right-hand side won’t change. variable that might change).

▶ Efficient for expensive calculations ▶ Necessary when right-hand side


done once. should be recalculated for each
input.

Comparison Example
f[x_] = D[(x+1) Cos[x], x] (* Derivative computed once at definition *
g[x_] := D[(x+1) Cos[x], x] (* Derivative recomputed for each call *)

In most cases for simple functions, := is the standard choice.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 12 / 126
Constants and Built-in Functions

Table 1: Common Mathematica Constants and Functions


Type Command / Syntax Meaning / Value
Constants Pi or 𝜋 Circle constant (3.14159 . . .)
E or e Base of natural log (2.71828 . . .)
Degree Conversion factor: 𝜋/180
Infinity Infinite quantity (∞)√
I Imaginary unit (i = −1)

Functions Sqrt[x] Square root x
Exp[x] Exponential e x
Log[x] Natural logarithm ln(x)
Log[b, x] Logarithm base b (logb x)
Abs[x] Absolute value |x|
Sin[x], Cos[x], Tan[x] Trig functions (radians)
ArcSin[x], ArcCos[x] Inverse trigonometric functions

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 13 / 126
Logical Relations: = vs. ==

Assignment Operator: = (Set)


A single equal sign = is used for assignment. It stores a value in a
variable.
myResult = 2 + 2
After this command, the variable myResult stores the value 4.

Example
x = 5; (* Assigns the value 5 to x *)
x == 5 (* Asks: is x equal to 5? Returns True *)
x == 4 (* Asks: is x equal to 4? Returns False *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 14 / 126
Logical Comparison Operator: == (Equal)

A double equal sign == is used for comparison. It asks a question: “Are


these two things equal?” and returns either True or False.
Relation Expression Meaning
Equal x == y True if x and y have same value
Unequal x != y True if values are different
Less than x < y True if x is less than y
Greater than x > y True if x is greater than y
Less or equal x <= y True if x ≤y
Greater or equal x >= y True if x ≥y

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 15 / 126
Logical Operations
These operations combine logical expressions (which are either True or
False).

Operation Common Forms Meaning


And (conjunction) And[p,q], p && q, p ∧ q True if both are True
Or (disjunction) Or[p,q], p || q, p ∨ q True if at least one is True
Xor (exclusive or) Xor[p,q] True if exactly one is True
Not (negation) Not[p], !p, ¬p True if p is False
Implies Implies[p,q], p ⇒ q False only if p is True and q is False

Table 2: Combining Logical Statements

Practical Example
x = 7;
x > 5 && x < 10 (* Returns True because both conditions are True *)
x < 5 || x > 10 (* Returns False because neither condition is True *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 16 / 126
Summary: Basic Concepts

Key Takeaways
▶ Arithmetic: Use +, -, *, /, ^. Remember space for multiplication.
▶ Functions: Define with f[x ] := .... The underscore ( ) is crucial.
▶ Constants: Built-in constants start with capitals: Pi, E, I, Degree.
▶ Logic: = for assignment, == for comparison.
▶ Clean Up: Use Clear[var1, var2] to avoid old definitions
interfering.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 17 / 126
Multiplication and Multiple Commands
Three Ways to Multiply
▶ Using a Space: 217 5713 (space is interpreted as multiplication)
▶ Using an Asterisk: 321 * 5.479
▶ Juxtaposition: 2x (when no ambiguity between variable and number)

Multiple Commands in One Cell


▶ A single input cell may contain several commands.
▶ Press Return to start a new line within same cell.
▶ Commands on same line must be separated by semicolons.
▶ Output is suppressed if command ends with semicolon.
▶ If last command lacks semicolon, its result is displayed.

a = 17/13 + 211/93; (* output suppressed *)


b = 23 a; (* output suppressed *)
c = (a + b)/51 (* result displayed *)

Only the value of c will be shown.


T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 18 / 126
Using Previous Results
Percent Symbol for Previous Output
▶ % refers to the last output generated.
▶ %% refers to the second-to-last output.
▶ %n (e.g., %5) refers to output line Out[n].
▶ Recommendation: Avoid using % across separate cells. Assign
results to named variables for reliable code.

Example: Binomial Probability with %


25! (* Out[1] = 15511210043330985984000000 *)
%/(3! 22!) (* Out[2] = 2300 (using Out[1]) *)
% * 0.1^3 * 0.9^22 (* Out[3] = 0.2659 (using Out[2]) *)

Semicolon Rule Recap


A semicolon at end of command suppresses its output. Useful for
intermediate calculations.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 19 / 126
Syntax Rules: Parentheses, Brackets, Braces

Strict Syntax Rules


Mathematica uses different brackets for distinct purposes:
▶ Parentheses ( ): Used only for grouping terms.
▶ Square Brackets [ ]: Used only for function arguments.
▶ Curly Braces { }: Used for defining lists, ranges, and sets.

Correct Syntax Examples


x (x + 2)^2 (* ( ) for grouping: x times (x+2)^2 *)
Cos[Pi/3] (* [ ] for function arguments *)
{1, 2, 3, 4} (* { } for lists *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 20 / 126
Common Syntax Errors

These expressions will not work as intended:

@x + y (1 - y)^2 (* @ is not multiplication *)


(1, 2) (* ( ) cannot be used for lists *)
Sin (Pi) (* Missing brackets: should be Sin[Pi]

Note: Sometimes no error is given. For example, p Sin is interpreted as


variable p multiplied by function Sin, which is probably not intended!

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 21 / 126
Exact vs. Numerical Computation
Symbolic by Default
Mathematica computes symbolically (exactly) unless told otherwise:

123/768 (* Returns 41/256, keeping exact fractions *)

Unless forced to approximate, Mathematica keeps exact forms:


Cos [ Pi /12] (* Returns Sqrt [2]*(1+ Sqrt [3]) /4 , not
decimal *)
Log [2] (* Returns Log [2] , not 0.6931 *)

To get a decimal approximation:


N[123/768] (* Returns 0.160156 *)
123./768 (* Decimal point forces numerical evaluation *)
N[Cos[Pi/12], 20] (* Result with 20 digits of precision *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 22 / 126
Built-in Functions and Naming

Capitalization Rule
All built-in objects follow a strict convention:
▶ They begin with a capital letter (e.g., Sin, Plot).
▶ Multi-word names capitalize each word (e.g., FindRoot,
AspectRatio).

Examples of Built-in Functions


Sin[Pi/3] (* Trigonometric function
PrimeQ[22801763489] (* Tests if a number is
Solve[x^2 + x - 12 == 0, x] (* Solves an equation *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 23 / 126
Elementary Functions
Sin[Pi/12], ArcTan[1], ArcCos[1/2], Log[E]

Important:
▶ Inverse trig functions use ”Arc-” prefix (ArcSin, not Sin^-1).
▶ Natural logarithm is Log, not Ln. Log[10, x] gives log10 (x).

Internal Representation: FullForm


Every expression has internal form. Understanding helps with debugging:

FullForm[x + 7] (* Returns Plus[7, x] *)


FullForm[x == x^2] (* Returns Equal[x, Power[x, 2]] *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 24 / 126
Algebraic Manipulation: Expand and Factor
Computer Algebra System (CAS)
Mathematica’s core strength is symbolic manipulation:
▶ Works with expressions symbolically, not just numbers.
▶ Performs exact algebraic computation.
▶ Simplifies, expands, and factors expressions.

Expand Factor
Transforms product into Transforms polynomial into
polynomial (sum of terms). product of factors.

Expand[(x+5)^3 (2x-1)^2] Factor[x^4 - 1]

Converts compact factored form Returns: (x − 1)(x + 1)(x 2 + 1)


into expanded polynomial.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 25 / 126
Rational Expressions: Together and Apart

Together Apart
Combines multiple fractions into Decomposes single fraction into
single fraction with common sum of simpler partial fractions.
denominator.
Apart[1/(x(x+1))]
Together[1/x + 1/(x+1)]

Result:
Result: 1 1

2x + 1 x x +1
x(x + 1)

Note: Together and Apart are inverse operations.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 26 / 126
Simplification: Simplify and FullSimplify

Simplify
Attempts to find simplest algebraic form:

Simplify[(x^2 - 1)/(x - 1)]

Result: x + 1. Tries wide range of algebraic transformations.

FullSimplify
More powerful (but potentially slower) simplifier:

FullSimplify[Sin[x]^2 + Cos[x]^2]

Result: 1. Applies broader set of rules, including trig and special function
identities.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 27 / 126
Exact vs Approximate in Algebra
Exact Arithmetic is Default
Mathematica keeps everything symbolic and exact unless asked for
numbers:
1/3 + 1/6 (*
Returns 1/2 , exact
fraction *)
Expand [( x +1) ^5] (*
Returns exact polynomial
*)

Numerical Approximation
Use N[ ] or decimal point to force numeric result:
N [1/3 + 1/6] (*
Returns 0.5 *)
(3+1) ^5 (*
Returns 1024 , because
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 28 / 126
Common Algebraic Mistakes
Frequent Errors
▶ Mixing decimals with exact: Using 0.5 instead of 1/2 can prevent
symbolic simplifications.
▶ Forgetting Simplify: Mathematica doesn’t auto-simplify; you must
call Simplify.
▶ Using Expand when Factor intended (and vice versa).

Quick Reference Table


Function Purpose
Expand Products → polynomial (multiply out)
Factor Polynomial → products (factor)
Together Multiple fractions → single fraction
Apart Single fraction → partial fractions
Simplify Basic algebraic simplification
FullSimplify Advanced simplification (slower)
N[ ] Convert exact result to numerical approximation
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 29 / 126
Simplification Requires Explicit Command

No Automatic Simplification
Mathematica does not automatically simplify all expressions:
x (3 - x ) - 5 x ^2 + ( x - 1) (2 x + 3)

This returns unsimplified expanded form.

Using Simplify to Clean Up


You must explicitly request simplification:

Simplify[x (3 - x) - 5 x^2 + (x - 1) (2 x + 3)]

Returns simplified result:


−3 + 4x − 4x 2

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 30 / 126
Summary: Basic Calculations

Key Takeaways
▶ Syntax: () for grouping, [] for functions, {} for lists.
▶ Multiple Commands: Separate with ; to suppress output.
▶ Exact vs. Numeric: Mathematica is exact by default. Use N[] for
decimals.
▶ Built-in Functions: Always start with capital letter (e.g., Log, not
ln).
▶ Algebraic Ops: Expand, Factor, Together, Apart, Simplify are
core tools.
▶ Explicit Simplification: Mathematica does not simplify
automatically; you must call Simplify.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 31 / 126
Lists: Introduction

Definition (List)
A list is a collection of elements treated as a single object. In
Mathematica, lists are written using curly braces { }.

Creating Lists
▶ Direct enumeration: {1, 4, 5, 6, 9} (equivalent to
List[1,4,5,6,9]).
▶ Using Range for arithmetic sequences:

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 32 / 126
▶ Range[10] generates

{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}

▶ Range[10,15] generates

{10, 11, 12, 13, 14, 15}

▶ Range[10,15,1/2] generates

{10, 10.5, 11, 11.5, 12, 12.5, 13, 13.5, 14, 14.5, 15}

Key Point
Lists are the fundamental data structure in Mathematica, used for vectors,
matrices, datasets, and plotting coordinates.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 33 / 126
Lists: Accessing Elements
Creating a List
L = {10, 20, 30, 40}

Accessing Elements
Use double square brackets [[ ]] with 1-based indexing:

L[[1]] (* 10 *)
L[[3]] (* 30 *)
L[[-1]] (* 40 *)

Important
▶ Indexing starts at 1, not 0.
▶ Use [[ ]] for indexing.
▶ L[1] is incorrect syntax in Mathematica.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 34 / 126
Operations on Lists: Vectorization

Vectorized Operations
Mathematica automatically applies many operations to every element in a
list.

Examples
L = {10, 11, 12, 13, 14, 15};

L^2
Sqrt[L]
2*L

Range[5]^2

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 35 / 126
The Range Function

Purpose
Range generates arithmetic sequences.

Examples
Range[5]

Range[2,10]

Range[0,1,0.2]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 36 / 126
The Table Function
Purpose
Table evaluates an expression repeatedly for an iterator.

Examples
Squares:

Table[i^2, {i,1,5}]

Equivalent:

Range[5]^2

Fractional step:

Table[Sqrt[x], {x,1,3,0.5}]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 37 / 126
Table: Creating Matrices

Example
Table[i + j, {i,1,3}, {j,1,3}]

Result: ⎛ ⎞
2 3 4
⎝3 4 5 ⎠
4 5 6
Mathematica output:

{{2, 3, 4}, {3, 4, 5}, {4, 5, 6}}

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 38 / 126
The NestList Function

Purpose
NestList repeatedly applies a function and returns all intermediate values.

Example
NestList[#^2 &, 2, 4]

Returns:
{2, 4, 16, 256, 65536}

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 39 / 126
Basic List Operations
Common Functions
▶ Length[L] — number of elements
▶ Total[L] — sum
▶ Max[L] — maximum
▶ Min[L] — minimum
▶ Mean[L] — average

Example
L = {5,2,8,1,9}

Length[L]
Total[L]
Max[L]
Min[L]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 40 / 126
Lists in Plotting

ListPlot
ListPlot[{1,4,9,16,25}]

Plots points: (1,1), (2,4), (3,9), ...

Coordinate Pairs
points = {{1,2},{2,4},{3,9},{4,16}}

ListPlot[points]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 41 / 126
Summary

List Generators
Function Use
{...} Manual lists
Range Numeric sequences
Table General generation
NestList Iterative processes

Exercises
1 Create the first 10 cubes.
2 Create a 5 × 5 identity matrix using Table.
3 Compute iterations of xn+1 = cos(xn ) starting at x0 = 0.5.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 42 / 126
Introduction to Plotting in Mathematica

▶ Mathematica is extremely powerful for creating graphics that help us


visualize and analyze mathematical problems.
▶ One of its major strengths is the ability to easily generate:
▶ Two–dimensional graphs of functions.
▶ Three–dimensional surfaces.
▶ Contour and density plots for functions of two variables.
▶ Specialized plots like bar charts, pie charts, and list plots.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 43 / 126
Introduction to Plotting

The Core 2D Plotting Command: Plot


General Form:

Plot[ f[x], {x, a, b} ]

▶ First argument: The function to plot (as an expression in x).


▶ Second argument: A list containing the variable name, the left
endpoint a, and the right endpoint b.
This generates a 2D graph of y = f (x) for x from a to b.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 44 / 126
Basic 2D Plotting: First Example

Plotting a Simple Function


The basic command for plotting a function is:

Plot[f[x], {x, xmin, xmax}]

Plot[x^2, {x, -5, 5}]

This plots the parabola y = x 2 for −5 ≤ x ≤ 5.


y
20

10
x
−4 −2 2 4

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 45 / 126
Plotting a More Complex Function: Example

(︀ )︀
Graphing f (x) = sin 𝜋x(3 − x) on 0 ≤ x ≤ 3
Plot [ Sin [ Pi x (3 - x ) ] , {x , 0 , 3} ]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 46 / 126
Plotting Multiple Functions on One Graph
Syntax for Multiple Functions
To plot several functions together, provide a list of functions as the first
argument:
Plot [{ f1 [ x ] , f2 [ x ] , f3 [ x ] , ...} , {x , xmin ,
xmax }]

Example
Plot [{ Sin [ x ] , Cos [ x ]} , {x , -2 Pi , 2 Pi }]

This plots both y = sin x and y = cos x on the same axes.


1 y
sin x
0.5 cos x
x
−5 5
−0.5
−1
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 47 / 126
Customizing 2D Graphs: Basic Options
Common Plot Options
▶ PlotStyle -> ... : Controls the appearance of curves (color,
thickness, dashing).
▶ PlotLabel -> "title" : Adds a title above the plot.
▶ AxesLabel -> {"x", "y"} : Labels the x and y axes.
▶ GridLines -> Automatic : Adds a grid to the plot for easier
reading.
▶ PlotRange -> All : Ensures no part of the curve is cropped.

Example with Options


Plot[Sin[x], {x, 0, 2 Pi},
PlotStyle -> {Red, Thick},
PlotLabel -> "Graph of Sin[x]",
AxesLabel -> {"x", "Sin[x]"},
GridLines -> Automatic]
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 48 / 126
More Plot Options: PlotRange and AspectRatio

PlotRange - Controlling the Visible Area


Sometimes parts of a curve are cut off. Use PlotRange to fix this:
▶ PlotRange -> All : Shows all points, even if they go far off the default scale.
▶ PlotRange -> {{xmin,xmax}, {ymin,ymax}} : Sets exact visible ranges for x
and y.

AspectRatio - Controlling Shape Proportions


▶ AspectRatio -> Automatic : Uses the natural scale (useful for circles).
▶ AspectRatio -> 1/GoldenRatio : Default aesthetically pleasing ratio.
▶ AspectRatio -> 1 : Makes the plot square.

Example: Fixing Cropped Curves


Plot[Sin[2 x^2]/(x^2 + 1), {x, 0, 10},
PlotRange -> All]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 49 / 126
The Show Function: Combining Plots
Definition (Show)
Show combines multiple graphics objects (plots) into a single output. This
is useful for overlaying plots created with different options.

Using Show to Combine Plots


plot1 = Plot[x^4, {x, -6, 6}, PlotStyle -> Blue];
plot2 = Plot[Sin[4 x], {x, -2 Pi, 2 Pi}, PlotStyle -> Oran
plot3 = Plot[Cos[x], {x, -2 Pi, 2 Pi}, PlotStyle -> Green]
Show[plot1, plot2, plot3, PlotRange -> All]

This overlays the three plots, respecting the options from each.

Important
Options in Show (like PlotRange) override the options from the individual
plots.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 50 / 126
Advanced Styling: Filling
The Filling Option
Filling shades the area between a curve and a reference (axis, another curve, or a
constant).
▶ Filling -> Bottom fills to the bottom of the plot.
▶ Filling -> Top fills to the top.
▶ Filling -> {1 -> {2}} fills between curve 1 and curve 2.

Filling to Axis Filling Between Curves


Plot[Sin[x], {x, 0, 6 Pi}, Plot[{1 - x^2, 2 - 2 x^2},
Filling -> Axis] {x, -1, 1},
Filling -> {1 -> {2}}]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 51 / 126
Specialized Plots: ListPlot
ListPlot for Discrete Data
ListPlot is used to plot individual data points, not continuous functions.

Two Ways to Use ListPlot


1. List of y-values: Assumes x-coordinates are 1, 2, 3, ...

ListPlot[{2, 4, 9, 16, 25}]

2. List of x,y pairs: Full control over coordinates.

points = {{1, 2}, {2, 3}, {3, 5}, {4, 8}, {5, 12}};
ListPlot[points,
PlotStyle -> {Red, PointSize[Medium]}, AxesLabel -> {"x", "y"}]

Related Functions
▶ ListLinePlot connects the points with lines.
▶ ListPlot3D for 3D data points.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 52 / 126
Specialized Plots: BarChart and PieChart
Mathematica includes many functions for statistical and data visualization.

Pie Chart Bar Chart


PieChart[{5, 3, 4.5, 9}, BarChart[{6, 3, 4, 1, 5},
ChartLabels -> {"A", "B", "C", ChartLabels
"D"}] -> {"2005", "2010",
"2015", "2020", "2025"}]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 53 / 126
Introduction to 3D Plotting: Plot3D

Plotting Functions of Two Variables


The command for plotting a surface z = f (x, y ) is:

Plot3D[f[x, y], {x, xmin, xmax}, {y, ymin, ymax}]

Basic 3D Example
Plot3D[x^2 + y^2, {x, -3, 3}, {y, -3, 3}]

This generates a 3D surface plot of the paraboloid z = x 2 + y 2 .

Multiple Surfaces
Just like in 2D, you can plot multiple surfaces by providing a list:
Plot3D [{ x ^2 + y ^2 , 5 - x ^2 - y ^2} , {x , -3 ,
3} , {y , -3 , 3}]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 54 / 126
Customizing 3D Plots
Common 3D Plot Options
Many 2D options work in 3D, plus some 3D-specific ones:
▶ ColorFunction -> "Rainbow" : Colors the surface by height.
▶ Mesh -> None : Removes the grid lines on the surface.
▶ PlotPoints -> 50 : Increases resolution (slower but smoother).
▶ Boxed -> False : Removes the bounding box.
▶ AxesLabel -> {"x", "y", "z"} : Labels all three axes.

Customized 3D Example
Plot3D[Sin[x y], {x, -3, 3}, {y, -3, 3},
ColorFunction -> "Rainbow",
Mesh -> None,
AxesLabel -> {"x", "y", "z"},
PlotPoints -> 50]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 55 / 126
Example: A Specific 3D Function
Defining and Plotting a Custom Function
f[x_, y_] := x^2 y^2 Exp[-(x^2 + y^2)];
Plot3D[f[x, y], {x, -2, 2}, {y, -2, 2}]

2 +y 2 )
This defines and plots f (x, y ) = x 2 y 2 e −(x .

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 56 / 126
Contour and Density Plots
ContourPlot
ContourPlot shows level curves (lines of constant value) of a function f (x, y ).

ContourPlot[x^2 + y^2, {x, -3, 3}, {y, -3, 3}]

This shows circles (contours) for the paraboloid.

DensityPlot
DensityPlot visualizes a function by coloring regions based on their value (like a
heat map).

DensityPlot[Sin[x y], {x, -3, 3}, {y, -3, 3}]

Use Case
Contour and density plots are excellent for visualizing functions of two variables
without the complexity of a full 3D surface.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 57 / 126
Parametric Plots

ParametricPlot (2D)
Plots curves defined parametrically as (x(t), y (t)).

ParametricPlot[{Cos[t], Sin[t]}, {t, 0, 2 Pi},


PlotStyle -> {Thick, Orange}]

This draws a circle.

ParametricPlot3D (3D)
Plots curves or surfaces defined parametrically in 3D.

ParametricPlot3D[{Cos[t], Sin[t], t/5}, {t, 0, 10 Pi}]

This draws a helix.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 58 / 126
Interactive Plots with Manipulate

Manipulate for Dynamic Exploration


Manipulate creates an interactive interface where you can adjust
parameters in real-time.

Example: Exploring Sine Waves


Manipulate [ Plot [ A Sin [ k x ] , {x , 0 , 2 Pi } ,
PlotRange -> { -2 , 2}] ,
{A , 0 , 2} , (* Amplitude slider from 0 to 2 *)
{k , 1 , 5} (* Frequency slider from 1 to 5 *) ]

This creates a plot with sliders to control amplitude and frequency.

Why Use Manipulate?


It’s perfect for teaching, exploration, and understanding how parameters
affect a function’s behavior.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 59 / 126
Summary: Plotting Commands Reference

Quick Reference Table


Command Purpose
Plot[f[x], {x,a,b}] 2D graph of y = f (x)
Plot[{f1[x],f2[x]}, ...] Multiple 2D curves
Plot3D[f[x,y], {x,a,b}, {y,c,d}] 3D surface z = f (x, y )
ContourPlot[f[x,y], ...] Level curves of f (x, y )
DensityPlot[f[x,y], ...] Colored 2D representation of f (x, y )
ParametricPlot[{x(t),y(t)}, {t,a,b}] 2D parametric curve
ParametricPlot3D[{x(t),y(t),z(t)}, ...] 3D parametric curve
ListPlot[data] Plot discrete data points
ListLinePlot[data] Plot data points connected by lines
BarChart[data], PieChart[data] Statistical charts
Show[plot1, plot2, ...] Combine multiple plots

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 60 / 126
Exercises

sin(x 3 )
1 Plot the function f (x) = on 0 ≤ x ≤ 1 with:
x3
a) No options (the default).
b) PlotRange -> All
c) PlotRange -> All, AspectRatio -> Automatic
What differences do you observe?
2 Create a plot containing y = x 2 and y = x 5 over 0 ≤ x ≤ 2 with:
a) No options.
b) PlotRange -> All
c) PlotRange -> {0,2} (what happens to x 5 ?)
d) PlotStyle -> {Red, Blue}
e) PlotStyle -> {{Red, Thick}, {Blue, Thick}}

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 61 / 126
Exercises

3 Use ContourPlot to visualize the function f (x, y ) = x 2 − y 2 over


−3 ≤ x ≤ 3, −3 ≤ y ≤ 3. What do the level curves look like?
4 Create a 3D plot of the ”witch’s hat” function:
1
f (x, y ) =
1 + x2 + y2
over −3 ≤ x ≤ 3, −3 ≤ y ≤ 3. Experiment with the ColorFunction
option.
5 Use Manipulate to explore the family of functions
f (x) = sin(ax + b) as a and b vary. Let x range from 0 to 4𝜋.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 62 / 126
Introduction to Solving Equations

Why Solve Equations in Mathematica?


▶ Mathematica provides powerful tools for solving mathematical
equations symbolically and numerically.
▶ It can handle:
▶ Algebraic equations (polynomials, rational functions).
▶ Systems of equations (linear and nonlinear).
▶ Transcendental equations (involving trig, log, exp functions).
▶ Differential equations (covered later).

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 63 / 126
Solving Equations: Syntax

Basic Syntax: The Solve Function


General form:

Solve[equation, variable]

Example:
Solve [ x ^2 - 4 == 0 , x ] (* Returns {{ x -> -2} , { x
-> 2}} *)

Critical Syntax Reminder


Equations must use the double equal sign == for logical comparison. A
single equal sign = is for assignment and is a common source of errors.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 64 / 126
Solving Algebraic Equations: Examples
Single Equations
Solve finds exact symbolic solutions when possible.

Linear Equation Quadratic Equation


Solve 2x + 3 = 0: Solve x 2 − 9 = 0:

Solve[2x + 3 == 0, x] Solve[x^2 - 9 == 0, x]

Output: {{x → − 32 }} Output: {{x → −3}, {x → 3}}

Cubic Equation
Solve 2x 3 + 5x 2 − 4x − 3 = 0:

Solve[2x^3 + 5x^2 - 4x - 3 == 0, x]

Output: {{x → −3}, {x → − 21 }, {x → 1}}


T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 65 / 126
Solving Systems of Equations
Multiple Equations, Multiple Variables
To solve a system, provide a list of equations and a list of variables.

Example: Linear System


1 Solve the system: {︃
x + y = 10
2x − y = 5

Solve [{ x + y == 10 , 2 x - y == 5} , {x , y }]

Output: {{x → 5, y → 5}}


2 Solve the system: {︃
x +y =5
x −y =1

Solve [{ x + y == 5 , x - y == 1} , {x , y }]

Output: {{x → 3, y → 2}}


T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 66 / 126
Exact vs. Numerical Solutions

Solve (Exact) NSolve (Numerical)


▶ Finds exact symbolic solutions. ▶ Finds numerical approximations.
▶ Returns expressions with radicals, ▶ Default precision is about 6
fractions, etc. significant digits.
▶ Works for polynomials up to degree ▶ Can handle equations where exact
4 generally. solutions don’t exist.

Solve[x^3 - 2 == 0, x] NSolve[x^3 - 2 == 0, x]

Returns: Returns: {{x → 1.25992}, {x →


{{x → 21/3 }, {x → −(−1)1/3 21/3 }, . . . } −0.62996 + 1.09112i}, . . . }

Numerical Precision
To get more digits, specify precision:

NSolve[x^3 - 2 == 0, x, 20] (* 20-digit precision *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 67 / 126
The FindRoot Function
Purpose
FindRoot finds a numerical root of an equation starting from an initial guess. It is
useful when:
▶ No closed-form solution exists (e.g., cos(x) = x).
▶ You only need one root near a specific point.
▶ Solve or NSolve are too slow or fail.

Syntax and Example


FindRoot[equation, {variable, initial_guess}]

Find a root of x 3 − 2x + 1 = 0 near x = 1:

FindRoot[x^3 - 2x + 1 == 0, {x, 1}]

Output: {x → 0.618034}
Solve cos(x) = x near x = 1:

FindRoot[Cos[x]
T/Birhan Abraha, PhD (AKU) == x, {x, 1}] to Mathematica
Introduction March 12, 2026 68 / 126
Working with Solutions: Replacement Rules

Understanding the Output Format


Solve and NSolve return solutions as lists of replacement rules:

{{x -> a1, y -> b1}, {x -> a2, y -> b2}, ...}

Using /. (ReplaceAll) to Extract Values


eq = x^2 - 5x + 6 == 0;
sol = Solve[eq, x] (* {{x -> 2}, {x -> 3}} *)
x /. sol (* {2, 3} *)
x^2 + 2x /. sol (* {8, 15} *)

Complete Workflow
1. Define equation. 2. Solve it, storing the result. 3. Use /. to substitute solutions into
expressions.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 69 / 126
Domains and Conditions

Specifying the Domain


You can restrict solutions to a specific domain (e.g., real numbers).

Examples with Domains


Solve[x^2 + 1 == 0, x] (* Complex solutions: {i, -i} *)
Solve[x^2 + 1 == 0, x, Reals] (* {}, no real solutions *)
Solve[x^2 > 4, x] (* Returns a conditional expression *)
Reduce[x^2 > 4, x] (* x < -2 or x > 2 *)

Reduce vs. Solve


▶ Solve finds specific solutions.
▶ Reduce finds the complete set of conditions that satisfy the equation/inequality.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 70 / 126
Common Mistakes and Summary

Top Mistakes When Solving Equations


1 Using = (assignment) instead of == (equality).
2 Forgetting braces {} for systems of equations.
3 Not understanding replacement rules (->) and how to use /..
4 Expecting Solve to find closed-form solutions for all equations (many have none).

Quick Reference
Function Best Used For...
Solve Exact symbolic solutions
NSolve Numerical approximations
FindRoot Numerical root near a guess
Reduce Finding solution conditions
/. (ReplaceAll) Substituting solutions

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 71 / 126
Polynomial Algebra: Core Functions

Working with Polynomials


Mathematica has extensive built-in functions for polynomial manipulation.

Command Purpose
PolynomialQ[poly, x] Tests if poly is a polynomial in x
Variables[poly] Lists all independent variables
Coefficient[poly, x^n] Extracts coefficient of x n
CoefficientList[poly, x] List of coefficients (constant term upward)
Expand[poly] Expands products and powers
Factor[poly] Factors over integers
Collect[poly, x] Groups terms by powers of x
PolynomialQuotient[p,d,x] Quotient of polynomial division
PolynomialRemainder[p,d,x] Remainder of polynomial division

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 72 / 126
Polynomial Examples: Coefficients

Extracting Coefficients
poly = x^3 - 5x^2 + y + 3x y^2 - 7y^3;

▶ Coefficient of x: Coefficient[poly, x, 1] → 3y 2
▶ Coefficient of y 2 : Coefficient[poly, y, 2] → 3x
▶ Coefficient of xy 2 : Coefficient[poly, x*y^
2] → 3

Coefficient List
poly1 = (x + 1)^10;
CoefficientList[poly1, x]

Returns the list of coefficients from constant term to highest power:

{1, 10, 45, 120, 210, 252, 210, 120, 45, 10, 1}

(Note: This corresponds to row 10 of Pascal’s triangle.)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 73 / 126
Polynomial Examples: Factoring

Collecting Terms
poly = 1 + 2x + 3y + 4xy + 5x^2 y + 6x y^2 + 7x^2 y^2;
Collect[poly, x]

Result:1 + 3y + x(2 + 4y + 6y 2 ) + x 2 (5y + 7y 2 )

Factoring
Factor[x^8 - 41x^4 + 400]

Factor[x^8 - 41x^4 + 400, GaussianIntegers -> True]

(−2 + x)(−2i + x)(2i + x)(2 + x)(−5 + x 2 )(5 + x 2 )

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 74 / 126
Rational Functions

Key Commands
▶ Numerator[expr] and Denominator[expr]
▶ Cancel[expr]
▶ Together[expr]
▶ Apart[expr]
▶ ExpandNumerator[expr]
▶ ExpandDenominator[expr]

Examples
Cancel[(x^2 + 5x + 6)/(x^2 + 3x + 2)]
Together[1/(x+1) + 2/(x^2-1)]
Apart[(x^2+5x)/(x^4 + x^3 - x - 1)]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 75 / 126
Trigonometry: Basic Functions

Standard Trigonometric Functions


▶ Sin[x], Cos[x], Tan[x]
▶ ArcSin[x], ArcCos[x], ArcTan[x]
▶ Sec[x], Csc[x], Cot[x]
Angles are interpreted in radians.

Examples
Sin[Pi/4]

Cos[Pi/3]

Tan[Pi/6]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 76 / 126
Trigonometric Simplification

Examples
Simplify [ Sin [ x ]^2 + Cos [ x ]^2]

Cancel [ Sin [ x ]/(1 - Cos [ x ]^2) , Trig -> True ]

Useful Functions
▶ TrigExpand
▶ TrigReduce
▶ TrigFactor

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 77 / 126
Solving Trigonometric Equations

Exact Solutions
Solve [ Sin [ x ] == 1/2 , x ]

Result {︂ }︂
𝜋 5𝜋
x → + 2𝜋C [1], x → + 2𝜋C [1]
6 6

Numerical Solution
FindRoot [ Sin [ x ] == 0.5 , {x ,1}]

Result
{x → 0.523599}

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 78 / 126
Graphing Trigonometric Functions

Plot Example
Plot [{ Sin [ x ] , Cos [ x ]} , {x , -2 Pi , 2 Pi } ,
PlotLegends -> { " sin ( x ) " , " cos ( x ) " } ,
AxesLabel -> { " x " , " y " }]

Modified Functions
Plot [{ Sin [ x ] , 2 Sin [ x ] , Sin [ x + Pi /2]} , {x ,
0 , 2 Pi }]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 79 / 126
Summary

Key Ideas
▶ Polynomial manipulation: Expand, Factor, Collect
▶ Rational expressions: Cancel, Together, Apart
▶ Trigonometric identities: Simplify, TrigExpand
▶ Equation solving: Solve, NSolve, FindRoot

Exercises
1 Factor x 6 − 64.
x 2 +3x+2
2 Simplify x 2 +4x+3
.
2 1−cos 2x
3 Verify sin x = 2 .
4 Solve cos x = 0.3 for x ∈ [0, 2𝜋].

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 80 / 126
Overview of Calculus in Mathematica

What Mathematica Can Do


Mathematica provides comprehensive support for calculus, including:
▶ Limits: One-sided, two-sided, and infinite limits.
▶ Differentiation: Ordinary and partial derivatives of any order.
▶ Integration: Indefinite, definite, and multiple integrals (symbolic and
numerical).
▶ Applications: Critical points, area between curves, arc length, and
more.

Key Principle
Mathematica performs calculus symbolically by default. Use N[...] or
NIntegrate for numerical approximations.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 81 / 126
Limits in Mathematica
Basic Limit Syntax
Limit[f[x], x -> a] computes lim f (x)
x→a

One-Sided Limits
Use the Direction option:
▶ Direction -> "FromAbove" or Direction -> -1 for the left-hand limit
(approaching from below).
▶ Direction -> "FromBelow" or Direction -> +1 for the right-hand limit
(approaching from above).
Note: The Direction option can be confusing. Remember: -1 means ”from below” on
the number line, which is the left-hand limit.

|x|
Example: lim
x→0 x
Limit[Abs[x]/x, x -> 0, Direction -> "FromAbove"] →1
Limit[Abs[x]/x, x -> 0, Direction -> "FromBelow"] → −1
Limit[Abs[x]/x, x -> 0] → Indeterminate
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 82 / 126
Introduction to Differentiation

The derivative measures the rate of change or the slope of a function at a


point.

Three Ways to Compute Derivatives


1 Prime notation: f’[x], f’’[x], ... (for functions defined with f[x ]:=...)
2 D notation (single variable):
▶ D[f[x], x] (first derivative)
▶ D[f[x], {x, n}] (nth derivative)
3 D notation (multivariable):
▶ D[f[x,y], x] (partial derivative with respect to x)
▶ D[f[x,y], {x,2}, {y,3}] (mixed partial: differentiate twice in x,
then three times in y)

Basic Example
D[x^2 + 3x + 5, x] (* 2x + 3 *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 83 / 126
Higher-Order and Partial Derivatives
1 Second and Higher Derivatives
D [ E ^x , x ] (* E ^ x *)
D [ E ^x , {x , 2}] (* Second derivative : E ^ x *)
D [ x ^5 , {x , 3}] (* Third derivative : 60 x ^2 *)

2 Partial Derivatives
D [ x ^2 y + Sin [ x y ] , x] (* Treat y as constant :
2 xy + y Cos [ x y ] *)
D [ x ^2 y + Sin [ x y ] , y] (* Treat x as constant :
x ^2 + x Cos [ x y ] *)

3 Mixed Partials (Clairaut’s Theorem)


D [ x ^2 y ^3 z ^4 , x ] (* 2 x y ^3 z ^4 *)
D [ x ^2 y ^3 z ^4 , {z , 4}] (* 24 x ^2 y ^3 *)
D [ D [ x ^2 y ^3 z ^4 , {z , 4}] , {y , 2}] (* 144 x ^2 y *)
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 84 / 126
Applications of Derivatives
Finding Critical Points
Critical points occur where the first derivative is zero or undefined.

f[x_] := x^3 - 3x^2 + 4;


Solve[D[f[x], x] == 0, x] (* {{x -> 0}, {x -> 2}} *)

Second Derivative Test


Use the second derivative to classify critical points.

D[f[x], {x, 2}] /. {x -> 0} (* -6, so x=0 is a local maximum?


D[f[x], {x, 2}] /. {x -> 2} (* 6, so x=2 is a local minimum *)

Note: A negative second derivative indicates a local maximum; positive


indicates a local minimum.

Visualizing Function and Derivative


Plot[{f[x], f’[x]}, {x, -2, 4}]
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 85 / 126
Introduction to Integration

What is an Integral?
The integral represents the area under a curve (definite integral) or the
antiderivative (indefinite integral).

Basic Integration Syntax


▶ Indefinite integral: Integrate[f[x], x]
▶ Definite integral: Integrate[f[x], {x, a, b}]
▶ Numerical integration: NIntegrate[f[x], {x, a, b}]

Basic Examples
Integrate[3x^2 + 2x + 1, x] (* x^3 + x^2 + x *)
Integrate[3x^2 + 2x + 1, {x, 0, 1}] (* 3 *)

Note: Indefinite integrals do not include the +C constant.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 86 / 126
Definite Integrals and Area

Area Under a Curve


∫︁ b
The definite integral f (x) dx gives the signed area between the curve
a
and the x-axis.

Example: Area under f (x) = x 2 from 0 to 1


Integrate [ x ^2 , {x , 0 , 1}] (* 1/3 *)

Applications
∫︁ b
▶ Area between curves: |f (x) − g (x)| dx
a
∫︁ b
▶ Volume of revolution: 𝜋 [f (x)]2 dx (disk method)
a

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 87 / 126
Applications: Area and Volume

∫︁ b
Area between curves: Area= |f (x) − g (x)| dx
a
Area between f (x) = x and g (x) = x 2 on 0 ≤ x ≤ 1
Integrate [ Abs [ x - x ^2] , {x , 0 , 1}] (* 1/6 *)

∫︁ b
Volume of revolution (Disk method) V = 𝜋 [f (x)]2 dx
a
Volume of solid formed by rotating y = x 2 around the x-axis from x = 0
to x = 1:
Integrate [ Pi ( x ^2) ^2 , {x , 0 , 1}] (* Pi /5 *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 88 / 126
Exact vs. Numerical Integration

Integrate (Exact) NIntegrate (Numerical)


▶ Returns symbolic results ▶ Returns a numerical
(fractions, 𝜋, e, etc.) approximation.
▶ Best when an elementary ▶ Necessary when no closed form
antiderivative exists. exists.
Integrate [ x ^2 E ^(3 x ) , {x NIntegrate [ x ^2 E ^(3 x ) , {
,0 ,1}] x ,0 ,1}]
1
Returns: 27 (−2 + 5e 3 ) Returns: 3.64547

When to Use Each


▶ Use Integrate for exact results and symbolic manipulation.
▶ Use NIntegrate for difficult integrals, or when you only need a
number.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 89 / 126
Improper Integrals

Infinite Limits and Discontinuities


Integrate handles improper integrals automatically.

Examples of Improper Integrals


Integrate[1/x^2, {x, 1, Infinity}] (* 1 *)
Integrate[1/x, {x, 0, 1}] (* Integral does not converge *)
Integrate[1/Sqrt[1 - x^2], {x, 0, 1}] (* Pi/2 *)

Important
Mathematica will indicate if an integral diverges (does not converge to a
finite value).

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 90 / 126
Multivariate Calculus

Partial Derivatives (Review)


Partial derivatives measure the rate of change with respect to one variable
while holding others constant.

Examples with f (x, y ) = x 2 y + y 3


D[x^2 y + y^3, x](* 2xy - derivative with respect to x *)
D[x^2 y + y^3, y](* x^2 + 3y^2 - derivative with respect to y

The Grad Function


The gradient is a vector of all partial derivatives.
Grad [ x ^2 + y ^2 , {x , y }] (* {2 x , 2 y } *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 91 / 126
Multiple Integrals
Syntax for Multiple Integrals
∫︀Integrate[f[x,y], {x, xmin, xmax}, {y, ymin, ymax}] computes
xmax ∫︀ ymax
xmin ymin f (x, y ) dy dx.

Important: Order of Integration


In the Integrate command, the integration is performed from the inner
to outer variable. The first variable listed (x) is the outer integral, and
the last variable listed (y) is the inner integral.
∫︁ b (︂∫︁ d )︂
Integrate[f[x,y], {x,a,b}, {y,c,d}] = f (x, y ) dy dx
a c

Double Integral Example


Integrate f (x, y ) = x + y over the rectangle 0 ≤ x ≤ 1, 0 ≤ y ≤ 1:

Integrate[x + y, {x, 0, 1}, {y, 0, 1}] (* 1 *)


T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 92 / 126
Triple Integrals Example

Setting Up a Triple Integral


Integrate f (x, y , z) = xyz over the region:

0 ≤ x ≤ 2, 0 ≤ y ≤ x, 0 ≤ z ≤ xy

Mathematica Implementation
Integrate[x y z, {x, 0, 2}, {y, 0, x}, {z, 0, x y}]

Result: 4

Interpretation
The limits of integration can depend on outer variables. Here:
▶ y ranges from 0 to x.
▶ z ranges from 0 to xy .
This defines a 3D region.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 93 / 126
Applied Calculus
Area Between Curves
General Approach
1 Find intersection points of the curves.
2 Integrate the difference (top function minus bottom function)
between intersections.

Example: Area between y = x and y = x 2


Solve[x == x^2, x] (* Intersections at x = 0 and x = 1 *)
Integrate[x - x^2, {x, 0, 1}] (* Area = 1/6 *)

Since x ≥ x 2 on [0, 1], we subtract x 2 from x.

Absolute Value for Unsure Order


If you’re unsure which function is on top, integrate the absolute value of
the difference:

Integrate[Abs[x
T/Birhan Abraha, PhD (AKU)
- x^2],Introduction
{x, 0,to Mathematica
1}] (* Also 1/6 *)
March 12, 2026 94 / 126
Arc Length

Arc Length Formula


For a curve y = f (x) from x = a to x = b:
∫︁ b √︁
L= 1 + [f ′ (x)]2 dx
a

Example: Length of y = x 2 from 0 to 1


f[x_] := x^2;
Integrate[Sqrt[1 + (f’[x])^2], {x, 0, 1}](* Exact symbolic res
NIntegrate[Sqrt[1 + (2x)^2], {x, 0, 1}](* Numerical: 1.47894 *

When to Use Numerical Integration


Arc length integrals often lead to expressions that cannot be expressed in
elementary functions. NIntegrate is frequently the practical choice.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 95 / 126
Summary: Calculus in Mathematica

Quick Reference
Operation Command
Limit Limit[f[x], x -> a]
One-sided limit Limit[f[x], x -> a, Direction -> -1]
Derivative (1st) D[f[x], x] or f’[x]
Higher derivative D[f[x], x, n]
Partial derivative D[f[x,y], x]
Gradient Grad[f[x,y], x,y]
Indefinite integral Integrate[f[x], x]
Definite integral Integrate[f[x], x,a,b]
Numerical integral NIntegrate[f[x], x,a,b]
Multiple integral Integrate[f[x,y], x,a,b, y,c,d]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 96 / 126
Practical Exercises: Limits and Derivatives

Limits
Compute the following limits.
Derivatives
x2 − 4
1 Find the derivatives of the
1 lim following functions.
x→2 x − 2
1 f (x) = x 3 + 2x 2 − 5x
sin x
2 lim 2 g (x) = e x sin x
x→0 x 3 h(x) = ln(x 2 + 1)
3x 2 + 5
3 lim 2 2 Find the critical points of
x→∞ x − 1
sin x f (x) = x 4 − 4x 3 + 4x 2 .
4 lim
x→0 x

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 97 / 126
Practical Exercises: Integrals

Compute the Integrals


∫︁
1 x 2 dx
Area Under a Curve
∫︁ 2 1 Find the area under the curve
2 x 2 dx
∫︁0 𝜋 f (x) = x 2
3 sin x dx
∫︁0 𝜋 between x = 0 and x = 3.
2
4 sin x dx exactly and 2 Find the area between
0
numerically. y = sin x and y = cos x from 0
∫︁ ∫︁ to 𝜋/2.
5 (x 2 + y 2 ) dA where R is
R
the rectangle [−1, 1] × [−1, 1].

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 98 / 126
Practical Exercises: Applications of Calculus

Graphing Functions
1 Plot f (x) = x 3 − 3x
2 Plot g (x) = sin x
3 Plot both functions on the same axes.

Optimization
Find the maximum and minimum values of

f (x) = x 3 − 6x 2 + 9x + 1

on the interval [0, 4].


1 Compute the derivative.
2 Find the critical points.
3 Determine the maximum and minimum values.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 99 / 126
Ordinary Differential Equations (ODEs)

▶ An ordinary differential equation (ODE) involves derivatives of a


function with respect to a single independent variable.
▶ General form: F (x, y , y ′ , y ′′ , . . . , y (n) ) = 0
▶ ODEs model many phenomena such as population growth, motion,
circuits, and heat transfer.

Key Terminology
▶ Order: Highest derivative appearing in the equation.
▶ Degree: Power of the highest derivative after rationalization.
▶ Linear ODE: an (x)y (n) + · · · + a1 (x)y ′ + a0 (x)y = g (x)

Example
For y ′′ + 3y ′ + 2y = 0
▶ Order: 2, Degree: 1, Linear: Yes
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 100 / 126
Solving ODEs in Mathematica

Main Commands
DSolve Finds symbolic solutions.
NDSolve Computes numerical solutions.

General Syntax
DSolve [ ode , y [ x ] , x ]
Important Syntax
▶ Equations use == DSolve [{ ode , conditions
▶ Derivatives are written as },
y’[x], y’’[x] y[x], x]

▶ Solutions are returned as NDSolve [{ ode , conditions


replacement rules },
y , {x , a , b }]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 101 / 126
First-Order ODE Examples

Separable Equation
dy
Solve = xy
dx
DSolve [y ’[ x ] == x y [ x ] , y [ x ] , x ]

Solution:
2 /2
y [x] = C [1]e x

Linear First-Order Equation


Solve y ′ + 2y = e x
DSolve [y ’[ x ] + 2 y [ x ] == Exp [ x ] , y [ x ] , x ]

Solution:
1
y [x] = e −2x C [1] + e x
3

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 102 / 126
Initial Value Problems

Exponential Decay Another IVP


dy
= −2y , y (0) = 5 y′ = x + y, y (0) = 2
dx
DSolve [{ y ’[ x ] == -2 y [ x DSolve [{ y ’[ x ] == x + y [ x
], ],
y [0] == 5} , y [ x y [0] == 2} , y [ x
], x] ], x]

Solution Solution

y [x] = 5e −2x y [x] = −1 − x + 3e x

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 103 / 126
Second-Order Linear ODEs

Homogeneous Equation
y ′′ − 3y ′ + 2y = 0

DSolve[y’’[x] - 3 y’[x] + 2 y[x] == 0, y[x], x]

Solution: y [x] = C [1]e x + C [2]e 2x

Nonhomogeneous Equation
y ′′ + 4y = sin x

DSolve[y’’[x] + 4 y[x] == Sin[x], y[x], x]


1
Solution: y [x] = C [1] cos(2x) + C [2] sin(2x) + sin x
3

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 104 / 126
Systems of Differential Equations

Simple Harmonic Oscillator


{︃
y1′ = y2
y2′ = −y1

DSolve[{y1’[x] == y2[x], y2’[x] == -y1[x]},


{y1[x], y2[x]}, x]

Solution:

y1 = C [1] cos x + C [2] sin x


y2 = C [2] cos x − C [1] sin x

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 105 / 126
Numerical Solution Using NDSolve

Example
y ′ = y − x, y (0) = 1

sol = NDSolve[{y’[x] == y[x] - x, y[0] == 1},


y, {x,0,5}]

Plot the Solution


Plot [ Evaluate [ y [ x ] /. sol ] , {x ,0 ,5}]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 106 / 126
Applications od ODE

Newton’s Law of Cooling


dT
= −k(T − Tenv )
dt
DSolve [T ’[ t ] == -k ( T [ t ] - Tenv ) , T [ t ] , t ]

Solution:
T [t] = Tenv + C [1]e −kt

DSolve [{ T ’[ t ] == -k ( T [ t ] - Tenv ) ,
T [0] == T0 } , T [ t ] , t ]

T [t] = Tenv + (T0 − Tenv )e −kt

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 107 / 126
Logistic Growth Model

dy (︁ y )︁
= ry 1 −
dt K
DSolve [y ’[ t ] == r y [ t ] (1 - y [ t ]/ K ) , y [ t ] , t ]

With y (0) = y0 :

Ky0 e rt
y (t) =
K + y0 (e rt − 1)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 108 / 126
Summary

Mathematica Commands for ODEs


Task Mathematica Command
Symbolic solution DSolve[ode, y[x], x]
Initial value problem DSolve[{ode, cond}, y[x], x]
System of ODEs DSolve[{ode1, ode2}, {y1[x], y2[x]}, x]
Numerical solution NDSolve[{ode, cond}, y, {x, a, b}]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 109 / 126
Exercises

1 Solve y ′ + 2xy = 0.
2 Find the solution of y ′ = y cos x with y (0) = 1.
3 Solve y ′′ + 4y ′ + 4y = 0.
4 Solve y ′′ + 9y = cos(2x).
5 Use NDSolve for y ′ = sin(xy ), y (0) = 1.
6 Solve the system

x ′ (t) = y (t), y ′ (t) = −x(t)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 110 / 126
Introduction to Linear Algebra

▶ Linear algebra is the branch of mathematics dealing with vectors,


vector spaces, and linear transformations.
▶ It provides the mathematical foundation for:
▶ Solving systems of linear equations.
▶ Computer graphics and 3D transformations.
▶ Quantum mechanics and many areas of physics.
▶ Machine learning and data science.
▶ Engineering and optimization problems.

Core Objects in Mathematica


▶ Vectors: Simple lists, e.g., {1, 2, 3}.
▶ Matrices: Lists of lists (rows), e.g., {{1,2}, {3,4}}.
▶ Display: Use //MatrixForm to visualize vectors and matrices in
standard mathematical notation.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 111 / 126
Vectors: Creation and Basic Operations
Creating Vectors
A vector is simply a list of numbers.
u = {1 , 2 , 3};
v = {4 , 5 , 6};
w = {7 , 8 , 9 , 10}; (* vectors can have any length
*)

Basic Vector Operations


▶ Addition: u + v returns {5, 7, 9}
▶ Scalar multiplication: 3 u returns {3, 6, 9}
▶ Dot product: u . v or Dot[u, v] returns 1 * 4 + 2 * 5 + 3 * 6 = 32
▶ Cross product (3D only): Cross[u, v] returns the vector
perpendicular to both.
▶ Visualizing a Vector with MatrixForm: MatrixForm[u]
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 112 / 126
Matrices: Creation and Display
Creating Matrices
A matrix is a list of rows, where each row is a list of equal length.

A = {{1, 2}, {3, 4}}; (* 2x2 matrix *)


B = {{9, 4, 2}, {2, 9, 3}, {0, 1, 4}}; (* 3x3 matrix *)

Viewing Matrices
Use MatrixForm to display matrices in traditional notation:
⎛ ⎞
(︂ )︂ 9 4 2
1 2
A // MatrixForm A= , B = ⎝2 9 3⎠
3 4
B // MatrixForm 0 1 4

Special Matrix Creation Functions


▶ IdentityMatrix[n]: Creates an n × n identity matrix.
▶ DiagonalMatrix[list]: Creates a diagonal matrix with the list elements on the
diagonal.
▶ ConstantArray[c, {m, n}]: Creates an m × n matrix filled with constant c.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 113 / 126
Matrix Operations: Basic Arithmetic

Element-wise Operations
These operations act on each element independently:
▶ Addition/Subtraction: A + B, A - B
▶ Scalar Multiplication: 2 * A
▶ Element-wise Multiplication (Schur/Hadamard product): A * B
▶ Element-wise Power: A^2 squares each element (not matrix
multiplication!)
(︂ )︂
1 2
Example with Matrix A =
3 4
A = {{1,2},{3,4}};
2 * A (* {{2,4},{6,8}} *)
A^2 (* {{1,4},{9,16}} - element-wise *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 114 / 126
Matrix Operations
Core Linear Algebra Operations
▶ Matrix Multiplication (Dot Product): A . B (uses a dot, not an
asterisk!)
▶ Matrix Power: MatrixPower[A, n] for An
▶ Transpose: Transpose[A] or AT
▶ Trace: Tr[A] (sum of diagonal elements)
▶ Determinant: Det[A]
▶ Inverse: Inverse[A]
▶ Row Reduce: RowReduce[A] (reduced row echelon form)

Critical Distinction
▶ A * B is element-wise multiplication.
▶ A . B is matrix multiplication (dot product). Mixing these up is a
very common mistake!
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 115 / 126
Matrix Operations: Examples

Working with Matrices A and B


A = {{9,4,2}, {2,9,3}, {0,1,4}};
B = {{2,8,1}, {8,3,4}, {6,4,0}};

▶ Addition A + B: ▶ Matrix Multiplication A.B:


⎛ ⎞ ⎛ ⎞
11 12 3 62 92 25
⎝10 12 7⎠ ⎝94 55 38⎠
6 5 4 32 19 4

▶ Element-wise A * B: ▶ Determinant:
⎛ ⎞ Det[A] = 269
18 32 2
⎝16 27 12⎠
0 4 0

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 116 / 126
Accessing Matrix Elements
Indexing in Matrices
Matrices use 1-based indexing, just like vectors. Use double brackets [[
]]

Examples with Matrix A


A = {{9,4,2}, {2,9,3}, {0,1,4}};

▶ A[[1]] returns the first row: {9, 4, 2}


▶ A[[2,3]] returns the element in row 2, column 3: 3
▶ A[[All, 2]] returns the entire second column: {4, 9, 1}
▶ A[[1 ;; 2, 1 ;; 2]] returns the top-left 2 × 2 submatrix.

Extracting Parts
▶ First[A], Last[A], Take[A, n], etc., work as with lists.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 117 / 126
Solving Systems of Linear Equations
Matrix Form of a Linear System
A system of linear equations can be written as:

Ax = b

where A is the coefficient matrix, x is the vector of variables, and b is the


constant vector. Example: 2×2 System: Solve:
{︃
x + 2y = 8
3x + 4y = 18

Method 1: Using Solve

Solve[{x + 2y == 8, 3x + 4y == 18}, {x, y}]

Output: {{x → 2, y → 3}}


T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 118 / 126
Solving Linear Systems with Matrices
Method 1: Using the Inverse
If A is invertible, the system Ax = b can be solved as x = A−1 b.

Example: Using Matrix Inverse


A = {{1, 2}, {3, 4}};
b = {8, 18};
Inverse[A] . b (* Output: {2, 3} *)

Method 2: Using LinearSolve (Preferred)


LinearSolve[A, b] computes the solution more efficiently and with
better numerical stability, especially for large systems.

Example: Using LinearSolve


LinearSolve[A, b] (* Output: {2, 3} *)

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 119 / 126
Eigenvalues and Eigenvectors
Definition
For a square matrix A, a scalar 𝜆 and a non-zero vector v satisfying

Av = 𝜆v

are called an eigenvalue and corresponding eigenvector.

Eigenvalues and eigenvectors are fundamental to:

▶ Stability analysis of dynamical ▶ Vibrational modes in


systems. mechanical systems.
▶ Principal Component Analysis ▶ Quantum mechanics (energy
(PCA) in data science. states).
(︂ )︂
4 1 A = {{4, 1}, {2, 3}};
Example For A = :
2 3 Eigenvalues[A](* Returns {5, 2}
Eigenvectors[A](* Returns {{1,
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 120 / 126
Working with Eigenvalues and Eigenvectors

▶ Eigenvalues[A]: Returns a list of eigenvalues.


▶ Eigenvectors[A]: Returns a list of eigenvectors.
▶ Eigensystem[A]: Returns a list {eigenvalues, eigenvectors} in
a single call.
▶ CharacteristicPolynomial[A, x]: Returns the characteristic
polynomial det(A − xI ).

Example with 3×3 Matrix


A = {{9,4,2}, {2,9,3}, {0,1,4}};
Eigensystem[A] // MatrixForm

Displays eigenvalues and corresponding eigenvectors.


CharacteristicPolynomial[A, x] 269 − 142x + 22x 2 − x 3

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 121 / 126
Matrix Norms and Properties
Matrix Norms
Various norms can be computed:
Norm [ A ] (* 2 - norm ( largest singular value ) *)
Norm [A , 1] (* 1 - norm ( maximum column sum ) *)
Norm [A , Infinity ] (* Infinity - norm ( maximum row
sum ) *)
Norm [A , " Frobenius " ] (* Frobenius norm ( sqrt of sum
of squares ) *)

Other Useful Functions


▶ MatrixRank[A]: Rank of the matrix.
▶ NullSpace[A]: Basis for the null space (solutions to Ax = 0).
▶ MatrixConditionNumber[A]: Condition number (sensitivity to
errors).
▶ SingularValueList[A]: List of singular values.
T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 122 / 126
Visualizing Matrices

MatrixPlot
MatrixPlot[A] creates a visual representation of a matrix, with colors
representing values.
A = RandomReal [1 , {10 , 10}];
MatrixPlot [ A ]

This is useful for seeing structure in large matrices.

ArrayPlot
Similar to MatrixPlot, but often used for binary or integer arrays.

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 123 / 126
Summary: Linear Algebra in Mathematica

Quick Reference
Operation Command
Vector/Matrix creation {1,2,3}, {{1,2},{3,4}}
Display //MatrixForm
Addition/Subtraction A + B, A - B
Scalar multiplication c * A
Element-wise multiplication A * B
Matrix multiplication A . B
Transpose Transpose[A]
Determinant Det[A]
Inverse Inverse[A]
Solve linear system LinearSolve[A, b]
Eigenvalues Eigenvalues[A]
Eigenvectors Eigenvectors[A]
Row reduce RowReduce[A]
Matrix rank MatrixRank[A]

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 124 / 126
Exercises
1 Define the vectors u = {1, -2, 3} and v = {-2, 1, 2}. Compute:
a) u+v
b) 3u − 2v
c) u · v (Dot product)
d) u × v (Cross product)
(︂ )︂ (︂ )︂
1 2 2 0
2 Define the matrices A = and B = . Compute:
3 4 1 3
a) A + B
b) A . B (Matrix multiplication)
c) A * B (Element-wise multiplication)
d) Det[A] and Inverse[A]
3 Solve the linear system using Solve and LinearSolve:

⎨x + 2y − z = 3

2x − y + 3z = 8

3x + y − 2z = 1

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 125 / 126
Exercises (Contd)

⎛ ⎞
4 1 0
4 For the matrix C = ⎝1 3 −1⎠:
0 −1 2
a) Find its eigenvalues and eigenvectors using Eigenvalues and
Eigenvectors.
b) Verify that for the first eigenvalue-eigenvector pair, C v = 𝜆v.
c) Compute the characteristic polynomial using
CharacteristicPolynomial.
5 Hilbert Matrices and Precision:
a) Create a 5 × 5 Hilbert matrix: H = HilbertMatrix[5].
b) Compute Det[H] and Inverse[H].
c) Convert the inverse to a decimal using N[...]. What do you observe
about the magnitude of the entries?

T/Birhan Abraha, PhD (AKU) Introduction to Mathematica March 12, 2026 126 / 126

You might also like