CMP 233 Note
CMP 233 Note
Computational Science and Numerical Methods is a fundamental course that explores the
mathematical techniques and computational tools used to solve complex numerical problems in
science and engineering. The course provides students with a strong foundation in numerical
applications, this course equips students with the essential skills needed to analyze and solve
computational science since real-world problems often require numerical estimations rather than
exact solutions. Students will learn about different approximation techniques, error analysis, and
also introduced to examine how programming languages handle numerical operations, including
floating-point arithmetic and rounding errors, which can significantly impact computational
accuracy.
algorithms depends on the underlying hardware. This section of the course provides an overview
of how computer processors, memory hierarchies, and parallel computing techniques influence
software, such as MATLAB, Python, and other computational tools that facilitate numerical
and scientific applications. Students will learn numerical techniques such as Gaussian
elimination and LU decomposition for solving these systems efficiently. Related to this is linear
least squares, which is used to approximate solutions in cases where exact solutions do not
Another crucial topic covered in CMP 233 is eigenvalues and singular values, which play a
significant role in various scientific and engineering applications, including stability analysis,
vibration analysis, and machine learning. The course introduces numerical methods for
computing eigenvalues and singular value decomposition (SVD), emphasizing their applications
in real-world problems.
The study of nonlinear equations and their numerical solutions is another critical area of focus.
Many scientific and engineering problems involve nonlinear behavior, and students will explore
iterative methods such as the Newton-Raphson method and other root-finding techniques to
solve these equations efficiently. The course also covers optimization, which is essential in
fields like artificial intelligence, economics, and engineering design. Students will learn about
numerical techniques for finding optimal solutions to constrained and unconstrained problems.
In addition, CMP 233 introduces interpolation and numerical integration and differentiation,
which are fundamental in approximating functions and evaluating integrals when analytical
solutions are impractical. Students will explore various interpolation techniques, including
polynomial and spline interpolation, as well as numerical methods such as the trapezoidal rule
and Simpson’s rule for integration. Numerical differentiation techniques will also be examined,
with a focus on their applications in solving differential equations and modeling dynamic
systems.
COMPUTER ARCHITECHTURE
Computers are a key part of our everyday lives, from the machines we use for work to the
All computers, no matter their size, are based on a set of rules stating how software and hardware
join together and interact to make them work. This is what is known as computer architecture.
encompassing its components, functionality, and the way they interact to execute tasks
efficiently.
It serves as the blueprint that defines the structure, behavior, and performance of a computer. The
field of computer architecture is concerned with aspects such as instruction set design, memory
essential for optimizing system performance, improving hardware efficiency, and developing
A computer system consists of various interconnected components, each playing a crucial role in
CPU
The Central Processing Unit (CPU) is often described as the brain of a computer. It performs
the essential tasks of processing data and executing instructions. A CPU consists of several key
components:
Arithmetic Logic Unit (ALU): This unit performs all arithmetic and logical operations.
Control Unit (CU): The CU directs the flow of data within the CPU and between the
CPU and other hardware components. It fetches, decodes, and executes instructions.
Registers: These are small memory locations within the CPU that temporarily hold data
Cache Memory: A smaller, faster type of volatile memory that provides high-speed data
access to the CPU. It stores frequently accessed data and instructions that improve
processing speed.
The CPU performs a series of functions that facilitate computation and data handling. Here are
Decode: The fetched instruction is translated into a format that the control unit can understand.
This often involves determining the operation to perform and the necessary operands.
Execute: The control unit sends the decoded instruction to the appropriate functional unit (ALU
Store: After execution, the result of the operation may be stored back in a register or written to
memory.
Analogy
class:
1. Fetch (Receiving the Question) – The teacher (Memory) gives a question to the student
2. Decode (Understanding the Question) – The student reads and interprets the question,
figuring out what needs to be done, just like the CPU deciphers the instruction.
3. Execute (Writing the Answer) – The student solves the question and writes down the
answer, similar to how the CPU performs the required computation or operation.
This process repeats continuously as the student receives new questions, understands them, and
Memory plays a vital role in computer architecture, enabling fast access to data and instructions.
RAM (Random Access Memory) – volatile memory i.e it loses data when there is a loss of
power supply
ROM (Read Only Memory) – non-volatile memory i.e does not loss data
Primary memory, or Random Access Memory (RAM), provides temporary storage for active
Cache memory serves as a high-speed intermediary between the CPU and RAM, storing
frequently accessed data to enhance performance. For long-term storage, computers use
secondary storage devices such as Hard Disk Drives (HDDs) and Solid-State Drives (SSDs),
I/O Devices
The input and output (I/O) subsystem allows communication between the user and the computer.
Input devices, such as keyboards and mice, enable users to enter data, while output devices,
The bus system, which includes data, address, and control buses, facilitates data transfer
between the CPU, memory, and I/O devices, ensuring seamless communication.
as an interface between software and hardware. It specifies the instruction formats, addressing
modes, and operations a CPU can perform. ISAs are broadly classified into Complex
Instruction Set Computing (CISC) and Reduced Instruction Set Computing (RISC)
architectures. CISC processors, such as those in Intel’s x86 family, feature a wide range of
complex instructions, reducing the need for multiple machine cycles per instruction. RISC
processors, like those in ARM-based systems, emphasize simplicity and efficiency by using a
small set of instructions, allowing faster execution with fewer cycles per instruction.
defining how hardware and software interact to execute instructions efficiently. There are four
primary types of computer architecture, each with unique design principles, advantages, and use
cases.
This is the most widely used computer architecture, named after John von Neumann. It follows
a single memory structure where both instructions and data share the same memory and
communication path.
Key Characteristics:
Advantages:
Flexible, as the same memory can be used for both instructions and data.
Disadvantages:
Von Neumann bottleneck: Since both data and instructions share the same bus, they
Example Usage:
2. Harvard Architecture
This architecture improves upon the von Neumann model by using separate memory for
instructions and data. It was originally developed for military applications but is now commonly
Key Characteristics:
Advantages:
Reduces bottlenecks as instructions and data do not compete for the same bus.
Disadvantages:
Example Usage:
Real-time systems requiring fast execution (e.g., aerospace and automotive applications).
CISC architecture focuses on reducing the number of instructions a program needs to execute by
Key Characteristics:
Large and complex instruction set, allowing single instructions to perform multiple
operations.
Advantages:
Efficient memory usage since fewer instructions are needed to accomplish a task.
Disadvantages:
cycles.
Example Usage:
x86 processors (used in Intel and AMD CPUs for desktops and laptops).
RISC architecture takes the opposite approach to CISC by using a small, highly optimized set
Key Characteristics:
Disadvantages:
Example Usage:
Comparison Table
Type Organization
computing
Compiler Arithmetic
Introduction
Computers perform arithmetic operations based on strict rules defined by the underlying
hardware and programming language specifications. Unlike human calculations, which can
handle approximations and flexible number formats, compiler arithmetic adheres to fixed
numerical representations, which can lead to unexpected behavior if not carefully managed.
Compiler Arithmetic refers to the set of optimizations and transformations that a compiler
applies to arithmetic expressions in a program during the compilation process. These techniques
help to simplify and speed up the resulting executable code. Essentially, compiler arithmetic
focuses on handling mathematical operations and expressions efficiently so that the program runs
faster and uses fewer resources, especially in terms of time and memory.
By applying these techniques, the compiler can optimize the code to make it more efficient,
ensuring that the program runs faster with less computational overhead.
numerical methods.
Programming languages support different data types, each with a defined range and precision.
Integer Arithmetic
Example:
5÷2=2
Instead of producing 2.5, the result is 2 because integer division discards the decimal part.
Floating-Point Arithmetic
Handles numbers with decimal points.
Example:
This occurs because the binary representation of decimal numbers is not always exact, causing
Since integer data types have fixed storage limits, exceeding these limits leads to overflow or
underflow.
Example:
Assume an 8-bit signed integer (range: -128 to 127). If we add 1 to 127, it overflows and wraps
Type conversion occurs when values of different data types are used in arithmetic operations.
Example:
int a = 5;
float b = 2.0;
Example:
int a = 5;
int b = 2;
Example:
3+5×2
If executed left to right, the incorrect result (16) is obtained. However, compilers follow
3 + (5×2) = 3 + 10 = 13
Here are some common optimizations that fall under compiler arithmetic:
a) Constant Folding
Constant folding is the process of simplifying expressions that involve constant values at
compile time. Instead of performing these computations when the program is running, the
compiler calculates the result ahead of time and directly inserts the constant result into the code.
Example:
int result = 8;
runtime.
b) Constant Propagation
Constant propagation occurs when the compiler recognizes that a variable always holds a
constant value and replaces instances of that variable with the constant. This allows the program
Example:
int x = 10;
directly.
c) Strength Reduction
Strength reduction replaces expensive operations (like multiplication or division) with cheaper
operations (like addition or bit shifting). This is particularly useful for loops where certain
Example:
operation:
multiplying by 4.
code and eliminates them by computing them only once. The result is then reused wherever
necessary.
Example:
int result1 = a * b + a * c;
int result2 = a * b + a * c;
In this optimization, the compiler identifies calculations that do not change within a loop and
moves them outside of the loop. This reduces unnecessary repeated calculations inside the loop,
Example:
result += 3 * i;
}
// The compiler moves `3` out of the loop since it's not
int factor = 3;
result += factor * i;
f) Arithmetic Rewriting
Sometimes the compiler can use mathematical identities to rewrite an arithmetic expression in a
more efficient form. For example, it can apply distributive or associative properties to simplify
expressions.
Example:
int result = a * b + a * c;
Compiler arithmetic plays a crucial role in optimizing a program’s performance. Here’s why:
i. Speed: By simplifying calculations and reducing redundant operations, the program can
run faster. This is especially important for applications that perform complex
mathematical computations.
ii. Efficiency: It helps in reducing the use of CPU resources by eliminating unnecessary
calculations, making the program more efficient in terms of processing power and
memory usage.
based on the target hardware. For example, some processors may perform certain
arithmetic operations faster than others, and the compiler can take advantage of these
hardware features.
arithmetic operations more efficient. By applying techniques like constant folding, common
subexpression elimination, and strength reduction, the compiler can significantly reduce the
time and resources needed for arithmetic operations. Understanding and leveraging compiler
arithmetic can result in faster, more efficient programs, ultimately improving the
Mathematical software plays a pivotal role in a wide array of disciplines, from scientific research
and engineering to education and business analytics. Its primary function is to perform complex
evolved significantly over the years, expanding its capabilities and becoming a central tool in
Initially, mathematical software was relatively simple and specialized for specific tasks. Early
programming languages like FORTRAN were used primarily for numerical simulations, while
more specialized software, such as Macsyma and REDUCE, focused on symbolic algebra. Over
time, however, the development of more comprehensive tools like MATLAB, Mathematica,
numerical methods, and powerful graphical capabilities. These tools are particularly valuable for
One of the most notable trends in the evolution of mathematical software has been the push
Mathematica can be quite expensive, open-source tools like Maxima, SageMath, and Python
(with libraries like NumPy and SciPy) have democratized access to high-powered mathematical
tools. These open-source platforms not only offer free access but also benefit from active user
communities that contribute to the development of new features and provide extensive support.
Choosing the right mathematical software depends on several factors. For example, symbolic
computation tools such as Mathematica and Maple are ideal for tasks involving algebraic
NumPy, and R would be more suitable. These tools provide the necessary functions to handle
large datasets, solve differential equations, and perform optimization or statistical analysis.
The ease of use of mathematical software is another key consideration. Some tools are
educators for teaching and learning purposes. Others, like MATLAB, offer an extensive range of
functions but might require a steeper learning curve, especially for users who are not familiar
with programming. The availability of tutorials, documentation, and user communities can
significantly ease the learning process and enhance the user experience, especially for those
A significant benefit of mathematical software is its ability to integrate with other tools and
platforms, allowing users to expand its capabilities. For instance, MATLAB can interact with C,
C++, or Java, enabling users to run high-performance routines alongside their mathematical
allowing for seamless integration with tools like R, MATLAB, and SciPy. This flexibility is
crucial in real-world applications, where users often need to process large amounts of data or
Cloud computing has also influenced the way mathematical software is used. Cloud-based
platforms like Wolfram Cloud and Google Colab allow users to perform heavy computations
without needing powerful local hardware. Cloud services not only provide the necessary
computational resources but also enable collaboration, making it easier for researchers or teams
to work together on large projects or share results in real time. This development has opened up
new possibilities for mathematical software, particularly in the realm of big data and machine
Looking forward, there are several trends that are likely to shape the future of mathematical
software. For one, machine learning and artificial intelligence are becoming increasingly
integrated into these tools. Many platforms are now equipped with built-in machine learning
algorithms, enabling users to run data analysis and model training seamlessly within the same
environment. Moreover, the push for parallel and distributed computing will continue to drive
the development of more scalable solutions for handling large datasets or complex models.
Despite the many advantages, there are challenges that users must contend with. One of the main
obstacles is the computational demand of some tasks, which can be resource-intensive and slow,
especially when dealing with large datasets or highly intricate simulations. Furthermore,
integrating multiple software tools or working with large, distributed systems can sometimes
introduce compatibility issues, making it difficult to combine the best features of various
platforms.
operations, assist with complex calculations, and support mathematical modeling, analysis, and
visualization. These software packages provide an environment for users to solve problems
ranging from simple arithmetic to complex scientific, engineering, and statistical computations.
physics, finance, and computer science. Below, we discuss the key concepts and types of
This type of software is designed to manipulate mathematical symbols and expressions rather
than just numbers. It can perform operations like simplification, differentiation, integration,
equation solving, and factorization symbolically, providing exact results rather than
approximations. Consider these mathematical expressions for example. Simplify the following:
2x+4
i. 2 Ans. = x +2
2
3 x +6 x x+2
ii. 9x
Ans. = 3
iii.
2
4 x −16 2(x−2)(x+ 2)
iv. 2
4 x +6 x
Ans. = x (x+3)
These tools are designed for performing numerical calculations, especially when exact symbolic
solutions are not possible or practical. They approximate solutions to mathematical problems
c. Statistical Software
Statistical software focuses on the analysis and interpretation of data. These tools can perform
complex statistical analysis, such as hypothesis testing, regression analysis, and data
visualization.
Applications: Performing data analysis in fields like economics, social sciences, and
biological sciences.
These programs help visualize mathematical concepts and data. They often provide graphical
representations of functions, surfaces, curves, and data points, making them useful for
IDEs for mathematical programming provide a complete environment for developing and
running mathematical models. These tools typically support high-level programming languages
for mathematical modeling and allow for integration with other libraries and frameworks.
Examples: Wolfram Mathematica, MATLAB, Julia.
Mathematical software can vary in terms of features and functionalities, but most offer the
following capabilities:
perform operations efficiently, whether it's solving equations, running simulations, or analyzing
large data sets. These algorithms are often fine-tuned for speed and accuracy.
b. Interactive User Interface: Many mathematical software tools come with interactive user
interfaces, allowing users to input mathematical expressions, run commands, and receive results
in a user-friendly format. Some also support visual programming, where users can drag and drop
c. Graphing and Plotting: Graphical visualization tools are commonly integrated into
mathematical software. These tools allow users to plot functions, generate 2D and 3D plots, and
visualize data trends, which is essential in fields like statistics and data science.
support multiple programming languages (e.g., MATLAB uses its own scripting language, but
also supports Python, C, and Java). This makes the software flexible and able to interface with
repetitive tasks and develop custom solutions through scripting languages. This is particularly
useful in research and engineering tasks, where automation can save time and reduce human
error.
Mathematical software is widely used in a range of disciplines and industries. Some common
applications include:
solving differential equations, and optimizing designs. For example, engineers can use
MATLAB for signal processing or finite element analysis (FEA) simulations. Similarly,
physicists use software like Mathematica to analyze complex phenomena in fields such as
In finance, mathematical software plays a crucial role in risk analysis, financial modeling, and
algorithmic trading. It can be used to model stock prices, analyze financial data, and perform
Statistical and numerical tools like R, Python (with libraries like NumPy and Pandas), and
MATLAB are used extensively in data science for data preprocessing, exploratory data analysis,
model training, and evaluation. Machine learning algorithms, optimization methods, and neural
d. Education
Mathematical software is an invaluable tool in teaching and learning mathematics. Programs like
GeoGebra and Wolfram Alpha allow students to experiment with mathematical concepts,
visualize functions, and solve problems interactively. These tools make abstract concepts more
i. Efficiency: Mathematical software can perform complex calculations faster than doing
ii. Accuracy: These tools reduce human error and offer high precision in calculations,
iii. Versatility: Mathematical software can be applied to a wide range of fields, making it
iv. Automation: Automation of repetitive tasks through scripting and programming features
v. Visualization: The ability to graph functions and data points helps users gain deeper
Cost: Some advanced mathematical software, such as MATLAB and Mathematica, can
require significant computational power, which may not be available to all users.
Introduction
A system of linear equations consists of multiple linear equations involving the same set of
variables. These systems are widely used in various fields such as science, engineering,
economics, and computing. They provide essential tools for solving practical problems in
Classification of Systems
A system of linear equations can be classified based on the number of solutions it possesses. If a
system has a unique solution, it is termed consistent and independent. Such a system contains
equations that are not redundant, and their solutions do not depend on one another. On the other
dependent. This scenario arises when some of the equations in the system are merely linear
combinations of others. Lastly, a system that has no solution is known as inconsistent. This
occurs when the equations contradict one another, making it impossible to satisfy all of them
simultaneously.
Various methods exist for solving systems of linear equations, depending on the size and
complexity of the system. These methods can be broadly classified into algebraic techniques and
numerical techniques.
One fundamental approach is the graphical method, which is primarily useful for systems with
two variables. In this method, each equation is represented as a straight line in a coordinate
plane. The point at which the lines intersect corresponds to the solution of the system. However,
this approach becomes impractical when dealing with three or more variables since visualizing
Another widely used method is the substitution method. This technique involves solving one of
the equations for one variable in terms of the others and then substituting this expression into the
remaining equations. By repeatedly applying this process, the system is reduced to a single
equation in one variable, which can then be solved directly. The values obtained are then back-
substituted to find the other variables. Although this method is straightforward, it can become
Example 1:
2 x+5 y =19
x−2 y=−4
Ans . x=2, y=3
Example 2:
2 x+3 y =8
5 x−3 y=−1
Example 3: y=5−2 x
4 x+3 y =13
x=1 , y=3
Example 4:
y=3 x +2
y=7 x −6
x=2 , y=8
Example 5:
2 x+ y=−1
3 x−5 y=−21
Ans .(−2 , 3)
Example 6:
x + y + z=3
x− y +2 z=−4
3 x+ y−z=7
Ans .=(1 ,3 , 1)
The elimination method, also known as the addition method, offers an alternative approach.
Here, the equations are manipulated algebraically to eliminate one of the variables. This is
achieved by multiplying one or more of the equations by appropriate constants to align the
coefficients of one of the variables. The equations are then added or subtracted to cancel out this
variable, reducing the system to a simpler form. This process is repeated until a solution is
obtained. The elimination method is particularly effective for solving small to medium-sized
Example
2 x+3 y =8
5 x−3 y=−1
Example 2:
2 x+5 y =19
x−2 y=−4
For larger and more complex systems, matrix methods provide a systematic and efficient
approach.
One of the most commonly used techniques is Gaussian elimination, which transforms the
system into an equivalent upper triangular form using a series of row operations. Once in this
Step 3: transform the entries below the leading diagonal to be equal to 0, using row reduction
technique
Example:
2 x+ y=−1
3 x−5 y=−21
Ans .(−2 , 3)
Example:
x +2 y−3 z=1
2 x+5 y −8 z=4
3 x+ 6 y−13 z=7
Solving this successfully following the step will the you the result x=−2 , y=0 , z=1
Example
An extension of this method is Gauss-Jordan elimination, which further reduces the system to
reduced row echelon form, allowing direct computation of the solution without requiring back-
substitution.
Step 3: transform the entries below and above the leading diagonal to be equal to 0, using row
reduction technique
x +2 y−3 z=1
2 x+5 y −8 z=4
3 x+ 6 y−13 z=7
Solving this successfully following the step will the you the result x=−2 , y=0 , z=−1
EXERCISE:
x + y + z=3
x− y +2 z=−4
3 x+ y−z=7
Ans .=(1 ,3 , 1)