Manual 1 Gvv Python 2d
User Manual:
Open the PDF directly: View PDF .
Page Count: 4
Download | ![]() |
Open PDF In Browser | View PDF |
1 JEE Problems in Linear Algebra: 2D G V V Sharma∗ Contents lam 1 = np.linspace(0,1,len) 1 Line 1 2 Medians of a Triangle 2 3 Altitudes of a Triangle 3 4 Angle Bisectors of a Triangle 4 Abstract—This manual introduces matrix computations using python and the properties of a triangle. 1 Line 1.1 Let ! ! ! −2 1 4 A= ,B = ,C = . −2 3 −1 (1) Draw ∆ABC. Solution: The following code yields the desired plot in Fig. 1.1 #Code by GVV Sharma #January 28, 2019 #released under GNU GPL import numpy as np import matplotlib.pyplot as plt #if using termux import subprocess import shlex #end if A = np.array([−2,−2]) B = np.array([1,3]) C = np.array([4,−1]) len =10 *The author is with the Department of Electrical Engineering, Indian Institute of Technology, Hyderabad 502285 India e-mail: gadepall@iith.ac.in. All content in this manual is released under GNU GPL. Free and open source. x AB = np.zeros((2,len)) x BC = np.zeros((2,len)) x CA = np.zeros((2,len)) for i in range(len): temp1 = A + lam 1[i]∗(B−A) x AB[:,i]= temp1.T temp2 = B + lam 1[i]∗(C−B) x BC[:,i]= temp2.T temp3 = C + lam 1[i]∗(A−C) x CA[:,i]= temp3.T #print(x plt.plot(x plt.plot(x plt.plot(x AB[0,:],x AB[0,:],x BC[0,:],x CA[0,:],x AB[1,:]) AB[1,:],label=’$AB$’) BC[1,:],label=’$BC$’) CA[1,:],label=’$CA$’) plt.plot(A[0], A[1], ’o’) plt.text(A[0] ∗ (1 + 0.1), A[1] ∗ (1 − 0.1) , ’ A’) plt.plot(B[0], B[1], ’o’) plt.text(B[0] ∗ (1 − 0.2), B[1] ∗ (1) , ’B’) plt.plot(C[0], C[1], ’o’) plt.text(C[0] ∗ (1 + 0.03), C[1] ∗ (1 − 0.1) , ’C’) plt.xlabel(’$x$’) plt.ylabel(’$y$’) plt.legend(loc=’best’) plt.grid() # minor #if using termux plt.savefig(’../figs/triangle.pdf’) plt.savefig(’../figs/triangle.eps’) subprocess.run(shlex.split(”termux−open ../ figs/triangle.pdf”)) #else #plt.show() 2 B 3 def dir vec(AB): return np.matmul(AB,dvec) AB BC CA def norm vec(AB): return np.matmul(omat,np.matmul(AB,dvec )) 2 y 1 A = np.array([−2,−2]) B = np.array([1,3]) dvec = np.array([−1,1]) omat = np.array([[0,1],[−1,0]]) AB =np.vstack((A,B)).T 0 C −1 −2 A −2 −1 0 1 x 2 3 4 print (dir vec(AB)) print (norm vec(AB)) Fig. 1.1 1.5 Find the equations of BC and CA 1.2 Find the equation of AB. Solution: The desired equation is obtained as AB : x = A + λ1 (B − A) ! ! 2 3 =− + λ1 2 5 (2) (3) Alternatively, the desired equation is 5 −3 (x − A) = 0 (4) 2! =⇒ 5 −3 x = − 5 −3 = −4 (5) 2 1.3 Find the direction vector and the normal vector for AB Solution: Let ! −2 1 T AB = A B = (6) −2 3 m = B − A = T AB =⇒ n = ! 0 1 5 m= −1 0 −3 ! (8) def mid pt(B,C): D = (B+C)/2 return D (9) 1.4 Write a python code for computing the direction and normal vectors. import numpy as np C+A A+B B+C ,E = ,F = (10) 2 2 2 The following code computes the values resulting in ! ! ! 2.5 1 −0.5 D= ,E = ,F = , (11) 1 −1.5 0.5 D= (7) The normal vector n is defined as nT m = 0 2.1 Find the coordinates of D, E and F of the mid points of AB, BC and CA respectively for ∆ABC. Solution: The coordinates of the mid points are given by #This program calculates the mid point between #any two coordinates import numpy as np import matplotlib.pyplot as plt The direction vector of AB is ! ! −1 3 = 1 5 2 Medians of a Triangle A = np. matrix(’−2;−2’) B = np. matrix(’1;3’) C = np. matrix(’4;−1’) print(mid pt(B,C)) print(mid pt(C,A)) print(mid pt(A,B)) 3 2.2 Find the equations of AD, BE and CF. These lines are the medians of ∆ABC Solution: Use the code in Problem 1.4. 2.3 Find the point of intersection of AD and CF. Solution: Let the respective equations be nT1 x = p1 and nT2 x = p2 (12) (13) This can be written as the matrix equation ! nT1 x=p (14) nT2 where =⇒ N T x = p (15) N = n1 n2 , (16) The point of intersection is then obtained as −1 x = NT p (17) = N −T p (18) The following code yields the point of intersection ! 1 G= (19) 0 D = mid pt(B,C) F = mid pt(A,B) AD =np.vstack((A,D)).T CF =np.vstack((C,F)).T dvec = np.array([−1,1]) omat = np.array([[0,1],[−1,0]]) print(line intersect(AD,CF)) 2.4 Using the code in Problem 2.3, verify that G is the point of intersection of BE, CF as well as AD, BE. G is known as the centroid of ∆ABC. 2.5 Graphically show that the medians of ∆ABC meet at the centroid. 2.6 Verify that G= A+B+C 3 (20) 3 Altitudes of a Triangle #This program calculates the #intersection of AD and CF import numpy as np def mid pt(B,C): D = (B+C)/2 return D def norm vec(AB): return np.matmul(omat,np.matmul(AB,dvec )) def line intersect(AD,CF): n1=norm vec(AD) n2=norm vec(CF) N =np.vstack((n1,n2)) p = np.zeros(2) p[0] = np.matmul(n1,AD[:,0]) p[1] = np.matmul(n2,CF[:,0]) return np.matmul(np.linalg.inv(N),p) A = np.array([−2,−2]) B = np.array([1,3]) C = np.array([4,−1]) 3.1 In ∆ABC, Let P be a point on BC such that AP ⊥ BC. Then AP is defined to be an altitude of ∆ABC. 3.2 Find the equation of AP. 3.3 Find the equations of the altitudes BQ and CR. 3.4 Find the point of intersection of AP and BQ. Solution: Using the code in Problem 2.3, the desired point of intersection is ! 1.407 H= (21) 0.56 Interestingly, BQ and CR also intersect at the same point. Thus, the altitudes of a triangle meet at a single point known as the orthocentre 3.5 Find P, Q, R. Solution: P is the intersection of AP and BC. Thus, the code in Problem 2.3 can be used to find P. The desired coordinates are ! ! ! 2.32 1.73 0.03 P= ,Q = ,R = (22) 1.24 −1.38 1.38 3.6 Draw AP, BQ and CR and verify that they meet at H. 4 4 Angle Bisectors of a Triangle 4.1 In ∆ABC, let U be a point on BC such that ∠BAU = ∠CAU. Then AU is known as the angle bisector. 4.2 Find the length of AB, BC and CA Solution: The length of CA is given by CA = kC − Ak It is easy to verify that even BV and CW meet at the same point. I is known as the incentre of ∆ABC. 4.6 Draw AU, BV and CW and verify that they meet at a point I. 4.7 Verify that I= (23) BC.A + CA.B + AB.C AB + BC + CA (31) The following code calculates the respective values as AB = 5.83, BC = 5, CA = 6.08 (24) nT (x − A) = 0 #This program calculates the distance between #two points import numpy as np import matplotlib.pyplot as plt IX = = knk IX = IY = IZ = r r is known as the inradius of ∆ABC. 4.10 Draw the incircle of △ABC 4.11 Draw the circumcircle of △ABC 4.3 If AU, BV and CW are the angle bisectors, find the coordinates of U, V and W. Solution: Using the section formula, CA .B + A BC CA +1 BC nT (I − A) (33) Verify through a Python script. 4.9 If IY ⊥ BC and IZ ⊥ CA, verify that print (np.linalg.norm(A−B)) AW.B + W B.A = AW + W B (32) show that A = np.array([−2,−2]) B = np.array([1,3]) C = np.array([4,−1]) W= 4.8 Let the perpendicular from I to AB be IX. If the equation of AB is AW .B + A WB AW +1 WB (25) (26) CA × B + BC × A (27) BC + CA a×A+b×B (28) = a+b where a = BC, b = CA, since the angle bisector has the property that = AW CA = (29) W B AB 4.4 Write a program to find U, V, W. 4.5 Find the intersection of AU and BV. Solution: Using the code in Problem 2.3, the desired point of intersection is ! 1.15 I= (30) 0.14 (34)
Source Exif Data:
File Type : PDF File Type Extension : pdf MIME Type : application/pdf PDF Version : 1.4 Linearized : No Page Count : 4 Page Mode : UseOutlines XMP Toolkit : XMP toolkit 2.9.1-13, framework 1.6 About : uuid:55ccda3c-5be4-11f4-0000-44043c455af8 Producer : dvips + GPL Ghostscript 9.26 Keywords : Modify Date : 2019:01:29 18:44:19+05:30 Create Date : 2019:01:29 18:44:19+05:30 Creator Tool : LaTeX with hyperref package Document ID : uuid:55ccda3c-5be4-11f4-0000-44043c455af8 Format : application/pdf Title : Creator : Description : Subject : Author :EXIF Metadata provided by EXIF.tools