This document provides an overview of algorithms and mathematics concepts. It defines an algorithm as a set of steps to solve a problem and lists key properties like unambiguous instructions and finite steps. It also discusses algorithm design techniques like divide-and-conquer. Additionally, the document covers mathematical topics like sets, functions, vectors, matrices, and linear equations that are important for algorithms. It provides examples and definitions for these concepts. Overall, the document serves as an introduction to algorithms and related mathematical foundations.
This document provides an overview of algorithms and mathematics concepts. It defines an algorithm as a set of steps to solve a problem and lists key properties like unambiguous instructions and finite steps. It also discusses algorithm design techniques like divide-and-conquer. Additionally, the document covers mathematical topics like sets, functions, vectors, matrices, and linear equations that are important for algorithms. It provides examples and definitions for these concepts. Overall, the document serves as an introduction to algorithms and related mathematical foundations.
This document provides an overview of algorithms and mathematics concepts. It defines an algorithm as a set of steps to solve a problem and lists key properties like unambiguous instructions and finite steps. It also discusses algorithm design techniques like divide-and-conquer. Additionally, the document covers mathematical topics like sets, functions, vectors, matrices, and linear equations that are important for algorithms. It provides examples and definitions for these concepts. Overall, the document serves as an introduction to algorithms and related mathematical foundations.
Mathematics Compiled By:- Sanjay Patel Assistant Professor, SVBIT. Outline What is an algorithm? Mathematics for Algorithmic Sets Functions and Relations Vectors and Matrices Linear Inequalities and Linear Equations. Sanjay Patel An algorithm is a set of rules for carrying out calculation either by hand or on a machine. An algorithm is a finite step-by-step procedure to achieve a required result. An algorithm is a sequence of computational steps that transform the input into the output. An algorithm is a sequence of operations performed on data that have to be organized in data structures. An algorithm is an abstraction of a program to be executed on a physical machine (model of Computation). What is an algorithm? Sanjay Patel Non-ambiguity:- Each instruction should be clear and precise. Range of input:- Range should be specified. Multiplicity:- sequence of instruction (sequential search method) Speed:- should be efficient and produce fast speed. Finiteness:- performing required operation. Properties of Algorithm Sanjay Patel Brute force:- Straightforward technique Divide-and-conquer:- The problem is divided into smaller instances Dynamic programming:-The result of smaller, reoccurring instances are obtained to solve the problem Greedy technique:- Optimal solution Back tracking:- This method is based on the trial and error. If we want to solve the problem then desired solution is choosen from the finite set S. Algorithm Design techniques Sanjay Patel Time complexity Space complexity Simplicity Generality Range of inputs Analysis of Algorithm Sanjay Patel 1. Multiplication, the American way: Multiply the multiplicand one after another by each digit of the multiplier taken from right to left. The Classic Multiplication Algorithm Sanjay Patel 2. Multiplication, the English way: Multiply the multiplicand one after another by each digit of the multiplier taken from left to right. Contd Sanjay Patel Algorithmic is a branch of computer science that consists of designing and analyzing computer algorithms 1. The design pertain to i. The description of algorithm at an abstract level by means of a pseudo language, and ii. Proof of correctness that is, the algorithm solves the given problem in all cases. 2. The analysis deals with performance evaluation (complexity analysis). Contd Sanjay Patel Two important ways to characterize the effectiveness of an algorithm are its space complexity and time complexity. Time complexity of an algorithm concerns determining an expression of the number of steps needed as a function of the problem size. Asymptotic analysis makes use of the O (Big Oh) notation. (Worst-Case) (Big Theta) notation and (Average Case) (Big Omega) notation. (Best Case) Algorithm's Performance Sanjay Patel A set is a collection of different things (distinguishable objects or distinct objects) represented as a unit. The objects in a set are called its elements or members. If an object x is a member of a set S, we write x S. On the the hand, if x is not a member of S, we write xS. Mathematics for Algorithmic (Sets) Sanjay Patel Function can be defined as the relationship between two sets. That means using function we can may one element of one set to some other element of another set. A function is an relation but relation is not necessarily a function. f(x) = x3 F(2) = 8 F(5) = 125 Functions & Relations Sanjay Patel If D is a set then we can define function as, f(D) = { f(x) | x D } if we map some element to some other element then it can be denoted as. f: D > R i.e. X > x 3 if set D consists of all the real number then D= {1,2,.} is domain. example :- D={1,2,3,4} and f(x)= x 3 Then the range of f will be R={f(1),f(2),f(3),f(4)}= (1,8,27,64) If we take Cartesian product of D and R then we obtain. F= {(1,1),(2,8),(3,27),(4,64)} Basic terminologies of function Sanjay Patel Example: The domain and range of a relation. Relation {(2,9),(3,14),(4,21)} In the relation above the domain is { 2,3,4 } And the range is { 9,14,21} . Function F(x)=x 2 +5. Contd Sanjay Patel Relationship is major aspect between two objects, even this is true in our real life. A relation is any association between elements of one set, called the domain or (less formally) the set of inputs, and another set, called the range or set of outputs. Relation Sanjay Patel Reflexive:- a R a Irreflexive:- a R b Symmetric :- a R b implies b R a Asymmetric:- a R b and b R a implies that a=b Transitive :- a R b and b R c implies a R c Properties of Relation Sanjay Patel Given the above information, determine which relations are reflexive, transitive, symmetric, or antisymmetric on the following - there may be more than one characteristic. (Answers follow.) x R y if 1. x = y 2. x < y 3. x 2 = y 2 4. x y Answers 1. Symmetric, Reflexive and Antisymmetric 2. Transitive 3. Symmetric, Reflexive, Transitive and Antisymmetric (x 2 = y 2 is just a special case of equality, so all properties that apply to x = y also apply to this case) 4. Reflexive, Transitive and Antisymmetric Problem Set Sanjay Patel A vector, u, means a list (or n-tuple) of numbers: u = (u 1 , u 2 , . . . , u n ) where u i are called the components of u. If all the u i are zero i.e., u i = 0, then u is called the zero vector. Given vectors u and v are equal i.e., u = v, if they have the same number of components and if corresponding components are equal Vectors and Matrices Sanjay Patel Contd Sanjay Patel Addition of Two Vectors If two vectors, u and v, have the number of components, their sum, u + v, is the vector obtained by adding corresponding components from u and v. u + v = (u 1 , u 2 , . . . , u n ) + (v 1 , v 2 , . . . , v n ) = (u 1 + v 1 + u 2 + v 2 , . . . , u n + v n ) Multiplication of a vector by a Scalar The product of a scalar k and a vector u i.e., k u , is the vector obtained by multiplying each component of u by k: ku = k(u 1 , u 2 , . . . , u n ) = ku 1 , ku 2 , . . . , ku n Here, we define -u = (-1)u and u-v = u +(-v) It is not difficult to see k(u + v) = ku + kv where k is a scalar and u and v are vectors Dot Product and Norm The dot product or inner product of vectors u = (u 1 , u 2 , . . . , u n ) and v = (v 1 , v 2 , . . . , v n ) is denoted by u.v and defined by u.v = u 1 v 1 + u 2 v 2 + . . . + u n v n The norm or length of a vector, u, is denoted by ||u|| and defined by Contd Sanjay Patel Let A, B, and C be matrices of same size and let k and l be scalars. Then (A + B) + C = A + (B + C) A + B = B + A A + 0 = 0 + A = A A + (-A) = (-A) + A = 0 k(A + B) = kA + kB (k + l)A = kA + lA (kl)A = k(lA) lA = A
Properties of Matrix under Addition and
Multiplication Sanjay Patel Let A, B, and C be matrices and let k be a scalar. Then (AB)C = A(BC) A(B+C) = AB + AC (B+C)A = BA + CA k(AB) = (kA)B = A(kB) Properties of Matrix Multiplication Sanjay Patel The term inequality is applied to any statement involving one of the symbols <, >, , . Example of inequalities are: i. x 1 ii. x + y + 2z > 16 iii. p 2 + q 2 1/2 iv. a 2 + ab > 1 Linear Inequalities and Linear Equations Sanjay Patel 1. If a b and c is any real number, then a + c b + c. For example, -3 -1 implies -3+4 -1 + 4. 2. If a b and c is positive, then ac bc. For example, 2 3 implies 2(4) 3(4). 3. If a b and c is negative, then ac bc. For example, 3 9 implies 3(-2) 9(-2). 4. If a b and b c, then a c. For example, -1/2 2 and 2 8/3 imply -1/2 8/3. Fundamental Properties of Inequalities Sanjay Patel By solution of the one variable inequality 2x + 3 7 we mean any number which substituted for x yields a true statement. For example, 1 is a solution of 2x + 3 7 since 2(1) + 3 = 5 and 5 is less than and equal to 7. By a solution of the two variable inequality x - y 5 we mean any ordered pair of numbers which when substituted for x and y, respectively, yields a true statement. For example, (2, 1) is a solution of x - y 5 because 2-1 = 1 and 1 5. By a solution of the three variable inequality 2x - y + z 3 we means an ordered triple of number which when substituted for x, y and z respectively, yields a true statement. For example, (2, 0, 1) is a solution of 2x - y + z 3. Solution of Inequality Sanjay Patel An inequality in two variable x and y describes a region in the x-y plane (called its graph), namely, the set of all points whose coordinates satisfy the inequality. The y-axis divide, the xy-plane into two regions, called half- planes. Right half-plane The region of points whose coordinates satisfy inequality x > 0. Left half-plane The region of points whose coordinates satisfy inequality x < 0. Similarly, the x-axis divides the xy-plane into two half-planes. Upper half-plane In which inequality y > 0 is true. Lower half-plane In which inequality y < 0 is true. Geometric Interpretation of Inequalities Sanjay Patel One Unknown A linear equation in one unknown can always be stated into the standard form ax = b where x is an unknown and a and b are constants. If a is not equal to zero, this equation has a unique solution x = b/a Two Unknowns A linear equation in two unknown, x and y, can be put into the form ax + by = c where x and y are two unknowns and a, b, c are real numbers. Also, we assume that a and b are no zero. Linear Equations Sanjay Patel 3x + 2y = 8 ------------ (1) 2x - 5y = -1 ------------ (2) Two Equations in the Two Unknowns Sanjay Patel x - 3y - 2z = 6 --- (1) 2x - 4y + 2z = 18 --- (2) -3x + 8y + 9z = -9 --- (3) x = 1, y = -3, z = 2 Three Equations in the three Unknowns Sanjay Patel Gaussian elimination is a method of solving a linear system ax=b (consisting of equations in unknowns) by bringing the augmented matrix, to an upper triangular form and then obtaining a solution by backward substitution method. Gauss Elimination Sanjay Patel Solve the linear system by Gauss elimination method. Sanjay Patel Sanjay Patel Sanjay Patel Solve the linear system by Gauss elimination method. Sanjay Patel http://nptel.iitm.ac.in/courses/Webcourse-contents/IIT-KANPUR/mathematics- 2/node18.html