Document Details

ImpeccableGyrolite4856

Uploaded by ImpeccableGyrolite4856

L-Università ta' Malta

Matthew Montebello

Tags

scalars vectors linear algebra numerical methods

Summary

This presentation introduces the concepts of scalars and vectors, providing a basic overview of linear algebra. The document also covers various operations involving scalars and vectors, and illustrates how they can be applied from a physics and a data science perspective.

Full Transcript

1. Introduction to Scalars and Vectors ARI1103: AI Numerical Methods 1 Professor Matthew Montebello Slides adapted from Dr Ingrid Galea 1 Linear algebra o To formalise concepts, we need to have a set of symbols and a set of rules. These are known as algebra. o In linear algebra, we...

1. Introduction to Scalars and Vectors ARI1103: AI Numerical Methods 1 Professor Matthew Montebello Slides adapted from Dr Ingrid Galea 1 Linear algebra o To formalise concepts, we need to have a set of symbols and a set of rules. These are known as algebra. o In linear algebra, we study vectors and the rules that we need to manipulate these vectors. o But before we dive into vectors… 2 scalars what is a scalar? o A scalar is a single value, 𝑥 1 o E.g. 7, −4, 3 3 https://stickmanphysics.com/stickman-physics-home/one-dimensional-motion/scalars-and-vectors/ vectors what is a vector? o The vectors that we are familiar with from school are geometric vectors, denoted by an arrow above the letter 𝑥Ԧ or in lowercase bold 𝒙. 4 https://stickmanphysics.com/stickman-physics-home/one-dimensional-motion/scalars-and-vectors/ vectors what is a vector? o 3 ways to look at vectors: o Physics way o Maths way o Data science way 5 vectors the physics way o Vectors are arrows pointing in space. o They have magnitude and direction. 6 vectors the maths way o Vectors are quantities that can be added together and multiplied by scalars to produce another object of the same kind. o Two vectors 𝒓 and 𝒔 can be added such that 𝒓+𝒔=𝒕 where 𝒕 is another vector. o For vectors to be added, they must have the same number of elements (size) 7 vectors the maths way o E.g. 3 2 5 o + = −5 8 3 8 vectors the maths way o Vectors can also be added graphically. 3 2 5 o E.g. + = −5 8 3 o Note that 𝒓 + 𝒔 = 𝒔 + 𝒓 (COMMUTATIVE) 9 vectors the maths way o 𝒓+𝒔 +𝒕=𝒓+ 𝒔+𝒕 (ASSOCIATIVE) 3 2 −5 0 o E.g. + + = −5 8 −5 −2 10 10 vectors the maths way o Note that 𝒓 + −𝒓 = 𝟎 2 2 0 o E.g. +− = 8 8 0 11 vectors the maths way 𝟑𝒓 o We can scale a vector by a number. 𝜆𝒙, 𝜆∈ℝ 𝒓 o Multiply each element by the scalar 𝜆. −𝒓 3 o E.g. 𝑟 = 3 3 3 −3 3 = 9 and −1 = 3 9 3 −3 12 vectors the maths way o E.g. 2 1 3 o + = 3 1 4 2 8 o4 = 3 12 13 vectors the maths way o Polynomials are also vectors. o Two polynomials can be added together to give a third polynomial. o A polynomial can also be multiplied by a scalar to give another polynomial. 14 vectors the data science way o Vectors are ordered lists of numbers o They are tuples of 𝑛 real numbers arranged in a row or column, 𝒙 or 𝑥Ԧ 9 1 E.g. is a column vector and 5 −2 8 is a row vector 7 −3 15 vectors the data science way o E.g. If we are analysing the housing market, what features would you expect our vector to include? 100 𝑠𝑞𝑢𝑎𝑟𝑒 𝑚𝑒𝑡𝑟𝑒𝑠 100 2 𝑏𝑒𝑑𝑟𝑜𝑜𝑚𝑠 2 1 𝑏𝑎𝑡ℎ𝑟𝑜𝑜𝑚 1 𝐸𝑢𝑟 150,000 150,000 o This vector has 4 dimensions. 16 vectors the data science way o If we had two identical houses, then 100 200 2 4 2 1 = 2 150,000 300,000 17 vectors vector space o The set of vectors that we get by scaling and/or adding any two vectors is called the vector space. 18 vector modulus o The modulus is the magnitude of the vector. o E.g. Find the modulus of 3 4 19 vector modulus o If our coordinate system is constructed from two orthogonal unit vectors 𝒊Ƹ and 𝒋,Ƹ then 𝒓 = 𝑎𝒊Ƹ + 𝑏𝒋Ƹ 𝒓 = 𝑎2 + 𝑏2 𝑏𝒋Ƹ 𝑏 𝒓 𝒋Ƹ o So, the modulus of 3 4 is … 𝒊Ƹ 𝑎𝒊Ƹ 𝑎 20 vector modulus 𝑎1 o The modulus of a vector that has more than 2 dimensions, 𝒓 = ⋮ , is 𝑎𝑛 𝑎12 + ⋯ + 𝑎𝑛2 o E.g. Find the modulus of 𝒓 = 3 −4 5 2 0 vector modulus exercise 3 0 Let 𝒂 = 0 and 𝒃 = 5. 4 12 Which is larger, |𝒂 + 𝒃| or |𝒂| + |𝒃|? Answer: 𝒂 + 𝒃 |𝒂 + 𝒃| ≤ 𝒂 + 𝒃 for any 𝒂 and 𝒃 the unit vector o A unit vector has its modulus equal to 1 o We can obtain the unit vector by normalizing o To normalize a vector, divide all the vector elements by the vector modulus 4 1 4 1 4 o E.g. Normalise = =5 3 16+9 3 3 Why Normalize a Vector? Direction without magnitude: Normalizing gives you a direction vector without changing the relative direction. Unit vectors: Many operations in mathematics, physics, and computer science (like defining a direction or working in vector spaces) often require unit vectors. Simplifying calculations: In some algorithms, working with unit vectors can simplify mathematical operations. the dot product inner product / projection product o The dot product of vectors 𝒓 and 𝒔 is denoted by 𝒓. 𝒔 and is given by 𝒓𝑁 𝒔 = σ𝑁 𝑖=1 𝑟𝑖 𝑠𝑖 o The dot product is the sum of the products of the values in the same dimension. 2 4 Let’s say you have two 3D vectors: a=(2,3,1) and b=(4,−1,2) OR a = 3 and b = −1 1 2 The dot product is calculated as: a⋅b= (2 × 4) + (3 × −1) + (1 × 2) = 8−3+2 = 7 Geometric Interpretation & Applications: If a⋅b>0 then angle between the vectors is acute (< 90°), point roughly in same direction. If a⋅b=0 then vectors are orthogonal (perpendicular, 90° angle), independent in direction. If a⋅b 90°), point roughly in opposite directions. Projection: The dot product helps in finding the projection of one vector onto another. Angle Calculation: To compute the angle between two vectors using cos(θ)=a⋅b / ∣a∣∣b∣ Physics: Dot product used in calculating work … dot product of force & displacement vectors. the dot product inner product / projection product 𝑟1 𝑠1 𝒓= 𝑟 𝒔= 𝑠 𝑗Ƹ 2 2 𝑖Ƹ 𝒓. 𝒔 = 𝑟𝑖 𝑠𝑖 + 𝑟𝑗 𝑠𝑗 𝑟1 𝑠1 𝑟2. 𝑠2 = 𝑟1 𝑠1 + 𝑟2 𝑠2 the dot product examples −1 3 o E.g. Find the dot product of 𝒔 = and 𝒓 = 2 2 3 −1. = 3 −1 + 2 2 = 1 2 2 3 1 o E.g. Find the dot product of −2 and 3 =5 4 2 the dot product properties o The dot product can only be applied on vectors of equal dimensions … and always returns a scalar o The dot product is commutative 𝒓. 𝒔 = 𝒔. 𝒓 o The dot product is distributive over addition 𝒓. 𝒔 + 𝒕 = 𝒓. 𝒔 + 𝒓. 𝒕 o The dot product is associative over scalar multiplication 𝒓. 𝑎𝒕 = 𝑎(𝒓. 𝒕) the dot product to find the modulus of a vector o What if I take the dot product of a vector by itself? 𝒓. 𝒓 = 𝑟1 𝑟1 + 𝑟2 𝑟2 = 𝑟1 2 + 𝑟2 2 2 = 2 𝑟1 + 𝑟2 2 = |𝒓|2 Therefore, 𝒓. 𝒓 = |𝒓| the dot product and the cosine rule 𝑐 2 = 𝑎2 + 𝑏 2 − 2𝑎𝑏 cos 𝜃 |𝒓 − 𝒔|2 = |𝒓|2 + |𝒔|2 − 2 𝒓 𝒔 cos 𝜃 𝒔 b Expanding the LHS c 𝒓−𝒔 𝒓 − 𝒔. 𝒓 − 𝒔 = 𝒓. 𝒓 − 2𝒓. 𝒔 + 𝒔. 𝒔 𝜃 𝒓 − 𝒔. 𝒓 − 𝒔 = |𝒓|2 − 2𝒓. 𝒔 + 𝒔 2 a 𝒓 Therefore, −2 𝒓 𝒔 cos 𝜃 = −2𝒓. 𝒔 𝒓 𝒔 cos 𝜃 = 𝒓. 𝒔 29 the dot product nd the cosine rule s 𝜃 3 1 a= −2 and 3 r Example: If you have two vectors: 𝒓. 𝒔 4 2 cos 𝜃 = 𝒓 𝒔 Dot product: a⋅b = 5 Magnitude of vectors: ∣a∣ = √(32+(−2)2+42) = √29 and ∣b∣ = √14​ Cosine of the angle: cos(θ) = 5 / (√29× √14) = 5/ √406 ​≈ 0.247 Angle: θ = cos−1(0.247) ≈ 75.68 So, the angle between the vectors is approximately 75.68°. the dot product nd the cosine rule s 𝜃 o What would happen if 𝜃 = 0°? r 𝒓. 𝒔 cos 𝜃 = s r 𝒓 𝒔 𝒓. 𝒔 = 𝒓 |𝒔| o What would happen if 𝜃 = 90°? o What would happen if vectors pointed in opposite directions? s r s r 𝒓. 𝒔 = 0 𝒓. 𝒔 = − 𝒓 |𝒔| … coming next week the dot product inner product / projection product o Go to this Google Form … https://shorturl.at/KJiRJ o Login with your UM credentials o Use any tool you like including your brain o Submit once you are ready

Use Quizgecko on...
Browser
Browser