Mathematical and Programming Ability - Revision Notes (5) (1)
Mathematical and Programming Ability - Revision Notes (5) (1)
In mathematics, a function is a relation that uniquely assigns a single output for each input
element. Functions are fundamental in both algebra and calculus for describing and
managing variable relationships.
○ Linear Function f(x)=mx+b where mmm is the slope and b is the y-intercept.
● Derivatives: Measure how a function's output changes as its input changes. The
derivative of a function at a point quantifies the instant rate of change at that point.
○ Example: For f(x)=𝑥 2 , the derivative f′(x) is 2x. This tells us that for each unit
increase in x, the value of f(x) increases by 2x.
○ Definite Integral: Gives the area under the curve of a function between two
𝑏
points. If f(x) is defined from a to b, the integral is written as ∫𝑎 𝑓(𝑥) 𝑑𝑥.
𝑠𝑖𝑛(𝑥)
○ Example: The limit of as x approaches 0 is 1, crucial for understanding
𝑥
small angle approximations in trigonometry.
Percentages
Percentages are used to express how one quantity relates to another as a fraction of 100.
They are crucial in financial calculations, data analysis, and everyday transactions. Here’s a
detailed look at their applications:
● Calculating Taxes: Sales tax is a percentage added to the original price of goods and
services. Continuing from the previous example, if a 10% tax is then applied to the
discounted price of Rs. 90, the tax amount would be 10% of Rs. 90, or Rs. 9. Thus,
the final price after tax would be Rs. 90 + Rs. 9 = Rs. 99.
Area Calculation
Calculating the area is essential in various practical fields such as construction, interior
design, and land assessment. Here’s how to perform basic area calculations:
● Example Problem: Tile Fitting: To determine how many tiles are needed to cover a
floor, divide the total area of the floor by the area of one tile. Ensure that all
measurements are in the same unit.
● Unit Conversions: Often, it’s necessary to convert units for accurate calculations. In
tiling, measurements might be given in inches, requiring conversion to feet (12
inches = 1 foot) or meters, depending on the standard unit of measure in your
region.
Probability
Basics of Probability
● Sample Space: The set of all possible outcomes of a probabilistic experiment. For a
coin toss, the sample space is {Heads, Tails}.
● Event: A subset of the sample space. An event can include one outcome, multiple
outcomes, or no outcomes at all (the empty set, which has a probability of 0).
Independent Events
When the outcome of one event does not affect the outcome of another, the events are
considered independent. Here’s how probabilities are calculated for independent events:
Combinatorics
● Permutations and Combinations: These are used to calculate the probability of
events where order matters (permutations) and where it does not (combinations).
For instance, choosing 4 students out of 6 to sit on a bench can be calculated using
combinations since the order in which they sit does not matter.
● Examples:
6!
○ Choosing Students: C(6,4) = = 15 ways.
4!(6−4)!
𝑛 𝑛−1
×
𝑛+𝑟 𝑛+𝑟 −1
Linear Algebra
Vectors and Dot Product
Linear algebra is a branch of mathematics that deals with vectors, matrices, and linear
transformations. It is essential in various fields such as engineering, physics, computer
science, and data science. In this section, we'll focus on vectors and one of the
fundamental operations associated with them, the dot product.
Introduction to Vectors
A vector is a mathematical object that has magnitude and direction. Vectors can be used
to represent physical quantities such as force, velocity, and displacement. Here are the
basics:
● Direction: The direction of a vector describes the angle it makes with a reference
direction (like the positive x-axis in a plane).
The dot product is a way of multiplying vectors together to obtain a scalar (a single
number). It is defined as follows:
● Definition: For two vectors a and b, both in 𝑅 𝑛 , their dot product is given by:
a.b=𝑎1 𝑏1 + 𝑎2 𝑏2 +. . . . +𝑎𝑛 𝑏𝑛
● Geometric Interpretation: The dot product of a and b can also be expressed as:
a.b=Magnitude (a) * Magnitude (b) * cos(θ)
where θ is the angle between a and b. This formula shows that the dot product is
proportional to the cosine of the angle between the two vectors, providing a
measure of how "aligned" two vectors are.
Arithmetic Mean
The arithmetic mean, commonly known as the average, is the most widely used measure
of central tendency. It is calculated by adding up all the numbers in a dataset and then
dividing by the count of numbers.
● Formula:
1
Arithmetic Mean(AM) = 𝑛 ∑𝑛𝑖=1 𝑥𝑖
where 𝑥𝑖 represents each value in the dataset, and 𝑛 is the number of values.
● Example: If the test scores for a class are 70, 75, 80, 85, and 90, the arithmetic
mean is:
70+75+80+85+90
= 80
5
This tells us that the average score is 80.
Geometric Mean
The geometric mean is another type of average where you multiply all the numbers
together and then take a root of the product based on the number of values. This mean is
particularly useful when dealing with ratios and percentages because it represents the
central tendency of multiplicative sets of numbers.
● Formula:
1
Geometric Mean(GM) = (∏𝑛𝑖=1 𝑥𝑖 )𝑛
where 𝑥𝑖 are the values in the dataset, and 𝑛 is the number of values.
● Example: For investment returns of 5%, 15%, and 10% over three years, the
geometric mean would be:
1
(1.05 × 1.15 × 1.10)3 ≈ 1.097 or 9.7%
This indicates an average annual return of 9.7%.
Harmonic Mean
The harmonic mean is used when the data is defined in terms of ratios, particularly speeds
or densities, and is the reciprocal of the arithmetic mean of the reciprocals of the data
points.
● Formula:
𝑛
Harmonic Mean(HM) = 1
∑𝑛
𝑖−1 𝑥𝑖
Variables are placeholders used in programming to store data that can vary during the
execution of a program. Different data types allow variables to store different kinds of
information. Here's a quick overview:
● Integers (int): Whole numbers without a fractional component. Used for counts,
indexes, and other discrete quantities.
● Floating-point numbers (float): Numbers that include a decimal point. They are
crucial for representing real numbers in calculations involving precision.
● Strings (str): Sequences of characters used for storing text. They can be
manipulated through operations like concatenation, slicing, and transformation.
● Boolean (bool): Represents truth values, typically denoted by the keywords True
and False. Booleans are often used in control flow to decide which blocks of code
to execute.
● Complex: A number that has a real and an imaginary part, represented as a + bj,
where a is the real part and b is the imaginary part multiplied by the imaginary unit
j.
number = 42 # Integer
Control Structures
Control structures govern the flow of a program and direct how blocks of code are
executed based on conditions or iterations.
○ Conditional Statements: Use if, elif, and else to perform different actions
based on conditions.
else:
print("Normal temperature")
Loops:
○ For Loops: Iterate over a sequence (like a list or a range). Ideal for situations
where the number of iterations is known before the loop begins.
sum += i
while x > 0:
Algorithms
○ Example: Finding the greatest common divisor (GCD) of two numbers using
the Euclidean algorithm.
while b != 0:
a, b = b, a % b
return a
● Properties of Algorithms:
○ Correctness: The algorithm must produce the correct output for any valid
input.
○ Efficiency: Measures how fast the algorithm runs and how much memory it
uses.
○ Functions: Encapsulate a task; they take input, process it, and return an
output.
def square(number):
def factorial(n):
if n == 1:
return 1
else:
return n * factorial(n - 1)